open-telemetry / open-telemetry/opentelemetry-python
OpenTracing Shim not converting exceptions to format expected by OpenTelemetry
@zhihali is already working on this.
Since Sep 4, 2024.
- Dominant language
- Python
- Stars
- 2.6k
- Forks
- 1k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 19
Description
Describe your environment
No response
What happened?
When using TracerShim.start_active_span as a context manager, errors raised inside this context manager are being caught by _on_error function that underneath calls SpanShim.log_kv and this is where problem lays. _on_error catches exception as an object, same with traceback and exception type. These are being passed in log_kv to OpenTelemetry's Span.add_event as argument attributes which is expected to be a dict of primitive types or lists of primitive types. All in all, OpenTelemetry logs a warning Invalid type type for attribute 'error.kind' value. Expected one of ["bool","str","bytes","int","float"] or a sequence of those types and discards this error.
It should be an easy fix with casting all objects present inside key_values to string inside log_kv function or something like that
Steps to Reproduce
with tracer.start_active_span("whatever"):
raise Exception
Expected Result
An error present in logs
Actual Result
Warning Invalid type type for attribute 'error.kind' value. Expected one of ["bool","str","bytes","int","float"] or a sequence of those types
Additional context
No response
Would you like to implement a fix?
None
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.