traceloop / traceloop/openllmetry
๐ Bug Report: Workflow annotation closure in python is not cleared on exiting the function
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.4k
- Forks
- 1.1k
- Avg merge
- 8d 14h
- Merged PRs (30d)
- 2
Description
Which component is this bug for?
Traceloop SDK
๐ Description
When you are reporting metrics to Otel in the Python SDK, using the annotations (@workflow and @task) to describe the levels, the Workflow annotation is not cleared when exiting the function.
If no followup workflow annotation is given prior to another task being encountered, the 'traceloop.workflow.name' attribute on subsequent tasks will be the last workflow encountered
๐ Reproduction steps
Using the traceloop-sdk version 0.25.1
Using this example code:
traceloop.workflow.name@task()
def task_wrapper():
pass
@workflow()
def workflow_wrapper():
task_wrapper()
@task()
def workflowless_task():
pass
workflowless_task() #has no workflow when the metric is sent up
workflow_wrapper() #metric sent up has workflow and task wrapper correctly assigned
workflowless_task()# Metric has the workflow from above (incorrect) with the correct task
๐ Expected behavior
workflow should be cleared when exiting the function. It should reset to null
๐ Actual Behavior with Screenshots
The below shows the create a story task being incorrectly assigned a workflow some of the time
๐ค Python Version
3.11
๐ Provide any additional context for the Bug.
No response
๐ Have you spent some time to check if this bug has been raised before?
- I checked and didn't find similar issue
Are you willing to submit PR?
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.
Research direction
Start by reproducing the provided Python example with the @workflow and @task annotations in the Traceloop SDK. Trace how the workflow context is handled when the decorated function exits; done means a later workflowless task reports no previous workflow name.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- observability-sre
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100