netra-sdk 0.1.7__py3-none-any.whl → 0.1.10__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/__init__.py +2 -2
- netra/config.py +2 -2
- netra/instrumentation/__init__.py +26 -1
- netra/instrumentation/fastapi/__init__.py +363 -0
- netra/instrumentation/fastapi/version.py +1 -0
- netra/instrumentation/instruments.py +1 -0
- netra/instrumentation/openai/__init__.py +153 -0
- netra/instrumentation/openai/version.py +1 -0
- netra/instrumentation/openai/wrappers.py +554 -0
- netra/processors/__init__.py +1 -2
- netra/span_wrapper.py +15 -0
- netra/tracer.py +1 -2
- netra/version.py +1 -1
- {netra_sdk-0.1.7.dist-info → netra_sdk-0.1.10.dist-info}/METADATA +53 -1
- {netra_sdk-0.1.7.dist-info → netra_sdk-0.1.10.dist-info}/RECORD +17 -13
- netra/processors/error_detection_processor.py +0 -84
- {netra_sdk-0.1.7.dist-info → netra_sdk-0.1.10.dist-info}/LICENCE +0 -0
- {netra_sdk-0.1.7.dist-info → netra_sdk-0.1.10.dist-info}/WHEEL +0 -0
|
@@ -1,42 +1,46 @@
|
|
|
1
|
-
netra/__init__.py,sha256=
|
|
1
|
+
netra/__init__.py,sha256=0w42KiANH31q0sXFL2hLxRjueepfo_jbx2oMDc5miFo,4733
|
|
2
2
|
netra/anonymizer/__init__.py,sha256=KeGPPZqKVZbtkbirEKYTYhj6aZHlakjdQhD7QHqBRio,133
|
|
3
3
|
netra/anonymizer/anonymizer.py,sha256=1VeYAsFpF_tYDlqJF-Q82-ZXGOR4YWBqrKUsRw3qOrA,3539
|
|
4
4
|
netra/anonymizer/base.py,sha256=ytPxHCUD2OXlEY6fNTuMmwImNdIjgj294I41FIgoXpU,5946
|
|
5
5
|
netra/anonymizer/fp_anonymizer.py,sha256=_6svIYmE0eejdIMkhKBUWCNjGtGimtrGtbLvPSOp8W4,6493
|
|
6
|
-
netra/config.py,sha256=
|
|
6
|
+
netra/config.py,sha256=S9GsCvwtakrmryAaV-AhyVB_wAQ6tjwPLLZQemLgXko,5006
|
|
7
7
|
netra/decorators.py,sha256=V_WpZ2IgW2Y7B_WnSXmKUGGhkM5Cra2TwONddmJpPaI,6837
|
|
8
8
|
netra/exceptions/__init__.py,sha256=uDgcBxmC4WhdS7HRYQk_TtJyxH1s1o6wZmcsnSHLAcM,174
|
|
9
9
|
netra/exceptions/injection.py,sha256=ke4eUXRYUFJkMZgdSyPPkPt5PdxToTI6xLEBI0hTWUQ,1332
|
|
10
10
|
netra/exceptions/pii.py,sha256=MT4p_x-zH3VtYudTSxw1Z9qQZADJDspq64WrYqSWlZc,2438
|
|
11
11
|
netra/input_scanner.py,sha256=bzP3s7YudGHQrIbUgQGrcIBEJ6CmOewzuYNSu75cVXM,4988
|
|
12
|
-
netra/instrumentation/__init__.py,sha256=
|
|
12
|
+
netra/instrumentation/__init__.py,sha256=Mz7BlRp4zgKAD3oLBGfBzh5naVVgAP0sLw4ISDydhLw,39567
|
|
13
13
|
netra/instrumentation/aiohttp/__init__.py,sha256=M1kuF0R3gKY5rlbhEC1AR13UWHelmfokluL2yFysKWc,14398
|
|
14
14
|
netra/instrumentation/aiohttp/version.py,sha256=Zy-0Aukx-HS_Mo3NKPWg-hlUoWKDzS0w58gLoVtJec8,24
|
|
15
15
|
netra/instrumentation/cohere/__init__.py,sha256=3XwmCAZwZiMkHdNN3YvcBOLsNCx80ymbU31TyMzv1IY,17685
|
|
16
16
|
netra/instrumentation/cohere/version.py,sha256=eFXRvO5AgP2DDj5tMt7hkuzi30NOLEqZ9dJpPaHFZLs,23
|
|
17
|
+
netra/instrumentation/fastapi/__init__.py,sha256=v955lLezcI-3toA60RVkTYqlstu-QjMOAbLkM9uHHU4,16611
|
|
18
|
+
netra/instrumentation/fastapi/version.py,sha256=FX3pdiCFGDsISNiq2rT0sQFwNLZ5IGKhiVknXkSE3O0,24
|
|
17
19
|
netra/instrumentation/google_genai/__init__.py,sha256=470x3o5_NDQHRNT4o-IWnSZw1JjPnAoFSZ-mpaWvAuE,17894
|
|
18
20
|
netra/instrumentation/google_genai/config.py,sha256=XCyo3mk30qkvqyCqeTrKwROahu0gcOEwmbDLOo53J5k,121
|
|
19
21
|
netra/instrumentation/google_genai/utils.py,sha256=2OeSN5jUaMKF4x5zWiW65R1LB_a44Roi00isv2vxFME,921
|
|
20
22
|
netra/instrumentation/google_genai/version.py,sha256=Hww1duZrC8kYK7ThBSQVyz0HNOb0ys_o8Pln-wVQ1hI,23
|
|
21
23
|
netra/instrumentation/httpx/__init__.py,sha256=w1su_eQP_w5ZJHq0Lf-4miF5zM4OOW0ItmRp0wi85Ew,19388
|
|
22
24
|
netra/instrumentation/httpx/version.py,sha256=ZRQKbgDaGz_yuLk-cUKuk6ZBKCSRKZC8nQd041NRNXk,23
|
|
23
|
-
netra/instrumentation/instruments.py,sha256=
|
|
25
|
+
netra/instrumentation/instruments.py,sha256=_25TCDiBsgqP_fzL4OgwWx2UKD8EnzvLn0WA8t3lB_U,4269
|
|
24
26
|
netra/instrumentation/mistralai/__init__.py,sha256=RE0b-rS6iXdoynJMFKHL9s97eYo5HghrJa013fR4ZhI,18910
|
|
25
27
|
netra/instrumentation/mistralai/config.py,sha256=XCyo3mk30qkvqyCqeTrKwROahu0gcOEwmbDLOo53J5k,121
|
|
26
28
|
netra/instrumentation/mistralai/utils.py,sha256=nhdIer5gJFxuGwg8FCT222hggDHeMQDhJctnDSwLqcc,894
|
|
27
29
|
netra/instrumentation/mistralai/version.py,sha256=d6593s-XBNvVxri9lr2qLUDZQ3Zk3-VXHEwdb4pj8qA,22
|
|
30
|
+
netra/instrumentation/openai/__init__.py,sha256=HztqLMw8Tf30-Ydqr4N7FcvAwj-5cnGZNqI-S3wIZ_4,5143
|
|
31
|
+
netra/instrumentation/openai/version.py,sha256=_J-N1qG50GykJDM356BSQf0E8LoLbB8AaC3RKho494A,23
|
|
32
|
+
netra/instrumentation/openai/wrappers.py,sha256=hXUgWKAs2_LCKIBnScoIJt_AkHhdQKnZWk7D94UjPGU,20685
|
|
28
33
|
netra/instrumentation/weaviate/__init__.py,sha256=EOlpWxobOLHYKqo_kMct_7nu26x1hr8qkeG5_h99wtg,4330
|
|
29
34
|
netra/instrumentation/weaviate/version.py,sha256=PiCZHjonujPbnIn0KmD3Yl68hrjPRG_oKe5vJF3mmG8,24
|
|
30
35
|
netra/pii.py,sha256=S7GnVzoNJEzKiUWnqN9bOCKPeNLsriztgB2E6Rx-yJU,27023
|
|
31
|
-
netra/processors/__init__.py,sha256=
|
|
32
|
-
netra/processors/error_detection_processor.py,sha256=TtSZoJ7BCMHlVaXWYfqLHSZ6uIx43tdqYb7AFXpt0BA,2898
|
|
36
|
+
netra/processors/__init__.py,sha256=wfnSskRBtMT90hO7LqFJoEW374LgoH_gnTxhynqtByI,109
|
|
33
37
|
netra/processors/session_span_processor.py,sha256=qcsBl-LnILWefsftI8NQhXDGb94OWPc8LvzhVA0JS_c,2432
|
|
34
38
|
netra/scanner.py,sha256=wqjMZnEbVvrGMiUSI352grUyHpkk94oBfHfMiXPhpGU,3866
|
|
35
39
|
netra/session_manager.py,sha256=EVcnWcSj4NdkH--HmqHx0mmzivQiM4GCyFLu6lwi33M,6252
|
|
36
|
-
netra/span_wrapper.py,sha256=
|
|
37
|
-
netra/tracer.py,sha256=
|
|
38
|
-
netra/version.py,sha256=
|
|
39
|
-
netra_sdk-0.1.
|
|
40
|
-
netra_sdk-0.1.
|
|
41
|
-
netra_sdk-0.1.
|
|
42
|
-
netra_sdk-0.1.
|
|
40
|
+
netra/span_wrapper.py,sha256=MMFuQTqEmQ33pj6qUeIx7EbJJoEz_hzW-4dt1Y2N7s8,7286
|
|
41
|
+
netra/tracer.py,sha256=In5QPVLz_6BxrolWpav9EuR9_hirD2UUIlyY75QUaKk,3450
|
|
42
|
+
netra/version.py,sha256=z0zCHFTcKSR0tJ6h5qrpNmRVP21QIPP8N0p7quCnnm0,23
|
|
43
|
+
netra_sdk-0.1.10.dist-info/LICENCE,sha256=8B_UoZ-BAl0AqiHAHUETCgd3I2B9yYJ1WEQtVb_qFMA,11359
|
|
44
|
+
netra_sdk-0.1.10.dist-info/METADATA,sha256=h3pHq1tLHZpGI8_DhN_6x499Ek0RZsGUBHOvy6JMQio,25101
|
|
45
|
+
netra_sdk-0.1.10.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
46
|
+
netra_sdk-0.1.10.dist-info/RECORD,,
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import logging
|
|
2
|
-
from typing import Any, Optional, Union
|
|
3
|
-
|
|
4
|
-
import httpx
|
|
5
|
-
from opentelemetry.sdk.trace import SpanProcessor
|
|
6
|
-
from opentelemetry.trace import Context, Span, Status, StatusCode
|
|
7
|
-
|
|
8
|
-
from netra import Netra
|
|
9
|
-
|
|
10
|
-
logger = logging.getLogger(__name__)
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
class ErrorDetectionProcessor(SpanProcessor): # type: ignore[misc]
|
|
14
|
-
"""
|
|
15
|
-
OpenTelemetry span processor that monitors for error attributes in spans and creates custom events.
|
|
16
|
-
"""
|
|
17
|
-
|
|
18
|
-
def __init__(self) -> None:
|
|
19
|
-
pass
|
|
20
|
-
|
|
21
|
-
def on_start(self, span: Span, parent_context: Optional[Context] = None) -> None:
|
|
22
|
-
"""Called when a span starts."""
|
|
23
|
-
span_id = self._get_span_id(span)
|
|
24
|
-
if not span_id:
|
|
25
|
-
return
|
|
26
|
-
|
|
27
|
-
# Wrap span methods to capture data
|
|
28
|
-
self._wrap_span_methods(span, span_id)
|
|
29
|
-
|
|
30
|
-
def on_end(self, span: Span) -> None:
|
|
31
|
-
"""Called when a span ends."""
|
|
32
|
-
|
|
33
|
-
def force_flush(self, timeout_millis: int = 30000) -> bool:
|
|
34
|
-
"""Force flush any pending data."""
|
|
35
|
-
return True
|
|
36
|
-
|
|
37
|
-
def shutdown(self) -> bool:
|
|
38
|
-
"""Shutdown the processor."""
|
|
39
|
-
return True
|
|
40
|
-
|
|
41
|
-
def _get_span_id(self, span: Span) -> Optional[str]:
|
|
42
|
-
"""Get a unique identifier for the span."""
|
|
43
|
-
try:
|
|
44
|
-
span_context = span.get_span_context()
|
|
45
|
-
return f"{span_context.trace_id:032x}-{span_context.span_id:016x}"
|
|
46
|
-
except Exception:
|
|
47
|
-
return None
|
|
48
|
-
|
|
49
|
-
def _status_code_processing(self, status_code: int) -> None:
|
|
50
|
-
if httpx.codes.is_error(status_code):
|
|
51
|
-
event_attributes = {"has_error": True, "status_code": status_code}
|
|
52
|
-
Netra.set_custom_event(event_name="error_detected", attributes=event_attributes)
|
|
53
|
-
|
|
54
|
-
def _wrap_span_methods(self, span: Span, span_id: str) -> Any:
|
|
55
|
-
"""Wrap span methods to capture attributes and events."""
|
|
56
|
-
# Wrap set_attribute
|
|
57
|
-
original_set_attribute = span.set_attribute
|
|
58
|
-
|
|
59
|
-
def wrapped_set_attribute(key: str, value: Any) -> Any:
|
|
60
|
-
# Status code processing
|
|
61
|
-
if key == "http.status_code":
|
|
62
|
-
self._status_code_processing(value)
|
|
63
|
-
|
|
64
|
-
return original_set_attribute(key, value)
|
|
65
|
-
|
|
66
|
-
# Wrap set_status
|
|
67
|
-
original_set_status = span.set_status
|
|
68
|
-
|
|
69
|
-
def wrapped_set_status(status: Union[Status, StatusCode]) -> Any:
|
|
70
|
-
# Check if status code is ERROR
|
|
71
|
-
if isinstance(status, Status):
|
|
72
|
-
status_code = status.status_code
|
|
73
|
-
elif isinstance(status, StatusCode):
|
|
74
|
-
status_code = status
|
|
75
|
-
if status_code == StatusCode.ERROR:
|
|
76
|
-
event_attributes = {
|
|
77
|
-
"has_error": True,
|
|
78
|
-
}
|
|
79
|
-
Netra.set_custom_event(event_name="error_detected", attributes=event_attributes)
|
|
80
|
-
|
|
81
|
-
return original_set_status(status)
|
|
82
|
-
|
|
83
|
-
span.set_attribute = wrapped_set_attribute
|
|
84
|
-
span.set_status = wrapped_set_status
|
|
File without changes
|
|
File without changes
|