[codex] Add shared proxy telemetry sinks#205
Merged
Merged
Conversation
9f0fef2 to
bc6adb0
Compare
There was a problem hiding this comment.
Pull request overview
Adds a shared “proxy observability” fanout so model-gateway attempt telemetry can be emitted to multiple sinks (log, HTTP JSON/webhook, and OTLP JSON targets such as Traceloop) without treating observability tools as provider adapters.
Changes:
- Introduces
TelemetryFanout+ sink implementations and wires emission into the routed provider path. - Adds
[[proxy.observability]]config schema + validation (including header validation and endpoint requirements). - Updates model-gateway docs + ADR to describe observability sinks as a separate surface from provider adapters.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| docs/model-gateway.md | Documents [[proxy.observability]] sink configuration and redaction guarantees. |
| docs/adr/0001-model-gateway-and-agent-boundaries.md | Updates ADR guidance to separate observability sinks from provider gateways. |
| crates/calciforge/src/proxy/telemetry.rs | Implements telemetry events, sink fanout, HTTP/OTLP JSON emitters, and unit tests. |
| crates/calciforge/src/proxy/telemetry_tests.rs | Adds an integration-style test ensuring routing emits redacted attempt telemetry. |
| crates/calciforge/src/proxy/mod.rs | Exposes telemetry module and stores TelemetryFanout in ProxyState. |
| crates/calciforge/src/proxy/handlers.rs | Emits gateway-attempt events after provider/model resolution (success/failure + duration). |
| crates/calciforge/src/config/validator.rs | Validates observability sink kinds, endpoints, timeouts, and headers. |
| crates/calciforge/src/config/validator_tests_3.rs | Adds validator tests covering new observability sink rules. |
| crates/calciforge/src/config/observability.rs | Adds ProxyObservabilityConfig schema for [[proxy.observability]]. |
| crates/calciforge/src/config.rs | Wires observability sink config into ProxyConfig. |
| Ok(response) => telemetry_attempt.success(duration, response.choices.len()), | ||
| Err(error) => telemetry_attempt.failure(duration, error.failure_kind()), | ||
| }; | ||
| state.telemetry.emit_gateway_attempt(event).await; |
Comment on lines
+298
to
+299
| let start_ns = event.timestamp_ms.saturating_mul(1_000_000); | ||
| let end_ns = start_ns.saturating_add(event.duration_ms.saturating_mul(1_000_000)); |
Comment on lines
+146
to
+151
| pub(crate) async fn emit_gateway_attempt(&self, event: GatewayTelemetryEvent) { | ||
| for sink in self.sinks.iter() { | ||
| if let Err(err) = sink.emit_gateway_attempt(&event).await { | ||
| warn!(error = %err, sink = sink.name(), "Gateway telemetry sink failed"); | ||
| } | ||
| } |
| /// Observability sink for model-gateway attempt telemetry. | ||
| #[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)] | ||
| pub struct ProxyObservabilityConfig { | ||
| /// Sink type. Supported values: "log", "http-json", "otel", "traceloop". |
bc6adb0 to
25ae18a
Compare
25ae18a to
8decaee
Compare
Comment on lines
+146
to
+150
| pub(crate) async fn emit_gateway_attempt(&self, event: GatewayTelemetryEvent) { | ||
| for sink in self.sinks.iter() { | ||
| let sink = Arc::clone(sink); | ||
| let event = event.clone(); | ||
| tokio::task::spawn(async move { |
Comment on lines
+151
to
+152
| if let Err(_err) = sink.emit_gateway_attempt(&event).await { | ||
| warn!(sink = sink.name(), "Gateway telemetry sink failed"); |
|
|
||
| gateway.chat_completion(gateway_req).await | ||
| let upstream_model = gateway_req.model.clone(); | ||
| let gateway_engine = gateway.engine_info().id; |
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.
What changed
[[proxy.observability]]sinks for model-gateway attempt telemetry.log,http-json/webhook, and OTLP JSON sinks viaotel/otlp/traceloop.Why
Provider engines should own model routing, retry policy, and credentials. Observability tools such as Traceloop should be able to receive events without pretending to be model gateways. This keeps the provider-adapter contract cleaner and gives us one place to fan out gateway attempt metadata.
Validation
cargo test -p calciforgecargo clippy -p calciforge -- -D warningsruby scripts/check-architecture-ratchets.rbruby scripts/check-docs-site.rb