traccia 0.1.2__py3-none-any.whl → 0.1.5__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.
Files changed (55) hide show
  1. traccia/__init__.py +73 -0
  2. traccia/auto.py +736 -0
  3. traccia/auto_instrumentation.py +74 -0
  4. traccia/cli.py +349 -0
  5. traccia/config.py +693 -0
  6. traccia/context/__init__.py +33 -0
  7. traccia/context/context.py +67 -0
  8. traccia/context/propagators.py +283 -0
  9. traccia/errors.py +48 -0
  10. traccia/exporter/__init__.py +8 -0
  11. traccia/exporter/console_exporter.py +31 -0
  12. traccia/exporter/file_exporter.py +178 -0
  13. traccia/exporter/http_exporter.py +214 -0
  14. traccia/exporter/otlp_exporter.py +190 -0
  15. traccia/instrumentation/__init__.py +20 -0
  16. traccia/instrumentation/anthropic.py +92 -0
  17. traccia/instrumentation/decorator.py +263 -0
  18. traccia/instrumentation/fastapi.py +38 -0
  19. traccia/instrumentation/http_client.py +21 -0
  20. traccia/instrumentation/http_server.py +25 -0
  21. traccia/instrumentation/openai.py +178 -0
  22. traccia/instrumentation/requests.py +68 -0
  23. traccia/integrations/__init__.py +22 -0
  24. traccia/integrations/langchain/__init__.py +14 -0
  25. traccia/integrations/langchain/callback.py +418 -0
  26. traccia/integrations/langchain/utils.py +129 -0
  27. traccia/pricing_config.py +58 -0
  28. traccia/processors/__init__.py +35 -0
  29. traccia/processors/agent_enricher.py +159 -0
  30. traccia/processors/batch_processor.py +140 -0
  31. traccia/processors/cost_engine.py +71 -0
  32. traccia/processors/cost_processor.py +70 -0
  33. traccia/processors/drop_policy.py +44 -0
  34. traccia/processors/logging_processor.py +31 -0
  35. traccia/processors/rate_limiter.py +223 -0
  36. traccia/processors/sampler.py +22 -0
  37. traccia/processors/token_counter.py +216 -0
  38. traccia/runtime_config.py +106 -0
  39. traccia/tracer/__init__.py +15 -0
  40. traccia/tracer/otel_adapter.py +577 -0
  41. traccia/tracer/otel_utils.py +24 -0
  42. traccia/tracer/provider.py +155 -0
  43. traccia/tracer/span.py +286 -0
  44. traccia/tracer/span_context.py +16 -0
  45. traccia/tracer/tracer.py +243 -0
  46. traccia/utils/__init__.py +19 -0
  47. traccia/utils/helpers.py +95 -0
  48. {traccia-0.1.2.dist-info → traccia-0.1.5.dist-info}/METADATA +32 -15
  49. traccia-0.1.5.dist-info/RECORD +53 -0
  50. traccia-0.1.5.dist-info/top_level.txt +1 -0
  51. traccia-0.1.2.dist-info/RECORD +0 -6
  52. traccia-0.1.2.dist-info/top_level.txt +0 -1
  53. {traccia-0.1.2.dist-info → traccia-0.1.5.dist-info}/WHEEL +0 -0
  54. {traccia-0.1.2.dist-info → traccia-0.1.5.dist-info}/entry_points.txt +0 -0
  55. {traccia-0.1.2.dist-info → traccia-0.1.5.dist-info}/licenses/LICENSE +0 -0
traccia/__init__.py ADDED
@@ -0,0 +1,73 @@
1
+ """Python SDK entrypoint for the agent tracing library."""
2
+
3
+ from traccia.auto import start_tracing, stop_tracing, init, trace, end_auto_trace
4
+ from traccia.tracer import TracerProvider
5
+ from traccia.instrumentation.decorator import observe
6
+
7
+ # Version exposure
8
+ try:
9
+ from importlib.metadata import version, PackageNotFoundError
10
+ try:
11
+ __version__ = version("traccia")
12
+ except PackageNotFoundError:
13
+ __version__ = "0.1.0" # Fallback version
14
+ except ImportError:
15
+ __version__ = "0.1.0" # Fallback for Python < 3.8
16
+
17
+ # Initialize global tracer provider (now uses OpenTelemetry directly)
18
+ _global_tracer_provider = TracerProvider()
19
+
20
+
21
+ def get_tracer(name: str = "default"):
22
+ """Fetch a tracer from the global provider."""
23
+ return _global_tracer_provider.get_tracer(name)
24
+
25
+
26
+ def span(name: str, attributes: dict = None):
27
+ """
28
+ Convenience function to create a span using the default tracer.
29
+
30
+ This is a simpler alternative to:
31
+ tracer = get_tracer("name")
32
+ with tracer.start_as_current_span("span_name") as span:
33
+
34
+ Usage:
35
+ from traccia import span
36
+
37
+ with span("my_operation"):
38
+ # Your code here
39
+ pass
40
+
41
+ # With attributes
42
+ with span("my_operation", {"key": "value"}) as s:
43
+ s.set_attribute("another", "attr")
44
+ # Your code here
45
+ """
46
+ tracer = get_tracer()
47
+ return tracer.start_as_current_span(name, attributes=attributes)
48
+
49
+
50
+ def set_tracer_provider(provider: TracerProvider) -> None:
51
+ """Override the global tracer provider (primarily for tests or customization)."""
52
+ global _global_tracer_provider
53
+ _global_tracer_provider = provider
54
+
55
+
56
+ def get_tracer_provider() -> TracerProvider:
57
+ return _global_tracer_provider
58
+
59
+
60
+ __all__ = [
61
+ "__version__",
62
+ "get_tracer",
63
+ "get_tracer_provider",
64
+ "set_tracer_provider",
65
+ "start_tracing",
66
+ "stop_tracing",
67
+ "init",
68
+ "trace",
69
+ "end_auto_trace",
70
+ "span",
71
+ "observe",
72
+ ]
73
+