Skip to content

Threading integration breaks OpenCensus' threading integration #2076

Closed
@EpicWink

Description

@EpicWink

How do you use Sentry?

Sentry Saas (sentry.io)

Version

1.21.1

Steps to Reproduce

  1. Enable threading Sentry integration (it seems to be enabled by default)
  2. Enable threading OpenCensus integration
  3. Start a thread
import threading

import sentry_sdk.integrations.threading
import opencensus.trace.config_integration

sentry_sdk.init(integrations=[
    sentry_sdk.integrations.threading.ThreadingIntegration(),
])

opencensus.trace.config_integration.trace_integrations(
    integrations=["threading"],
)

thread = threading.Thread(target=print, args=("foo",))
thread.start()
thread.join()

Expected Result

No error, output: foo

Actual Result

Exceptions raised on every thread's startup

Exception in thread Thread-1 (print):
Traceback (most recent call last):
  File "/usr/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
    self.run()
  File ".venv/lib/python3.10/site-packages/sentry_sdk/integrations/threading.py", line 69, in run
    reraise(*_capture_exception())
  File ".venv/lib/python3.10/site-packages/sentry_sdk/_compat.py", line 60, in reraise
    raise value
  File ".venv/lib/python3.10/site-packages/sentry_sdk/integrations/threading.py", line 67, in run
    return old_run_func(self, *a, **kw)
  File ".venv/lib/python3.10/site-packages/opencensus/ext/threading/trace.py", line 80, in call
    *self._opencensus_context
AttributeError: 'Thread' object has no attribute '_opencensus_context'

Additional details

  • Python: 3.10
  • OpenCensus threading extension: 0.1.2

My suggestion is to use functools.update_wrapper (or the convenience decorator functools.wraps) to set the name of sentry_start to "start" (and maybe the same for the result of _wrap_run, to "run"), so it "holds up to basic introspection".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions