mseep-agentops 0.4.18__py3-none-any.whl → 0.4.23__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.
- agentops/__init__.py +0 -0
- agentops/client/api/base.py +28 -30
- agentops/client/api/versions/v3.py +29 -25
- agentops/client/api/versions/v4.py +87 -46
- agentops/client/client.py +98 -29
- agentops/client/http/README.md +87 -0
- agentops/client/http/http_client.py +126 -172
- agentops/config.py +8 -2
- agentops/instrumentation/OpenTelemetry.md +133 -0
- agentops/instrumentation/README.md +167 -0
- agentops/instrumentation/__init__.py +13 -1
- agentops/instrumentation/agentic/ag2/__init__.py +18 -0
- agentops/instrumentation/agentic/ag2/instrumentor.py +922 -0
- agentops/instrumentation/agentic/agno/__init__.py +19 -0
- agentops/instrumentation/agentic/agno/attributes/__init__.py +20 -0
- agentops/instrumentation/agentic/agno/attributes/agent.py +250 -0
- agentops/instrumentation/agentic/agno/attributes/metrics.py +214 -0
- agentops/instrumentation/agentic/agno/attributes/storage.py +158 -0
- agentops/instrumentation/agentic/agno/attributes/team.py +195 -0
- agentops/instrumentation/agentic/agno/attributes/tool.py +210 -0
- agentops/instrumentation/agentic/agno/attributes/workflow.py +254 -0
- agentops/instrumentation/agentic/agno/instrumentor.py +1313 -0
- agentops/instrumentation/agentic/crewai/LICENSE +201 -0
- agentops/instrumentation/agentic/crewai/NOTICE.md +10 -0
- agentops/instrumentation/agentic/crewai/__init__.py +6 -0
- agentops/instrumentation/agentic/crewai/crewai_span_attributes.py +335 -0
- agentops/instrumentation/agentic/crewai/instrumentation.py +535 -0
- agentops/instrumentation/agentic/crewai/version.py +1 -0
- agentops/instrumentation/agentic/google_adk/__init__.py +19 -0
- agentops/instrumentation/agentic/google_adk/instrumentor.py +68 -0
- agentops/instrumentation/agentic/google_adk/patch.py +767 -0
- agentops/instrumentation/agentic/haystack/__init__.py +1 -0
- agentops/instrumentation/agentic/haystack/instrumentor.py +186 -0
- agentops/instrumentation/agentic/langgraph/__init__.py +3 -0
- agentops/instrumentation/agentic/langgraph/attributes.py +54 -0
- agentops/instrumentation/agentic/langgraph/instrumentation.py +598 -0
- agentops/instrumentation/agentic/langgraph/version.py +1 -0
- agentops/instrumentation/agentic/openai_agents/README.md +156 -0
- agentops/instrumentation/agentic/openai_agents/SPANS.md +145 -0
- agentops/instrumentation/agentic/openai_agents/TRACING_API.md +144 -0
- agentops/instrumentation/agentic/openai_agents/__init__.py +30 -0
- agentops/instrumentation/agentic/openai_agents/attributes/common.py +549 -0
- agentops/instrumentation/agentic/openai_agents/attributes/completion.py +172 -0
- agentops/instrumentation/agentic/openai_agents/attributes/model.py +58 -0
- agentops/instrumentation/agentic/openai_agents/attributes/tokens.py +275 -0
- agentops/instrumentation/agentic/openai_agents/exporter.py +469 -0
- agentops/instrumentation/agentic/openai_agents/instrumentor.py +107 -0
- agentops/instrumentation/agentic/openai_agents/processor.py +58 -0
- agentops/instrumentation/agentic/smolagents/README.md +88 -0
- agentops/instrumentation/agentic/smolagents/__init__.py +12 -0
- agentops/instrumentation/agentic/smolagents/attributes/agent.py +354 -0
- agentops/instrumentation/agentic/smolagents/attributes/model.py +205 -0
- agentops/instrumentation/agentic/smolagents/instrumentor.py +286 -0
- agentops/instrumentation/agentic/smolagents/stream_wrapper.py +258 -0
- agentops/instrumentation/agentic/xpander/__init__.py +15 -0
- agentops/instrumentation/agentic/xpander/context.py +112 -0
- agentops/instrumentation/agentic/xpander/instrumentor.py +877 -0
- agentops/instrumentation/agentic/xpander/trace_probe.py +86 -0
- agentops/instrumentation/agentic/xpander/version.py +3 -0
- agentops/instrumentation/common/README.md +65 -0
- agentops/instrumentation/common/attributes.py +1 -2
- agentops/instrumentation/providers/anthropic/__init__.py +24 -0
- agentops/instrumentation/providers/anthropic/attributes/__init__.py +23 -0
- agentops/instrumentation/providers/anthropic/attributes/common.py +64 -0
- agentops/instrumentation/providers/anthropic/attributes/message.py +541 -0
- agentops/instrumentation/providers/anthropic/attributes/tools.py +231 -0
- agentops/instrumentation/providers/anthropic/event_handler_wrapper.py +90 -0
- agentops/instrumentation/providers/anthropic/instrumentor.py +146 -0
- agentops/instrumentation/providers/anthropic/stream_wrapper.py +436 -0
- agentops/instrumentation/providers/google_genai/README.md +33 -0
- agentops/instrumentation/providers/google_genai/__init__.py +24 -0
- agentops/instrumentation/providers/google_genai/attributes/__init__.py +25 -0
- agentops/instrumentation/providers/google_genai/attributes/chat.py +125 -0
- agentops/instrumentation/providers/google_genai/attributes/common.py +88 -0
- agentops/instrumentation/providers/google_genai/attributes/model.py +284 -0
- agentops/instrumentation/providers/google_genai/instrumentor.py +170 -0
- agentops/instrumentation/providers/google_genai/stream_wrapper.py +238 -0
- agentops/instrumentation/providers/ibm_watsonx_ai/__init__.py +28 -0
- agentops/instrumentation/providers/ibm_watsonx_ai/attributes/__init__.py +27 -0
- agentops/instrumentation/providers/ibm_watsonx_ai/attributes/attributes.py +277 -0
- agentops/instrumentation/providers/ibm_watsonx_ai/attributes/common.py +104 -0
- agentops/instrumentation/providers/ibm_watsonx_ai/instrumentor.py +162 -0
- agentops/instrumentation/providers/ibm_watsonx_ai/stream_wrapper.py +302 -0
- agentops/instrumentation/providers/mem0/__init__.py +45 -0
- agentops/instrumentation/providers/mem0/common.py +377 -0
- agentops/instrumentation/providers/mem0/instrumentor.py +270 -0
- agentops/instrumentation/providers/mem0/memory.py +430 -0
- agentops/instrumentation/providers/openai/__init__.py +21 -0
- agentops/instrumentation/providers/openai/attributes/__init__.py +7 -0
- agentops/instrumentation/providers/openai/attributes/common.py +55 -0
- agentops/instrumentation/providers/openai/attributes/response.py +607 -0
- agentops/instrumentation/providers/openai/config.py +36 -0
- agentops/instrumentation/providers/openai/instrumentor.py +312 -0
- agentops/instrumentation/providers/openai/stream_wrapper.py +941 -0
- agentops/instrumentation/providers/openai/utils.py +44 -0
- agentops/instrumentation/providers/openai/v0.py +176 -0
- agentops/instrumentation/providers/openai/v0_wrappers.py +483 -0
- agentops/instrumentation/providers/openai/wrappers/__init__.py +30 -0
- agentops/instrumentation/providers/openai/wrappers/assistant.py +277 -0
- agentops/instrumentation/providers/openai/wrappers/chat.py +259 -0
- agentops/instrumentation/providers/openai/wrappers/completion.py +109 -0
- agentops/instrumentation/providers/openai/wrappers/embeddings.py +94 -0
- agentops/instrumentation/providers/openai/wrappers/image_gen.py +75 -0
- agentops/instrumentation/providers/openai/wrappers/responses.py +191 -0
- agentops/instrumentation/providers/openai/wrappers/shared.py +81 -0
- agentops/instrumentation/utilities/concurrent_futures/__init__.py +10 -0
- agentops/instrumentation/utilities/concurrent_futures/instrumentation.py +206 -0
- agentops/integration/callbacks/dspy/__init__.py +11 -0
- agentops/integration/callbacks/dspy/callback.py +471 -0
- agentops/integration/callbacks/langchain/README.md +59 -0
- agentops/integration/callbacks/langchain/__init__.py +15 -0
- agentops/integration/callbacks/langchain/callback.py +791 -0
- agentops/integration/callbacks/langchain/utils.py +54 -0
- agentops/legacy/crewai.md +121 -0
- agentops/logging/instrument_logging.py +4 -0
- agentops/sdk/README.md +220 -0
- agentops/sdk/core.py +75 -32
- agentops/sdk/descriptors/classproperty.py +28 -0
- agentops/sdk/exporters.py +152 -33
- agentops/semconv/README.md +125 -0
- agentops/semconv/span_kinds.py +0 -2
- agentops/validation.py +102 -63
- {mseep_agentops-0.4.18.dist-info → mseep_agentops-0.4.23.dist-info}/METADATA +30 -40
- mseep_agentops-0.4.23.dist-info/RECORD +178 -0
- {mseep_agentops-0.4.18.dist-info → mseep_agentops-0.4.23.dist-info}/WHEEL +1 -2
- mseep_agentops-0.4.18.dist-info/RECORD +0 -94
- mseep_agentops-0.4.18.dist-info/top_level.txt +0 -2
- tests/conftest.py +0 -10
- tests/unit/client/__init__.py +0 -1
- tests/unit/client/test_http_adapter.py +0 -221
- tests/unit/client/test_http_client.py +0 -206
- tests/unit/conftest.py +0 -54
- tests/unit/sdk/__init__.py +0 -1
- tests/unit/sdk/instrumentation_tester.py +0 -207
- tests/unit/sdk/test_attributes.py +0 -392
- tests/unit/sdk/test_concurrent_instrumentation.py +0 -468
- tests/unit/sdk/test_decorators.py +0 -763
- tests/unit/sdk/test_exporters.py +0 -241
- tests/unit/sdk/test_factory.py +0 -1188
- tests/unit/sdk/test_internal_span_processor.py +0 -397
- tests/unit/sdk/test_resource_attributes.py +0 -35
- tests/unit/test_config.py +0 -82
- tests/unit/test_context_manager.py +0 -777
- tests/unit/test_events.py +0 -27
- tests/unit/test_host_env.py +0 -54
- tests/unit/test_init_py.py +0 -501
- tests/unit/test_serialization.py +0 -433
- tests/unit/test_session.py +0 -676
- tests/unit/test_user_agent.py +0 -34
- tests/unit/test_validation.py +0 -405
- {tests → agentops/instrumentation/agentic/openai_agents/attributes}/__init__.py +0 -0
- /tests/unit/__init__.py → /agentops/instrumentation/providers/openai/attributes/tools.py +0 -0
- {mseep_agentops-0.4.18.dist-info → mseep_agentops-0.4.23.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,86 @@
|
|
1
|
+
"""Xpander trace probe for automatic instrumentation activation.
|
2
|
+
|
3
|
+
This module provides automatic instrumentation for Xpander SDK when imported.
|
4
|
+
It should be imported early in the application lifecycle to ensure all
|
5
|
+
Xpander interactions are captured.
|
6
|
+
"""
|
7
|
+
|
8
|
+
import logging
|
9
|
+
from agentops.instrumentation.agentic.xpander.instrumentor import XpanderInstrumentor
|
10
|
+
|
11
|
+
logger = logging.getLogger(__name__)
|
12
|
+
|
13
|
+
# Global instrumentor instance
|
14
|
+
_instrumentor = None
|
15
|
+
|
16
|
+
|
17
|
+
def activate_xpander_instrumentation():
|
18
|
+
"""Activate Xpander instrumentation."""
|
19
|
+
global _instrumentor
|
20
|
+
|
21
|
+
if _instrumentor is None:
|
22
|
+
try:
|
23
|
+
_instrumentor = XpanderInstrumentor()
|
24
|
+
_instrumentor.instrument()
|
25
|
+
logger.info("Xpander instrumentation activated successfully")
|
26
|
+
except Exception as e:
|
27
|
+
logger.error(f"Failed to activate Xpander instrumentation: {e}")
|
28
|
+
_instrumentor = None
|
29
|
+
|
30
|
+
return _instrumentor
|
31
|
+
|
32
|
+
|
33
|
+
def deactivate_xpander_instrumentation():
|
34
|
+
"""Deactivate Xpander instrumentation."""
|
35
|
+
global _instrumentor
|
36
|
+
|
37
|
+
if _instrumentor is not None:
|
38
|
+
try:
|
39
|
+
_instrumentor.uninstrument()
|
40
|
+
logger.info("Xpander instrumentation deactivated successfully")
|
41
|
+
except Exception as e:
|
42
|
+
logger.error(f"Failed to deactivate Xpander instrumentation: {e}")
|
43
|
+
finally:
|
44
|
+
_instrumentor = None
|
45
|
+
|
46
|
+
|
47
|
+
def get_instrumentor():
|
48
|
+
"""Get the active instrumentor instance."""
|
49
|
+
return _instrumentor
|
50
|
+
|
51
|
+
|
52
|
+
# Stub functions for backward compatibility
|
53
|
+
def wrap_openai_call_for_xpander(openai_call_func, purpose="general"):
|
54
|
+
"""Backward compatibility stub - functionality now handled by auto-instrumentation."""
|
55
|
+
logger.debug(f"wrap_openai_call_for_xpander called with purpose: {purpose}")
|
56
|
+
return openai_call_func
|
57
|
+
|
58
|
+
|
59
|
+
def is_xpander_session_active():
|
60
|
+
"""Check if xpander session is active."""
|
61
|
+
return _instrumentor is not None
|
62
|
+
|
63
|
+
|
64
|
+
def get_active_xpander_session():
|
65
|
+
"""Get active xpander session."""
|
66
|
+
return _instrumentor._context if _instrumentor else None
|
67
|
+
|
68
|
+
|
69
|
+
# Convenience functions for cleaner OpenAI integration
|
70
|
+
def wrap_openai_analysis(openai_call_func):
|
71
|
+
"""Wrap OpenAI calls for analysis/reasoning steps."""
|
72
|
+
return wrap_openai_call_for_xpander(openai_call_func, "analysis")
|
73
|
+
|
74
|
+
|
75
|
+
def wrap_openai_planning(openai_call_func):
|
76
|
+
"""Wrap OpenAI calls for planning steps."""
|
77
|
+
return wrap_openai_call_for_xpander(openai_call_func, "planning")
|
78
|
+
|
79
|
+
|
80
|
+
def wrap_openai_synthesis(openai_call_func):
|
81
|
+
"""Wrap OpenAI calls for synthesis/summary steps."""
|
82
|
+
return wrap_openai_call_for_xpander(openai_call_func, "synthesis")
|
83
|
+
|
84
|
+
|
85
|
+
# Note: Auto-activation is now handled by the main AgentOps instrumentation system
|
86
|
+
# activate_xpander_instrumentation()
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# AgentOps Instrumentation Common Module
|
2
|
+
|
3
|
+
The `agentops.instrumentation.common` module provides shared utilities for OpenTelemetry instrumentation across different LLM service providers.
|
4
|
+
|
5
|
+
## Core Components
|
6
|
+
|
7
|
+
### Attribute Handler Example
|
8
|
+
|
9
|
+
Attribute handlers extract data from method inputs and outputs:
|
10
|
+
|
11
|
+
```python
|
12
|
+
from typing import Optional, Any, Tuple, Dict
|
13
|
+
from agentops.instrumentation.common.attributes import AttributeMap
|
14
|
+
from agentops.semconv import SpanAttributes
|
15
|
+
|
16
|
+
def my_attribute_handler(args: Optional[Tuple] = None, kwargs: Optional[Dict] = None, return_value: Optional[Any] = None) -> AttributeMap:
|
17
|
+
attributes = {}
|
18
|
+
|
19
|
+
# Extract attributes from kwargs (method inputs)
|
20
|
+
if kwargs:
|
21
|
+
if "model" in kwargs:
|
22
|
+
attributes[SpanAttributes.MODEL_NAME] = kwargs["model"]
|
23
|
+
# ...
|
24
|
+
|
25
|
+
# Extract attributes from return value (method outputs)
|
26
|
+
if return_value:
|
27
|
+
if hasattr(return_value, "model"):
|
28
|
+
attributes[SpanAttributes.LLM_RESPONSE_MODEL] = return_value.model
|
29
|
+
# ...
|
30
|
+
|
31
|
+
return attributes
|
32
|
+
```
|
33
|
+
|
34
|
+
### `WrapConfig` Class
|
35
|
+
|
36
|
+
Config object defining how a method should be wrapped:
|
37
|
+
|
38
|
+
```python
|
39
|
+
from agentops.instrumentation.common.wrappers import WrapConfig
|
40
|
+
from opentelemetry.trace import SpanKind
|
41
|
+
|
42
|
+
config = WrapConfig(
|
43
|
+
trace_name="llm.completion", # Name that will appear in trace spans
|
44
|
+
package="openai.resources", # Path to the module containing the class
|
45
|
+
class_name="Completions", # Name of the class containing the method
|
46
|
+
method_name="create", # Name of the method to wrap
|
47
|
+
handler=my_attribute_handler, # Function that extracts attributes
|
48
|
+
span_kind=SpanKind.CLIENT # Type of span to create
|
49
|
+
)
|
50
|
+
```
|
51
|
+
|
52
|
+
### Wrapping/Unwrapping Methods
|
53
|
+
|
54
|
+
```python
|
55
|
+
from opentelemetry.trace import get_tracer
|
56
|
+
from agentops.instrumentation.common.wrappers import wrap, unwrap
|
57
|
+
|
58
|
+
# Create a tracer and wrap a method
|
59
|
+
tracer = get_tracer("openai", "0.0.0")
|
60
|
+
wrap(config, tracer)
|
61
|
+
|
62
|
+
# Later, unwrap the method
|
63
|
+
unwrap(config)
|
64
|
+
```
|
65
|
+
|
@@ -98,8 +98,7 @@ class IndexedAttribute(Protocol):
|
|
98
98
|
formatting of attribute keys based on the indices.
|
99
99
|
"""
|
100
100
|
|
101
|
-
def format(self, *, i: int, j: Optional[int] = None) -> str:
|
102
|
-
...
|
101
|
+
def format(self, *, i: int, j: Optional[int] = None) -> str: ...
|
103
102
|
|
104
103
|
|
105
104
|
IndexedAttributeMap = Dict[IndexedAttribute, str] # target_attribute_key: source_attribute
|
@@ -0,0 +1,24 @@
|
|
1
|
+
"""Anthropic API instrumentation.
|
2
|
+
|
3
|
+
This module provides instrumentation for the Anthropic API,
|
4
|
+
including chat completions, streaming, and event handling.
|
5
|
+
"""
|
6
|
+
|
7
|
+
import logging
|
8
|
+
from agentops.instrumentation.common import LibraryInfo
|
9
|
+
|
10
|
+
logger = logging.getLogger(__name__)
|
11
|
+
|
12
|
+
# Library information
|
13
|
+
_library_info = LibraryInfo(name="anthropic")
|
14
|
+
LIBRARY_NAME = _library_info.name
|
15
|
+
LIBRARY_VERSION = _library_info.version
|
16
|
+
|
17
|
+
# Import after defining constants to avoid circular imports
|
18
|
+
from agentops.instrumentation.providers.anthropic.instrumentor import AnthropicInstrumentor # noqa: E402
|
19
|
+
|
20
|
+
__all__ = [
|
21
|
+
"LIBRARY_NAME",
|
22
|
+
"LIBRARY_VERSION",
|
23
|
+
"AnthropicInstrumentor",
|
24
|
+
]
|
@@ -0,0 +1,23 @@
|
|
1
|
+
"""Attribute extraction for Anthropic API instrumentation."""
|
2
|
+
|
3
|
+
from agentops.instrumentation.providers.anthropic.attributes.common import get_common_instrumentation_attributes
|
4
|
+
from agentops.instrumentation.providers.anthropic.attributes.message import (
|
5
|
+
get_message_attributes,
|
6
|
+
get_completion_attributes,
|
7
|
+
)
|
8
|
+
from agentops.instrumentation.providers.anthropic.attributes.tools import (
|
9
|
+
extract_tool_definitions,
|
10
|
+
extract_tool_use_blocks,
|
11
|
+
extract_tool_results,
|
12
|
+
get_tool_attributes,
|
13
|
+
)
|
14
|
+
|
15
|
+
__all__ = [
|
16
|
+
"get_common_instrumentation_attributes",
|
17
|
+
"get_message_attributes",
|
18
|
+
"get_completion_attributes",
|
19
|
+
"extract_tool_definitions",
|
20
|
+
"extract_tool_use_blocks",
|
21
|
+
"extract_tool_results",
|
22
|
+
"get_tool_attributes",
|
23
|
+
]
|
@@ -0,0 +1,64 @@
|
|
1
|
+
"""Common attribute extraction for Anthropic instrumentation."""
|
2
|
+
|
3
|
+
from typing import Dict, Any
|
4
|
+
|
5
|
+
from agentops.semconv import InstrumentationAttributes, SpanAttributes
|
6
|
+
from agentops.instrumentation.common.attributes import AttributeMap, get_common_attributes
|
7
|
+
from agentops.instrumentation.providers.anthropic import LIBRARY_NAME, LIBRARY_VERSION
|
8
|
+
|
9
|
+
|
10
|
+
def get_common_instrumentation_attributes() -> AttributeMap:
|
11
|
+
"""Get common instrumentation attributes for the Anthropic instrumentation.
|
12
|
+
|
13
|
+
This combines the generic AgentOps attributes with Anthropic specific library attributes.
|
14
|
+
|
15
|
+
Returns:
|
16
|
+
Dictionary of common instrumentation attributes
|
17
|
+
"""
|
18
|
+
attributes = get_common_attributes()
|
19
|
+
attributes.update(
|
20
|
+
{
|
21
|
+
InstrumentationAttributes.LIBRARY_NAME: LIBRARY_NAME,
|
22
|
+
InstrumentationAttributes.LIBRARY_VERSION: LIBRARY_VERSION,
|
23
|
+
}
|
24
|
+
)
|
25
|
+
return attributes
|
26
|
+
|
27
|
+
|
28
|
+
def extract_request_attributes(kwargs: Dict[str, Any]) -> AttributeMap:
|
29
|
+
"""Extract all request attributes from kwargs.
|
30
|
+
|
31
|
+
This consolidated function extracts all relevant attributes from the request
|
32
|
+
kwargs, including model, system prompt, messages, max_tokens, temperature,
|
33
|
+
and other parameters. It replaces the individual extraction functions with
|
34
|
+
a single comprehensive approach.
|
35
|
+
|
36
|
+
Args:
|
37
|
+
kwargs: Request keyword arguments
|
38
|
+
|
39
|
+
Returns:
|
40
|
+
Dictionary of extracted request attributes
|
41
|
+
"""
|
42
|
+
attributes = {}
|
43
|
+
|
44
|
+
# Extract model
|
45
|
+
if "model" in kwargs:
|
46
|
+
attributes[SpanAttributes.LLM_REQUEST_MODEL] = kwargs["model"]
|
47
|
+
|
48
|
+
# Extract max_tokens
|
49
|
+
if "max_tokens" in kwargs:
|
50
|
+
attributes[SpanAttributes.LLM_REQUEST_MAX_TOKENS] = kwargs["max_tokens"]
|
51
|
+
|
52
|
+
# Extract temperature
|
53
|
+
if "temperature" in kwargs:
|
54
|
+
attributes[SpanAttributes.LLM_REQUEST_TEMPERATURE] = kwargs["temperature"]
|
55
|
+
|
56
|
+
# Extract top_p
|
57
|
+
if "top_p" in kwargs:
|
58
|
+
attributes[SpanAttributes.LLM_REQUEST_TOP_P] = kwargs["top_p"]
|
59
|
+
|
60
|
+
# Extract streaming
|
61
|
+
if "stream" in kwargs:
|
62
|
+
attributes[SpanAttributes.LLM_REQUEST_STREAMING] = kwargs["stream"]
|
63
|
+
|
64
|
+
return attributes
|