mirror of
https://github.com/openai/codex.git
synced 2026-11-17 22:10:37 +00:00
Default Statsig metrics exports to Zstandard compression (#61911)
## What changed Enable OTLP HTTP Zstandard support and use it by default for the Statsig metrics exporter. Leave compression selection to the SDK when any of `OTEL_EXPORTER_OTLP_COMPRESSION`, `OTEL_EXPORTER_OTLP_METRICS_COMPRESSION`, `OTEL_EXPORTER_OTLP_HEADERS`, or `OTEL_EXPORTER_OTLP_METRICS_HEADERS` is set. GitOrigin-RevId: 67c8088cf35fb95be3618337ea3ad2fe5a75586d
This commit is contained in:
Generated
+1
@@ -11621,6 +11621,7 @@ dependencies = [
|
||||
"tokio",
|
||||
"tonic",
|
||||
"tracing",
|
||||
"zstd",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
@@ -39,6 +39,7 @@ opentelemetry-otlp = { workspace = true, features = [
|
||||
"reqwest-rustls",
|
||||
"tls",
|
||||
"tls-roots",
|
||||
"zstd-http",
|
||||
]}
|
||||
opentelemetry-semantic-conventions = { workspace = true }
|
||||
opentelemetry_sdk = { workspace = true, features = [
|
||||
|
||||
@@ -19,6 +19,11 @@ use opentelemetry::metrics::Gauge;
|
||||
use opentelemetry::metrics::Histogram;
|
||||
use opentelemetry::metrics::Meter;
|
||||
use opentelemetry::metrics::MeterProvider as _;
|
||||
use opentelemetry_otlp::Compression;
|
||||
use opentelemetry_otlp::OTEL_EXPORTER_OTLP_COMPRESSION;
|
||||
use opentelemetry_otlp::OTEL_EXPORTER_OTLP_HEADERS;
|
||||
use opentelemetry_otlp::OTEL_EXPORTER_OTLP_METRICS_COMPRESSION;
|
||||
use opentelemetry_otlp::OTEL_EXPORTER_OTLP_METRICS_HEADERS;
|
||||
use opentelemetry_otlp::OTEL_EXPORTER_OTLP_METRICS_TIMEOUT;
|
||||
use opentelemetry_otlp::Protocol;
|
||||
use opentelemetry_otlp::WithExportConfig;
|
||||
@@ -400,6 +405,7 @@ impl MetricsClient {
|
||||
temporality,
|
||||
&http_client_factory,
|
||||
headers_helper,
|
||||
/*compression*/ None,
|
||||
)?,
|
||||
policy: http_client_factory.network_policy().clone(),
|
||||
};
|
||||
@@ -661,15 +667,29 @@ fn build_otlp_metric_exporter(
|
||||
temporality: Temporality,
|
||||
factory: &codex_http_client::HttpClientFactory,
|
||||
headers_helper: Option<Arc<HeadersHelper>>,
|
||||
compression: Option<Compression>,
|
||||
) -> Result<opentelemetry_otlp::MetricExporter> {
|
||||
match exporter {
|
||||
OtelExporter::None => Err(MetricsError::ExporterDisabled),
|
||||
OtelExporter::Statsig => build_otlp_metric_exporter(
|
||||
crate::config::resolve_exporter(&OtelExporter::Statsig),
|
||||
temporality,
|
||||
factory,
|
||||
/*headers_helper*/ None,
|
||||
),
|
||||
OtelExporter::Statsig => {
|
||||
// Leave explicit OTLP overrides to the SDK.
|
||||
let compression = [
|
||||
OTEL_EXPORTER_OTLP_METRICS_COMPRESSION,
|
||||
OTEL_EXPORTER_OTLP_COMPRESSION,
|
||||
OTEL_EXPORTER_OTLP_METRICS_HEADERS,
|
||||
OTEL_EXPORTER_OTLP_HEADERS,
|
||||
]
|
||||
.into_iter()
|
||||
.all(|key| std::env::var_os(key).is_none())
|
||||
.then_some(Compression::Zstd);
|
||||
build_otlp_metric_exporter(
|
||||
crate::config::resolve_exporter(&OtelExporter::Statsig),
|
||||
temporality,
|
||||
factory,
|
||||
/*headers_helper*/ None,
|
||||
compression,
|
||||
)
|
||||
}
|
||||
OtelExporter::OtlpGrpc {
|
||||
endpoint,
|
||||
headers,
|
||||
@@ -720,6 +740,10 @@ fn build_otlp_metric_exporter(
|
||||
.with_protocol(protocol)
|
||||
.with_headers(headers);
|
||||
|
||||
if let Some(compression) = compression {
|
||||
exporter_builder = exporter_builder.with_compression(compression);
|
||||
}
|
||||
|
||||
if headers_helper.is_some() || factory.network_policy().is_managed() {
|
||||
let client = crate::otlp::build_async_http_client(
|
||||
factory,
|
||||
|
||||
Reference in New Issue
Block a user