netra-sdk 0.1.5__tar.gz → 0.1.6__tar.gz

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.

Files changed (43) hide show
  1. {netra_sdk-0.1.5 → netra_sdk-0.1.6}/PKG-INFO +31 -22
  2. {netra_sdk-0.1.5 → netra_sdk-0.1.6}/README.md +30 -21
  3. {netra_sdk-0.1.5 → netra_sdk-0.1.6}/netra/processors/error_detection_processor.py +7 -3
  4. netra_sdk-0.1.6/netra/version.py +1 -0
  5. {netra_sdk-0.1.5 → netra_sdk-0.1.6}/pyproject.toml +1 -1
  6. netra_sdk-0.1.5/netra/version.py +0 -1
  7. {netra_sdk-0.1.5 → netra_sdk-0.1.6}/LICENCE +0 -0
  8. {netra_sdk-0.1.5 → netra_sdk-0.1.6}/netra/__init__.py +0 -0
  9. {netra_sdk-0.1.5 → netra_sdk-0.1.6}/netra/anonymizer/__init__.py +0 -0
  10. {netra_sdk-0.1.5 → netra_sdk-0.1.6}/netra/anonymizer/anonymizer.py +0 -0
  11. {netra_sdk-0.1.5 → netra_sdk-0.1.6}/netra/anonymizer/base.py +0 -0
  12. {netra_sdk-0.1.5 → netra_sdk-0.1.6}/netra/anonymizer/fp_anonymizer.py +0 -0
  13. {netra_sdk-0.1.5 → netra_sdk-0.1.6}/netra/config.py +0 -0
  14. {netra_sdk-0.1.5 → netra_sdk-0.1.6}/netra/decorators.py +0 -0
  15. {netra_sdk-0.1.5 → netra_sdk-0.1.6}/netra/exceptions/__init__.py +0 -0
  16. {netra_sdk-0.1.5 → netra_sdk-0.1.6}/netra/exceptions/injection.py +0 -0
  17. {netra_sdk-0.1.5 → netra_sdk-0.1.6}/netra/exceptions/pii.py +0 -0
  18. {netra_sdk-0.1.5 → netra_sdk-0.1.6}/netra/input_scanner.py +0 -0
  19. {netra_sdk-0.1.5 → netra_sdk-0.1.6}/netra/instrumentation/__init__.py +0 -0
  20. {netra_sdk-0.1.5 → netra_sdk-0.1.6}/netra/instrumentation/aiohttp/__init__.py +0 -0
  21. {netra_sdk-0.1.5 → netra_sdk-0.1.6}/netra/instrumentation/aiohttp/version.py +0 -0
  22. {netra_sdk-0.1.5 → netra_sdk-0.1.6}/netra/instrumentation/cohere/__init__.py +0 -0
  23. {netra_sdk-0.1.5 → netra_sdk-0.1.6}/netra/instrumentation/cohere/version.py +0 -0
  24. {netra_sdk-0.1.5 → netra_sdk-0.1.6}/netra/instrumentation/google_genai/__init__.py +0 -0
  25. {netra_sdk-0.1.5 → netra_sdk-0.1.6}/netra/instrumentation/google_genai/config.py +0 -0
  26. {netra_sdk-0.1.5 → netra_sdk-0.1.6}/netra/instrumentation/google_genai/utils.py +0 -0
  27. {netra_sdk-0.1.5 → netra_sdk-0.1.6}/netra/instrumentation/google_genai/version.py +0 -0
  28. {netra_sdk-0.1.5 → netra_sdk-0.1.6}/netra/instrumentation/httpx/__init__.py +0 -0
  29. {netra_sdk-0.1.5 → netra_sdk-0.1.6}/netra/instrumentation/httpx/version.py +0 -0
  30. {netra_sdk-0.1.5 → netra_sdk-0.1.6}/netra/instrumentation/instruments.py +0 -0
  31. {netra_sdk-0.1.5 → netra_sdk-0.1.6}/netra/instrumentation/mistralai/__init__.py +0 -0
  32. {netra_sdk-0.1.5 → netra_sdk-0.1.6}/netra/instrumentation/mistralai/config.py +0 -0
  33. {netra_sdk-0.1.5 → netra_sdk-0.1.6}/netra/instrumentation/mistralai/utils.py +0 -0
  34. {netra_sdk-0.1.5 → netra_sdk-0.1.6}/netra/instrumentation/mistralai/version.py +0 -0
  35. {netra_sdk-0.1.5 → netra_sdk-0.1.6}/netra/instrumentation/weaviate/__init__.py +0 -0
  36. {netra_sdk-0.1.5 → netra_sdk-0.1.6}/netra/instrumentation/weaviate/version.py +0 -0
  37. {netra_sdk-0.1.5 → netra_sdk-0.1.6}/netra/pii.py +0 -0
  38. {netra_sdk-0.1.5 → netra_sdk-0.1.6}/netra/processors/__init__.py +0 -0
  39. {netra_sdk-0.1.5 → netra_sdk-0.1.6}/netra/processors/session_span_processor.py +0 -0
  40. {netra_sdk-0.1.5 → netra_sdk-0.1.6}/netra/scanner.py +0 -0
  41. {netra_sdk-0.1.5 → netra_sdk-0.1.6}/netra/session.py +0 -0
  42. {netra_sdk-0.1.5 → netra_sdk-0.1.6}/netra/session_manager.py +0 -0
  43. {netra_sdk-0.1.5 → netra_sdk-0.1.6}/netra/tracer.py +0 -0
@@ -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
@@ -331,29 +331,38 @@ Netra.set_custom_event(event_name="conversion", attributes={
331
331
  Use the custom session tracking utility to track external API calls with detailed observability:
332
332
 
333
333
  ```python
334
- from netra import Netra
335
-
336
- # Initialize SDK
337
- Netra.init(app_name="My App")
338
-
339
- # Use session context manager for tracking API calls
340
- with Netra.start_session("video_generation_task") as session:
341
- # Set attributes before the API call
342
- session.set_prompt("A cat playing piano")
334
+ from netra import Netra, Session
335
+ from netra.session import UsageModel
336
+
337
+ # Start a new session
338
+ with Netra.start_session("image_generation") as session:
339
+ # Set session attributes
340
+ session.set_prompt("A beautiful sunset over mountains")
341
+ session.set_negative_prompt("blurry, low quality")
343
342
  session.set_height("1024")
344
343
  session.set_width("1024")
345
- session.set_output_type("image")
346
- session.set_model("stable-diffusion-xl")
347
-
348
- # Make your external API call
349
- result = external_api.generate_video(...)
350
-
351
- # Set post-call attributes
352
- session.set_completion_tokens("1250")
353
- session.set_credits("30")
354
- session.set_completion_tokens_cost("0.15")
355
-
356
- # Add events during session
344
+ session.set_model("dall-e-3")
345
+ session.set_llm_system("openai")
346
+
347
+ # Set usage data with UsageModel
348
+ usage_data = [
349
+ UsageModel(
350
+ model="dall-e-3",
351
+ type="image_generation",
352
+ unit_used=1,
353
+ cost_in_usd=0.02
354
+ )
355
+ ]
356
+ session.set_usage(usage_data)
357
+
358
+ # Your API calls here
359
+ # ...
360
+
361
+ # Set custom attributes
362
+ session.set_attribute("custom_key", "custom_value")
363
+
364
+ # Add events
365
+ session.add_event("generation_started", {"step": 1, "status": "processing"})
357
366
  session.add_event("processing_completed", {"step": "rendering"})
358
367
 
359
368
  # Session automatically captures duration, status, and any errors
@@ -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
  }
@@ -0,0 +1 @@
1
+ __version__ = "0.1.6"
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
4
4
 
5
5
  [project]
6
6
  name = "netra-sdk"
7
- version = "0.1.5"
7
+ version = "0.1.6"
8
8
  description = "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."
9
9
  authors = [
10
10
  {name = "Sooraj Thomas",email = "sooraj@keyvalue.systems"}
@@ -1 +0,0 @@
1
- __version__ = "0.1.5"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes