feat: OTLP metrics and logs export - #106
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
export_metrics: truemirrorsarbitus.requests.totalandarbitus.tokens.totalto any OTLP collector alongside the existing Prometheus/metricsendpoint (dual export, no conflict)export_logs: truebridges alltracing::*!()events to OTLP structured logs viaopentelemetry-appender-tracingdefault: false), fail gracefully when collector is unreachable, and are shut down cleanly on SIGTERM viaOtelGuardConfig
Test plan
TelemetryConfigdeserialization (defaults, all fields, partial flags)GatewayMetricsOTel calls are no-ops without a provider/metricsunaffected; blocked tools still blocked/metricswith OTLP configCloses #103