mirror of
https://github.com/openai/codex.git
synced 2026-04-30 01:16:54 +00:00
## Summary - reduce public module visibility across Rust crates, preferring private or crate-private modules with explicit crate-root public exports - update external call sites and tests to use the intended public crate APIs instead of reaching through module trees - add the module visibility guideline to AGENTS.md ## Validation - `cargo check --workspace --all-targets --message-format=short` passed before the final fix/format pass - `just fix` completed successfully - `just fmt` completed successfully - `git diff --check` passed
67 lines
2.3 KiB
Rust
67 lines
2.3 KiB
Rust
pub(crate) mod config;
|
|
mod events;
|
|
pub(crate) mod metrics;
|
|
pub(crate) mod provider;
|
|
pub(crate) mod trace_context;
|
|
|
|
mod otlp;
|
|
mod targets;
|
|
|
|
use crate::metrics::Result as MetricsResult;
|
|
use serde::Serialize;
|
|
use strum_macros::Display;
|
|
|
|
pub use crate::config::OtelExporter;
|
|
pub use crate::config::OtelHttpProtocol;
|
|
pub use crate::config::OtelSettings;
|
|
pub use crate::config::OtelTlsConfig;
|
|
pub use crate::events::session_telemetry::AuthEnvTelemetryMetadata;
|
|
pub use crate::events::session_telemetry::SessionTelemetry;
|
|
pub use crate::events::session_telemetry::SessionTelemetryMetadata;
|
|
pub use crate::metrics::runtime_metrics::RuntimeMetricTotals;
|
|
pub use crate::metrics::runtime_metrics::RuntimeMetricsSummary;
|
|
pub use crate::metrics::timer::Timer;
|
|
pub use crate::metrics::*;
|
|
pub use crate::provider::OtelProvider;
|
|
pub use crate::trace_context::context_from_w3c_trace_context;
|
|
pub use crate::trace_context::current_span_trace_id;
|
|
pub use crate::trace_context::current_span_w3c_trace_context;
|
|
pub use crate::trace_context::set_parent_from_context;
|
|
pub use crate::trace_context::set_parent_from_w3c_trace_context;
|
|
pub use crate::trace_context::span_w3c_trace_context;
|
|
pub use crate::trace_context::traceparent_context_from_env;
|
|
pub use codex_utils_string::sanitize_metric_tag_value;
|
|
|
|
#[derive(Debug, Clone, Serialize, Display)]
|
|
#[serde(rename_all = "snake_case")]
|
|
pub enum ToolDecisionSource {
|
|
AutomatedReviewer,
|
|
Config,
|
|
User,
|
|
}
|
|
|
|
/// Maps to API/auth `AuthMode` to avoid a circular dependency on codex-core.
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Display)]
|
|
pub enum TelemetryAuthMode {
|
|
ApiKey,
|
|
Chatgpt,
|
|
}
|
|
|
|
impl From<codex_app_server_protocol::AuthMode> for TelemetryAuthMode {
|
|
fn from(mode: codex_app_server_protocol::AuthMode) -> Self {
|
|
match mode {
|
|
codex_app_server_protocol::AuthMode::ApiKey => Self::ApiKey,
|
|
codex_app_server_protocol::AuthMode::Chatgpt
|
|
| codex_app_server_protocol::AuthMode::ChatgptAuthTokens => Self::Chatgpt,
|
|
}
|
|
}
|
|
}
|
|
|
|
/// Start a metrics timer using the globally installed metrics client.
|
|
pub fn start_global_timer(name: &str, tags: &[(&str, &str)]) -> MetricsResult<Timer> {
|
|
let Some(metrics) = crate::metrics::global() else {
|
|
return Err(MetricsError::ExporterDisabled);
|
|
};
|
|
metrics.start_timer(name, tags)
|
|
}
|