baseplate.context

Helpers that integrate common client libraries with baseplate’s diagnostics.

This package contains modules which integrate various client libraries with Baseplate’s instrumentation. When using these client library integrations, trace information is passed on and metrics are collected automatically.

To use these helpers, use the add_to_context() method on your application’s Baseplate object:

client = SomeClient("server, server, server")
baseplate.add_to_context("my_client", SomeContextFactory(client))

and then a context-aware version of the client will show up on the context object during requests:

def my_handler(self, context):
    context.my_client.make_some_remote_call()

DIY: The Factory

If a library you want isn’t supported here, it can be added to your own application by implementing ContextFactory.

class baseplate.context.ContextFactory

An interface for adding stuff to the context object.

Objects implementing this interface can be passed to add_to_context(). The return value of make_object_for_context() will be added to the context object with the name specified in add_to_context.

make_object_for_context(name, server_span)

Return an object that can be added to the context object.