Skip to content

Context API is missing CreateKey functionality #1737

@Oberon00

Description

@Oberon00

opentelemetry-python uses strings as keys for Context. However, the spec is written to expect a special Key object https://github.com/open-telemetry/opentelemetry-specification/blob/v1.1.0/specification/context/context.md#create-a-key

The key name exists for debugging purposes and does not uniquely identify the key. Multiple calls to CreateKey with the same name SHOULD NOT return the same value unless language constraints dictate otherwise.

I don't think "language constraints dictate otherwise" for Python (CreateKey could just return a new Key object every time and compare by identity).

Even then this is only a SHOULD requirement that is violated here, so the current implementation can in theory be made spec conformant just by providing a method def create_key(keyname: str): return keyname.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions