Sanitize skill names in injection metrics (#34601)

## Why

Skill names may contain characters that are not valid in metric tag values.

## What changed

Pass skill names through `sanitize_metric_tag_value` before using them as the
`skill` tag on `codex.skill.injected` counters for both explicit and implicit
skill invocations.

GitOrigin-RevId: 0ed633fbd468739acc30193b566d830e20bc7860
This commit is contained in:
mandal-OAI authored and copyberry committed 2026-07-21 19:25:39 +00:00
1 parent 87f71e35b8
commit 6c00dc087e
2 files changed
+6 -2

No files matched your search

+3 -1
View File
@@ -11,6 +11,7 @@ use codex_analytics::SkillInvocation;
use codex_analytics::TrackEventsContext;
use codex_exec_server::LOCAL_FS;
use codex_otel::SessionTelemetry;
use codex_otel::sanitize_metric_tag_value;
use codex_protocol::user_input::UserInput;
use codex_utils_absolute_path::AbsolutePathBuf;
use codex_utils_path_uri::PathUri;
@@ -135,11 +136,12 @@ fn emit_skill_injected_metric(
let Some(otel) = otel else {
return;
};
let skill_name_tag = sanitize_metric_tag_value(skill.name.as_str());
otel.counter(
"codex.skill.injected",
/*inc*/ 1,
&[("status", status), ("skill", skill.name.as_str())],
&[("status", status), ("skill", skill_name_tag.as_str())],
);
}