mirror of
https://github.com/openai/codex.git
synced 2026-12-06 01:10:58 +00:00
Record MCP server entrypoint telemetry
This commit is contained in:
@@ -915,6 +915,7 @@ async fn cli_main(arg0_paths: Arg0DispatchPaths) -> anyhow::Result<()> {
|
||||
arg0_paths.clone(),
|
||||
root_config_overrides,
|
||||
strict_config || root_strict_config,
|
||||
codex_mcp_server::McpServerEntrypoint::CodexCliSubcommand,
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
|
||||
@@ -52,14 +52,32 @@ pub use crate::patch_approval::PatchApprovalResponse;
|
||||
/// plenty for an interactive CLI.
|
||||
const CHANNEL_CAPACITY: usize = 128;
|
||||
const DEFAULT_ANALYTICS_ENABLED: bool = true;
|
||||
const MCP_SERVER_METRIC: &str = "codex.mcp_server";
|
||||
const MCP_SERVER_ENTRYPOINT_TAG: &str = "entrypoint";
|
||||
const OTEL_SERVICE_NAME: &str = "codex_mcp_server";
|
||||
|
||||
type IncomingMessage = JsonRpcMessage<ClientRequest, Value, ClientNotification>;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum McpServerEntrypoint {
|
||||
CodexCliSubcommand,
|
||||
StandaloneBinary,
|
||||
}
|
||||
|
||||
impl McpServerEntrypoint {
|
||||
fn telemetry_tag_value(self) -> &'static str {
|
||||
match self {
|
||||
Self::CodexCliSubcommand => "codex_cli_subcommand",
|
||||
Self::StandaloneBinary => "standalone_binary",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn run_main(
|
||||
arg0_paths: Arg0DispatchPaths,
|
||||
cli_config_overrides: CliConfigOverrides,
|
||||
strict_config: bool,
|
||||
entrypoint: McpServerEntrypoint,
|
||||
) -> IoResult<()> {
|
||||
// Parse CLI overrides once and derive the base Config eagerly so later
|
||||
// components do not need to work with raw TOML values.
|
||||
@@ -91,6 +109,13 @@ pub async fn run_main(
|
||||
)
|
||||
})?;
|
||||
codex_core::otel_init::record_process_start(otel.as_ref(), OTEL_SERVICE_NAME);
|
||||
if let Some(metrics) = otel.as_ref().and_then(|provider| provider.metrics()) {
|
||||
let _ = metrics.counter(
|
||||
MCP_SERVER_METRIC,
|
||||
/*inc*/ 1,
|
||||
&[(MCP_SERVER_ENTRYPOINT_TAG, entrypoint.telemetry_tag_value())],
|
||||
);
|
||||
}
|
||||
codex_core::otel_init::install_sqlite_telemetry(otel.as_ref(), OTEL_SERVICE_NAME);
|
||||
let state_db = codex_core::init_state_db(&config).await;
|
||||
let environment_manager = Arc::new(
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use codex_arg0::Arg0DispatchPaths;
|
||||
use codex_arg0::arg0_dispatch_or_else;
|
||||
use codex_mcp_server::McpServerEntrypoint;
|
||||
use codex_mcp_server::run_main;
|
||||
use codex_utils_cli::CliConfigOverrides;
|
||||
|
||||
@@ -9,6 +10,7 @@ fn main() -> anyhow::Result<()> {
|
||||
arg0_paths,
|
||||
CliConfigOverrides::default(),
|
||||
/*strict_config*/ false,
|
||||
McpServerEntrypoint::StandaloneBinary,
|
||||
)
|
||||
.await?;
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user