Version 0.3.0
Some checks failed
Run linters on applied template / Python 3.13 lint and build (push) Failing after 2m36s
Some checks failed
Run linters on applied template / Python 3.13 lint and build (push) Failing after 2m36s
Changes: - fix double exception message in main request_processing span - add OpenSearch to Jaeger and OpenTelemetry Logs - add optional OpenTelemetry Logs Exporter to structlog - update deploy README
This commit is contained in:
@@ -47,9 +47,15 @@ class ObservabilityMiddleware(BaseHTTPMiddleware): # pylint: disable=too-few-pu
|
||||
async def dispatch(self, request: Request, call_next):
|
||||
logger = logger_dep.obtain(request)
|
||||
_try_get_parent_span_id(request)
|
||||
with _tracer.start_as_current_span("http-request") as span:
|
||||
with _tracer.start_as_current_span("http-request", record_exception=False) as span:
|
||||
trace_id = hex(span.get_span_context().trace_id or randint(1, 1 << 63))[2:]
|
||||
span_id = span.get_span_context().span_id or randint(1, 1 << 31)
|
||||
if trace_id == 0:
|
||||
trace_id = format(randint(1, 1 << 63), "016x")
|
||||
span_id = format(randint(1, 1 << 31), "032x")
|
||||
logger = logger.bind(trace_id=trace_id, span_id=span_id)
|
||||
logger_dep.attach_to_request(request, logger)
|
||||
|
||||
span.set_attributes(
|
||||
{
|
||||
http_attributes.HTTP_REQUEST_METHOD: request.method,
|
||||
@@ -58,8 +64,6 @@ class ObservabilityMiddleware(BaseHTTPMiddleware): # pylint: disable=too-few-pu
|
||||
"request_client": request.client.host,
|
||||
}
|
||||
)
|
||||
logger = logger.bind(trace_id=trace_id, span_id=span_id)
|
||||
request.state.logger = logger
|
||||
|
||||
await logger.ainfo(
|
||||
"handling request",
|
||||
|
||||
Reference in New Issue
Block a user