mirror of
https://github.com/openai/codex.git
synced 2026-11-25 15:24:26 +00:00
Add bounded plugin measurement analytics (#38239)
## What changed - Add `PluginMeasurementsInput` and `PluginMeasurementRow`, plus an analytics client method for recording batches and checking whether analytics are enabled. - Emit each valid row as a `codex_plugin_measurement_event` with thread, turn, item, plugin, execution, and operation context. - Bound batches at 100 rows and reject non-finite values, invalid identifiers, and rows with more than eight dimensions. - Treat measurement events as plugin events when routing API-key analytics. ## Testing - Cover batch limits, row filtering, serialized event payloads, and API-key plugin-event routing. GitOrigin-RevId: f949ed06246ee1e22466df2660076f2d4f556444
This commit is contained in:
1 parent
dc8562d672
commit
d6eefb26a6
7 files changed
+318
No files matched your search
@@ -46,6 +46,7 @@ use codex_protocol::protocol::SubAgentSource;
|
||||
use codex_protocol::protocol::ThreadSource;
|
||||
use codex_protocol::protocol::TokenUsage;
|
||||
use serde::Serialize;
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
#[derive(Clone, Copy, Debug, Serialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
@@ -76,6 +77,7 @@ pub(crate) enum TrackEventRequest {
|
||||
TurnSteer(CodexTurnSteerEventRequest),
|
||||
ArtifactOperation(CodexArtifactOperationEventRequest),
|
||||
CommandExecution(CodexCommandExecutionEventRequest),
|
||||
PluginMeasurement(CodexPluginMeasurementEventRequest),
|
||||
FileChange(CodexFileChangeEventRequest),
|
||||
McpToolCall(CodexMcpToolCallEventRequest),
|
||||
DynamicToolCall(CodexDynamicToolCallEventRequest),
|
||||
@@ -160,6 +162,7 @@ impl TrackEventRequest {
|
||||
Self::SkillInvocation(event) => event.event_params.plugin_id.is_some(),
|
||||
Self::McpToolCall(event) => event.event_params.plugin_id.is_some(),
|
||||
Self::ArtifactOperation(event) => !event.event_params.plugin_id.is_empty(),
|
||||
Self::PluginMeasurement(event) => !event.event_params.plugin_id.is_empty(),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
@@ -750,6 +753,25 @@ pub(crate) struct CodexCommandExecutionEventRequest {
|
||||
pub(crate) event_params: CodexCommandExecutionEventParams,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub(crate) struct CodexPluginMeasurementEventParams {
|
||||
pub(crate) thread_id: String,
|
||||
pub(crate) turn_id: String,
|
||||
pub(crate) item_id: String,
|
||||
pub(crate) plugin_id: String,
|
||||
pub(crate) execution_id: String,
|
||||
pub(crate) operation: String,
|
||||
pub(crate) measurement_name: String,
|
||||
pub(crate) number_value: f64,
|
||||
pub(crate) dimensions: Option<BTreeMap<String, String>>,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub(crate) struct CodexPluginMeasurementEventRequest {
|
||||
pub(crate) event_type: &'static str,
|
||||
pub(crate) event_params: CodexPluginMeasurementEventParams,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub(crate) struct CodexFileChangeEventParams {
|
||||
#[serde(flatten)]
|
||||
|
||||
Reference in new issue
Block a user