Measure sampling, transport volume and bounded exporter losses with reproducible incidents
This commit is contained in:
@@ -100,8 +100,9 @@ async def request_log(request: Request, call_next):
|
||||
response.headers["X-Request-Id"] = request.state.request_id
|
||||
response.headers["X-Instance-Id"] = INSTANCE_ID
|
||||
return response
|
||||
method = request.method if request.method in {"GET", "POST", "DELETE", "PUT", "PATCH", "HEAD", "OPTIONS"} else "OTHER"
|
||||
context = propagate.extract(dict(request.headers))
|
||||
with telemetry.operation("HTTP " + request.method, context=context, kind=SpanKind.SERVER) as span:
|
||||
with telemetry.operation("HTTP " + method, context=context, kind=SpanKind.SERVER) as span:
|
||||
try:
|
||||
if (request.method == "POST" and request.url.path == "/api/v1/auth/sessions"
|
||||
and await request.body()):
|
||||
@@ -115,12 +116,14 @@ async def request_log(request: Request, call_next):
|
||||
response = error(request, 500, "Внутренняя ошибка")
|
||||
response.headers["X-Request-Id"] = request.state.request_id
|
||||
response.headers["X-Instance-Id"] = INSTANCE_ID
|
||||
response.headers["X-Trace-Id"] = format(span.get_span_context().trace_id, "032x")
|
||||
response.headers["X-Trace-Sampled"] = "true" if span.is_recording() else "false"
|
||||
route = getattr(request.scope.get("route"), "path", "unknown")
|
||||
elapsed = time.perf_counter() - start
|
||||
attrs = {"method": request.method, "route": route,
|
||||
attrs = {"method": method, "route": route,
|
||||
"status_class": str(response.status_code // 100) + "xx"}
|
||||
span.update_name(request.method + " " + route)
|
||||
span.set_attributes({"http.request.method": request.method, "http.route": route,
|
||||
span.update_name(method + " " + route)
|
||||
span.set_attributes({"http.request.method": method, "http.route": route,
|
||||
"http.response.status_code": response.status_code})
|
||||
if response.status_code >= 500:
|
||||
span.set_status(Status(StatusCode.ERROR, "server_error"))
|
||||
|
||||
Reference in New Issue
Block a user