agent-observability-trace-cli 0.1.2__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.
- agent_observability_trace_cli-0.1.2.dist-info/METADATA +336 -0
- agent_observability_trace_cli-0.1.2.dist-info/RECORD +51 -0
- agent_observability_trace_cli-0.1.2.dist-info/WHEEL +4 -0
- agent_observability_trace_cli-0.1.2.dist-info/entry_points.txt +2 -0
- agent_observability_trace_cli-0.1.2.dist-info/licenses/LICENSE +198 -0
- agent_trace/__init__.py +1182 -0
- agent_trace/_cli.py +1377 -0
- agent_trace/_inspect.py +2020 -0
- agent_trace/_replay/__init__.py +1 -0
- agent_trace/_replay/engine.py +268 -0
- agent_trace/_replay/fixture.py +868 -0
- agent_trace/core/__init__.py +1 -0
- agent_trace/core/clock.py +91 -0
- agent_trace/core/exceptions.py +51 -0
- agent_trace/core/span.py +271 -0
- agent_trace/core/trace.py +92 -0
- agent_trace/exporters/__init__.py +1 -0
- agent_trace/exporters/file.py +80 -0
- agent_trace/exporters/otlp.py +199 -0
- agent_trace/exporters/remote_fixture.py +307 -0
- agent_trace/exporters/stdout.py +258 -0
- agent_trace/integrations/__init__.py +69 -0
- agent_trace/integrations/agno.py +489 -0
- agent_trace/integrations/autogen.py +581 -0
- agent_trace/integrations/crewai.py +486 -0
- agent_trace/integrations/google_genai.py +731 -0
- agent_trace/integrations/haystack.py +254 -0
- agent_trace/integrations/langchain_core.py +361 -0
- agent_trace/integrations/langgraph.py +2093 -0
- agent_trace/integrations/langgraph_checkpoint.py +763 -0
- agent_trace/integrations/langgraph_state_diff.py +345 -0
- agent_trace/integrations/langgraph_stream_debug.py +202 -0
- agent_trace/integrations/llama_index.py +472 -0
- agent_trace/integrations/mcp.py +281 -0
- agent_trace/integrations/openai_agents.py +811 -0
- agent_trace/integrations/pydantic_ai.py +504 -0
- agent_trace/integrations/streaming.py +218 -0
- agent_trace/interceptor/__init__.py +64 -0
- agent_trace/interceptor/aiohttp_hook.py +152 -0
- agent_trace/interceptor/botocore_hook.py +223 -0
- agent_trace/interceptor/grpc_hook.py +651 -0
- agent_trace/interceptor/httpx_hook.py +866 -0
- agent_trace/interceptor/logging_hook.py +137 -0
- agent_trace/interceptor/requests_patch.py +184 -0
- agent_trace/interceptor/sse.py +176 -0
- agent_trace/interceptor/stdio_hook.py +245 -0
- agent_trace/interceptor/warnings_hook.py +132 -0
- agent_trace/interceptor/websocket_hook.py +323 -0
- agent_trace/plugins/__init__.py +35 -0
- agent_trace/plugins/base.py +111 -0
- agent_trace/py.typed +0 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"""
|
|
2
|
+
agent-trace Plugin SDK.
|
|
3
|
+
|
|
4
|
+
Third-party packages implement SpanPlugin and/or TracePlugin to observe
|
|
5
|
+
agent runs without modifying agent code. Register plugins on the tracer
|
|
6
|
+
instance; they are called synchronously on every span and trace event.
|
|
7
|
+
|
|
8
|
+
Quick start::
|
|
9
|
+
|
|
10
|
+
from agent_trace import tracer
|
|
11
|
+
from agent_trace.plugins import SpanPlugin, TracePlugin
|
|
12
|
+
from agent_trace.core.span import Span
|
|
13
|
+
from agent_trace.core.trace import Trace
|
|
14
|
+
|
|
15
|
+
class MyPlugin(SpanPlugin, TracePlugin):
|
|
16
|
+
def on_span_end(self, span: Span) -> None:
|
|
17
|
+
print(f"span {span.name} took {span.duration_ms:.1f}ms")
|
|
18
|
+
|
|
19
|
+
def on_trace_end(self, trace: Trace) -> None:
|
|
20
|
+
print(f"trace {trace.trace_id}: {len(trace.spans)} spans")
|
|
21
|
+
|
|
22
|
+
tracer.add_plugin(MyPlugin())
|
|
23
|
+
|
|
24
|
+
See ``PluginBase`` for a convenience base class that provides no-op defaults
|
|
25
|
+
for every hook, so you only override what you need.
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
from agent_trace.plugins.base import Plugin, PluginBase, SpanPlugin, TracePlugin
|
|
29
|
+
|
|
30
|
+
__all__ = [
|
|
31
|
+
"Plugin",
|
|
32
|
+
"PluginBase",
|
|
33
|
+
"SpanPlugin",
|
|
34
|
+
"TracePlugin",
|
|
35
|
+
]
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Plugin protocols and base class for the agent-trace Plugin SDK.
|
|
3
|
+
|
|
4
|
+
Two structural protocols define the plugin surface:
|
|
5
|
+
|
|
6
|
+
``SpanPlugin``
|
|
7
|
+
Observes individual spans. Implement ``on_span_start`` and/or
|
|
8
|
+
``on_span_end``.
|
|
9
|
+
|
|
10
|
+
``TracePlugin``
|
|
11
|
+
Observes full traces. Implement ``on_trace_start`` and/or
|
|
12
|
+
``on_trace_end``.
|
|
13
|
+
|
|
14
|
+
``Plugin``
|
|
15
|
+
Union type — any object that satisfies SpanPlugin, TracePlugin, or both.
|
|
16
|
+
|
|
17
|
+
``PluginBase``
|
|
18
|
+
Optional ABC with no-op defaults for all four hooks. Inherit from it
|
|
19
|
+
when you only want to override one or two hooks.
|
|
20
|
+
|
|
21
|
+
All hooks are synchronous and run on the calling thread/task. Exceptions
|
|
22
|
+
raised inside a hook are caught and logged at WARNING level so a buggy plugin
|
|
23
|
+
never silences the caller.
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
from __future__ import annotations
|
|
27
|
+
|
|
28
|
+
from typing import TYPE_CHECKING, Any, Protocol, runtime_checkable
|
|
29
|
+
|
|
30
|
+
if TYPE_CHECKING:
|
|
31
|
+
from agent_trace.core.span import Span
|
|
32
|
+
from agent_trace.core.trace import Trace
|
|
33
|
+
|
|
34
|
+
__all__ = [
|
|
35
|
+
"Plugin",
|
|
36
|
+
"PluginBase",
|
|
37
|
+
"SpanPlugin",
|
|
38
|
+
"TracePlugin",
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
@runtime_checkable
|
|
43
|
+
class SpanPlugin(Protocol):
|
|
44
|
+
"""Protocol for plugins that observe individual spans.
|
|
45
|
+
|
|
46
|
+
Implement one or both methods. Both default to a no-op if the
|
|
47
|
+
implementing class does not define them.
|
|
48
|
+
"""
|
|
49
|
+
|
|
50
|
+
def on_span_start(self, span: Span) -> None:
|
|
51
|
+
"""Called immediately after a span is created via ``Tracer.start_span``.
|
|
52
|
+
|
|
53
|
+
The span's ``start_time`` is set; ``end_time`` is None.
|
|
54
|
+
"""
|
|
55
|
+
... # pragma: no cover
|
|
56
|
+
|
|
57
|
+
def on_span_end(self, span: Span) -> None:
|
|
58
|
+
"""Called immediately after ``span.end()`` is called.
|
|
59
|
+
|
|
60
|
+
Both ``start_time`` and ``end_time`` are set; ``status`` is final.
|
|
61
|
+
"""
|
|
62
|
+
... # pragma: no cover
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
@runtime_checkable
|
|
66
|
+
class TracePlugin(Protocol):
|
|
67
|
+
"""Protocol for plugins that observe full traces.
|
|
68
|
+
|
|
69
|
+
Implement one or both methods.
|
|
70
|
+
"""
|
|
71
|
+
|
|
72
|
+
def on_trace_start(self, trace: Trace) -> None:
|
|
73
|
+
"""Called when ``Tracer.start_trace`` context is entered.
|
|
74
|
+
|
|
75
|
+
The trace has no spans yet; ``metadata["name"]`` is populated.
|
|
76
|
+
"""
|
|
77
|
+
... # pragma: no cover
|
|
78
|
+
|
|
79
|
+
def on_trace_end(self, trace: Trace) -> None:
|
|
80
|
+
"""Called after all spans are complete and ``trace.json`` is written.
|
|
81
|
+
|
|
82
|
+
All spans are accessible; the trace is immutable from this point.
|
|
83
|
+
"""
|
|
84
|
+
... # pragma: no cover
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
Plugin = SpanPlugin | TracePlugin
|
|
88
|
+
"""Type alias: any object that satisfies SpanPlugin, TracePlugin, or both."""
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
class PluginBase:
|
|
92
|
+
"""Convenience base class with no-op defaults for all plugin hooks.
|
|
93
|
+
|
|
94
|
+
Inherit from this when you only need to override a subset of hooks::
|
|
95
|
+
|
|
96
|
+
class MyPlugin(PluginBase):
|
|
97
|
+
def on_span_end(self, span: Span) -> None:
|
|
98
|
+
metrics.record(span.name, span.duration_ms)
|
|
99
|
+
"""
|
|
100
|
+
|
|
101
|
+
def on_span_start(self, span: Any) -> None:
|
|
102
|
+
pass
|
|
103
|
+
|
|
104
|
+
def on_span_end(self, span: Any) -> None:
|
|
105
|
+
pass
|
|
106
|
+
|
|
107
|
+
def on_trace_start(self, trace: Any) -> None:
|
|
108
|
+
pass
|
|
109
|
+
|
|
110
|
+
def on_trace_end(self, trace: Any) -> None:
|
|
111
|
+
pass
|
agent_trace/py.typed
ADDED
|
File without changes
|