mirror of
https://github.com/openai/codex.git
synced 2026-11-09 00:39:32 +00:00
## Why Guardian request and section cost distributions need shared bucket boundaries across synchronous and asynchronous reviewers so their measurements align. ## What changed - Add `histogram_with_boundaries` to session telemetry and extension metrics while preserving session attribution. - Use shared request-token buckets up to 2,000,000 tokens and section-cost buckets up to 16,777,216 for both review paths. ## Testing Extend telemetry tests to verify explicit bucket boundaries and sample counts, and Guardian integration coverage to check exported request and section metric bounds for both synchronous and asynchronous reviews. GitOrigin-RevId: e34f6972b3418bac3b061939b62eeeccaec5a299
36 lines
970 B
Rust
36 lines
970 B
Rust
use std::sync::Arc;
|
|
|
|
use codex_extension_api::ExtensionMetrics;
|
|
use codex_otel::SessionTelemetry;
|
|
|
|
struct SessionTelemetryExtensionMetrics {
|
|
session_telemetry: SessionTelemetry,
|
|
}
|
|
|
|
impl ExtensionMetrics for SessionTelemetryExtensionMetrics {
|
|
fn counter(&self, name: &str, inc: i64, tags: &[(&str, &str)]) {
|
|
self.session_telemetry.counter(name, inc, tags);
|
|
}
|
|
|
|
fn histogram(&self, name: &str, value: i64, tags: &[(&str, &str)]) {
|
|
self.session_telemetry.histogram(name, value, tags);
|
|
}
|
|
|
|
fn histogram_with_boundaries(
|
|
&self,
|
|
name: &str,
|
|
value: i64,
|
|
boundaries: &[f64],
|
|
tags: &[(&str, &str)],
|
|
) {
|
|
self.session_telemetry
|
|
.histogram_with_boundaries(name, value, boundaries, tags);
|
|
}
|
|
}
|
|
|
|
pub(crate) fn from_session_telemetry(
|
|
session_telemetry: SessionTelemetry,
|
|
) -> Arc<dyn ExtensionMetrics> {
|
|
Arc::new(SessionTelemetryExtensionMetrics { session_telemetry })
|
|
}
|