opentelemetry-dotnet icon indicating copy to clipboard operation
opentelemetry-dotnet copied to clipboard

OTEL_RESOURCE_ATTRIBUTES values are not parsed as defined per spec

Open pellared opened this issue 3 years ago • 3 comments
trafficstars

From the OTel spec:

The OTEL_RESOURCE_ATTRIBUTES environment variable will contain of a list of key value pairs, and these are expected to be represented in a format matching to the W3C Baggage, except that additional semi-colon delimited metadata is not supported, i.e.: key1=value1,key2=value2. All attribute values MUST be considered strings.

From the W3C spec:

A value contains a URL encoded UTF-8 string. Leading and trailing whitespaces (OWS) are allowed but MUST be trimmed when converting the header into a data structure.

Currently, the values defined in OTEL_RESOURCE_ATTRIBUTES (splitted by ,) are not parsed at all. Source code here.

Found thanks to: https://github.com/open-telemetry/opentelemetry-go/pull/2963

pellared avatar Jun 21 '22 06:06 pellared

https://github.com/open-telemetry/opentelemetry-specification/pull/2670 updates the Resource spec to take percent-decode into account.

lgfa29 avatar Jul 31 '22 23:07 lgfa29

Is this still the case @pellared ?

martinjt avatar Feb 22 '24 14:02 martinjt

The OTEL_RESOURCE_ATTRIBUTES env var is still still not properly parsed.

It accepts keys that should not be allowed.

They values are not precent decoded as noted https://github.com/open-telemetry/opentelemetry-dotnet/issues/3395#issuecomment-1200526391

Reference: https://www.w3.org/TR/baggage/#definition

pellared avatar Feb 22 '24 16:02 pellared