Skip to content

feat: OTLP metrics and logs export - #106

Merged
nfvelten merged 1 commit into
masterfrom
feat/otlp-metrics-logs
Apr 6, 2026
Merged

feat: OTLP metrics and logs export#106
nfvelten merged 1 commit into
masterfrom
feat/otlp-metrics-logs

Conversation

@nfvelten

@nfvelten nfvelten commented Apr 6, 2026

Copy link
Copy Markdown
Contributor

Summary

  • export_metrics: true mirrors arbitus.requests.total and arbitus.tokens.total to any OTLP collector alongside the existing Prometheus /metrics endpoint (dual export, no conflict)
  • export_logs: true bridges all tracing::*!() events to OTLP structured logs via opentelemetry-appender-tracing
  • Both pipelines are opt-in (default: false), fail gracefully when collector is unreachable, and are shut down cleanly on SIGTERM via OtelGuard
  • Existing OTLP trace export is unchanged

Config

telemetry:
  otlp_endpoint: "http://otel-collector:4317"
  service_name: "arbitus"
  export_metrics: true
  export_logs: true

Test plan

  • 3 unit tests — TelemetryConfig deserialization (defaults, all fields, partial flags)
  • 3 unit tests — GatewayMetrics OTel calls are no-ops without a provider
  • 5 integration tests — gateway starts and handles requests with unreachable OTLP collector; Prometheus /metrics unaffected; blocked tools still blocked
  • e2e.sh section 21 — health, request handling, and /metrics with OTLP config

Closes #103

Add dual-export for metrics and structured logs alongside the existing
OTLP trace pipeline. Both pipelines are opt-in via config and fail
gracefully when the collector is unreachable.

Config:
  telemetry:
    otlp_endpoint: "http://otel-collector:4317"
    export_metrics: true   # mirrors Prometheus counters to OTLP
    export_logs: true      # bridges all tracing:: events to OTLP logs

Changes:
- Cargo.toml: add metrics+logs features to opentelemetry/otlp/sdk;
  add opentelemetry-appender-tracing for the tracing→OTLP log bridge
- config.rs: add export_metrics and export_logs fields (both default false)
- metrics.rs: mirror arbitus.requests.total and arbitus.tokens.total to
  the global OTel meter (no-op when no provider is installed)
- arbitus.rs: build_otel_metrics(), build_otel_logs(), updated OtelGuard
  to shut down all three providers on drop; init_tracing() uses
  Option<Layer> to compose pipelines without combinatorial match arms

Tests:
- 3 unit tests for TelemetryConfig deserialization (defaults, all fields, partial)
- 3 unit tests for metrics.rs OTel no-op behaviour
- 5 integration tests: gateway starts/operates correctly with unreachable
  collector; Prometheus /metrics unaffected; blocked tools still work
- e2e.sh section 21: health, request handling, and /metrics with OTLP config

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@nfvelten
nfvelten merged commit a171dae into master Apr 6, 2026
3 checks passed
@nfvelten
nfvelten deleted the feat/otlp-metrics-logs branch April 6, 2026 05:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: complete OTLP pipeline — add metrics and logs export alongside existing traces

1 participant