feat: expose detailed metrics to runtime metrics (#10699)

This commit is contained in:
Anton Panasenko
2026-02-05 18:22:30 -08:00
committed by GitHub
parent d74fa8edd1
commit 4ee039744e
8 changed files with 279 additions and 11 deletions
+44
View File
@@ -1,6 +1,10 @@
use crate::TelemetryAuthMode;
use crate::metrics::names::API_CALL_COUNT_METRIC;
use crate::metrics::names::API_CALL_DURATION_METRIC;
use crate::metrics::names::RESPONSES_API_ENGINE_IAPI_TBT_DURATION_METRIC;
use crate::metrics::names::RESPONSES_API_ENGINE_IAPI_TTFT_DURATION_METRIC;
use crate::metrics::names::RESPONSES_API_ENGINE_SERVICE_TBT_DURATION_METRIC;
use crate::metrics::names::RESPONSES_API_ENGINE_SERVICE_TTFT_DURATION_METRIC;
use crate::metrics::names::RESPONSES_API_INFERENCE_TIME_DURATION_METRIC;
use crate::metrics::names::RESPONSES_API_OVERHEAD_DURATION_METRIC;
use crate::metrics::names::SSE_EVENT_COUNT_METRIC;
@@ -48,6 +52,10 @@ const RESPONSES_WEBSOCKET_TIMING_KIND: &str = "responsesapi.websocket_timing";
const RESPONSES_WEBSOCKET_TIMING_METRICS_FIELD: &str = "timing_metrics";
const RESPONSES_API_OVERHEAD_FIELD: &str = "responses_duration_excl_engine_and_client_tool_time_ms";
const RESPONSES_API_INFERENCE_FIELD: &str = "engine_service_total_ms";
const RESPONSES_API_ENGINE_IAPI_TTFT_FIELD: &str = "engine_iapi_ttft_total_ms";
const RESPONSES_API_ENGINE_SERVICE_TTFT_FIELD: &str = "engine_service_ttft_total_ms";
const RESPONSES_API_ENGINE_IAPI_TBT_FIELD: &str = "engine_iapi_tbt_across_engine_calls_ms";
const RESPONSES_API_ENGINE_SERVICE_TBT_FIELD: &str = "engine_service_tbt_across_engine_calls_ms";
impl OtelManager {
#[allow(clippy::too_many_arguments)]
@@ -674,6 +682,42 @@ impl OtelManager {
if let Some(duration) = duration_from_ms_value(inference_value) {
self.record_duration(RESPONSES_API_INFERENCE_TIME_DURATION_METRIC, duration, &[]);
}
let engine_iapi_ttft_value =
timing_metrics.and_then(|value| value.get(RESPONSES_API_ENGINE_IAPI_TTFT_FIELD));
if let Some(duration) = duration_from_ms_value(engine_iapi_ttft_value) {
self.record_duration(
RESPONSES_API_ENGINE_IAPI_TTFT_DURATION_METRIC,
duration,
&[],
);
}
let engine_service_ttft_value =
timing_metrics.and_then(|value| value.get(RESPONSES_API_ENGINE_SERVICE_TTFT_FIELD));
if let Some(duration) = duration_from_ms_value(engine_service_ttft_value) {
self.record_duration(
RESPONSES_API_ENGINE_SERVICE_TTFT_DURATION_METRIC,
duration,
&[],
);
}
let engine_iapi_tbt_value =
timing_metrics.and_then(|value| value.get(RESPONSES_API_ENGINE_IAPI_TBT_FIELD));
if let Some(duration) = duration_from_ms_value(engine_iapi_tbt_value) {
self.record_duration(RESPONSES_API_ENGINE_IAPI_TBT_DURATION_METRIC, duration, &[]);
}
let engine_service_tbt_value =
timing_metrics.and_then(|value| value.get(RESPONSES_API_ENGINE_SERVICE_TBT_FIELD));
if let Some(duration) = duration_from_ms_value(engine_service_tbt_value) {
self.record_duration(
RESPONSES_API_ENGINE_SERVICE_TBT_DURATION_METRIC,
duration,
&[],
);
}
}
fn responses_type(event: &ResponseEvent) -> String {