Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

URL encoded values for OTEL_EXPORTER_OTLP_HEADERS are not exported #2523

Closed
pyohannes opened this issue Feb 6, 2024 · 2 comments · Fixed by #2579
Closed

URL encoded values for OTEL_EXPORTER_OTLP_HEADERS are not exported #2523

pyohannes opened this issue Feb 6, 2024 · 2 comments · Fixed by #2579
Labels
bug Something isn't working triage/accepted Indicates an issue or PR is ready to be actively worked on.

Comments

@pyohannes
Copy link
Contributor

pyohannes commented Feb 6, 2024

Describe your environment

$ uname -a
Linux [...] 6.5.0-14-generic #14~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Nov 20 18:15:30 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/11/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 11.4.0-1ubuntu1~22.04' --with-bugurl=file:///usr/share/doc/gcc-11/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-11 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --enable-cet --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-11-XeT9lY/gcc-11-11.4.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-11-XeT9lY/gcc-11-11.4.0/debian/tmp-gcn/usr --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-serialization=2
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.4.0 (Ubuntu 11.4.0-1ubuntu1~22.04) 
$ git log -1 --format="%H"
2b5c2b404448d8b675c2d645e27e9affd609ccb7

Steps to reproduce

$ export OTEL_EXPORTER_OTLP_HEADERS=Authorization=Basic%20NzAx[...]==
$ ./examples/otlp/example_otlp_http
,Body:{"status":"error","error":"authentication error: no credentials provided"}tp_client.cc:103 [OTLP HTTP Client] Export failed, Status:401, Header:  Content-Length: 74
[Error] File: /home/johannes/Source/opentelemetry-cpp/exporters/otlp/src/otlp_http_exporter.cc:118 [OTLP HTTP Client] ERROR: Export 1 trace span(s) error: 1
,Body:{"status":"error","error":"authentication error: no credentials provided"}tp_client.cc:103 [OTLP HTTP Client] Export failed, Status:401, Header:  Content-Length: 74
[Error] File: /home/johannes/Source/opentelemetry-cpp/exporters/otlp/src/otlp_http_exporter.cc:118 [OTLP HTTP Client] ERROR: Export 1 trace span(s) error: 1
,Body:{"status":"error","error":"authentication error: no credentials provided"}tp_client.cc:103 [OTLP HTTP Client] Export failed, Status:401, Header:  Content-Length: 74
[Error] File: /home/johannes/Source/opentelemetry-cpp/exporters/otlp/src/otlp_http_exporter.cc:118 [OTLP HTTP Client] ERROR: Export 1 trace span(s) error: 1
,Body:{"status":"error","error":"authentication error: no credentials provided"}tp_client.cc:103 [OTLP HTTP Client] Export failed, Status:401, Header:  Content-Length: 74
[Error] File: /home/johannes/Source/opentelemetry-cpp/exporters/otlp/src/otlp_http_exporter.cc:118 [OTLP HTTP Client] ERROR: Export 1 trace span(s) error: 1
$
$ export OTEL_EXPORTER_OTLP_HEADERS="Authorization=Basic 20NzAx[...]=="
$ ./examples/otlp/example_otlp_http
$

What is the expected behavior?

The C++ SDK should support URL encoded values in OTEL_EXPORTER_OTLP_HEADERS. For backward compatibility, also non-URL encoded values should be supported.

Both this settings should work:

OTEL_EXPORTER_OTLP_HEADERS="Authorization=Basic%20AAA"
OTEL_EXPORTER_OTLP_HEADERS="Authorization=Basic AAA"

What is the actual behavior?

Currently only non-URL encoded values are supported.

Additional context

The OTel specification requires values for OTEL_EXPORTER_OTLP_HEADERS to be formatted conforming with the W3C Baggage specification.

The W3C Baggage spec requires values to be URL encoded:

A value contains a string whose character encoding MUST be UTF-8 [Encoding]. Any characters outside of the baggage-octet range of characters MUST be percent-encoded. Characters which are not required to be percent-encoded MAY be percent-encoded.

This has been discussed in open-telemetry/opentelemetry-specification#3832, the result being that the behavior described in the OTel and W3C specification is desired and SDKs should support URL encoded values.

@pyohannes pyohannes added the bug Something isn't working label Feb 6, 2024
@github-actions github-actions bot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Feb 6, 2024
@marcalff
Copy link
Member

marcalff commented Feb 6, 2024

Thanks for the report.

I also assume this is about C++, not .NET.

@pyohannes pyohannes changed the title URL encoded values for OTEL_EXPORTER_OTLP_HEADERS are not exported URL encoded values for OTEL_EXPORTER_OTLP_HEADERS are not exported Feb 6, 2024
@lalitb
Copy link
Member

lalitb commented Feb 6, 2024

And @pyohannes can self-assign this one, he still knows the otel-cpp code better. jk :)

@marcalff marcalff added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Feb 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants