Skip to content

[Bug] GeneratorExit possibly causing issues on context detach in OTel finally #441

Open
@cretz

Description

@cretz

Describe the bug

Reports of:

Failed to detach context

Traceback (most recent call last):
  File "/path/to/temporalio/contrib/opentelemetry.py", line 427, in _top_level_workflow_context
    yield None
  File "/path/to/temporalio/contrib/opentelemetry.py", line 340, in execute_workflow
    return await super().execute_workflow(input)
GeneratorExit

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/path/to/opentelemetry/context/__init__.py", line 157, in detach
    _RUNTIME_CONTEXT.detach(token)  # type: ignore
  File "/path/to/opentelemetry/context/contextvars_context.py", line 50, in detach
    self._current_context.reset(token)  # type: ignore
ValueError: <Token var=<ContextVar name='current_context' default={} at 0x79340011d590> at 0x7933a4b4c9c0> was created in a different Context"

There are outstanding issues like open-telemetry/opentelemetry-python#2606 that may be related.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions