Skip to content

Centralize shared OpenTelemetry code into `source/extensions/common/o…

7c85abe
Select commit
Loading
Failed to load commit list.
Open

Centralize shared OpenTelemetry code into source/extensions/common/opentelemetry/ #44379

Centralize shared OpenTelemetry code into `source/extensions/common/o…
7c85abe
Select commit
Loading
Failed to load commit list.
CI (Envoy) / Envoy/Checks failed Apr 14, 2026 in 33m 59s

Envoy/Checks (failure)

Check has finished

Details

Check run finished (failure ❌)

The check run can be viewed here:

Envoy/Checks (pr/44379/main@7c85abe)

Check started by

Request (pr/44379/main@7c85abe)

mmorel-35 @mmorel-35 7c85abe #44379 merge main@5aeaf37

Centralize shared OpenTelemetry code into `source/extensions/common/opentelemetry/`

Centralizes shared OpenTelemetry types, utilities, and exporters into source/extensions/common/opentelemetry/, aligning the directory structure and naming conventions with opentelemetry-cpp.

Changes Made

SDK structure (mirrors opentelemetry-cpp)

  • Added sdk/common/types.h with a shared AttributeValue variant type (Sdk::Common namespace) and #include <cstdint>
  • Added sdk/trace/constants.h, sdk/logs/constants.h, and sdk/metrics/constants.h with per-signal OTLP service method and HTTP endpoint constants (Sdk::Trace, Sdk::Logs, Sdk::Metrics namespaces) — avoids empty placeholder files and provides real utility, mirroring the approach in #41011

Exporters

  • Moved OTLP trace exporter (gRPC + HTTP) to exporters/otlp/ under Exporters::Otlp namespace; original tracer headers retained as forwarding/compat headers
  • Added exporters/otlp/environment.h/cc with Exporters::Otlp::GetUserAgent() — mirrors GetOtlpDefaultUserAgent() from opentelemetry-cpp's otlp_environment.h; used by both gRPC and HTTP exporters as it is an exporter identity concern, not HTTP-specific

Attribute utilities (mirrors opentelemetry-cpp)

  • Moved populate_attribute_utils.h/cc to exporters/otlp/ under Exporters::Otlp namespace — mirrors OtlpPopulateAttributeUtils from opentelemetry-cpp, which lives alongside the OTLP exporters
  • Renamed getStringKeyValue()makeKeyValue()
  • otlp_utils.h / otlp_utils_lib kept as backward-compatibility forwarding shims with using OtlpUtils = PopulateAttributeUtils
  • Fixed populateAnyValue() to handle all 17 AttributeValue alternatives, including array types for bool/int/uint/int64/double/uint64/bytes (previously fell into IS_ENVOY_BUG); uint64 values exceeding INT64_MAX are now clamped rather than silently wrapping to negative

Cross-extension dependency fix

  • stat_sinks/open_telemetry/open_telemetry_http_impl.cc now depends on common/opentelemetry directly instead of access_loggers/open_telemetry
  • Updated grpc_trace_exporter.cc, grpc_access_log_impl.cc, and open_telemetry_impl.cc to consume the new sdk/{trace,logs,metrics}/constants.h rather than inline string literals

Type safety & correctness

  • Added resource_spans_size() / scope_spans_size() guards in logExportedSpans() to prevent out-of-bounds proto access
  • OtelAttributes changed from std::map to absl::flat_hash_map; compile-time static_assert added to test

Tests & docs

  • Moved populate_attribute_utils_test.cc to test/extensions/common/opentelemetry/exporters/otlp/ to mirror source layout
  • Split tests into ExporterEnvironmentTest + PopulateAttributeUtilsTest; renamed test cases to match new API names (MakeKeyValue, GetUserAgent)
  • Added #include <type_traits>, #include "absl/strings/match.h" to tests
  • Updated README.md to document new API names and locations (PopulateAttributeUtils in exporters/otlp/, Exporters::Otlp::GetUserAgent(), environment_lib, and the new sdk/{trace,logs,metrics}_constants_lib targets)
  • Updated changelog
Environment

Request variables

Key Value
ref 1b0ef65
sha 7c85abe
pr 44379
base-sha 5aeaf37
actor mmorel-35 @mmorel-35
message Centralize shared OpenTelemetry code into source/extensions/common/opentelemetry/...
started 1776142701.081967
target-branch main
trusted false
Build image

Container image/s (as used in this CI run)

Key Value
default docker.io/envoyproxy/envoy-build:86873047235e9b8232df989a5999b9bebf9db69c
mobile docker.io/envoyproxy/envoy-build:mobile-86873047235e9b8232df989a5999b9bebf9db69c
Version

Envoy version (as used in this CI run)

Key Value
major 1
minor 38
patch 0
dev true