mseep-agentops 0.4.18__py3-none-any.whl → 0.4.22__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 (153) hide show
  1. agentops/__init__.py +0 -0
  2. agentops/client/api/base.py +28 -30
  3. agentops/client/api/versions/v3.py +29 -25
  4. agentops/client/api/versions/v4.py +87 -46
  5. agentops/client/client.py +98 -29
  6. agentops/client/http/README.md +87 -0
  7. agentops/client/http/http_client.py +126 -172
  8. agentops/config.py +8 -2
  9. agentops/instrumentation/OpenTelemetry.md +133 -0
  10. agentops/instrumentation/README.md +167 -0
  11. agentops/instrumentation/__init__.py +13 -1
  12. agentops/instrumentation/agentic/ag2/__init__.py +18 -0
  13. agentops/instrumentation/agentic/ag2/instrumentor.py +922 -0
  14. agentops/instrumentation/agentic/agno/__init__.py +19 -0
  15. agentops/instrumentation/agentic/agno/attributes/__init__.py +20 -0
  16. agentops/instrumentation/agentic/agno/attributes/agent.py +250 -0
  17. agentops/instrumentation/agentic/agno/attributes/metrics.py +214 -0
  18. agentops/instrumentation/agentic/agno/attributes/storage.py +158 -0
  19. agentops/instrumentation/agentic/agno/attributes/team.py +195 -0
  20. agentops/instrumentation/agentic/agno/attributes/tool.py +210 -0
  21. agentops/instrumentation/agentic/agno/attributes/workflow.py +254 -0
  22. agentops/instrumentation/agentic/agno/instrumentor.py +1313 -0
  23. agentops/instrumentation/agentic/crewai/LICENSE +201 -0
  24. agentops/instrumentation/agentic/crewai/NOTICE.md +10 -0
  25. agentops/instrumentation/agentic/crewai/__init__.py +6 -0
  26. agentops/instrumentation/agentic/crewai/crewai_span_attributes.py +335 -0
  27. agentops/instrumentation/agentic/crewai/instrumentation.py +535 -0
  28. agentops/instrumentation/agentic/crewai/version.py +1 -0
  29. agentops/instrumentation/agentic/google_adk/__init__.py +19 -0
  30. agentops/instrumentation/agentic/google_adk/instrumentor.py +68 -0
  31. agentops/instrumentation/agentic/google_adk/patch.py +767 -0
  32. agentops/instrumentation/agentic/haystack/__init__.py +1 -0
  33. agentops/instrumentation/agentic/haystack/instrumentor.py +186 -0
  34. agentops/instrumentation/agentic/langgraph/__init__.py +3 -0
  35. agentops/instrumentation/agentic/langgraph/attributes.py +54 -0
  36. agentops/instrumentation/agentic/langgraph/instrumentation.py +598 -0
  37. agentops/instrumentation/agentic/langgraph/version.py +1 -0
  38. agentops/instrumentation/agentic/openai_agents/README.md +156 -0
  39. agentops/instrumentation/agentic/openai_agents/SPANS.md +145 -0
  40. agentops/instrumentation/agentic/openai_agents/TRACING_API.md +144 -0
  41. agentops/instrumentation/agentic/openai_agents/__init__.py +30 -0
  42. agentops/instrumentation/agentic/openai_agents/attributes/common.py +549 -0
  43. agentops/instrumentation/agentic/openai_agents/attributes/completion.py +172 -0
  44. agentops/instrumentation/agentic/openai_agents/attributes/model.py +58 -0
  45. agentops/instrumentation/agentic/openai_agents/attributes/tokens.py +275 -0
  46. agentops/instrumentation/agentic/openai_agents/exporter.py +469 -0
  47. agentops/instrumentation/agentic/openai_agents/instrumentor.py +107 -0
  48. agentops/instrumentation/agentic/openai_agents/processor.py +58 -0
  49. agentops/instrumentation/agentic/smolagents/README.md +88 -0
  50. agentops/instrumentation/agentic/smolagents/__init__.py +12 -0
  51. agentops/instrumentation/agentic/smolagents/attributes/agent.py +354 -0
  52. agentops/instrumentation/agentic/smolagents/attributes/model.py +205 -0
  53. agentops/instrumentation/agentic/smolagents/instrumentor.py +286 -0
  54. agentops/instrumentation/agentic/smolagents/stream_wrapper.py +258 -0
  55. agentops/instrumentation/agentic/xpander/__init__.py +15 -0
  56. agentops/instrumentation/agentic/xpander/context.py +112 -0
  57. agentops/instrumentation/agentic/xpander/instrumentor.py +877 -0
  58. agentops/instrumentation/agentic/xpander/trace_probe.py +86 -0
  59. agentops/instrumentation/agentic/xpander/version.py +3 -0
  60. agentops/instrumentation/common/README.md +65 -0
  61. agentops/instrumentation/common/attributes.py +1 -2
  62. agentops/instrumentation/providers/anthropic/__init__.py +24 -0
  63. agentops/instrumentation/providers/anthropic/attributes/__init__.py +23 -0
  64. agentops/instrumentation/providers/anthropic/attributes/common.py +64 -0
  65. agentops/instrumentation/providers/anthropic/attributes/message.py +541 -0
  66. agentops/instrumentation/providers/anthropic/attributes/tools.py +231 -0
  67. agentops/instrumentation/providers/anthropic/event_handler_wrapper.py +90 -0
  68. agentops/instrumentation/providers/anthropic/instrumentor.py +146 -0
  69. agentops/instrumentation/providers/anthropic/stream_wrapper.py +436 -0
  70. agentops/instrumentation/providers/google_genai/README.md +33 -0
  71. agentops/instrumentation/providers/google_genai/__init__.py +24 -0
  72. agentops/instrumentation/providers/google_genai/attributes/__init__.py +25 -0
  73. agentops/instrumentation/providers/google_genai/attributes/chat.py +125 -0
  74. agentops/instrumentation/providers/google_genai/attributes/common.py +88 -0
  75. agentops/instrumentation/providers/google_genai/attributes/model.py +284 -0
  76. agentops/instrumentation/providers/google_genai/instrumentor.py +170 -0
  77. agentops/instrumentation/providers/google_genai/stream_wrapper.py +238 -0
  78. agentops/instrumentation/providers/ibm_watsonx_ai/__init__.py +28 -0
  79. agentops/instrumentation/providers/ibm_watsonx_ai/attributes/__init__.py +27 -0
  80. agentops/instrumentation/providers/ibm_watsonx_ai/attributes/attributes.py +277 -0
  81. agentops/instrumentation/providers/ibm_watsonx_ai/attributes/common.py +104 -0
  82. agentops/instrumentation/providers/ibm_watsonx_ai/instrumentor.py +162 -0
  83. agentops/instrumentation/providers/ibm_watsonx_ai/stream_wrapper.py +302 -0
  84. agentops/instrumentation/providers/mem0/__init__.py +45 -0
  85. agentops/instrumentation/providers/mem0/common.py +377 -0
  86. agentops/instrumentation/providers/mem0/instrumentor.py +270 -0
  87. agentops/instrumentation/providers/mem0/memory.py +430 -0
  88. agentops/instrumentation/providers/openai/__init__.py +21 -0
  89. agentops/instrumentation/providers/openai/attributes/__init__.py +7 -0
  90. agentops/instrumentation/providers/openai/attributes/common.py +55 -0
  91. agentops/instrumentation/providers/openai/attributes/response.py +607 -0
  92. agentops/instrumentation/providers/openai/config.py +36 -0
  93. agentops/instrumentation/providers/openai/instrumentor.py +312 -0
  94. agentops/instrumentation/providers/openai/stream_wrapper.py +941 -0
  95. agentops/instrumentation/providers/openai/utils.py +44 -0
  96. agentops/instrumentation/providers/openai/v0.py +176 -0
  97. agentops/instrumentation/providers/openai/v0_wrappers.py +483 -0
  98. agentops/instrumentation/providers/openai/wrappers/__init__.py +30 -0
  99. agentops/instrumentation/providers/openai/wrappers/assistant.py +277 -0
  100. agentops/instrumentation/providers/openai/wrappers/chat.py +259 -0
  101. agentops/instrumentation/providers/openai/wrappers/completion.py +109 -0
  102. agentops/instrumentation/providers/openai/wrappers/embeddings.py +94 -0
  103. agentops/instrumentation/providers/openai/wrappers/image_gen.py +75 -0
  104. agentops/instrumentation/providers/openai/wrappers/responses.py +191 -0
  105. agentops/instrumentation/providers/openai/wrappers/shared.py +81 -0
  106. agentops/instrumentation/utilities/concurrent_futures/__init__.py +10 -0
  107. agentops/instrumentation/utilities/concurrent_futures/instrumentation.py +206 -0
  108. agentops/integration/callbacks/dspy/__init__.py +11 -0
  109. agentops/integration/callbacks/dspy/callback.py +471 -0
  110. agentops/integration/callbacks/langchain/README.md +59 -0
  111. agentops/integration/callbacks/langchain/__init__.py +15 -0
  112. agentops/integration/callbacks/langchain/callback.py +791 -0
  113. agentops/integration/callbacks/langchain/utils.py +54 -0
  114. agentops/legacy/crewai.md +121 -0
  115. agentops/logging/instrument_logging.py +4 -0
  116. agentops/sdk/README.md +220 -0
  117. agentops/sdk/core.py +75 -32
  118. agentops/sdk/descriptors/classproperty.py +28 -0
  119. agentops/sdk/exporters.py +152 -33
  120. agentops/semconv/README.md +125 -0
  121. agentops/semconv/span_kinds.py +0 -2
  122. agentops/validation.py +102 -63
  123. {mseep_agentops-0.4.18.dist-info → mseep_agentops-0.4.22.dist-info}/METADATA +30 -40
  124. mseep_agentops-0.4.22.dist-info/RECORD +178 -0
  125. {mseep_agentops-0.4.18.dist-info → mseep_agentops-0.4.22.dist-info}/WHEEL +1 -2
  126. mseep_agentops-0.4.18.dist-info/RECORD +0 -94
  127. mseep_agentops-0.4.18.dist-info/top_level.txt +0 -2
  128. tests/conftest.py +0 -10
  129. tests/unit/client/__init__.py +0 -1
  130. tests/unit/client/test_http_adapter.py +0 -221
  131. tests/unit/client/test_http_client.py +0 -206
  132. tests/unit/conftest.py +0 -54
  133. tests/unit/sdk/__init__.py +0 -1
  134. tests/unit/sdk/instrumentation_tester.py +0 -207
  135. tests/unit/sdk/test_attributes.py +0 -392
  136. tests/unit/sdk/test_concurrent_instrumentation.py +0 -468
  137. tests/unit/sdk/test_decorators.py +0 -763
  138. tests/unit/sdk/test_exporters.py +0 -241
  139. tests/unit/sdk/test_factory.py +0 -1188
  140. tests/unit/sdk/test_internal_span_processor.py +0 -397
  141. tests/unit/sdk/test_resource_attributes.py +0 -35
  142. tests/unit/test_config.py +0 -82
  143. tests/unit/test_context_manager.py +0 -777
  144. tests/unit/test_events.py +0 -27
  145. tests/unit/test_host_env.py +0 -54
  146. tests/unit/test_init_py.py +0 -501
  147. tests/unit/test_serialization.py +0 -433
  148. tests/unit/test_session.py +0 -676
  149. tests/unit/test_user_agent.py +0 -34
  150. tests/unit/test_validation.py +0 -405
  151. {tests → agentops/instrumentation/agentic/openai_agents/attributes}/__init__.py +0 -0
  152. /tests/unit/__init__.py → /agentops/instrumentation/providers/openai/attributes/tools.py +0 -0
  153. {mseep_agentops-0.4.18.dist-info → mseep_agentops-0.4.22.dist-info}/licenses/LICENSE +0 -0
@@ -1,241 +0,0 @@
1
- """
2
- Unit tests for AuthenticatedOTLPExporter.
3
- """
4
-
5
- import unittest
6
- from unittest.mock import Mock, patch
7
-
8
- import requests
9
- from opentelemetry.sdk.trace import ReadableSpan
10
- from opentelemetry.sdk.trace.export import SpanExportResult
11
- from opentelemetry.exporter.otlp.proto.http import Compression
12
-
13
- from agentops.sdk.exporters import AuthenticatedOTLPExporter
14
- from agentops.exceptions import AgentOpsApiJwtExpiredException, ApiServerException
15
-
16
- # these are simple tests on a simple file, basically just to get test coverage
17
-
18
-
19
- class TestAuthenticatedOTLPExporter(unittest.TestCase):
20
- """Tests for AuthenticatedOTLPExporter class."""
21
-
22
- def setUp(self):
23
- """Set up test fixtures."""
24
- self.endpoint = "https://api.agentops.ai/v1/traces"
25
- self.jwt = "test-jwt-token"
26
- self.timeout = 30
27
- self.compression = Compression.Gzip
28
- self.custom_headers = {"X-Custom-Header": "test-value"}
29
-
30
- def test_initialization_with_required_params(self):
31
- """Test exporter initialization with required parameters."""
32
- exporter = AuthenticatedOTLPExporter(endpoint=self.endpoint, jwt=self.jwt)
33
-
34
- # Verify the exporter was created successfully
35
- self.assertIsInstance(exporter, AuthenticatedOTLPExporter)
36
- self.assertEqual(exporter._endpoint, self.endpoint)
37
-
38
- def test_initialization_with_all_params(self):
39
- """Test exporter initialization with all parameters."""
40
- exporter = AuthenticatedOTLPExporter(
41
- endpoint=self.endpoint,
42
- jwt=self.jwt,
43
- headers=self.custom_headers,
44
- timeout=self.timeout,
45
- compression=self.compression,
46
- )
47
-
48
- # Verify the exporter was created successfully
49
- self.assertIsInstance(exporter, AuthenticatedOTLPExporter)
50
- self.assertEqual(exporter._endpoint, self.endpoint)
51
-
52
- def test_initialization_without_optional_params(self):
53
- """Test exporter initialization without optional parameters."""
54
- exporter = AuthenticatedOTLPExporter(endpoint=self.endpoint, jwt=self.jwt)
55
-
56
- # Verify the exporter was created successfully
57
- self.assertIsInstance(exporter, AuthenticatedOTLPExporter)
58
- self.assertEqual(exporter._endpoint, self.endpoint)
59
-
60
- def test_export_success(self):
61
- """Test successful span export."""
62
- mock_spans = [Mock(spec=ReadableSpan), Mock(spec=ReadableSpan)]
63
-
64
- with patch("opentelemetry.exporter.otlp.proto.http.trace_exporter.OTLPSpanExporter.export") as mock_export:
65
- mock_export.return_value = SpanExportResult.SUCCESS
66
-
67
- exporter = AuthenticatedOTLPExporter(endpoint=self.endpoint, jwt=self.jwt)
68
-
69
- result = exporter.export(mock_spans)
70
-
71
- # Verify the result
72
- self.assertEqual(result, SpanExportResult.SUCCESS)
73
-
74
- def test_export_jwt_expired_exception(self):
75
- """Test export handling of JWT expired exception."""
76
- mock_spans = [Mock(spec=ReadableSpan)]
77
-
78
- with patch("opentelemetry.exporter.otlp.proto.http.trace_exporter.OTLPSpanExporter.export") as mock_export:
79
- mock_export.side_effect = AgentOpsApiJwtExpiredException("Token expired")
80
-
81
- with patch("agentops.sdk.exporters.logger") as mock_logger:
82
- exporter = AuthenticatedOTLPExporter(endpoint=self.endpoint, jwt=self.jwt)
83
-
84
- result = exporter.export(mock_spans)
85
-
86
- # Verify failure result and logging
87
- self.assertEqual(result, SpanExportResult.FAILURE)
88
- mock_logger.warning.assert_called_once()
89
-
90
- def test_export_api_server_exception(self):
91
- """Test export handling of API server exception."""
92
- mock_spans = [Mock(spec=ReadableSpan)]
93
-
94
- with patch("opentelemetry.exporter.otlp.proto.http.trace_exporter.OTLPSpanExporter.export") as mock_export:
95
- mock_export.side_effect = ApiServerException("Server error")
96
-
97
- with patch("agentops.sdk.exporters.logger") as mock_logger:
98
- exporter = AuthenticatedOTLPExporter(endpoint=self.endpoint, jwt=self.jwt)
99
-
100
- result = exporter.export(mock_spans)
101
-
102
- # Verify failure result and logging
103
- self.assertEqual(result, SpanExportResult.FAILURE)
104
- mock_logger.error.assert_called_once()
105
-
106
- def test_export_requests_exception(self):
107
- """Test export handling of requests exception."""
108
- mock_spans = [Mock(spec=ReadableSpan)]
109
-
110
- with patch("opentelemetry.exporter.otlp.proto.http.trace_exporter.OTLPSpanExporter.export") as mock_export:
111
- mock_export.side_effect = requests.RequestException("Network error")
112
-
113
- with patch("agentops.sdk.exporters.logger") as mock_logger:
114
- exporter = AuthenticatedOTLPExporter(endpoint=self.endpoint, jwt=self.jwt)
115
-
116
- result = exporter.export(mock_spans)
117
-
118
- # Verify failure result and logging
119
- self.assertEqual(result, SpanExportResult.FAILURE)
120
- mock_logger.error.assert_called_once()
121
-
122
- def test_export_unexpected_exception(self):
123
- """Test export handling of unexpected exception."""
124
- mock_spans = [Mock(spec=ReadableSpan)]
125
-
126
- with patch("opentelemetry.exporter.otlp.proto.http.trace_exporter.OTLPSpanExporter.export") as mock_export:
127
- mock_export.side_effect = ValueError("Unexpected error")
128
-
129
- with patch("agentops.sdk.exporters.logger") as mock_logger:
130
- exporter = AuthenticatedOTLPExporter(endpoint=self.endpoint, jwt=self.jwt)
131
-
132
- result = exporter.export(mock_spans)
133
-
134
- # Verify failure result and logging
135
- self.assertEqual(result, SpanExportResult.FAILURE)
136
- mock_logger.error.assert_called_once()
137
-
138
- def test_export_empty_spans_list(self):
139
- """Test export with empty spans list."""
140
- mock_spans = []
141
-
142
- with patch("opentelemetry.exporter.otlp.proto.http.trace_exporter.OTLPSpanExporter.export") as mock_export:
143
- mock_export.return_value = SpanExportResult.SUCCESS
144
-
145
- exporter = AuthenticatedOTLPExporter(endpoint=self.endpoint, jwt=self.jwt)
146
-
147
- result = exporter.export(mock_spans)
148
-
149
- # Verify the result
150
- self.assertEqual(result, SpanExportResult.SUCCESS)
151
-
152
- def test_clear_method(self):
153
- """Test clear method (should be a no-op)."""
154
- exporter = AuthenticatedOTLPExporter(endpoint=self.endpoint, jwt=self.jwt)
155
-
156
- # Clear method should not raise any exception
157
- exporter.clear()
158
-
159
- def test_initialization_with_kwargs(self):
160
- """Test exporter initialization with additional kwargs."""
161
- exporter = AuthenticatedOTLPExporter(endpoint=self.endpoint, jwt=self.jwt, custom_param="test_value")
162
-
163
- # Verify the exporter was created successfully
164
- self.assertIsInstance(exporter, AuthenticatedOTLPExporter)
165
-
166
- def test_headers_merging(self):
167
- """Test that custom headers are properly merged with authorization header."""
168
- custom_headers = {"X-Custom-Header": "test-value", "Content-Type": "application/json"}
169
-
170
- exporter = AuthenticatedOTLPExporter(endpoint=self.endpoint, jwt=self.jwt, headers=custom_headers)
171
-
172
- # Verify the exporter was created successfully
173
- self.assertIsInstance(exporter, AuthenticatedOTLPExporter)
174
-
175
- def test_headers_override_authorization(self):
176
- """Test that custom Authorization header overrides the default one."""
177
- custom_headers = {"Authorization": "Custom-Auth custom-token", "X-Custom-Header": "test-value"}
178
-
179
- exporter = AuthenticatedOTLPExporter(endpoint=self.endpoint, jwt=self.jwt, headers=custom_headers)
180
-
181
- # Verify the exporter was created successfully
182
- self.assertIsInstance(exporter, AuthenticatedOTLPExporter)
183
-
184
-
185
- class TestAuthenticatedOTLPExporterIntegration(unittest.TestCase):
186
- """Integration-style tests for AuthenticatedOTLPExporter."""
187
-
188
- def setUp(self):
189
- """Set up test fixtures."""
190
- self.endpoint = "https://api.agentops.ai/v1/traces"
191
- self.jwt = "test-jwt-token"
192
-
193
- def test_full_export_cycle(self):
194
- """Test a complete export cycle with multiple spans."""
195
- # Create mock spans
196
- mock_spans = [
197
- Mock(spec=ReadableSpan, name="span1"),
198
- Mock(spec=ReadableSpan, name="span2"),
199
- Mock(spec=ReadableSpan, name="span3"),
200
- ]
201
-
202
- with patch("opentelemetry.exporter.otlp.proto.http.trace_exporter.OTLPSpanExporter.export") as mock_export:
203
- mock_export.return_value = SpanExportResult.SUCCESS
204
-
205
- # Create exporter
206
- exporter = AuthenticatedOTLPExporter(endpoint=self.endpoint, jwt=self.jwt)
207
-
208
- # Export spans
209
- result = exporter.export(mock_spans)
210
-
211
- # Verify results
212
- self.assertEqual(result, SpanExportResult.SUCCESS)
213
-
214
- # Test clear method
215
- exporter.clear() # Should not raise any exception
216
-
217
- def test_export_with_different_compression_types(self):
218
- """Test exporter with different compression types."""
219
- compression_types = [Compression.Gzip, Compression.Deflate, None]
220
-
221
- for compression in compression_types:
222
- with self.subTest(compression=compression):
223
- exporter = AuthenticatedOTLPExporter(endpoint=self.endpoint, jwt=self.jwt, compression=compression)
224
-
225
- # Verify the exporter was created successfully
226
- self.assertIsInstance(exporter, AuthenticatedOTLPExporter)
227
-
228
- def test_export_with_different_timeouts(self):
229
- """Test exporter with different timeout values."""
230
- timeout_values = [10, 30, 60, None]
231
-
232
- for timeout in timeout_values:
233
- with self.subTest(timeout=timeout):
234
- exporter = AuthenticatedOTLPExporter(endpoint=self.endpoint, jwt=self.jwt, timeout=timeout)
235
-
236
- # Verify the exporter was created successfully
237
- self.assertIsInstance(exporter, AuthenticatedOTLPExporter)
238
-
239
-
240
- if __name__ == "__main__":
241
- unittest.main()