Skip to content
Draft
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
14 changes: 11 additions & 3 deletions src/uipath/tracing/_otel_exporters.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
SpanExporter,
SpanExportResult,
)
from opentelemetry.trace import NonRecordingSpan

from uipath._utils._ssl_context import get_httpx_client_kwargs

Expand Down Expand Up @@ -404,10 +405,12 @@ def _get_base_url(self) -> str:
return uipath_url

def _should_drop_span(self, span: ReadableSpan) -> bool:
"""Check if span is marked for dropping.
"""Check if span should be dropped.

Spans with telemetry.filter="drop" are skipped by this exporter.
Drops NonRecordingSpan instances and spans with telemetry.filter="drop".
"""
if isinstance(span, NonRecordingSpan):
return True
attrs = span.attributes or {}
return attrs.get("telemetry.filter") == "drop"

Expand All @@ -422,7 +425,12 @@ def __init__(self, file_path: str):

def export(self, spans: Sequence[ReadableSpan]) -> SpanExportResult:
try:
dict_spans = [span.to_json(indent=None) for span in spans]
# Filter out NonRecordingSpan instances
recording_spans = [s for s in spans if not isinstance(s, NonRecordingSpan)]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be

[s for s in spans if not self._should_drop_span(s)]

if not recording_spans:
return SpanExportResult.SUCCESS

dict_spans = [span.to_json(indent=None) for span in recording_spans]

with open(self.file_path, "a") as f:
for span in dict_spans:
Expand Down