Skip to content

Instantly share code, notes, and snippets.

View yothinix's full-sized avatar

Yothin M yothinix

View GitHub Profile
@tonybaloney
tonybaloney / app.py
Last active March 25, 2024 23:52
FastAPI with OpenTelemetry
from azure.monitor.opentelemetry.exporter import AzureMonitorTraceExporter
from fastapi import FastAPI, Request
from fastapi.responses import JSONResponse
from opentelemetry.context import get_current as get_current_context
from opentelemetry.instrumentation.fastapi import FastAPIInstrumentor
from opentelemetry.sdk.trace import TracerProvider, _Span
from opentelemetry.sdk.trace.export import (BatchSpanProcessor,
ConsoleSpanExporter,
SimpleSpanProcessor)
from starlette.exceptions import HTTPException as StarletteHTTPException