You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
@Oberon00
I understand that this is for spec compliancy, but is there much point in creating a CreateKey method if we are using strings as keys? If there is a strong argument for using objects over strings that would make more sense.
Keys are used to allow cross-cutting concerns to control access to their local state. They are unique such that other libraries which may use the same context cannot accidentally use the same key.
This argument is less important for Python where you cannot easily load the same Context-using library multiple times (which can happen for example in Java with the classloader mechanism).
Another argument would be that object identity comparison might be faster than string comparison.
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
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
.The text was updated successfully, but these errors were encountered: