-
Notifications
You must be signed in to change notification settings - Fork 658
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
Support Opentelemetry Proto definitions for span attributes #4380
Comments
Hi, the OTLP protocol is not the primary definition of what should be allowed as attribute, the spec is. The spec does not allow map values for span attributes: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/common/README.md#attribute
It also calls out logs as one example where "Any" is actually the allowed attribute type, but span uses standard attributes, so IMHO opentelemetry-python behavior is correct, allowing map values would make it non-conforming. (There were also many discussions about allowing map values, nested attributes, ... in the past in the spec if you want to research why this is the case) |
I see, thanks @Oberon00 do you know why logs are exception? And hence the same logic (query etc), that would work on logs attributes would not work in span attributes because the data type is now changed. Any reasoning for this inconsistency that you are aware of? |
AFAIK because for logs the API is not defined by OTel (OTLP logs are mainly used to transport logs that were produced with some existing non-OTel logging framework) and some of these support such attribute types already. For tracing, maybe open-telemetry/opentelemetry-specification#3858 and open-telemetry/opentelemetry-specification#376 can provide explanations. |
Summary
Otel python api should support AnyValue instead of AnyAttributeValue, according to the proto definition for span attributes' value, (see KeyValue reference here)
What happened?
The trace proto definition defines span attributes to be of kind
KeyValue
.KayValues
supports Value of kindAnyValue
BUT,
Opentelemetry-python defines span attributes' values as types.AttributeValue, which is doesn't support
AnyValue
(this is the how it is defined)The value of trace attributes should be of kind AnyValue, and not AttributeValue
This is causing the unit tests to fail in this PR open-telemetry/opentelemetry-python-contrib#3170
Steps to Reproduce
Run the unit tests in this PR open-telemetry/opentelemetry-python-contrib#3170
The PR adds map as attributes, which is supported by the proto definition of spans but not by python implementation of it https://github.com/open-telemetry/opentelemetry-python/blob/main/opentelemetry-api/src/opentelemetry/trace/span.py#L82
Expected Result
Opentelemetry python should adhere to trace proto definition as described here
So, that it can support map values as valid value in attribute values of a span, currently it doesn't support that.
Ideally https://github.com/open-telemetry/opentelemetry-python/blob/main/opentelemetry-api/src/opentelemetry/util/types.py#L21 should be used here instead of https://github.com/open-telemetry/opentelemetry-python/blob/main/opentelemetry-api/src/opentelemetry/util/types.py#L32
Actual Result
AnyValue is not sported in span attributes, and hence map values are not supported in span attributes.
Additional context
No response
Would you like to implement a fix?
None
The text was updated successfully, but these errors were encountered: