mirror of
https://github.com/openai/codex.git
synced 2026-11-12 21:20:34 +00:00
## What changed - Give tool fragment sizes and namespace counts logarithmic boundaries through 32,768. - Give enabled and kept skill counts integer boundaries from 0 through 512, removed description characters logarithmic boundaries through 131,072, and skill truncation flags boundaries at 0 and 1. - Record these metrics with explicit boundaries, separating zero values and retaining overflow buckets above each range. ## Testing Extend tool and skill metric tests to assert explicit boundaries. Add an export test covering zero, one, the upper boundary, and overflow, including bucket counts, ordering, and sample totals. GitOrigin-RevId: 9fbf3acbe352d7c74f3ad11f0b690148c083a6ef
103 lines
3.1 KiB
Rust
103 lines
3.1 KiB
Rust
use std::sync::Mutex;
|
|
|
|
use codex_extension_api::ExtensionMetrics;
|
|
use pretty_assertions::assert_eq;
|
|
|
|
use super::*;
|
|
|
|
#[derive(Debug, PartialEq)]
|
|
struct RecordedHistogram {
|
|
name: String,
|
|
value: i64,
|
|
boundaries: Vec<f64>,
|
|
tags: Vec<(String, String)>,
|
|
}
|
|
|
|
#[derive(Default)]
|
|
struct RecordingMetrics {
|
|
samples: Mutex<Vec<RecordedHistogram>>,
|
|
}
|
|
|
|
impl ExtensionMetrics for RecordingMetrics {
|
|
fn histogram_with_boundaries(
|
|
&self,
|
|
name: &str,
|
|
value: i64,
|
|
boundaries: &[f64],
|
|
tags: &[(&str, &str)],
|
|
) {
|
|
self.samples
|
|
.lock()
|
|
.unwrap_or_else(std::sync::PoisonError::into_inner)
|
|
.push(RecordedHistogram {
|
|
name: name.to_string(),
|
|
value,
|
|
boundaries: boundaries.to_vec(),
|
|
tags: tags
|
|
.iter()
|
|
.map(|(key, value)| ((*key).to_string(), (*value).to_string()))
|
|
.collect(),
|
|
});
|
|
}
|
|
|
|
fn counter(&self, name: &str, _inc: i64, _tags: &[(&str, &str)]) {
|
|
panic!("unexpected counter: {name}");
|
|
}
|
|
|
|
fn histogram(&self, name: &str, _value: i64, _tags: &[(&str, &str)]) {
|
|
panic!("unexpected histogram without context boundaries: {name}");
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn records_core_equivalent_catalog_render_metrics_with_surface() {
|
|
let metrics = RecordingMetrics::default();
|
|
let report = SkillRenderReport {
|
|
total_count: 5,
|
|
included_count: 3,
|
|
omitted_count: 2,
|
|
truncated_description_chars: 700,
|
|
truncated_description_count: 4,
|
|
};
|
|
|
|
record_catalog_render(
|
|
Some(&metrics),
|
|
CatalogSurface::TurnInput,
|
|
SkillMetadataBudget::Tokens(400),
|
|
&report,
|
|
);
|
|
|
|
assert_eq!(
|
|
*metrics
|
|
.samples
|
|
.lock()
|
|
.unwrap_or_else(std::sync::PoisonError::into_inner),
|
|
vec![
|
|
RecordedHistogram {
|
|
name: THREAD_SKILLS_ENABLED_TOTAL_METRIC.to_string(),
|
|
value: 5,
|
|
boundaries: THREAD_SKILLS_COUNT_METRIC_BUCKETS.to_vec(),
|
|
tags: vec![("catalog_surface".to_string(), "turn_input".to_string())],
|
|
},
|
|
RecordedHistogram {
|
|
name: THREAD_SKILLS_KEPT_TOTAL_METRIC.to_string(),
|
|
value: 3,
|
|
boundaries: THREAD_SKILLS_COUNT_METRIC_BUCKETS.to_vec(),
|
|
tags: vec![("catalog_surface".to_string(), "turn_input".to_string())],
|
|
},
|
|
RecordedHistogram {
|
|
name: THREAD_SKILLS_TRUNCATED_METRIC.to_string(),
|
|
value: 1,
|
|
boundaries: THREAD_SKILLS_TRUNCATED_BUCKETS.to_vec(),
|
|
tags: vec![("catalog_surface".to_string(), "turn_input".to_string())],
|
|
},
|
|
RecordedHistogram {
|
|
name: THREAD_SKILLS_DESCRIPTION_TRUNCATED_CHARS_METRIC.to_string(),
|
|
value: 700,
|
|
boundaries: THREAD_SKILLS_DESCRIPTION_TRUNCATED_CHARS_BUCKETS.to_vec(),
|
|
tags: vec![("catalog_surface".to_string(), "turn_input".to_string())],
|
|
},
|
|
]
|
|
);
|
|
}
|