netra-sdk 0.1.5__py3-none-any.whl → 0.1.6__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.

@@ -1,5 +1,5 @@
1
1
  import logging
2
- from typing import Any, Optional
2
+ from typing import Any, Optional, Union
3
3
 
4
4
  import httpx
5
5
  from opentelemetry.sdk.trace import SpanProcessor
@@ -66,9 +66,13 @@ class ErrorDetectionProcessor(SpanProcessor): # type: ignore[misc]
66
66
  # Wrap set_status
67
67
  original_set_status = span.set_status
68
68
 
69
- def wrapped_set_status(status: Status) -> Any:
69
+ def wrapped_set_status(status: Union[Status, StatusCode]) -> Any:
70
70
  # Check if status code is ERROR
71
- if status.status_code == StatusCode.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:
72
76
  event_attributes = {
73
77
  "has_error": True,
74
78
  }
netra/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.1.5"
1
+ __version__ = "0.1.6"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: netra-sdk
3
- Version: 0.1.5
3
+ Version: 0.1.6
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
@@ -407,29 +407,38 @@ Netra.set_custom_event(event_name="conversion", attributes={
407
407
  Use the custom session tracking utility to track external API calls with detailed observability:
408
408
 
409
409
  ```python
410
- from netra import Netra
411
-
412
- # Initialize SDK
413
- Netra.init(app_name="My App")
414
-
415
- # Use session context manager for tracking API calls
416
- with Netra.start_session("video_generation_task") as session:
417
- # Set attributes before the API call
418
- session.set_prompt("A cat playing piano")
410
+ from netra import Netra, Session
411
+ from netra.session import UsageModel
412
+
413
+ # Start a new session
414
+ with Netra.start_session("image_generation") as session:
415
+ # Set session attributes
416
+ session.set_prompt("A beautiful sunset over mountains")
417
+ session.set_negative_prompt("blurry, low quality")
419
418
  session.set_height("1024")
420
419
  session.set_width("1024")
421
- session.set_output_type("image")
422
- session.set_model("stable-diffusion-xl")
423
-
424
- # Make your external API call
425
- result = external_api.generate_video(...)
426
-
427
- # Set post-call attributes
428
- session.set_completion_tokens("1250")
429
- session.set_credits("30")
430
- session.set_completion_tokens_cost("0.15")
431
-
432
- # Add events during session
420
+ session.set_model("dall-e-3")
421
+ session.set_llm_system("openai")
422
+
423
+ # Set usage data with UsageModel
424
+ usage_data = [
425
+ UsageModel(
426
+ model="dall-e-3",
427
+ type="image_generation",
428
+ unit_used=1,
429
+ cost_in_usd=0.02
430
+ )
431
+ ]
432
+ session.set_usage(usage_data)
433
+
434
+ # Your API calls here
435
+ # ...
436
+
437
+ # Set custom attributes
438
+ session.set_attribute("custom_key", "custom_value")
439
+
440
+ # Add events
441
+ session.add_event("generation_started", {"step": 1, "status": "processing"})
433
442
  session.add_event("processing_completed", {"step": "rendering"})
434
443
 
435
444
  # Session automatically captures duration, status, and any errors
@@ -29,14 +29,14 @@ netra/instrumentation/weaviate/__init__.py,sha256=EOlpWxobOLHYKqo_kMct_7nu26x1hr
29
29
  netra/instrumentation/weaviate/version.py,sha256=PiCZHjonujPbnIn0KmD3Yl68hrjPRG_oKe5vJF3mmG8,24
30
30
  netra/pii.py,sha256=S7GnVzoNJEzKiUWnqN9bOCKPeNLsriztgB2E6Rx-yJU,27023
31
31
  netra/processors/__init__.py,sha256=G16VumYTpgV4jsWrKNFSgm6xMQAsZ2Rrux25UVeo5YQ,215
32
- netra/processors/error_detection_processor.py,sha256=vlFQ8-Zgoj83htk_ciVhlT41RfU2GiGmDHGBzjKgtYQ,2701
32
+ netra/processors/error_detection_processor.py,sha256=TtSZoJ7BCMHlVaXWYfqLHSZ6uIx43tdqYb7AFXpt0BA,2898
33
33
  netra/processors/session_span_processor.py,sha256=qcsBl-LnILWefsftI8NQhXDGb94OWPc8LvzhVA0JS_c,2432
34
34
  netra/scanner.py,sha256=wqjMZnEbVvrGMiUSI352grUyHpkk94oBfHfMiXPhpGU,3866
35
35
  netra/session.py,sha256=o1wXrPzMauqj_3P-iNBHVlcIR7zcKcbsmkrcHjQMKuY,7263
36
36
  netra/session_manager.py,sha256=EVcnWcSj4NdkH--HmqHx0mmzivQiM4GCyFLu6lwi33M,6252
37
37
  netra/tracer.py,sha256=9jAKdIHXbaZ6WV_p8I1syQiMdqXVCXMhpEhCBsbbci8,3538
38
- netra/version.py,sha256=rPSfWgIeq2YWVPyESOAwCBt8vftsTpIkuLAGDEzyRQc,22
39
- netra_sdk-0.1.5.dist-info/LICENCE,sha256=8B_UoZ-BAl0AqiHAHUETCgd3I2B9yYJ1WEQtVb_qFMA,11359
40
- netra_sdk-0.1.5.dist-info/METADATA,sha256=-82nUeU3ogSqDhIpMzYAUkjgS5emC5yy_jA_WTkpsPU,23518
41
- netra_sdk-0.1.5.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
42
- netra_sdk-0.1.5.dist-info/RECORD,,
38
+ netra/version.py,sha256=n3oM6B_EMz93NsTI18NNZd-jKFcUPzUkbIKj5VFK5ok,22
39
+ netra_sdk-0.1.6.dist-info/LICENCE,sha256=8B_UoZ-BAl0AqiHAHUETCgd3I2B9yYJ1WEQtVb_qFMA,11359
40
+ netra_sdk-0.1.6.dist-info/METADATA,sha256=5iMVB2PTJpnGBVB-JSsBF9AS5OzGUT2heIdfRoOXR1s,23730
41
+ netra_sdk-0.1.6.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
42
+ netra_sdk-0.1.6.dist-info/RECORD,,