From 78bb00267f0d441bbd568f29018d6a57b3908b82 Mon Sep 17 00:00:00 2001 From: ionmincu Date: Fri, 16 Jan 2026 16:07:53 +0200 Subject: [PATCH] feat(traces): filter out NonRecordingSpan --- src/uipath/tracing/_otel_exporters.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/uipath/tracing/_otel_exporters.py b/src/uipath/tracing/_otel_exporters.py index 34317f878..2c1d5e760 100644 --- a/src/uipath/tracing/_otel_exporters.py +++ b/src/uipath/tracing/_otel_exporters.py @@ -10,6 +10,7 @@ SpanExporter, SpanExportResult, ) +from opentelemetry.trace import NonRecordingSpan from uipath._utils._ssl_context import get_httpx_client_kwargs @@ -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" @@ -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)] + 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: