netra-sdk 0.1.15__py3-none-any.whl → 0.1.17__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 CHANGED
@@ -2,7 +2,7 @@ import logging
2
2
  import threading
3
3
  from typing import Any, Dict, Optional, Set
4
4
 
5
- from netra.instrumentation.instruments import NetraInstruments
5
+ from netra.instrumentation.instruments import InstrumentSet, NetraInstruments
6
6
 
7
7
  from .config import Config
8
8
 
@@ -70,6 +70,7 @@ class Netra:
70
70
 
71
71
  # Instrument all supported modules
72
72
  # Pass trace_content flag to instrumentors that can capture prompts/completions
73
+
73
74
  init_instrumentations(
74
75
  should_enrich_metrics=True,
75
76
  base64_image_uploader=None,
@@ -88,7 +89,10 @@ class Netra:
88
89
  Args:
89
90
  session_id: Session identifier
90
91
  """
91
- SessionManager.set_session_context("session_id", session_id)
92
+ if session_id:
93
+ SessionManager.set_session_context("session_id", session_id)
94
+ else:
95
+ logger.warning("Session ID must be provided for setting session_id.")
92
96
 
93
97
  @classmethod
94
98
  def set_user_id(cls, user_id: str) -> None:
@@ -98,7 +102,10 @@ class Netra:
98
102
  Args:
99
103
  user_id: User identifier
100
104
  """
101
- SessionManager.set_session_context("user_id", user_id)
105
+ if user_id:
106
+ SessionManager.set_session_context("user_id", user_id)
107
+ else:
108
+ logger.warning("User ID must be provided for setting user_id.")
102
109
 
103
110
  @classmethod
104
111
  def set_tenant_id(cls, tenant_id: str) -> None:
@@ -108,7 +115,10 @@ class Netra:
108
115
  Args:
109
116
  user_account_id: User account identifier
110
117
  """
111
- SessionManager.set_session_context("tenant_id", tenant_id)
118
+ if tenant_id:
119
+ SessionManager.set_session_context("tenant_id", tenant_id)
120
+ else:
121
+ logger.warning("Tenant ID must be provided for setting tenant_id.")
112
122
 
113
123
  @classmethod
114
124
  def set_custom_attributes(cls, key: str, value: Any) -> None:
@@ -119,7 +129,10 @@ class Netra:
119
129
  key: Custom attribute key
120
130
  value: Custom attribute value
121
131
  """
122
- SessionManager.set_session_context("custom_attributes", {key: value})
132
+ if key and value:
133
+ SessionManager.set_session_context("custom_attributes", {key: value})
134
+ else:
135
+ logger.warning("Both key and value must be provided for custom attributes.")
123
136
 
124
137
  @classmethod
125
138
  def set_custom_event(cls, event_name: str, attributes: Any) -> None:
@@ -130,7 +143,10 @@ class Netra:
130
143
  event_name: Name of the custom event
131
144
  attributes: Attributes of the custom event
132
145
  """
133
- SessionManager.set_custom_event(event_name, attributes)
146
+ if event_name and attributes:
147
+ SessionManager.set_custom_event(event_name, attributes)
148
+ else:
149
+ logger.warning("Both event_name and attributes must be provided for custom events.")
134
150
 
135
151
  @classmethod
136
152
  def start_span(
@@ -31,6 +31,20 @@ def init_instrumentations(
31
31
  netra_custom_block_instruments.add(getattr(CustomInstruments, instrument.name))
32
32
  else:
33
33
  traceloop_block_instruments.add(getattr(Instruments, instrument.name))
34
+
35
+ # If no instruments are provided for instrumentation
36
+ if instruments is None:
37
+ traceloop_block_instruments = set(Instruments)
38
+ netra_custom_block_instruments = set(CustomInstruments)
39
+
40
+ # If only custom instruments from netra are provided for instrumentation
41
+ if instruments is not None and not traceloop_instruments and not traceloop_block_instruments:
42
+ traceloop_block_instruments = set(Instruments)
43
+
44
+ # If only traceloop instruments are provided for instrumentation
45
+ if instruments is not None and not netra_custom_instruments and not netra_custom_block_instruments:
46
+ netra_custom_block_instruments = set(CustomInstruments)
47
+
34
48
  traceloop_block_instruments.update(
35
49
  {
36
50
  Instruments.WEAVIATE,
@@ -40,8 +54,6 @@ def init_instrumentations(
40
54
  Instruments.OPENAI,
41
55
  }
42
56
  )
43
- if instruments is not None and traceloop_instruments is None and traceloop_block_instruments is None:
44
- traceloop_block_instruments = set(Instruments)
45
57
 
46
58
  init_instrumentations(
47
59
  should_enrich_metrics=should_enrich_metrics,
netra/version.py CHANGED
@@ -1,2 +1 @@
1
- __version__ = "0.1.15"
2
-
1
+ __version__ = "0.1.17"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: netra-sdk
3
- Version: 0.1.15
3
+ Version: 0.1.17
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: Apache-2.0
6
6
  Keywords: netra,tracing,observability,sdk,ai,llm,vector,database
@@ -18,7 +18,8 @@ Classifier: Programming Language :: Python :: 3.12
18
18
  Classifier: Programming Language :: Python :: 3.13
19
19
  Classifier: Typing :: Typed
20
20
  Provides-Extra: llm-guard
21
- Requires-Dist: llm-guard (>=0.3.16,<0.4.0) ; extra == "llm-guard"
21
+ Provides-Extra: presidio
22
+ Requires-Dist: llm-guard (==0.3.16) ; extra == "llm-guard"
22
23
  Requires-Dist: opentelemetry-api (>=1.34.0,<2.0.0)
23
24
  Requires-Dist: opentelemetry-instrumentation-aio-pika (>=0.55b1,<1.0.0)
24
25
  Requires-Dist: opentelemetry-instrumentation-aiohttp-client (>=0.55b1,<1.0.0)
@@ -66,7 +67,8 @@ Requires-Dist: opentelemetry-instrumentation-tortoiseorm (>=0.55b1,<1.0.0)
66
67
  Requires-Dist: opentelemetry-instrumentation-urllib (>=0.55b1,<1.0.0)
67
68
  Requires-Dist: opentelemetry-instrumentation-urllib3 (>=0.55b1,<1.0.0)
68
69
  Requires-Dist: opentelemetry-sdk (>=1.34.0,<2.0.0)
69
- Requires-Dist: presidio-analyzer (>=2.2.358,<3.0.0)
70
+ Requires-Dist: presidio-analyzer (==2.2.358) ; extra == "presidio"
71
+ Requires-Dist: presidio-anonymizer (==2.2.358) ; extra == "presidio"
70
72
  Requires-Dist: traceloop-sdk (>=0.40.7,<0.43.0)
71
73
  Project-URL: Bug Tracker, https://github.com/KeyValueSoftwareSystems/netra-sdk-py/issues
72
74
  Project-URL: Documentation, https://github.com/KeyValueSoftwareSystems/netra-sdk-py/blob/main/README.md
@@ -108,6 +110,21 @@ poetry add netra-sdk
108
110
 
109
111
  Netra SDK supports optional dependencies for enhanced functionality:
110
112
 
113
+ #### Presidio for PII Detection
114
+ To use the PII detection features provided by Netra SDK:
115
+
116
+ ```bash
117
+ pip install 'netra-sdk[presidio]'
118
+ ```
119
+
120
+ Or, using Poetry:
121
+
122
+ ```bash
123
+ poetry add netra-sdk --extras "presidio"
124
+ ```
125
+
126
+
127
+
111
128
  #### LLM-Guard for Prompt Injection Protection
112
129
 
113
130
  To use the full functionality of prompt injection scanning provided by llm-guard:
@@ -132,6 +149,7 @@ Initialize the Netra SDK at the start of your application:
132
149
 
133
150
  ```python
134
151
  from netra import Netra
152
+ from netra.instrumentation.instruments import InstrumentSet
135
153
 
136
154
  # Initialize with default settings
137
155
  Netra.init(app_name="Your application name")
@@ -143,7 +161,8 @@ Netra.init(
143
161
  app_name="Your application name",
144
162
  headers=headers,
145
163
  trace_content=True,
146
- environment="Your Application environment"
164
+ environment="Your Application environment",
165
+ instruments={InstrumentSet.OPENAI, InstrumentSet.ANTHROPIC},
147
166
  )
148
167
  ```
149
168
 
@@ -573,7 +592,7 @@ Control which instrumentations are enabled:
573
592
  from netra import Netra
574
593
  from netra.instrumentation.instruments import InstrumentSet
575
594
 
576
- # Enable specific instruments only
595
+ # Enable specific instruments
577
596
  Netra.init(
578
597
  app_name="Selective App",
579
598
  instruments={
@@ -621,9 +640,10 @@ export NETRA_HEADERS="authorization=Bearer your-token"
621
640
 
622
641
  ```python
623
642
  from netra import Netra
643
+ from netra.instrumentation.instruments import InstrumentSet
624
644
 
625
645
  # Simple initialization - SDK automatically picks up environment variables
626
- Netra.init(app_name="Your App")
646
+ Netra.init(app_name="Your App", instruments={InstrumentSet})
627
647
  # No endpoint configuration needed in code!
628
648
  ```
629
649
 
@@ -1,4 +1,4 @@
1
- netra/__init__.py,sha256=0w42KiANH31q0sXFL2hLxRjueepfo_jbx2oMDc5miFo,4733
1
+ netra/__init__.py,sha256=49R2bZrVu30HhpE3gfpu0b5C5cNovC6WyNyUwHCOfQ8,5392
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
@@ -9,7 +9,7 @@ netra/exceptions/__init__.py,sha256=uDgcBxmC4WhdS7HRYQk_TtJyxH1s1o6wZmcsnSHLAcM,
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=Mz7BlRp4zgKAD3oLBGfBzh5naVVgAP0sLw4ISDydhLw,39567
12
+ netra/instrumentation/__init__.py,sha256=ZORhcso04LPD6-Y7oPsh74rY-jwz1unsfYZBcP--SzM,40081
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
@@ -39,8 +39,8 @@ netra/scanner.py,sha256=wqjMZnEbVvrGMiUSI352grUyHpkk94oBfHfMiXPhpGU,3866
39
39
  netra/session_manager.py,sha256=EVcnWcSj4NdkH--HmqHx0mmzivQiM4GCyFLu6lwi33M,6252
40
40
  netra/span_wrapper.py,sha256=DA5jjXkHBUJ8_mdlYP06rcZzFoSih4gdP71Wwr3btcQ,8104
41
41
  netra/tracer.py,sha256=In5QPVLz_6BxrolWpav9EuR9_hirD2UUIlyY75QUaKk,3450
42
- netra/version.py,sha256=s5mBMy--qmLbYWG9g95dqUqvmR31MlOMaNfvabrDFlQ,24
43
- netra_sdk-0.1.15.dist-info/LICENCE,sha256=8B_UoZ-BAl0AqiHAHUETCgd3I2B9yYJ1WEQtVb_qFMA,11359
44
- netra_sdk-0.1.15.dist-info/METADATA,sha256=QkYln6aEvwGYpfto8eAE2rCV-7Lk-kgqWGWcWGFxfok,25352
45
- netra_sdk-0.1.15.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
46
- netra_sdk-0.1.15.dist-info/RECORD,,
42
+ netra/version.py,sha256=BzIjnki8Bz3evNWo6bjGxxpLhy_tN9MRYhtM0MnDiWs,23
43
+ netra_sdk-0.1.17.dist-info/LICENCE,sha256=8B_UoZ-BAl0AqiHAHUETCgd3I2B9yYJ1WEQtVb_qFMA,11359
44
+ netra_sdk-0.1.17.dist-info/METADATA,sha256=BR_VdbI6-h6x9-z23F0uX8Z9HtVcxRduPXC6UBhsrw4,25876
45
+ netra_sdk-0.1.17.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
46
+ netra_sdk-0.1.17.dist-info/RECORD,,