traceloop / traceloop/openllmetry

๐Ÿ› Bug Report: Workflow annotation closure in python is not cleared on exiting the function

Open
#1,518 3 comments 0 reactions 0 assignees View on GitHub

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
image

๐Ÿค– 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

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 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.