open-telemetry / opentelemetry-python

OpenTelemetry Python API and SDK
https://opentelemetry.io
Apache License 2.0
1.67k stars 571 forks source link

`exception.type` should capture the fully qualified type name, not just the class name #3824

Closed lmolkova closed 2 months ago

lmolkova commented 3 months ago

https://github.com/open-telemetry/opentelemetry-python/blob/721beb8b530e7a830c1e27b70c2fb9af6465baf1/opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py#L999

According to the spec, it should contain

The type of the exception (its fully-qualified class name, if applicable).

It'd uniquely identify exceptions and will make it easier to understand where they are coming from.

xrmx commented 3 months ago

The second example in the linked spec OSError looks like python , and that's exactly what the linked code is returning.

lmolkova commented 3 months ago

@xrmx the spec then contradicts itself and I don't mind fixing it :)

xrmx commented 3 months ago

In python some exceptions are builtin you won't have a path like in java. For others maybe prefixing it with its .__class__.__module__ if it's not builtins.

pvaneck commented 3 months ago

Seems like it would also be better to use __qualname__ instead of __name__ in the (likely uncommon) case of nested exceptions.