From 6b33cdfae5334e6e2e2436ad401cda6efb5a1d8e Mon Sep 17 00:00:00 2001 From: tammy-baylis-swi Date: Fri, 4 Apr 2025 17:12:22 -0700 Subject: [PATCH] OTLP exporter compression gzip by default --- solarwinds_apm/distro.py | 3 +++ tests/unit/test_distro.py | 2 ++ 2 files changed, 5 insertions(+) diff --git a/solarwinds_apm/distro.py b/solarwinds_apm/distro.py index fc072d25..6e8477da 100644 --- a/solarwinds_apm/distro.py +++ b/solarwinds_apm/distro.py @@ -26,6 +26,7 @@ from opentelemetry.instrumentation.version import __version__ as inst_version from opentelemetry.metrics import NoOpMeterProvider from opentelemetry.sdk.environment_variables import ( + OTEL_EXPORTER_OTLP_COMPRESSION, OTEL_EXPORTER_OTLP_LOGS_ENDPOINT, OTEL_EXPORTER_OTLP_LOGS_HEADERS, OTEL_EXPORTER_OTLP_LOGS_PROTOCOL, @@ -234,6 +235,8 @@ def _configure(self, **kwargs): # Always opt into new semconv for all instrumentors (if supported) environ["OTEL_SEMCONV_STABILITY_OPT_IN"] = self.get_semconv_opt_in() + environ.setdefault(OTEL_EXPORTER_OTLP_COMPRESSION, "gzip") + def load_instrumentor(self, entry_point: EntryPoint, **kwargs): """Takes a collection of instrumentation entry points and activates them by instantiating and calling instrument() diff --git a/tests/unit/test_distro.py b/tests/unit/test_distro.py index 620e76f5..248c17c3 100644 --- a/tests/unit/test_distro.py +++ b/tests/unit/test_distro.py @@ -14,6 +14,7 @@ OTEL_TRACES_EXPORTER ) from opentelemetry.sdk.environment_variables import ( + OTEL_EXPORTER_OTLP_COMPRESSION, OTEL_EXPORTER_OTLP_LOGS_ENDPOINT, OTEL_EXPORTER_OTLP_LOGS_HEADERS, OTEL_EXPORTER_OTLP_LOGS_PROTOCOL, @@ -485,6 +486,7 @@ def test_configure_no_env(self, mocker): mocker.patch.dict(os.environ, {}) distro.SolarWindsDistro()._configure() assert os.environ[OTEL_PROPAGATORS] == "tracecontext,baggage,solarwinds_propagator" + assert os.environ[OTEL_EXPORTER_OTLP_COMPRESSION] == "gzip" assert os.environ[OTEL_TRACES_EXPORTER] == "solarwinds_exporter" assert os.environ[OTEL_METRICS_EXPORTER] == "otlp_proto_http" assert os.environ[OTEL_LOGS_EXPORTER] == "otlp_proto_http"