Skip to content

Add OpenTelemetry observability integration #35

Description

@PAMulligan

Description

Add OpenTelemetry (OTel) integration as an optional observability layer for generated APIs. This provides distributed tracing, metrics, and structured logging out of the box.

Why

Observability is essential for production APIs. OpenTelemetry is the industry standard for instrumentation — supporting it means Nerva-generated APIs can export telemetry to Jaeger, Grafana, Datadog, Honeycomb, or any OTel-compatible backend without vendor lock-in.

Acceptance Criteria

  • Create a Hono middleware that:
    • Creates spans for each HTTP request (method, path, status code, duration)
    • Propagates trace context headers (W3C Trace Context)
    • Records errors as span events
    • Adds custom attributes (request ID, user ID if authenticated)
  • Add `@opentelemetry/api` and relevant SDK packages
  • Create a trace configuration template (`tracing.ts`) with:
    • Console exporter for development
    • OTLP exporter for production
    • Automatic span batching and sampling
  • Add optional `--otel` flag to `setup-project.sh`
  • Create a new `monitoring` skill documenting OTel setup
  • Include a docker-compose service for Jaeger (local development)
  • CI passes

Notes

For Cloudflare Workers, use the Workers-compatible OTel SDK (`@microlabs/otel-cf-workers` or similar).

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

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions