OtelEventHandler#
dbally.audit.OtelEventHandler
#
OtelEventHandler(provider: Optional[TracerProvider] = None, record_inputs: bool = True, record_outputs: bool = True)
Bases: EventHandler[SpanHandler, SpanHandler]
This handler emits OpenTelemetry spans for recorded events.
Initialize OtelEventHandler. By default, it will try to use globaly configured TracerProvider. Pass it explicitly if you want custom implementation, or you do not use OTel auto-instrumentation.
To comply with the OTel Semantic Conventions recording of inputs and outputs can be disabled.
PARAMETER | DESCRIPTION |
---|---|
provider |
Optional tracer provider. By default global provider is used.
TYPE:
|
record_inputs |
if true (default) all inputs are recorded as span attributes. Depending on usecase it maybe turned off, to save resources and improve performance.
TYPE:
|
record_outputs |
if true (default) all outputs are recorded as span attributes. Depending on usecase it maybe turned off, to save resources and improve performance.
TYPE:
|
Source code in src/dbally/audit/event_handlers/otel_event_handler.py
request_start
async
#
request_start(user_request: RequestStart) -> SpanHandler
Initializes new OTel Span as a parent.
PARAMETER | DESCRIPTION |
---|---|
user_request |
The start of the request.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
SpanHandler
|
span object as a parent for all subsequent events for this request |
Source code in src/dbally/audit/event_handlers/otel_event_handler.py
event_start
async
#
event_start(event: Event, request_context: SpanHandler) -> SpanHandler
Starts a new event in a system as a span. Uses request span as a parent.
PARAMETER | DESCRIPTION |
---|---|
event |
Event to register
TYPE:
|
request_context |
Parent span for this event
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
SpanHandler
|
span object capturing start of execution for this event |
RAISES | DESCRIPTION |
---|---|
ValueError
|
it is thrown when unknown event type is passed as argument |
Source code in src/dbally/audit/event_handlers/otel_event_handler.py
event_end
async
#
event_end(event: Optional[Event], request_context: SpanHandler, event_context: SpanHandler) -> None
Finalizes execution of the event, ending a span for this event.
PARAMETER | DESCRIPTION |
---|---|
event |
optional event information
TYPE:
|
request_context |
parent span
TYPE:
|
event_context |
event span
TYPE:
|
Source code in src/dbally/audit/event_handlers/otel_event_handler.py
request_end
async
#
request_end(output: RequestEnd, request_context: SpanHandler) -> None
Finalizes entire request, ending the span for this request.
PARAMETER | DESCRIPTION |
---|---|
output |
output generated for this request
TYPE:
|
request_context |
span to be closed
TYPE:
|