openlit 1.33.19__py3-none-any.whl → 1.33.20__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.
- openlit/__helpers.py +7 -7
- openlit/__init__.py +3 -3
- openlit/evals/utils.py +7 -7
- openlit/guard/utils.py +7 -7
- openlit/instrumentation/ag2/ag2.py +24 -24
- openlit/instrumentation/ai21/ai21.py +3 -3
- openlit/instrumentation/ai21/async_ai21.py +3 -3
- openlit/instrumentation/ai21/utils.py +59 -59
- openlit/instrumentation/anthropic/anthropic.py +2 -2
- openlit/instrumentation/anthropic/async_anthropic.py +2 -2
- openlit/instrumentation/anthropic/utils.py +34 -34
- openlit/instrumentation/assemblyai/assemblyai.py +24 -24
- openlit/instrumentation/astra/astra.py +3 -3
- openlit/instrumentation/astra/async_astra.py +3 -3
- openlit/instrumentation/astra/utils.py +39 -39
- openlit/instrumentation/azure_ai_inference/async_azure_ai_inference.py +2 -2
- openlit/instrumentation/azure_ai_inference/azure_ai_inference.py +2 -2
- openlit/instrumentation/azure_ai_inference/utils.py +36 -36
- openlit/instrumentation/bedrock/bedrock.py +2 -2
- openlit/instrumentation/bedrock/utils.py +35 -35
- openlit/instrumentation/chroma/chroma.py +57 -57
- openlit/instrumentation/cohere/async_cohere.py +88 -88
- openlit/instrumentation/cohere/cohere.py +88 -88
- openlit/instrumentation/controlflow/controlflow.py +15 -15
- openlit/instrumentation/crawl4ai/async_crawl4ai.py +14 -14
- openlit/instrumentation/crawl4ai/crawl4ai.py +14 -14
- openlit/instrumentation/crewai/crewai.py +22 -22
- openlit/instrumentation/dynamiq/dynamiq.py +19 -19
- openlit/instrumentation/elevenlabs/async_elevenlabs.py +24 -25
- openlit/instrumentation/elevenlabs/elevenlabs.py +23 -25
- openlit/instrumentation/embedchain/embedchain.py +15 -15
- openlit/instrumentation/firecrawl/firecrawl.py +10 -10
- openlit/instrumentation/google_ai_studio/async_google_ai_studio.py +33 -33
- openlit/instrumentation/google_ai_studio/google_ai_studio.py +33 -33
- openlit/instrumentation/gpt4all/gpt4all.py +78 -78
- openlit/instrumentation/gpu/__init__.py +8 -8
- openlit/instrumentation/groq/async_groq.py +74 -74
- openlit/instrumentation/groq/groq.py +74 -74
- openlit/instrumentation/haystack/haystack.py +6 -6
- openlit/instrumentation/julep/async_julep.py +14 -14
- openlit/instrumentation/julep/julep.py +14 -14
- openlit/instrumentation/langchain/async_langchain.py +39 -39
- openlit/instrumentation/langchain/langchain.py +39 -39
- openlit/instrumentation/letta/letta.py +26 -26
- openlit/instrumentation/litellm/async_litellm.py +94 -94
- openlit/instrumentation/litellm/litellm.py +94 -94
- openlit/instrumentation/llamaindex/llamaindex.py +7 -7
- openlit/instrumentation/mem0/mem0.py +13 -13
- openlit/instrumentation/milvus/milvus.py +47 -47
- openlit/instrumentation/mistral/async_mistral.py +88 -88
- openlit/instrumentation/mistral/mistral.py +88 -88
- openlit/instrumentation/multion/async_multion.py +21 -21
- openlit/instrumentation/multion/multion.py +21 -21
- openlit/instrumentation/ollama/async_ollama.py +3 -3
- openlit/instrumentation/ollama/ollama.py +3 -3
- openlit/instrumentation/ollama/utils.py +50 -50
- openlit/instrumentation/openai/async_openai.py +225 -225
- openlit/instrumentation/openai/openai.py +225 -225
- openlit/instrumentation/openai_agents/openai_agents.py +11 -11
- openlit/instrumentation/phidata/phidata.py +15 -15
- openlit/instrumentation/pinecone/pinecone.py +43 -43
- openlit/instrumentation/premai/premai.py +86 -86
- openlit/instrumentation/qdrant/async_qdrant.py +95 -95
- openlit/instrumentation/qdrant/qdrant.py +99 -99
- openlit/instrumentation/reka/async_reka.py +33 -33
- openlit/instrumentation/reka/reka.py +33 -33
- openlit/instrumentation/together/async_together.py +90 -90
- openlit/instrumentation/together/together.py +90 -90
- openlit/instrumentation/transformers/transformers.py +26 -26
- openlit/instrumentation/vertexai/async_vertexai.py +64 -64
- openlit/instrumentation/vertexai/vertexai.py +64 -64
- openlit/instrumentation/vllm/vllm.py +24 -24
- openlit/otel/metrics.py +11 -11
- openlit/semcov/__init__.py +3 -3
- {openlit-1.33.19.dist-info → openlit-1.33.20.dist-info}/METADATA +8 -8
- openlit-1.33.20.dist-info/RECORD +131 -0
- {openlit-1.33.19.dist-info → openlit-1.33.20.dist-info}/WHEEL +1 -1
- openlit-1.33.19.dist-info/RECORD +0 -131
- {openlit-1.33.19.dist-info → openlit-1.33.20.dist-info}/LICENSE +0 -0
@@ -16,7 +16,7 @@ from openlit.__helpers import (
|
|
16
16
|
calculate_tbt,
|
17
17
|
create_metrics_attributes,
|
18
18
|
)
|
19
|
-
from openlit.semcov import
|
19
|
+
from openlit.semcov import SemanticConvention
|
20
20
|
|
21
21
|
# Initialize logger for logging potential issues and operations
|
22
22
|
logger = logging.getLogger(__name__)
|
@@ -151,51 +151,51 @@ def completion(version, environment, application_name,
|
|
151
151
|
|
152
152
|
# Set Span attributes (OTel Semconv)
|
153
153
|
self._span.set_attribute(TELEMETRY_SDK_NAME, 'openlit')
|
154
|
-
self._span.set_attribute(
|
155
|
-
|
156
|
-
self._span.set_attribute(
|
157
|
-
|
158
|
-
self._span.set_attribute(
|
154
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
|
155
|
+
SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
|
156
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
|
157
|
+
SemanticConvention.GEN_AI_SYSTEM_LITELLM)
|
158
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
|
159
159
|
request_model)
|
160
|
-
self._span.set_attribute(
|
160
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SEED,
|
161
161
|
self._kwargs.get('seed', ''))
|
162
|
-
self._span.set_attribute(
|
162
|
+
self._span.set_attribute(SemanticConvention.SERVER_PORT,
|
163
163
|
self._server_port)
|
164
|
-
self._span.set_attribute(
|
164
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY,
|
165
165
|
self._kwargs.get('frequency_penalty', 0.0))
|
166
|
-
self._span.set_attribute(
|
166
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS,
|
167
167
|
self._kwargs.get('max_tokens', -1))
|
168
|
-
self._span.set_attribute(
|
168
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY,
|
169
169
|
self._kwargs.get('presence_penalty', 0.0))
|
170
|
-
self._span.set_attribute(
|
170
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES,
|
171
171
|
self._kwargs.get('stop', []))
|
172
|
-
self._span.set_attribute(
|
172
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE,
|
173
173
|
self._kwargs.get('temperature', 1.0))
|
174
|
-
self._span.set_attribute(
|
174
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_P,
|
175
175
|
self._kwargs.get('top_p', 1.0))
|
176
|
-
self._span.set_attribute(
|
176
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
|
177
177
|
[self._finish_reason])
|
178
|
-
self._span.set_attribute(
|
178
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID,
|
179
179
|
self._response_id)
|
180
|
-
self._span.set_attribute(
|
180
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
|
181
181
|
self._response_model)
|
182
|
-
self._span.set_attribute(
|
182
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
|
183
183
|
input_tokens)
|
184
|
-
self._span.set_attribute(
|
184
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
|
185
185
|
output_tokens)
|
186
|
-
self._span.set_attribute(
|
186
|
+
self._span.set_attribute(SemanticConvention.SERVER_ADDRESS,
|
187
187
|
self._server_address)
|
188
|
-
self._span.set_attribute(
|
188
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SERVICE_TIER,
|
189
189
|
self._kwargs.get('service_tier', 'auto'))
|
190
|
-
self._span.set_attribute(
|
190
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_SERVICE_TIER,
|
191
191
|
self._response_service_tier)
|
192
|
-
self._span.set_attribute(
|
192
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_SYSTEM_FINGERPRINT,
|
193
193
|
self._response_service_tier)
|
194
194
|
if isinstance(self._llmresponse, str):
|
195
|
-
self._span.set_attribute(
|
195
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
|
196
196
|
'text')
|
197
197
|
else:
|
198
|
-
self._span.set_attribute(
|
198
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
|
199
199
|
'json')
|
200
200
|
|
201
201
|
# Set Span attributes (Extra)
|
@@ -203,31 +203,31 @@ def completion(version, environment, application_name,
|
|
203
203
|
environment)
|
204
204
|
self._span.set_attribute(SERVICE_NAME,
|
205
205
|
application_name)
|
206
|
-
self._span.set_attribute(
|
206
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_USER,
|
207
207
|
self._kwargs.get('user', ''))
|
208
|
-
self._span.set_attribute(
|
208
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
|
209
209
|
True)
|
210
|
-
self._span.set_attribute(
|
210
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
|
211
211
|
input_tokens + output_tokens)
|
212
|
-
self._span.set_attribute(
|
212
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
|
213
213
|
cost)
|
214
|
-
self._span.set_attribute(
|
214
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TBT,
|
215
215
|
self._tbt)
|
216
|
-
self._span.set_attribute(
|
216
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
|
217
217
|
self._ttft)
|
218
|
-
self._span.set_attribute(
|
218
|
+
self._span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
|
219
219
|
version)
|
220
220
|
if capture_message_content:
|
221
221
|
self._span.add_event(
|
222
|
-
name=
|
222
|
+
name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
|
223
223
|
attributes={
|
224
|
-
|
224
|
+
SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
|
225
225
|
},
|
226
226
|
)
|
227
227
|
self._span.add_event(
|
228
|
-
name=
|
228
|
+
name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
|
229
229
|
attributes={
|
230
|
-
|
230
|
+
SemanticConvention.GEN_AI_CONTENT_COMPLETION: self._llmresponse,
|
231
231
|
},
|
232
232
|
)
|
233
233
|
self._span.set_status(Status(StatusCode.OK))
|
@@ -236,8 +236,8 @@ def completion(version, environment, application_name,
|
|
236
236
|
attributes = create_metrics_attributes(
|
237
237
|
service_name=application_name,
|
238
238
|
deployment_environment=environment,
|
239
|
-
operation=
|
240
|
-
system=
|
239
|
+
operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
|
240
|
+
system=SemanticConvention.GEN_AI_SYSTEM_LITELLM,
|
241
241
|
request_model=request_model,
|
242
242
|
server_address=self._server_address,
|
243
243
|
server_port=self._server_port,
|
@@ -290,7 +290,7 @@ def completion(version, environment, application_name,
|
|
290
290
|
server_address, server_port = 'NOT_FOUND', 'NOT_FOUND'
|
291
291
|
request_model = kwargs.get('model', 'openai/gpt-4o')
|
292
292
|
|
293
|
-
span_name = f'{
|
293
|
+
span_name = f'{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}'
|
294
294
|
|
295
295
|
# pylint: disable=no-else-return
|
296
296
|
if streaming:
|
@@ -339,41 +339,41 @@ def completion(version, environment, application_name,
|
|
339
339
|
|
340
340
|
# Set base span attribues (OTel Semconv)
|
341
341
|
span.set_attribute(TELEMETRY_SDK_NAME, 'openlit')
|
342
|
-
span.set_attribute(
|
343
|
-
|
344
|
-
span.set_attribute(
|
345
|
-
|
346
|
-
span.set_attribute(
|
342
|
+
span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
|
343
|
+
SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT)
|
344
|
+
span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
|
345
|
+
SemanticConvention.GEN_AI_SYSTEM_LITELLM)
|
346
|
+
span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
|
347
347
|
request_model)
|
348
|
-
span.set_attribute(
|
348
|
+
span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SEED,
|
349
349
|
kwargs.get('seed', ''))
|
350
|
-
span.set_attribute(
|
350
|
+
span.set_attribute(SemanticConvention.SERVER_PORT,
|
351
351
|
server_port)
|
352
|
-
span.set_attribute(
|
352
|
+
span.set_attribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY,
|
353
353
|
kwargs.get('frequency_penalty', 0.0))
|
354
|
-
span.set_attribute(
|
354
|
+
span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS,
|
355
355
|
kwargs.get('max_tokens', -1))
|
356
|
-
span.set_attribute(
|
356
|
+
span.set_attribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY,
|
357
357
|
kwargs.get('presence_penalty', 0.0))
|
358
|
-
span.set_attribute(
|
358
|
+
span.set_attribute(SemanticConvention.GEN_AI_REQUEST_STOP_SEQUENCES,
|
359
359
|
kwargs.get('stop', []))
|
360
|
-
span.set_attribute(
|
360
|
+
span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE,
|
361
361
|
kwargs.get('temperature', 1.0))
|
362
|
-
span.set_attribute(
|
362
|
+
span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_P,
|
363
363
|
kwargs.get('top_p', 1.0))
|
364
|
-
span.set_attribute(
|
364
|
+
span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_ID,
|
365
365
|
response_dict.get('id'))
|
366
|
-
span.set_attribute(
|
366
|
+
span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
|
367
367
|
response_dict.get('model'))
|
368
|
-
span.set_attribute(
|
368
|
+
span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
|
369
369
|
input_tokens)
|
370
|
-
span.set_attribute(
|
370
|
+
span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS,
|
371
371
|
output_tokens)
|
372
|
-
span.set_attribute(
|
372
|
+
span.set_attribute(SemanticConvention.SERVER_ADDRESS,
|
373
373
|
server_address)
|
374
|
-
span.set_attribute(
|
374
|
+
span.set_attribute(SemanticConvention.GEN_AI_REQUEST_SERVICE_TIER,
|
375
375
|
kwargs.get('service_tier', 'auto'))
|
376
|
-
span.set_attribute(
|
376
|
+
span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_SYSTEM_FINGERPRINT,
|
377
377
|
str(response_dict.get('system_fingerprint')))
|
378
378
|
|
379
379
|
# Set base span attribues (Extras)
|
@@ -381,46 +381,46 @@ def completion(version, environment, application_name,
|
|
381
381
|
environment)
|
382
382
|
span.set_attribute(SERVICE_NAME,
|
383
383
|
application_name)
|
384
|
-
span.set_attribute(
|
384
|
+
span.set_attribute(SemanticConvention.GEN_AI_REQUEST_USER,
|
385
385
|
kwargs.get('user', ''))
|
386
|
-
span.set_attribute(
|
386
|
+
span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM,
|
387
387
|
False)
|
388
|
-
span.set_attribute(
|
388
|
+
span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
|
389
389
|
input_tokens + output_tokens)
|
390
|
-
span.set_attribute(
|
390
|
+
span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
|
391
391
|
cost)
|
392
|
-
span.set_attribute(
|
392
|
+
span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
|
393
393
|
end_time - start_time)
|
394
|
-
span.set_attribute(
|
394
|
+
span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
|
395
395
|
version)
|
396
396
|
if capture_message_content:
|
397
397
|
span.add_event(
|
398
|
-
name=
|
398
|
+
name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
|
399
399
|
attributes={
|
400
|
-
|
400
|
+
SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
|
401
401
|
},
|
402
402
|
)
|
403
403
|
|
404
404
|
for i in range(kwargs.get('n',1)):
|
405
|
-
span.set_attribute(
|
405
|
+
span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_FINISH_REASON,
|
406
406
|
[response_dict.get('choices')[i].get('finish_reason')])
|
407
407
|
if capture_message_content:
|
408
408
|
span.add_event(
|
409
|
-
name=
|
409
|
+
name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
|
410
410
|
attributes={
|
411
411
|
# pylint: disable=line-too-long
|
412
|
-
|
412
|
+
SemanticConvention.GEN_AI_CONTENT_COMPLETION: str(response_dict.get('choices')[i].get('message').get('content')),
|
413
413
|
},
|
414
414
|
)
|
415
415
|
if kwargs.get('tools'):
|
416
|
-
span.set_attribute(
|
416
|
+
span.set_attribute(SemanticConvention.GEN_AI_TOOL_CALLS,
|
417
417
|
str(response_dict.get('choices')[i].get('message').get('tool_calls')))
|
418
418
|
|
419
419
|
if isinstance(response_dict.get('choices')[i].get('message').get('content'), str):
|
420
|
-
span.set_attribute(
|
420
|
+
span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
|
421
421
|
'text')
|
422
422
|
elif response_dict.get('choices')[i].get('message').get('content') is not None:
|
423
|
-
span.set_attribute(
|
423
|
+
span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE,
|
424
424
|
'json')
|
425
425
|
|
426
426
|
span.set_status(Status(StatusCode.OK))
|
@@ -429,8 +429,8 @@ def completion(version, environment, application_name,
|
|
429
429
|
attributes = create_metrics_attributes(
|
430
430
|
service_name=application_name,
|
431
431
|
deployment_environment=environment,
|
432
|
-
operation=
|
433
|
-
system=
|
432
|
+
operation=SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT,
|
433
|
+
system=SemanticConvention.GEN_AI_SYSTEM_LITELLM,
|
434
434
|
request_model=request_model,
|
435
435
|
server_address=server_address,
|
436
436
|
server_port=server_port,
|
@@ -500,7 +500,7 @@ def embedding(version, environment, application_name,
|
|
500
500
|
server_address, server_port = 'NOT_FOUND', 'NOT_FOUND'
|
501
501
|
request_model = kwargs.get('model', 'text-embedding-ada-002')
|
502
502
|
|
503
|
-
span_name = f'{
|
503
|
+
span_name = f'{SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING} {request_model}'
|
504
504
|
|
505
505
|
with tracer.start_as_current_span(span_name, kind= SpanKind.CLIENT) as span:
|
506
506
|
start_time = time.time()
|
@@ -517,21 +517,21 @@ def embedding(version, environment, application_name,
|
|
517
517
|
|
518
518
|
# Set Span attributes (OTel Semconv)
|
519
519
|
span.set_attribute(TELEMETRY_SDK_NAME, 'openlit')
|
520
|
-
span.set_attribute(
|
521
|
-
|
522
|
-
span.set_attribute(
|
523
|
-
|
524
|
-
span.set_attribute(
|
520
|
+
span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
|
521
|
+
SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING)
|
522
|
+
span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
|
523
|
+
SemanticConvention.GEN_AI_SYSTEM_LITELLM)
|
524
|
+
span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL,
|
525
525
|
request_model)
|
526
|
-
span.set_attribute(
|
526
|
+
span.set_attribute(SemanticConvention.GEN_AI_REQUEST_ENCODING_FORMATS,
|
527
527
|
[kwargs.get('encoding_format', 'float')])
|
528
|
-
span.set_attribute(
|
528
|
+
span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
|
529
529
|
response_dict.get('model'))
|
530
|
-
span.set_attribute(
|
530
|
+
span.set_attribute(SemanticConvention.SERVER_ADDRESS,
|
531
531
|
server_address)
|
532
|
-
span.set_attribute(
|
532
|
+
span.set_attribute(SemanticConvention.SERVER_PORT,
|
533
533
|
server_port)
|
534
|
-
span.set_attribute(
|
534
|
+
span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS,
|
535
535
|
input_tokens)
|
536
536
|
|
537
537
|
# Set Span attributes (Extras)
|
@@ -539,20 +539,20 @@ def embedding(version, environment, application_name,
|
|
539
539
|
environment)
|
540
540
|
span.set_attribute(SERVICE_NAME,
|
541
541
|
application_name)
|
542
|
-
span.set_attribute(
|
542
|
+
span.set_attribute(SemanticConvention.GEN_AI_REQUEST_USER,
|
543
543
|
kwargs.get('user', ''))
|
544
|
-
span.set_attribute(
|
544
|
+
span.set_attribute(SemanticConvention.GEN_AI_USAGE_TOTAL_TOKENS,
|
545
545
|
input_tokens)
|
546
|
-
span.set_attribute(
|
546
|
+
span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST,
|
547
547
|
cost)
|
548
|
-
span.set_attribute(
|
548
|
+
span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION,
|
549
549
|
version)
|
550
550
|
|
551
551
|
if capture_message_content:
|
552
552
|
span.add_event(
|
553
|
-
name=
|
553
|
+
name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
|
554
554
|
attributes={
|
555
|
-
|
555
|
+
SemanticConvention.GEN_AI_CONTENT_PROMPT: str(kwargs.get('input', '')),
|
556
556
|
},
|
557
557
|
)
|
558
558
|
|
@@ -562,8 +562,8 @@ def embedding(version, environment, application_name,
|
|
562
562
|
attributes = create_metrics_attributes(
|
563
563
|
service_name=application_name,
|
564
564
|
deployment_environment=environment,
|
565
|
-
operation=
|
566
|
-
system=
|
565
|
+
operation=SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING,
|
566
|
+
system=SemanticConvention.GEN_AI_SYSTEM_LITELLM,
|
567
567
|
request_model=request_model,
|
568
568
|
server_address=server_address,
|
569
569
|
server_port=server_port,
|
@@ -7,7 +7,7 @@ import logging
|
|
7
7
|
from opentelemetry.trace import SpanKind, Status, StatusCode
|
8
8
|
from opentelemetry.sdk.resources import SERVICE_NAME, TELEMETRY_SDK_NAME, DEPLOYMENT_ENVIRONMENT
|
9
9
|
from openlit.__helpers import handle_exception
|
10
|
-
from openlit.semcov import
|
10
|
+
from openlit.semcov import SemanticConvention
|
11
11
|
|
12
12
|
# Initialize logger for logging potential issues and operations
|
13
13
|
logger = logging.getLogger(__name__)
|
@@ -59,17 +59,17 @@ def load_data(gen_ai_endpoint, version, environment, application_name,
|
|
59
59
|
|
60
60
|
try:
|
61
61
|
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
|
62
|
-
span.set_attribute(
|
63
|
-
|
64
|
-
span.set_attribute(
|
62
|
+
span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
|
63
|
+
SemanticConvention.GEN_AI_SYSTEM_LLAMAINDEX)
|
64
|
+
span.set_attribute(SemanticConvention.GEN_AI_ENDPOINT,
|
65
65
|
gen_ai_endpoint)
|
66
66
|
span.set_attribute(DEPLOYMENT_ENVIRONMENT,
|
67
67
|
environment)
|
68
|
-
span.set_attribute(
|
69
|
-
|
68
|
+
span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
|
69
|
+
SemanticConvention.GEN_AI_OPERATION_TYPE_FRAMEWORK)
|
70
70
|
span.set_attribute(SERVICE_NAME,
|
71
71
|
application_name)
|
72
|
-
span.set_attribute(
|
72
|
+
span.set_attribute(SemanticConvention.GEN_AI_RETRIEVAL_SOURCE,
|
73
73
|
response[0].metadata["file_path"])
|
74
74
|
span.set_status(Status(StatusCode.OK))
|
75
75
|
|
@@ -7,7 +7,7 @@ import logging
|
|
7
7
|
from opentelemetry.trace import SpanKind, Status, StatusCode
|
8
8
|
from opentelemetry.sdk.resources import SERVICE_NAME, TELEMETRY_SDK_NAME, DEPLOYMENT_ENVIRONMENT
|
9
9
|
from openlit.__helpers import handle_exception
|
10
|
-
from openlit.semcov import
|
10
|
+
from openlit.semcov import SemanticConvention
|
11
11
|
|
12
12
|
# Initialize logger for logging potential issues and operations
|
13
13
|
logger = logging.getLogger(__name__)
|
@@ -59,44 +59,44 @@ def mem0_wrap(gen_ai_endpoint, version, environment, application_name,
|
|
59
59
|
|
60
60
|
try:
|
61
61
|
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
|
62
|
-
span.set_attribute(
|
63
|
-
|
64
|
-
span.set_attribute(
|
62
|
+
span.set_attribute(SemanticConvention.GEN_AI_SYSTEM,
|
63
|
+
SemanticConvention.GEN_AI_SYSTEM_MEM0)
|
64
|
+
span.set_attribute(SemanticConvention.GEN_AI_ENDPOINT,
|
65
65
|
gen_ai_endpoint)
|
66
66
|
span.set_attribute(DEPLOYMENT_ENVIRONMENT,
|
67
67
|
environment)
|
68
|
-
span.set_attribute(
|
69
|
-
|
68
|
+
span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
|
69
|
+
SemanticConvention.GEN_AI_OPERATION_TYPE_FRAMEWORK)
|
70
70
|
span.set_attribute(SERVICE_NAME,
|
71
71
|
application_name)
|
72
72
|
|
73
73
|
if gen_ai_endpoint == "mem0.memory_add":
|
74
|
-
span.set_attribute(
|
74
|
+
span.set_attribute(SemanticConvention.DB_METADATA,
|
75
75
|
str(kwargs.get('metadata', '')))
|
76
76
|
if response:
|
77
|
-
span.set_attribute(
|
77
|
+
span.set_attribute(SemanticConvention.GEN_AI_DATA_SOURCES,
|
78
78
|
len(response))
|
79
79
|
|
80
80
|
elif gen_ai_endpoint == "mem0.memory_get_all":
|
81
81
|
if response:
|
82
|
-
span.set_attribute(
|
82
|
+
span.set_attribute(SemanticConvention.GEN_AI_DATA_SOURCES,
|
83
83
|
len(response))
|
84
84
|
|
85
85
|
elif gen_ai_endpoint == "mem0.memory_get":
|
86
86
|
if response:
|
87
|
-
span.set_attribute(
|
87
|
+
span.set_attribute(SemanticConvention.GEN_AI_DATA_SOURCES,
|
88
88
|
len(response))
|
89
89
|
|
90
90
|
elif gen_ai_endpoint == "mem0.memory_search":
|
91
|
-
span.set_attribute(
|
91
|
+
span.set_attribute(SemanticConvention.DB_STATEMENT,
|
92
92
|
kwargs.get("query", ""))
|
93
93
|
|
94
94
|
elif gen_ai_endpoint == "mem0.memory_update":
|
95
|
-
span.set_attribute(
|
95
|
+
span.set_attribute(SemanticConvention.DB_UPDATE_ID,
|
96
96
|
kwargs.get("memory_id", ""))
|
97
97
|
|
98
98
|
elif gen_ai_endpoint == "mem0.memory_delete":
|
99
|
-
span.set_attribute(
|
99
|
+
span.set_attribute(SemanticConvention.DB_DELETE_ID,
|
100
100
|
kwargs.get("memory_id", ""))
|
101
101
|
|
102
102
|
|
@@ -7,7 +7,7 @@ import logging
|
|
7
7
|
from opentelemetry.trace import SpanKind, Status, StatusCode
|
8
8
|
from opentelemetry.sdk.resources import SERVICE_NAME, TELEMETRY_SDK_NAME, DEPLOYMENT_ENVIRONMENT
|
9
9
|
from openlit.__helpers import handle_exception
|
10
|
-
from openlit.semcov import
|
10
|
+
from openlit.semcov import SemanticConvention
|
11
11
|
|
12
12
|
# Initialize logger for logging potential issues and operations
|
13
13
|
logger = logging.getLogger(__name__)
|
@@ -71,80 +71,80 @@ def general_wrap(gen_ai_endpoint, version, environment, application_name,
|
|
71
71
|
|
72
72
|
try:
|
73
73
|
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
|
74
|
-
span.set_attribute(
|
74
|
+
span.set_attribute(SemanticConvention.GEN_AI_ENDPOINT,
|
75
75
|
gen_ai_endpoint)
|
76
76
|
span.set_attribute(DEPLOYMENT_ENVIRONMENT,
|
77
77
|
environment)
|
78
78
|
span.set_attribute(SERVICE_NAME,
|
79
79
|
application_name)
|
80
|
-
span.set_attribute(
|
81
|
-
|
82
|
-
span.set_attribute(
|
83
|
-
|
80
|
+
span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
|
81
|
+
SemanticConvention.GEN_AI_OPERATION_TYPE_VECTORDB)
|
82
|
+
span.set_attribute(SemanticConvention.DB_SYSTEM_NAME,
|
83
|
+
SemanticConvention.DB_SYSTEM_MILVUS)
|
84
84
|
|
85
85
|
if gen_ai_endpoint == "milvus.create_collection":
|
86
|
-
db_operation =
|
87
|
-
span.set_attribute(
|
88
|
-
|
89
|
-
span.set_attribute(
|
86
|
+
db_operation = SemanticConvention.DB_OPERATION_CREATE_COLLECTION
|
87
|
+
span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
|
88
|
+
SemanticConvention.DB_OPERATION_CREATE_COLLECTION)
|
89
|
+
span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
|
90
90
|
kwargs.get("collection_name", ""))
|
91
|
-
span.set_attribute(
|
91
|
+
span.set_attribute(SemanticConvention.DB_COLLECTION_DIMENSION,
|
92
92
|
kwargs.get("dimension", ""))
|
93
93
|
|
94
94
|
elif gen_ai_endpoint == "milvus.drop_collection":
|
95
|
-
db_operation =
|
96
|
-
span.set_attribute(
|
97
|
-
|
98
|
-
span.set_attribute(
|
95
|
+
db_operation = SemanticConvention.DB_OPERATION_DELETE_COLLECTION
|
96
|
+
span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
|
97
|
+
SemanticConvention.DB_OPERATION_DELETE_COLLECTION)
|
98
|
+
span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
|
99
99
|
kwargs.get("collection_name", ""))
|
100
100
|
|
101
101
|
elif gen_ai_endpoint == "milvus.insert":
|
102
|
-
db_operation =
|
103
|
-
span.set_attribute(
|
104
|
-
|
105
|
-
span.set_attribute(
|
102
|
+
db_operation = SemanticConvention.DB_OPERATION_ADD
|
103
|
+
span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
|
104
|
+
SemanticConvention.DB_OPERATION_ADD)
|
105
|
+
span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
|
106
106
|
kwargs.get("collection_name", ""))
|
107
|
-
span.set_attribute(
|
107
|
+
span.set_attribute(SemanticConvention.DB_VECTOR_COUNT,
|
108
108
|
object_count(kwargs.get("data")))
|
109
|
-
span.set_attribute(
|
109
|
+
span.set_attribute(SemanticConvention.DB_OPERATION_COST,
|
110
110
|
response["cost"])
|
111
111
|
|
112
112
|
elif gen_ai_endpoint == "milvus.search":
|
113
|
-
db_operation =
|
114
|
-
span.set_attribute(
|
115
|
-
|
116
|
-
span.set_attribute(
|
113
|
+
db_operation = SemanticConvention.DB_OPERATION_QUERY
|
114
|
+
span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
|
115
|
+
SemanticConvention.DB_OPERATION_QUERY)
|
116
|
+
span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
|
117
117
|
kwargs.get("collection_name", ""))
|
118
|
-
span.set_attribute(
|
118
|
+
span.set_attribute(SemanticConvention.DB_STATEMENT,
|
119
119
|
str(kwargs.get("data")))
|
120
120
|
|
121
121
|
elif gen_ai_endpoint in ["milvus.query", "milvus.get"]:
|
122
|
-
db_operation =
|
123
|
-
span.set_attribute(
|
124
|
-
|
125
|
-
span.set_attribute(
|
122
|
+
db_operation = SemanticConvention.DB_OPERATION_QUERY
|
123
|
+
span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
|
124
|
+
SemanticConvention.DB_OPERATION_QUERY)
|
125
|
+
span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
|
126
126
|
kwargs.get("collection_name", ""))
|
127
|
-
span.set_attribute(
|
127
|
+
span.set_attribute(SemanticConvention.DB_STATEMENT,
|
128
128
|
str(kwargs.get("output_fields")))
|
129
129
|
|
130
130
|
elif gen_ai_endpoint == "milvus.upsert":
|
131
|
-
db_operation =
|
132
|
-
span.set_attribute(
|
133
|
-
|
134
|
-
span.set_attribute(
|
131
|
+
db_operation = SemanticConvention.DB_OPERATION_ADD
|
132
|
+
span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
|
133
|
+
SemanticConvention.DB_OPERATION_UPSERT)
|
134
|
+
span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
|
135
135
|
kwargs.get("collection_name", ""))
|
136
|
-
span.set_attribute(
|
136
|
+
span.set_attribute(SemanticConvention.DB_VECTOR_COUNT,
|
137
137
|
object_count(kwargs.get("data")))
|
138
|
-
span.set_attribute(
|
138
|
+
span.set_attribute(SemanticConvention.DB_OPERATION_COST,
|
139
139
|
response["cost"])
|
140
140
|
|
141
141
|
elif gen_ai_endpoint == "milvus.delete":
|
142
|
-
db_operation =
|
143
|
-
span.set_attribute(
|
144
|
-
|
145
|
-
span.set_attribute(
|
142
|
+
db_operation = SemanticConvention.DB_OPERATION_DELETE
|
143
|
+
span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
|
144
|
+
SemanticConvention.DB_OPERATION_DELETE)
|
145
|
+
span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
|
146
146
|
kwargs.get("collection_name", ""))
|
147
|
-
span.set_attribute(
|
147
|
+
span.set_attribute(SemanticConvention.DB_FILTER,
|
148
148
|
str(kwargs.get("filter", "")))
|
149
149
|
|
150
150
|
span.set_status(Status(StatusCode.OK))
|
@@ -155,13 +155,13 @@ def general_wrap(gen_ai_endpoint, version, environment, application_name,
|
|
155
155
|
"openlit",
|
156
156
|
SERVICE_NAME:
|
157
157
|
application_name,
|
158
|
-
|
159
|
-
|
158
|
+
SemanticConvention.DB_SYSTEM_NAME:
|
159
|
+
SemanticConvention.DB_SYSTEM_MILVUS,
|
160
160
|
DEPLOYMENT_ENVIRONMENT:
|
161
161
|
environment,
|
162
|
-
|
163
|
-
|
164
|
-
|
162
|
+
SemanticConvention.GEN_AI_OPERATION:
|
163
|
+
SemanticConvention.GEN_AI_OPERATION_TYPE_VECTORDB,
|
164
|
+
SemanticConvention.DB_OPERATION_NAME:
|
165
165
|
db_operation
|
166
166
|
}
|
167
167
|
|