Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import logging
from contextvars import ContextVar
from typing import Any, Dict
from opentelemetry import context as otel_context, propagate

from sap_cloud_sdk.core.telemetry.constants import (
ATTR_SAP_TRIGGER_TYPE,
Expand Down Expand Up @@ -32,9 +33,12 @@ def __init__(self, app: Any, attrs_var: ContextVar[Dict[str, Any]]) -> None:

async def dispatch(self, request: Request, call_next: Any) -> Response:
token = self._attrs_var.set(_extract_ias_attrs(request))
ctx = propagate.extract(request.headers)
ctx_token = otel_context.attach(ctx)
try:
return await call_next(request)
finally:
otel_context.detach(ctx_token)
self._attrs_var.reset(token)


Expand Down
Loading