Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions packages/traceloop-sdk/traceloop/sdk/tracing/tracing.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import atexit
import logging
import os
import contextvars
import uuid


from colorama import Fore
Expand Down Expand Up @@ -59,6 +61,7 @@ class TracerWrapper(object):
enable_content_tracing: bool = True
endpoint: str = None
headers: Dict[str, str] = {}
association_properties_var: ContextVar = None
__tracer_provider: TracerProvider = None
__image_uploader: ImageUploader = None

Expand Down Expand Up @@ -462,6 +465,12 @@ def get_tracer(self):
def set_association_properties(properties: dict) -> None:
attach(set_value("association_properties", properties))

# Generate a unique UUID for the task
wrapper_uuid = str(uuid.uuid4())

# Set a wrapper-specific value using the generated UUID
token = TracerWrapper.association_properties_var.set({'wrapper_uuid': wrapper_uuid})

# Attach association properties to the current span, if it's a workflow or a task
span = trace.get_current_span()
if get_value("workflow_name") is not None or get_value("entity_name") is not None:
Expand Down