Propagate traces over HTTP and add Redis spans

setup_telemetry now instruments httpx and redis process-wide. Both patch
the client classes, so clients created at import time (gateway's
_proxy_client, common.redis_client) are covered too. httpx CLIENT spans
inject traceparent, so the downstream FastAPI SERVER spans join the
caller's trace. gateway and fraud get setup_telemetry, the FastAPI span,
and the OTLP auth header. All seven services now export traces.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Movses Aslanyan
2026-10-13 11:28:03 +03:30
co-authored by Claude Opus 5.5
parent ec6ddb6a26
commit 14938ab36b
4 changed files with 29 additions and 0 deletions
+7
View File
@@ -3,6 +3,8 @@ from opentelemetry.sdk.resources import SERVICE_NAME, Resource
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
from opentelemetry.instrumentation.httpx import HTTPXClientInstrumentor
from opentelemetry.instrumentation.redis import RedisInstrumentor
def setup_telemetry(service_name: str):
@@ -11,3 +13,8 @@ def setup_telemetry(service_name: str):
provider = TracerProvider(resource=resource)
provider.add_span_processor(processor)
trace.set_tracer_provider(provider)
# Process-wide patches on the client classes, so they also cover clients
# created at import time (gateway's _proxy_client, common.redis_client).
HTTPXClientInstrumentor().instrument()
RedisInstrumentor().instrument()