open-telemetry / open-telemetry/opentelemetry-python-contrib

The stack trace is missing when an exception is thrown.

Open Beginner friendly
#3,914 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.1k
Forks
1.1k
Avg merge
4d 15h
Merged PRs (30d)
16

Description

Hi,
I'm using datadog and collect span with some intrumentation (httpx, wsgi), but when an exception is raised, the stacktrace is missing in datadog.
I looked at the instrumentation code and saw that the command span.record_exception(exception) was missing here:

https://github.com/open-telemetry/opentelemetry-python-contrib/blob/5a15f57588fa94e3f761c1bd9400ab5a6a66a9c8/instrumentation/opentelemetry-instrumentation-httpx/src/opentelemetry/instrumentation/httpx/__init__.py#L875

            if exception:
                if span.is_recording() and _report_new(
                    self._sem_conv_opt_in_mode
                ):
                    span.set_attribute(
                        ERROR_TYPE, type(exception).__qualname__
                    )
                    metric_attributes[ERROR_TYPE] = type(
                        exception
                    ).__qualname__

                raise exception.with_traceback(exception.__traceback__)

What do you think? I'm not a coding expert, but if it seems relevant to you, I'd be happy to submit a pull request.

Thanks a lot,

Axel

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in instrumentation/opentelemetry-instrumentation-httpx/src/opentelemetry/instrumentation/httpx/init.py around the exception-handling code at the linked line. Review how the command span handles the exception and verify the related instrumentation tests, if present. Done means exceptions raised there produce a stack trace in the collected Datadog span.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
observability
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.