baseplate.diagnostics
¶
Observers¶
Observers watch Baseplate for events that happen during requests, such as
requests starting and ending and service calls being made. Observers can also
add attributes to the context object for your application to use during
the request. Under the hood, the context factories
(baseplate.context
) are implemented as observers. All of the
following observers can be configured with Convenience Methods on your
application’s Baseplate
object.
-
class
baseplate.diagnostics.logging.
LoggingBaseplateObserver
¶ Logging observer.
This observer adds request context to the thread-local state so that the log formatters can give more informative logs. Currently, this just sets the thread name to the current request’s trace ID.
-
class
baseplate.diagnostics.metrics.
MetricsBaseplateObserver
(client)¶ Metrics collecting observer.
This observer reports metrics to statsd. It does two important things:
- it tracks the time taken in serving each request.
- it batches all metrics generated during a request into as few packets as possible.
The batch is accessible to your application during requests as the
metrics
attribute on the context object.Parameters: client (baseplate.metrics.Client) – The client where metrics will be sent.
-
class
baseplate.diagnostics.sentry.
SentryBaseplateObserver
(raven)¶ Error reporting observer.
This observer reports unexpected exceptions to Sentry.
The raven client is accessible to your application during requests as the
sentry
attribute on the context object.Parameters: client (raven.Client) – A configured raven client.
-
class
baseplate.diagnostics.tracing.
TraceBaseplateObserver
(tracing_client)¶ Distributed tracing observer.
This observer handles Zipkin-compatible distributed tracing instrumentation for both inbound and outbound requests. Baseplate span-specific tracing observers (TraceSpanObserver and TraceServerSpanObserver) are registered for tracking, serializing, and recording span data.
Parameters: client (baseplate.diagnostics.tracing.TracingClient) – The client where metrics will be sent.