Skip to content

Observability: Initial instrumentation #135

Description

@i5okie

Description

Add OTel auto-instrumentation to the didwebvh FastAPI server with centralized OTel init covering both traces and metrics, and SQLAlchemy database tracing.

Requirements

  • Add opentelemetry-instrumentation-fastapi, opentelemetry-instrumentation-logging, opentelemetry-instrumentation-sqlalchemy to server/pyproject.toml
  • Create server/app/otel.py for centralized OTel init — configure both TracerProvider (BatchSpanProcessor + OTLPSpanExporter) and MeterProvider (PeriodicExportingMetricReader + OTLPMetricExporter)
  • Call OTel init from server/main.py before uvicorn.run (must be active before uvicorn imports the app module)
  • Apply FastAPIInstrumentor.instrument_app(app) in server/app/__init__.py where app is defined (uses modern lifespan context manager)
  • Apply SQLAlchemyInstrumentor().instrument(engine=self._engine) in server/app/plugins/storage.pyStorageManager.__init__, immediately after self._engine is first created

Acceptance Criteria

  • FastAPI request spans visible in Tempo
  • SQLAlchemy/psycopg2 query spans appear as children
  • HTTP RED metrics appear in Mimir
  • Log correlation enabled (trace_id present in stdout log records)
  • No regression in existing test suite

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions