netra-sdk 0.1.43__py3-none-any.whl → 0.1.44__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of netra-sdk might be problematic. Click here for more details.
- netra/tracer.py +63 -39
- netra/version.py +1 -1
- {netra_sdk-0.1.43.dist-info → netra_sdk-0.1.44.dist-info}/METADATA +1 -1
- {netra_sdk-0.1.43.dist-info → netra_sdk-0.1.44.dist-info}/RECORD +6 -6
- {netra_sdk-0.1.43.dist-info → netra_sdk-0.1.44.dist-info}/WHEEL +1 -1
- {netra_sdk-0.1.43.dist-info → netra_sdk-0.1.44.dist-info}/licenses/LICENCE +0 -0
netra/tracer.py
CHANGED
|
@@ -57,50 +57,74 @@ class FilteringSpanExporter(SpanExporter): # type: ignore[misc]
|
|
|
57
57
|
|
|
58
58
|
def export(self, spans: Sequence[ReadableSpan]) -> SpanExportResult:
|
|
59
59
|
filtered: List[ReadableSpan] = []
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
blocked_parent_map: Dict[Any, Any] = {}
|
|
61
|
+
for span in spans:
|
|
62
|
+
name = getattr(span, "name", None)
|
|
63
|
+
if name is None or not self._is_blocked(name):
|
|
64
|
+
filtered.append(span)
|
|
64
65
|
continue
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
try:
|
|
73
|
-
has_valid_parent = bool(is_valid_attr())
|
|
74
|
-
except Exception:
|
|
75
|
-
has_valid_parent = False
|
|
76
|
-
else:
|
|
77
|
-
has_valid_parent = bool(is_valid_attr)
|
|
78
|
-
|
|
79
|
-
is_root_span = parent is None or not has_valid_parent
|
|
80
|
-
|
|
81
|
-
if is_root_span:
|
|
82
|
-
# Apply name-based blocking only for root spans
|
|
83
|
-
if name in self._exact:
|
|
84
|
-
continue
|
|
85
|
-
blocked = False
|
|
86
|
-
for pref in self._prefixes:
|
|
87
|
-
if name.startswith(pref):
|
|
88
|
-
blocked = True
|
|
89
|
-
break
|
|
90
|
-
if not blocked and self._suffixes:
|
|
91
|
-
for suf in self._suffixes:
|
|
92
|
-
if name.endswith(suf):
|
|
93
|
-
blocked = True
|
|
94
|
-
break
|
|
95
|
-
if not blocked:
|
|
96
|
-
filtered.append(s)
|
|
97
|
-
else:
|
|
98
|
-
# Do not block child spans based on name
|
|
99
|
-
filtered.append(s)
|
|
66
|
+
|
|
67
|
+
span_context = getattr(span, "context", None)
|
|
68
|
+
span_id = getattr(span_context, "span_id", None) if span_context else None
|
|
69
|
+
if span_id is not None:
|
|
70
|
+
blocked_parent_map[span_id] = getattr(span, "parent", None)
|
|
71
|
+
if blocked_parent_map:
|
|
72
|
+
self._reparent_blocked_children(filtered, blocked_parent_map)
|
|
100
73
|
if not filtered:
|
|
101
74
|
return SpanExportResult.SUCCESS
|
|
102
75
|
return self._exporter.export(filtered)
|
|
103
76
|
|
|
77
|
+
def _is_blocked(self, name: str) -> bool:
|
|
78
|
+
if name in self._exact:
|
|
79
|
+
return True
|
|
80
|
+
for pref in self._prefixes:
|
|
81
|
+
if name.startswith(pref):
|
|
82
|
+
return True
|
|
83
|
+
for suf in self._suffixes:
|
|
84
|
+
if name.endswith(suf):
|
|
85
|
+
return True
|
|
86
|
+
return False
|
|
87
|
+
|
|
88
|
+
def _reparent_blocked_children(
|
|
89
|
+
self,
|
|
90
|
+
spans: Sequence[ReadableSpan],
|
|
91
|
+
blocked_parent_map: Dict[Any, Any],
|
|
92
|
+
) -> None:
|
|
93
|
+
if not blocked_parent_map:
|
|
94
|
+
return
|
|
95
|
+
|
|
96
|
+
for span in spans:
|
|
97
|
+
parent_context = getattr(span, "parent", None)
|
|
98
|
+
if parent_context is None:
|
|
99
|
+
continue
|
|
100
|
+
|
|
101
|
+
updated_parent = parent_context
|
|
102
|
+
visited: set[Any] = set()
|
|
103
|
+
changed = False
|
|
104
|
+
|
|
105
|
+
while updated_parent is not None:
|
|
106
|
+
parent_span_id = getattr(updated_parent, "span_id", None)
|
|
107
|
+
if parent_span_id not in blocked_parent_map or parent_span_id in visited:
|
|
108
|
+
break
|
|
109
|
+
visited.add(parent_span_id)
|
|
110
|
+
updated_parent = blocked_parent_map[parent_span_id]
|
|
111
|
+
changed = True
|
|
112
|
+
|
|
113
|
+
if changed:
|
|
114
|
+
self._set_span_parent(span, updated_parent)
|
|
115
|
+
|
|
116
|
+
def _set_span_parent(self, span: ReadableSpan, parent: Any) -> None:
|
|
117
|
+
if hasattr(span, "_parent"):
|
|
118
|
+
try:
|
|
119
|
+
span._parent = parent
|
|
120
|
+
return
|
|
121
|
+
except Exception:
|
|
122
|
+
pass
|
|
123
|
+
try:
|
|
124
|
+
setattr(span, "parent", parent)
|
|
125
|
+
except Exception:
|
|
126
|
+
logger.debug("Failed to reparent span %s", getattr(span, "name", "<unknown>"), exc_info=True)
|
|
127
|
+
|
|
104
128
|
def shutdown(self) -> None:
|
|
105
129
|
try:
|
|
106
130
|
self._exporter.shutdown()
|
netra/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.1.
|
|
1
|
+
__version__ = "0.1.44"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: netra-sdk
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.44
|
|
4
4
|
Summary: A Python SDK for AI application observability that provides OpenTelemetry-based monitoring, tracing, and PII protection for LLM and vector database applications. Enables easy instrumentation, session tracking, and privacy-focused data collection for AI systems in production environments.
|
|
5
5
|
License-Expression: Apache-2.0
|
|
6
6
|
License-File: LICENCE
|
|
@@ -47,10 +47,10 @@ netra/processors/session_span_processor.py,sha256=qcsBl-LnILWefsftI8NQhXDGb94OWP
|
|
|
47
47
|
netra/scanner.py,sha256=kyDpeZiscCPb6pjuhS-sfsVj-dviBFRepdUWh0sLoEY,11554
|
|
48
48
|
netra/session_manager.py,sha256=VzmSAiP63ODCuOWv-irsxyU2LvHoqjOBUuXtyxboBU0,13740
|
|
49
49
|
netra/span_wrapper.py,sha256=IygQX78xQRlL_Z1MfKfUbv0okihx92qNClnRlYFtRNc,8004
|
|
50
|
-
netra/tracer.py,sha256=
|
|
50
|
+
netra/tracer.py,sha256=3s_ZAHgpfeegcnA43KVEinEPVyo3kGi_0bvSrQcKljk,8348
|
|
51
51
|
netra/utils.py,sha256=FblSzI8qMTfEbusakGBKE9CNELW0GEBHl09mPPxgI-w,2521
|
|
52
|
-
netra/version.py,sha256=
|
|
53
|
-
netra_sdk-0.1.
|
|
54
|
-
netra_sdk-0.1.
|
|
55
|
-
netra_sdk-0.1.
|
|
56
|
-
netra_sdk-0.1.
|
|
52
|
+
netra/version.py,sha256=AoJtnEXXv6E20uj57ChQUsGoLfKG8mvSQpdz97tcyis,23
|
|
53
|
+
netra_sdk-0.1.44.dist-info/METADATA,sha256=f7QrKDQQtQyaaAzIzGFF44KOpHpNW00wrZ3KIPt0zvA,28208
|
|
54
|
+
netra_sdk-0.1.44.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
|
|
55
|
+
netra_sdk-0.1.44.dist-info/licenses/LICENCE,sha256=8B_UoZ-BAl0AqiHAHUETCgd3I2B9yYJ1WEQtVb_qFMA,11359
|
|
56
|
+
netra_sdk-0.1.44.dist-info/RECORD,,
|
|
File without changes
|