ioa-observe-sdk 1.0.3__tar.gz → 1.0.5__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.
Files changed (53) hide show
  1. {ioa_observe_sdk-1.0.3 → ioa_observe_sdk-1.0.5}/PKG-INFO +10 -2
  2. {ioa_observe_sdk-1.0.3 → ioa_observe_sdk-1.0.5}/README.md +9 -1
  3. ioa_observe_sdk-1.0.5/ioa_observe/sdk/tracing/context_utils.py +82 -0
  4. {ioa_observe_sdk-1.0.3 → ioa_observe_sdk-1.0.5}/ioa_observe/sdk/tracing/tracing.py +21 -11
  5. {ioa_observe_sdk-1.0.3 → ioa_observe_sdk-1.0.5}/ioa_observe_sdk.egg-info/PKG-INFO +10 -2
  6. {ioa_observe_sdk-1.0.3 → ioa_observe_sdk-1.0.5}/ioa_observe_sdk.egg-info/SOURCES.txt +1 -0
  7. {ioa_observe_sdk-1.0.3 → ioa_observe_sdk-1.0.5}/pyproject.toml +1 -1
  8. {ioa_observe_sdk-1.0.3 → ioa_observe_sdk-1.0.5}/LICENSE.md +0 -0
  9. {ioa_observe_sdk-1.0.3 → ioa_observe_sdk-1.0.5}/ioa_observe/__init__.py +0 -0
  10. {ioa_observe_sdk-1.0.3 → ioa_observe_sdk-1.0.5}/ioa_observe/sdk/__init__.py +0 -0
  11. {ioa_observe_sdk-1.0.3 → ioa_observe_sdk-1.0.5}/ioa_observe/sdk/client/__init__.py +0 -0
  12. {ioa_observe_sdk-1.0.3 → ioa_observe_sdk-1.0.5}/ioa_observe/sdk/client/client.py +0 -0
  13. {ioa_observe_sdk-1.0.3 → ioa_observe_sdk-1.0.5}/ioa_observe/sdk/client/http.py +0 -0
  14. {ioa_observe_sdk-1.0.3 → ioa_observe_sdk-1.0.5}/ioa_observe/sdk/config/__init__.py +0 -0
  15. {ioa_observe_sdk-1.0.3 → ioa_observe_sdk-1.0.5}/ioa_observe/sdk/connectors/__init__.py +0 -0
  16. {ioa_observe_sdk-1.0.3 → ioa_observe_sdk-1.0.5}/ioa_observe/sdk/connectors/slim.py +0 -0
  17. {ioa_observe_sdk-1.0.3 → ioa_observe_sdk-1.0.5}/ioa_observe/sdk/decorators/__init__.py +0 -0
  18. {ioa_observe_sdk-1.0.3 → ioa_observe_sdk-1.0.5}/ioa_observe/sdk/decorators/base.py +0 -0
  19. {ioa_observe_sdk-1.0.3 → ioa_observe_sdk-1.0.5}/ioa_observe/sdk/decorators/util.py +0 -0
  20. {ioa_observe_sdk-1.0.3 → ioa_observe_sdk-1.0.5}/ioa_observe/sdk/instrumentations/__init__.py +0 -0
  21. {ioa_observe_sdk-1.0.3 → ioa_observe_sdk-1.0.5}/ioa_observe/sdk/instrumentations/slim.py +0 -0
  22. {ioa_observe_sdk-1.0.3 → ioa_observe_sdk-1.0.5}/ioa_observe/sdk/instruments.py +0 -0
  23. {ioa_observe_sdk-1.0.3 → ioa_observe_sdk-1.0.5}/ioa_observe/sdk/logging/__init__.py +0 -0
  24. {ioa_observe_sdk-1.0.3 → ioa_observe_sdk-1.0.5}/ioa_observe/sdk/logging/logging.py +0 -0
  25. {ioa_observe_sdk-1.0.3 → ioa_observe_sdk-1.0.5}/ioa_observe/sdk/metrics/__init__.py +0 -0
  26. {ioa_observe_sdk-1.0.3 → ioa_observe_sdk-1.0.5}/ioa_observe/sdk/metrics/agent.py +0 -0
  27. {ioa_observe_sdk-1.0.3 → ioa_observe_sdk-1.0.5}/ioa_observe/sdk/metrics/agents/__init__.py +0 -0
  28. {ioa_observe_sdk-1.0.3 → ioa_observe_sdk-1.0.5}/ioa_observe/sdk/metrics/agents/agent_connections.py +0 -0
  29. {ioa_observe_sdk-1.0.3 → ioa_observe_sdk-1.0.5}/ioa_observe/sdk/metrics/agents/availability.py +0 -0
  30. {ioa_observe_sdk-1.0.3 → ioa_observe_sdk-1.0.5}/ioa_observe/sdk/metrics/agents/heuristics.py +0 -0
  31. {ioa_observe_sdk-1.0.3 → ioa_observe_sdk-1.0.5}/ioa_observe/sdk/metrics/agents/recovery_tracker.py +0 -0
  32. {ioa_observe_sdk-1.0.3 → ioa_observe_sdk-1.0.5}/ioa_observe/sdk/metrics/agents/tool_call_tracker.py +0 -0
  33. {ioa_observe_sdk-1.0.3 → ioa_observe_sdk-1.0.5}/ioa_observe/sdk/metrics/agents/tracker.py +0 -0
  34. {ioa_observe_sdk-1.0.3 → ioa_observe_sdk-1.0.5}/ioa_observe/sdk/metrics/metrics.py +0 -0
  35. {ioa_observe_sdk-1.0.3 → ioa_observe_sdk-1.0.5}/ioa_observe/sdk/telemetry.py +0 -0
  36. {ioa_observe_sdk-1.0.3 → ioa_observe_sdk-1.0.5}/ioa_observe/sdk/tracing/__init__.py +0 -0
  37. {ioa_observe_sdk-1.0.3 → ioa_observe_sdk-1.0.5}/ioa_observe/sdk/tracing/content_allow_list.py +0 -0
  38. {ioa_observe_sdk-1.0.3 → ioa_observe_sdk-1.0.5}/ioa_observe/sdk/tracing/context_manager.py +0 -0
  39. {ioa_observe_sdk-1.0.3 → ioa_observe_sdk-1.0.5}/ioa_observe/sdk/tracing/manual.py +0 -0
  40. {ioa_observe_sdk-1.0.3 → ioa_observe_sdk-1.0.5}/ioa_observe/sdk/utils/__init__.py +0 -0
  41. {ioa_observe_sdk-1.0.3 → ioa_observe_sdk-1.0.5}/ioa_observe/sdk/utils/const.py +0 -0
  42. {ioa_observe_sdk-1.0.3 → ioa_observe_sdk-1.0.5}/ioa_observe/sdk/utils/in_memory_span_exporter.py +0 -0
  43. {ioa_observe_sdk-1.0.3 → ioa_observe_sdk-1.0.5}/ioa_observe/sdk/utils/json_encoder.py +0 -0
  44. {ioa_observe_sdk-1.0.3 → ioa_observe_sdk-1.0.5}/ioa_observe/sdk/utils/package_check.py +0 -0
  45. {ioa_observe_sdk-1.0.3 → ioa_observe_sdk-1.0.5}/ioa_observe/sdk/version.py +0 -0
  46. {ioa_observe_sdk-1.0.3 → ioa_observe_sdk-1.0.5}/ioa_observe_sdk.egg-info/dependency_links.txt +0 -0
  47. {ioa_observe_sdk-1.0.3 → ioa_observe_sdk-1.0.5}/ioa_observe_sdk.egg-info/requires.txt +0 -0
  48. {ioa_observe_sdk-1.0.3 → ioa_observe_sdk-1.0.5}/ioa_observe_sdk.egg-info/top_level.txt +0 -0
  49. {ioa_observe_sdk-1.0.3 → ioa_observe_sdk-1.0.5}/setup.cfg +0 -0
  50. {ioa_observe_sdk-1.0.3 → ioa_observe_sdk-1.0.5}/tests/test_client.py +0 -0
  51. {ioa_observe_sdk-1.0.3 → ioa_observe_sdk-1.0.5}/tests/test_instrumentor.py +0 -0
  52. {ioa_observe_sdk-1.0.3 → ioa_observe_sdk-1.0.5}/tests/test_manual_instrumentation.py +0 -0
  53. {ioa_observe_sdk-1.0.3 → ioa_observe_sdk-1.0.5}/tests/test_version.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ioa-observe-sdk
3
- Version: 1.0.3
3
+ Version: 1.0.5
4
4
  Summary: IOA Observability SDK
5
5
  Requires-Python: >=3.10
6
6
  Description-Content-Type: text/markdown
@@ -90,6 +90,7 @@ IOA observability SDK for your multi-agentic application.
90
90
  ## Table of Contents
91
91
 
92
92
  - [Installation](#installation)
93
+ - [Schema](#schema)
93
94
  - [Dev](#dev)
94
95
  - [Testing](#testing)
95
96
  - [Getting Started](#getting-started)
@@ -109,6 +110,13 @@ Alternatively, to download the SDK from git, you could also use the following co
109
110
  uv add "git+https://github.com/agntcy/observe"
110
111
  ```
111
112
 
113
+ ## Schema
114
+
115
+ The AGNTCY observability schema is an extension of the OTel LLM Semantic Conventions for Generative AI systems.
116
+ This schema is designed to provide comprehensive observability for Multi-Agent Systems (MAS).
117
+
118
+ Link: [AGNTCY Observability Schema](https://github.com/agntcy/observe/blob/main/schema/)
119
+
112
120
  ## Dev
113
121
 
114
122
  To get started with development, start a Clickhouse DB and an OTel collector container locally using docker-compose like so:
@@ -152,7 +160,7 @@ To run the unit tests, ensure you have the `OPENAI_API_KEY` set in your environm
152
160
  OPENAI_API_KEY=<KEY> make test
153
161
  ```
154
162
 
155
- ## Getting Started
163
+ ## 🚀 Getting Started
156
164
 
157
165
  For getting started with the SDK, please refer to the [Getting Started](https://github.com/agntcy/observe/blob/main/GETTING-STARTED.md)
158
166
  file. It contains detailed instructions on how to set up and use the SDK effectively.
@@ -5,6 +5,7 @@ IOA observability SDK for your multi-agentic application.
5
5
  ## Table of Contents
6
6
 
7
7
  - [Installation](#installation)
8
+ - [Schema](#schema)
8
9
  - [Dev](#dev)
9
10
  - [Testing](#testing)
10
11
  - [Getting Started](#getting-started)
@@ -24,6 +25,13 @@ Alternatively, to download the SDK from git, you could also use the following co
24
25
  uv add "git+https://github.com/agntcy/observe"
25
26
  ```
26
27
 
28
+ ## Schema
29
+
30
+ The AGNTCY observability schema is an extension of the OTel LLM Semantic Conventions for Generative AI systems.
31
+ This schema is designed to provide comprehensive observability for Multi-Agent Systems (MAS).
32
+
33
+ Link: [AGNTCY Observability Schema](https://github.com/agntcy/observe/blob/main/schema/)
34
+
27
35
  ## Dev
28
36
 
29
37
  To get started with development, start a Clickhouse DB and an OTel collector container locally using docker-compose like so:
@@ -67,7 +75,7 @@ To run the unit tests, ensure you have the `OPENAI_API_KEY` set in your environm
67
75
  OPENAI_API_KEY=<KEY> make test
68
76
  ```
69
77
 
70
- ## Getting Started
78
+ ## 🚀 Getting Started
71
79
 
72
80
  For getting started with the SDK, please refer to the [Getting Started](https://github.com/agntcy/observe/blob/main/GETTING-STARTED.md)
73
81
  file. It contains detailed instructions on how to set up and use the SDK effectively.
@@ -0,0 +1,82 @@
1
+ from opentelemetry.trace.propagation.tracecontext import TraceContextTextMapPropagator
2
+ from opentelemetry.baggage.propagation import W3CBaggagePropagator
3
+ from opentelemetry import baggage
4
+
5
+ from ioa_observe.sdk import TracerWrapper
6
+ from ioa_observe.sdk.client import kv_store
7
+ from ioa_observe.sdk.tracing import set_execution_id, get_current_traceparent
8
+ from opentelemetry import context as otel_context
9
+
10
+ """
11
+ Usage Example:
12
+
13
+
14
+ Sender:
15
+ Before sending a message, call get_current_context_headers() and attach the returned headers to your message.
16
+ Receiver:
17
+ After receiving a message, extract headers and call set_context_from_headers(headers) before processing.
18
+ """
19
+
20
+
21
+ def get_current_context_headers():
22
+ """
23
+ Extracts the current trace context, baggage, and execution_id into headers.
24
+ """
25
+ _global_tracer = TracerWrapper().get_tracer()
26
+ with _global_tracer.start_as_current_span("get_current_context_headers"):
27
+ carrier = {}
28
+ # Use the current OpenTelemetry context for injection
29
+ current_ctx = otel_context.get_current()
30
+ TraceContextTextMapPropagator().inject(carrier, context=current_ctx)
31
+ W3CBaggagePropagator().inject(carrier, context=current_ctx)
32
+ traceparent = carrier.get("traceparent")
33
+ execution_id = None
34
+ if traceparent:
35
+ execution_id = kv_store.get(f"execution.{traceparent}")
36
+ if execution_id:
37
+ carrier["execution_id"] = execution_id
38
+ return carrier
39
+
40
+
41
+ def set_context_from_headers(headers):
42
+ """
43
+ Restores the trace context, baggage, and execution_id from headers.
44
+ """
45
+ # Extract trace context and baggage
46
+ _global_tracer = TracerWrapper().get_tracer()
47
+ with _global_tracer.start_as_current_span("set_context_from_headers"):
48
+ ctx = TraceContextTextMapPropagator().extract(carrier=headers)
49
+ ctx = W3CBaggagePropagator().extract(carrier=headers, context=ctx)
50
+ # Restore execution_id if present
51
+ if headers is not None:
52
+ if "traceparent" in headers:
53
+ traceparent = headers.get("traceparent")
54
+ if "executionID" in headers:
55
+ execution_id = headers.get("executionID")
56
+ if traceparent and execution_id and execution_id != "None":
57
+ set_execution_id(execution_id, traceparent=traceparent)
58
+ kv_store.set(f"execution.{traceparent}", execution_id)
59
+ return ctx
60
+
61
+
62
+ def set_baggage_item(key, value):
63
+ baggage.set_baggage(key, value)
64
+
65
+
66
+ def get_baggage_item(key):
67
+ return baggage.get_baggage(key)
68
+
69
+
70
+ def get_current_execution_id():
71
+ traceparent = get_current_traceparent()
72
+ if traceparent:
73
+ return kv_store.get(f"execution.{traceparent}")
74
+ return None
75
+
76
+
77
+ def set_execution_id_from_headers(headers):
78
+ traceparent = headers.get("traceparent")
79
+ execution_id = headers.get("execution_id")
80
+ if traceparent and execution_id:
81
+ set_execution_id(execution_id, traceparent=traceparent)
82
+ kv_store.set(f"execution.{traceparent}", execution_id)
@@ -404,14 +404,30 @@ def set_workflow_name(workflow_name: str) -> None:
404
404
 
405
405
  def session_start():
406
406
  """
407
- Marks the start of a session by setting the workflow name and execution ID.
408
- This is typically called at the beginning of a workflow execution.
407
+ Can be used as a context manager or a normal function.
408
+ As a context manager, yields session metadata.
409
+ As a normal function, just sets up the session.
409
410
  """
410
- # Set execution ID if not already set
411
- # execution_id = get_value("execution.id")
412
- # if not execution_id:
413
411
  execution_id = TracerWrapper.app_name + "_" + str(uuid.uuid4())
414
412
  set_execution_id(execution_id)
413
+ metadata = {
414
+ "executionID": get_value("execution.id") or execution_id,
415
+ "traceparent": get_current_traceparent(),
416
+ }
417
+ import inspect
418
+
419
+ frame = inspect.currentframe().f_back
420
+ if frame and "__enter__" in frame.f_code.co_names:
421
+ # Used as a context manager
422
+ from contextlib import contextmanager
423
+
424
+ @contextmanager
425
+ def _cm():
426
+ yield metadata
427
+
428
+ return _cm()
429
+ # Used as a normal function
430
+ return None
415
431
 
416
432
 
417
433
  def set_execution_id(execution_id: str, traceparent: str = None) -> None:
@@ -435,8 +451,6 @@ def set_execution_id(execution_id: str, traceparent: str = None) -> None:
435
451
 
436
452
  # If traceparent is provided (e.g., from incoming message), use it
437
453
  if traceparent:
438
- print(f"Using provided traceparent: {traceparent}")
439
-
440
454
  # Store execution ID with provided traceparent
441
455
  kv_key = f"execution.{traceparent}"
442
456
  if kv_store.get(kv_key) is None:
@@ -455,18 +469,14 @@ def set_execution_id(execution_id: str, traceparent: str = None) -> None:
455
469
  carrier = {}
456
470
  TraceContextTextMapPropagator().inject(carrier)
457
471
  extracted_traceparent = carrier.get("traceparent")
458
- print(f"Extracted from active span: {extracted_traceparent}")
459
472
  else:
460
473
  # Only create new span if absolutely necessary (no existing context)
461
- print("No active span or existing context, creating new trace context")
462
474
  tracer = trace.get_tracer(__name__)
463
475
  with tracer.start_as_current_span("set_execution_id"):
464
476
  carrier = {}
465
477
  TraceContextTextMapPropagator().inject(carrier)
466
478
  extracted_traceparent = carrier.get("traceparent")
467
479
 
468
- print("Final traceparent:", extracted_traceparent)
469
-
470
480
  # Store execution ID with traceparent as key
471
481
  if extracted_traceparent:
472
482
  kv_key = f"execution.{extracted_traceparent}"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ioa-observe-sdk
3
- Version: 1.0.3
3
+ Version: 1.0.5
4
4
  Summary: IOA Observability SDK
5
5
  Requires-Python: >=3.10
6
6
  Description-Content-Type: text/markdown
@@ -90,6 +90,7 @@ IOA observability SDK for your multi-agentic application.
90
90
  ## Table of Contents
91
91
 
92
92
  - [Installation](#installation)
93
+ - [Schema](#schema)
93
94
  - [Dev](#dev)
94
95
  - [Testing](#testing)
95
96
  - [Getting Started](#getting-started)
@@ -109,6 +110,13 @@ Alternatively, to download the SDK from git, you could also use the following co
109
110
  uv add "git+https://github.com/agntcy/observe"
110
111
  ```
111
112
 
113
+ ## Schema
114
+
115
+ The AGNTCY observability schema is an extension of the OTel LLM Semantic Conventions for Generative AI systems.
116
+ This schema is designed to provide comprehensive observability for Multi-Agent Systems (MAS).
117
+
118
+ Link: [AGNTCY Observability Schema](https://github.com/agntcy/observe/blob/main/schema/)
119
+
112
120
  ## Dev
113
121
 
114
122
  To get started with development, start a Clickhouse DB and an OTel collector container locally using docker-compose like so:
@@ -152,7 +160,7 @@ To run the unit tests, ensure you have the `OPENAI_API_KEY` set in your environm
152
160
  OPENAI_API_KEY=<KEY> make test
153
161
  ```
154
162
 
155
- ## Getting Started
163
+ ## 🚀 Getting Started
156
164
 
157
165
  For getting started with the SDK, please refer to the [Getting Started](https://github.com/agntcy/observe/blob/main/GETTING-STARTED.md)
158
166
  file. It contains detailed instructions on how to set up and use the SDK effectively.
@@ -32,6 +32,7 @@ ioa_observe/sdk/metrics/agents/tracker.py
32
32
  ioa_observe/sdk/tracing/__init__.py
33
33
  ioa_observe/sdk/tracing/content_allow_list.py
34
34
  ioa_observe/sdk/tracing/context_manager.py
35
+ ioa_observe/sdk/tracing/context_utils.py
35
36
  ioa_observe/sdk/tracing/manual.py
36
37
  ioa_observe/sdk/tracing/tracing.py
37
38
  ioa_observe/sdk/utils/__init__.py
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
5
5
 
6
6
  [project]
7
7
  name = "ioa-observe-sdk"
8
- version = "1.0.3"
8
+ version = "1.0.5"
9
9
  description = "IOA Observability SDK"
10
10
  readme = "README.md"
11
11
  requires-python = ">=3.10"