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()
Instrumented Client Libraries¶
- baseplate.context.cassandra: Cassandra CQL Client
- baseplate.context.hvac: Client for using Vault's advanced features
- baseplate.context.kombu: Client for publishing to queues
- baseplate.context.memcache: Memcached Client
- baseplate.context.redis: Redis Client
- baseplate.context.sqlalchemy: SQL Client for relational databases (e.g. PostgreSQL)
- baseplate.context.thrift: Thrift client for RPC to other backend services
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 ofmake_object_for_context()
will be added to the context object with the name specified inadd_to_context
.-
make_object_for_context
(name, span)¶ Return an object that can be added to the context object.
-