Skip to content

Support Opentelemetry Proto definitions for span attributes #4380

Open
@shivanshuraj1333

Description

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 kind AnyValue

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions