baseplate.clients
¶
Helpers that integrate common client libraries with Baseplate.py.
This package contains modules which integrate various client libraries with Baseplate.py’s instrumentation. When using these client library integrations, trace information is passed on and metrics are collected automatically.
Instrumented Client Libraries¶
- baseplate.clients.cassandra: Cassandra CQL Client
- baseplate.clients.kombu: Client for publishing to queues
- baseplate.clients.memcache: Memcached Client
- baseplate.clients.redis: Redis Client
- baseplate.clients.redis_cluster: Redis Cluster Client
- baseplate.clients.requests: Requests (HTTP) Client
- baseplate.clients.sqlalchemy: SQL Client for relational databases (e.g. PostgreSQL)
- baseplate.clients.thrift: Thrift client for RPC to other backend services
DIY: The Factory¶
If a library you want is not supported here, it can be added to your own
application by implementing ContextFactory
.
- class baseplate.clients.ContextFactory[source]¶
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 theRequestContext
with the name specified inadd_to_context
.
To integrate with configure_context()
for maximum
convenience, make a parser that implements
baseplate.lib.config.Parser
and returns your
ContextFactory
.
class MyClient(config.Parser):
def parse(
self, key_path: str, raw_config: config.RawConfig
) -> "MyContextFactory":
parser = config.SpecParser(
{
"foo": config.Integer(),
"bar": config.Boolean(),
}
)
result = parser.parse(key_path, raw_config)
return MyContextFactory(foo=result.foo, bar=result.bar)