Skip to content

Observability: Initial instrumentation #4162

Description

@i5okie

Description

Add OpenTelemetry auto-instrumentation to acapy-agent to enable distributed tracing and application metrics for HTTP endpoints and PostgreSQL queries.

Requirements

  • Add opentelemetry-api, opentelemetry-sdk, opentelemetry-exporter-otlp, opentelemetry-instrumentation-aiohttp-server to dependencies in pyproject.toml
  • Initialize OTel SDK in acapy_agent/commands/start.py inside run_app(), before conductor.setup()not in __main__.py (that file is a thin debug/dispatch wrapper only); set up both TracerProvider and MeterProvider with OTLP exporters
  • Add aiohttp server instrumentation in acapy_agent/admin/server.pymake_application() where the middleware list is built
  • Add PostgreSQL tracing via opentelemetry-instrumentation-psycopg (psycopg v3); instrument at pool creation in acapy_agent/database_manager/databases/postgresql_normalized/connection_pool.py

Acceptance Criteria

  • OTel SDK initializes on startup without errors
  • Inbound HTTP requests to the admin API generate trace spans visible in Tempo
  • PostgreSQL queries appear as child spans within HTTP request traces
  • HTTP RED metrics (http.server.request.duration histogram) appear in Mimir
  • No regression in existing test suite

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions