Helpers that integrate common client libraries with

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

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 of make_object_for_context() will be added to the RequestContext with the name specified in add_to_context.


Report runtime metrics to the stats system.


batch (baseplate.lib.metrics.Client) – A metrics client to report statistics to.

Return type


make_object_for_context(name, span)[source]

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

  • name (str) – The name assigned to this object on the context.

  • span (baseplate.Span) – The current span this object is being made for.

Return type


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(,