open-telemetry / opentelemetry-cpp

The OpenTelemetry C++ Client
https://opentelemetry.io/
Apache License 2.0
851 stars 403 forks source link

[EXPORTER] Support URL-encoded values for `OTEL_EXPORTER_OTLP_HEADERS` #2579

Closed pyohannes closed 6 months ago

pyohannes commented 6 months ago

Fixes #2523

Changes

This PR adds support for URL-encoded values in OTEL_EXPORTER_OTLP_HEADERS and related headers, which is required by the specification.

The necessary url_decode function is added to ext/include/opentelemetry/ext/http/common/url_parser.h, which was renamed to ext/include/opentelemetry/ext/http/common/url_util.h to reflect the change.

For backwards compatibility, both URL-encoded and non-URL-encoded values are supported, for example:

OTEL_EXPORTER_OTLP_HEADERS="Authorization=Basic%20AAA"
OTEL_EXPORTER_OTLP_HEADERS="Authorization=Basic AAA"
pyohannes commented 6 months ago

Could we not rename url_parser.h to url_util.h ?

@marcalff Got it, I reverted the renaming.