openlit 1.33.7__py3-none-any.whl → 1.33.9__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 +83 -0
- openlit/__init__.py +1 -1
- openlit/instrumentation/ag2/ag2.py +2 -2
- openlit/instrumentation/ai21/__init__.py +4 -4
- openlit/instrumentation/ai21/ai21.py +370 -319
- openlit/instrumentation/ai21/async_ai21.py +371 -319
- openlit/instrumentation/anthropic/__init__.py +4 -4
- openlit/instrumentation/anthropic/anthropic.py +321 -189
- openlit/instrumentation/anthropic/async_anthropic.py +323 -190
- openlit/instrumentation/assemblyai/__init__.py +1 -1
- openlit/instrumentation/assemblyai/assemblyai.py +59 -43
- openlit/instrumentation/astra/astra.py +4 -4
- openlit/instrumentation/astra/async_astra.py +4 -4
- openlit/instrumentation/azure_ai_inference/__init__.py +4 -4
- openlit/instrumentation/azure_ai_inference/async_azure_ai_inference.py +406 -252
- openlit/instrumentation/azure_ai_inference/azure_ai_inference.py +406 -252
- openlit/instrumentation/bedrock/__init__.py +1 -1
- openlit/instrumentation/bedrock/bedrock.py +115 -58
- openlit/instrumentation/chroma/chroma.py +4 -4
- openlit/instrumentation/cohere/__init__.py +33 -10
- openlit/instrumentation/cohere/async_cohere.py +610 -0
- openlit/instrumentation/cohere/cohere.py +410 -219
- openlit/instrumentation/controlflow/controlflow.py +2 -2
- openlit/instrumentation/crawl4ai/async_crawl4ai.py +2 -2
- openlit/instrumentation/crawl4ai/crawl4ai.py +2 -2
- openlit/instrumentation/crewai/crewai.py +2 -2
- openlit/instrumentation/dynamiq/dynamiq.py +2 -2
- openlit/instrumentation/elevenlabs/async_elevenlabs.py +73 -47
- openlit/instrumentation/elevenlabs/elevenlabs.py +73 -52
- openlit/instrumentation/embedchain/embedchain.py +4 -4
- openlit/instrumentation/firecrawl/firecrawl.py +2 -2
- openlit/instrumentation/google_ai_studio/__init__.py +9 -9
- openlit/instrumentation/google_ai_studio/async_google_ai_studio.py +183 -219
- openlit/instrumentation/google_ai_studio/google_ai_studio.py +183 -220
- openlit/instrumentation/gpt4all/gpt4all.py +17 -17
- openlit/instrumentation/groq/async_groq.py +14 -14
- openlit/instrumentation/groq/groq.py +14 -14
- openlit/instrumentation/haystack/haystack.py +2 -2
- openlit/instrumentation/julep/async_julep.py +2 -2
- openlit/instrumentation/julep/julep.py +2 -2
- openlit/instrumentation/langchain/langchain.py +36 -31
- openlit/instrumentation/letta/letta.py +6 -6
- openlit/instrumentation/litellm/async_litellm.py +20 -20
- openlit/instrumentation/litellm/litellm.py +20 -20
- openlit/instrumentation/llamaindex/llamaindex.py +2 -2
- openlit/instrumentation/mem0/mem0.py +2 -2
- openlit/instrumentation/milvus/milvus.py +4 -4
- openlit/instrumentation/mistral/async_mistral.py +18 -18
- openlit/instrumentation/mistral/mistral.py +18 -18
- openlit/instrumentation/multion/async_multion.py +2 -2
- openlit/instrumentation/multion/multion.py +2 -2
- openlit/instrumentation/ollama/async_ollama.py +29 -29
- openlit/instrumentation/ollama/ollama.py +29 -29
- openlit/instrumentation/openai/__init__.py +11 -230
- openlit/instrumentation/openai/async_openai.py +434 -409
- openlit/instrumentation/openai/openai.py +415 -393
- openlit/instrumentation/phidata/phidata.py +2 -2
- openlit/instrumentation/pinecone/pinecone.py +4 -4
- openlit/instrumentation/premai/premai.py +20 -20
- openlit/instrumentation/qdrant/async_qdrant.py +4 -4
- openlit/instrumentation/qdrant/qdrant.py +4 -4
- openlit/instrumentation/reka/async_reka.py +6 -6
- openlit/instrumentation/reka/reka.py +6 -6
- openlit/instrumentation/together/async_together.py +18 -18
- openlit/instrumentation/together/together.py +18 -18
- openlit/instrumentation/transformers/transformers.py +6 -6
- openlit/instrumentation/vertexai/async_vertexai.py +53 -53
- openlit/instrumentation/vertexai/vertexai.py +53 -53
- openlit/instrumentation/vllm/vllm.py +6 -6
- openlit/otel/metrics.py +98 -7
- openlit/semcov/__init__.py +113 -80
- {openlit-1.33.7.dist-info → openlit-1.33.9.dist-info}/METADATA +2 -1
- openlit-1.33.9.dist-info/RECORD +121 -0
- {openlit-1.33.7.dist-info → openlit-1.33.9.dist-info}/WHEEL +1 -1
- openlit/instrumentation/openai/async_azure_openai.py +0 -900
- openlit/instrumentation/openai/azure_openai.py +0 -898
- openlit-1.33.7.dist-info/RECORD +0 -122
- {openlit-1.33.7.dist-info → openlit-1.33.9.dist-info}/LICENSE +0 -0
@@ -68,8 +68,8 @@ def wrap_controlflow(gen_ai_endpoint, version, environment, application_name,
|
|
68
68
|
environment)
|
69
69
|
span.set_attribute(SemanticConvetion.GEN_AI_APPLICATION_NAME,
|
70
70
|
application_name)
|
71
|
-
span.set_attribute(SemanticConvetion.
|
72
|
-
SemanticConvetion.
|
71
|
+
span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
|
72
|
+
SemanticConvetion.GEN_AI_OPERATION_TYPE_AGENT)
|
73
73
|
|
74
74
|
if gen_ai_endpoint == "controlflow.create_agent":
|
75
75
|
span.set_attribute(SemanticConvetion.GEN_AI_AGENT_ROLE,
|
@@ -58,8 +58,8 @@ def async_wrap_crawl(gen_ai_endpoint, version, environment, application_name,
|
|
58
58
|
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
|
59
59
|
span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
|
60
60
|
SemanticConvetion.GEN_AI_SYSTEM_CRAWL4AI)
|
61
|
-
span.set_attribute(SemanticConvetion.
|
62
|
-
SemanticConvetion.
|
61
|
+
span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
|
62
|
+
SemanticConvetion.GEN_AI_OPERATION_TYPE_AGENT)
|
63
63
|
span.set_attribute(SemanticConvetion.GEN_AI_ENDPOINT,
|
64
64
|
gen_ai_endpoint)
|
65
65
|
span.set_attribute(SemanticConvetion.GEN_AI_APPLICATION_NAME,
|
@@ -58,8 +58,8 @@ def wrap_crawl(gen_ai_endpoint, version, environment, application_name,
|
|
58
58
|
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
|
59
59
|
span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
|
60
60
|
SemanticConvetion.GEN_AI_SYSTEM_CRAWL4AI)
|
61
|
-
span.set_attribute(SemanticConvetion.
|
62
|
-
SemanticConvetion.
|
61
|
+
span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
|
62
|
+
SemanticConvetion.GEN_AI_OPERATION_TYPE_AGENT)
|
63
63
|
span.set_attribute(SemanticConvetion.GEN_AI_ENDPOINT,
|
64
64
|
gen_ai_endpoint)
|
65
65
|
span.set_attribute(SemanticConvetion.GEN_AI_APPLICATION_NAME,
|
@@ -71,8 +71,8 @@ def crew_wrap(gen_ai_endpoint, version, environment, application_name,
|
|
71
71
|
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
|
72
72
|
span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
|
73
73
|
SemanticConvetion.GEN_AI_SYSTEM_CREWAI)
|
74
|
-
span.set_attribute(SemanticConvetion.
|
75
|
-
SemanticConvetion.
|
74
|
+
span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
|
75
|
+
SemanticConvetion.GEN_AI_OPERATION_TYPE_AGENT)
|
76
76
|
span.set_attribute(SemanticConvetion.GEN_AI_ENDPOINT,
|
77
77
|
gen_ai_endpoint)
|
78
78
|
span.set_attribute(SemanticConvetion.GEN_AI_APPLICATION_NAME,
|
@@ -58,8 +58,8 @@ def dynamiq_wrap(gen_ai_endpoint, version, environment, application_name,
|
|
58
58
|
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
|
59
59
|
span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
|
60
60
|
SemanticConvetion.GEN_AI_SYSTEM_DYNAMIQ)
|
61
|
-
span.set_attribute(SemanticConvetion.
|
62
|
-
SemanticConvetion.
|
61
|
+
span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
|
62
|
+
SemanticConvetion.GEN_AI_OPERATION_TYPE_AGENT)
|
63
63
|
span.set_attribute(SemanticConvetion.GEN_AI_ENDPOINT,
|
64
64
|
gen_ai_endpoint)
|
65
65
|
span.set_attribute(SemanticConvetion.GEN_AI_APPLICATION_NAME,
|
@@ -1,13 +1,17 @@
|
|
1
|
-
# pylint: disable=duplicate-code, broad-exception-caught, too-many-statements, unused-argument, possibly-used-before-assignment
|
2
1
|
"""
|
3
2
|
Module for monitoring Ollama API calls.
|
4
3
|
"""
|
5
4
|
|
6
5
|
import logging
|
6
|
+
import time
|
7
|
+
from urllib.parse import urlparse
|
7
8
|
from opentelemetry.trace import SpanKind, Status, StatusCode
|
8
|
-
from opentelemetry.sdk.resources import TELEMETRY_SDK_NAME
|
9
|
-
from openlit.__helpers import
|
10
|
-
|
9
|
+
from opentelemetry.sdk.resources import SERVICE_NAME, TELEMETRY_SDK_NAME, DEPLOYMENT_ENVIRONMENT
|
10
|
+
from openlit.__helpers import (
|
11
|
+
get_audio_model_cost,
|
12
|
+
handle_exception,
|
13
|
+
create_metrics_attributes,
|
14
|
+
)
|
11
15
|
from openlit.semcov import SemanticConvetion
|
12
16
|
|
13
17
|
# Initialize logger for logging potential issues and operations
|
@@ -19,7 +23,6 @@ def async_generate(gen_ai_endpoint, version, environment, application_name,
|
|
19
23
|
Generates a telemetry wrapper for creating speech audio to collect metrics.
|
20
24
|
|
21
25
|
Args:
|
22
|
-
gen_ai_endpoint: Endpoint identifier for logging and tracing.
|
23
26
|
version: Version of the monitoring package.
|
24
27
|
environment: Deployment environment (e.g., production, staging).
|
25
28
|
application_name: Name of the application using the ElevenLabs API.
|
@@ -47,73 +50,96 @@ def async_generate(gen_ai_endpoint, version, environment, application_name,
|
|
47
50
|
Returns:
|
48
51
|
The response from the original 'generate' method.
|
49
52
|
"""
|
53
|
+
url = urlparse(instance._client_wrapper._base_url)
|
54
|
+
server_address, server_port = url.hostname, url.port or 443
|
55
|
+
request_model = kwargs.get('model', kwargs.get('model_id', 'eleven_multilingual_v2'))
|
50
56
|
|
51
|
-
|
52
|
-
response = await wrapped(*args, **kwargs)
|
57
|
+
span_name = f'{SemanticConvetion.GEN_AI_OPERATION_TYPE_AUDIO} {request_model}'
|
53
58
|
|
59
|
+
with tracer.start_as_current_span(span_name, kind= SpanKind.CLIENT) as span:
|
60
|
+
start_time = time.time()
|
61
|
+
response = await wrapped(*args, **kwargs)
|
62
|
+
end_time = time.time()
|
63
|
+
for key, value in instance.__dict__.items():
|
64
|
+
print(f'{key}: {value}')
|
54
65
|
try:
|
55
66
|
# Calculate cost of the operation
|
56
|
-
cost = get_audio_model_cost(
|
57
|
-
pricing_info, kwargs.get(
|
67
|
+
cost = get_audio_model_cost(request_model,
|
68
|
+
pricing_info, kwargs.get('text', ''))
|
58
69
|
|
59
70
|
# Set Span attributes
|
60
|
-
span.set_attribute(TELEMETRY_SDK_NAME,
|
71
|
+
span.set_attribute(TELEMETRY_SDK_NAME, 'openlit')
|
72
|
+
span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
|
73
|
+
SemanticConvetion.GEN_AI_OPERATION_TYPE_AUDIO)
|
61
74
|
span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
|
62
|
-
SemanticConvetion.
|
63
|
-
span.set_attribute(SemanticConvetion.
|
64
|
-
|
65
|
-
span.set_attribute(SemanticConvetion.
|
66
|
-
|
67
|
-
span.set_attribute(SemanticConvetion.
|
68
|
-
|
69
|
-
span.set_attribute(SemanticConvetion.
|
70
|
-
|
75
|
+
SemanticConvetion.GEN_AI_SYSTEM_ASSEMBLYAI)
|
76
|
+
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
|
77
|
+
request_model)
|
78
|
+
span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
|
79
|
+
server_address)
|
80
|
+
span.set_attribute(SemanticConvetion.SERVER_PORT,
|
81
|
+
server_port)
|
82
|
+
span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
|
83
|
+
request_model)
|
71
84
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
|
72
|
-
|
73
|
-
|
85
|
+
request_model)
|
86
|
+
span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
|
87
|
+
'audio')
|
88
|
+
|
89
|
+
# Set Span attributes (Extras)
|
90
|
+
if gen_ai_endpoint == 'elevenlabs.generate':
|
91
|
+
if isinstance(kwargs.get('voice', 'Rachel'), str):
|
92
|
+
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_AUDIO_VOICE,
|
93
|
+
kwargs.get('voice', 'Rachel'))
|
94
|
+
else:
|
74
95
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_AUDIO_VOICE,
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
96
|
+
kwargs.get('voice_id', ''))
|
97
|
+
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_AUDIO_RESPONSE_FORMAT,
|
98
|
+
kwargs.get('output_format', 'mp3'))
|
99
|
+
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_AUDIO_SETTINGS,
|
100
|
+
str(kwargs.get('voice_settings', '')))
|
101
|
+
span.set_attribute(DEPLOYMENT_ENVIRONMENT,
|
102
|
+
environment)
|
103
|
+
span.set_attribute(SERVICE_NAME,
|
104
|
+
application_name)
|
105
|
+
span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
|
106
|
+
cost)
|
107
|
+
span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
|
108
|
+
version)
|
82
109
|
if trace_content:
|
83
110
|
span.add_event(
|
84
111
|
name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
|
85
112
|
attributes={
|
86
|
-
SemanticConvetion.GEN_AI_CONTENT_PROMPT: str(kwargs.get(
|
113
|
+
SemanticConvetion.GEN_AI_CONTENT_PROMPT: str(kwargs.get('text', '')),
|
87
114
|
},
|
88
115
|
)
|
89
116
|
|
90
117
|
span.set_status(Status(StatusCode.OK))
|
91
118
|
|
92
119
|
if disable_metrics is False:
|
93
|
-
attributes =
|
94
|
-
|
95
|
-
|
96
|
-
SemanticConvetion.
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
metrics[
|
109
|
-
metrics["genai_cost"].record(cost, attributes)
|
120
|
+
attributes = create_metrics_attributes(
|
121
|
+
service_name=application_name,
|
122
|
+
deployment_environment=environment,
|
123
|
+
operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_AUDIO,
|
124
|
+
system=SemanticConvetion.GEN_AI_SYSTEM_ELEVENLABS,
|
125
|
+
request_model=request_model,
|
126
|
+
server_address=server_address,
|
127
|
+
server_port=server_port,
|
128
|
+
response_model=request_model,
|
129
|
+
)
|
130
|
+
|
131
|
+
metrics['genai_client_operation_duration'].record(
|
132
|
+
end_time - start_time, attributes
|
133
|
+
)
|
134
|
+
metrics['genai_requests'].add(1, attributes)
|
135
|
+
metrics['genai_cost'].record(cost, attributes)
|
110
136
|
|
111
137
|
# Return original response
|
112
138
|
return response
|
113
139
|
|
114
140
|
except Exception as e:
|
115
141
|
handle_exception(span, e)
|
116
|
-
logger.error(
|
142
|
+
logger.error('Error in trace creation: %s', e)
|
117
143
|
|
118
144
|
# Return original response
|
119
145
|
return response
|
@@ -1,13 +1,17 @@
|
|
1
|
-
# pylint: disable=duplicate-code, broad-exception-caught, too-many-statements, unused-argument, possibly-used-before-assignment
|
2
1
|
"""
|
3
2
|
Module for monitoring Ollama API calls.
|
4
3
|
"""
|
5
4
|
|
6
5
|
import logging
|
6
|
+
import time
|
7
|
+
from urllib.parse import urlparse
|
7
8
|
from opentelemetry.trace import SpanKind, Status, StatusCode
|
8
|
-
from opentelemetry.sdk.resources import TELEMETRY_SDK_NAME
|
9
|
-
from openlit.__helpers import
|
10
|
-
|
9
|
+
from opentelemetry.sdk.resources import SERVICE_NAME, TELEMETRY_SDK_NAME, DEPLOYMENT_ENVIRONMENT
|
10
|
+
from openlit.__helpers import (
|
11
|
+
get_audio_model_cost,
|
12
|
+
handle_exception,
|
13
|
+
create_metrics_attributes,
|
14
|
+
)
|
11
15
|
from openlit.semcov import SemanticConvetion
|
12
16
|
|
13
17
|
# Initialize logger for logging potential issues and operations
|
@@ -19,7 +23,6 @@ def generate(gen_ai_endpoint, version, environment, application_name,
|
|
19
23
|
Generates a telemetry wrapper for creating speech audio to collect metrics.
|
20
24
|
|
21
25
|
Args:
|
22
|
-
gen_ai_endpoint: Endpoint identifier for logging and tracing.
|
23
26
|
version: Version of the monitoring package.
|
24
27
|
environment: Deployment environment (e.g., production, staging).
|
25
28
|
application_name: Name of the application using the ElevenLabs API.
|
@@ -48,78 +51,96 @@ def generate(gen_ai_endpoint, version, environment, application_name,
|
|
48
51
|
The response from the original 'generate' method.
|
49
52
|
"""
|
50
53
|
|
51
|
-
|
52
|
-
|
54
|
+
url = urlparse(instance._client_wrapper._base_url)
|
55
|
+
server_address, server_port = url.hostname, url.port or 443
|
56
|
+
request_model = kwargs.get('model', kwargs.get('model_id', 'eleven_multilingual_v2'))
|
57
|
+
|
58
|
+
span_name = f'{SemanticConvetion.GEN_AI_OPERATION_TYPE_AUDIO} {request_model}'
|
53
59
|
|
60
|
+
with tracer.start_as_current_span(span_name, kind= SpanKind.CLIENT) as span:
|
61
|
+
start_time = time.time()
|
62
|
+
response = wrapped(*args, **kwargs)
|
63
|
+
end_time = time.time()
|
64
|
+
for key, value in instance.__dict__.items():
|
65
|
+
print(f'{key}: {value}')
|
54
66
|
try:
|
55
67
|
# Calculate cost of the operation
|
56
|
-
cost = get_audio_model_cost(
|
57
|
-
pricing_info, kwargs.get(
|
68
|
+
cost = get_audio_model_cost(request_model,
|
69
|
+
pricing_info, kwargs.get('text', ''))
|
58
70
|
|
59
71
|
# Set Span attributes
|
60
|
-
span.set_attribute(TELEMETRY_SDK_NAME,
|
72
|
+
span.set_attribute(TELEMETRY_SDK_NAME, 'openlit')
|
73
|
+
span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
|
74
|
+
SemanticConvetion.GEN_AI_OPERATION_TYPE_AUDIO)
|
61
75
|
span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
|
62
|
-
SemanticConvetion.
|
63
|
-
span.set_attribute(SemanticConvetion.
|
64
|
-
|
65
|
-
span.set_attribute(SemanticConvetion.
|
66
|
-
|
67
|
-
span.set_attribute(SemanticConvetion.
|
68
|
-
|
69
|
-
span.set_attribute(SemanticConvetion.
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
76
|
+
SemanticConvetion.GEN_AI_SYSTEM_ASSEMBLYAI)
|
77
|
+
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
|
78
|
+
request_model)
|
79
|
+
span.set_attribute(SemanticConvetion.SERVER_ADDRESS,
|
80
|
+
server_address)
|
81
|
+
span.set_attribute(SemanticConvetion.SERVER_PORT,
|
82
|
+
server_port)
|
83
|
+
span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_MODEL,
|
84
|
+
request_model)
|
85
|
+
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
|
86
|
+
request_model)
|
87
|
+
span.set_attribute(SemanticConvetion.GEN_AI_OUTPUT_TYPE,
|
88
|
+
'audio')
|
89
|
+
|
90
|
+
# Set Span attributes (Extras)
|
91
|
+
if gen_ai_endpoint == 'elevenlabs.generate':
|
92
|
+
if isinstance(kwargs.get('voice', 'Rachel'), str):
|
75
93
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_AUDIO_VOICE,
|
76
|
-
kwargs.get(
|
94
|
+
kwargs.get('voice', 'Rachel'))
|
77
95
|
else:
|
78
|
-
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
|
79
|
-
kwargs.get("model_id", "eleven_multilingual_v2"))
|
80
96
|
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_AUDIO_VOICE,
|
81
|
-
kwargs.get(
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
97
|
+
kwargs.get('voice_id', ''))
|
98
|
+
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_AUDIO_RESPONSE_FORMAT,
|
99
|
+
kwargs.get('output_format', 'mp3'))
|
100
|
+
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_AUDIO_SETTINGS,
|
101
|
+
str(kwargs.get('voice_settings', '')))
|
102
|
+
span.set_attribute(DEPLOYMENT_ENVIRONMENT,
|
103
|
+
environment)
|
104
|
+
span.set_attribute(SERVICE_NAME,
|
105
|
+
application_name)
|
106
|
+
span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
|
107
|
+
cost)
|
108
|
+
span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
|
109
|
+
version)
|
88
110
|
if trace_content:
|
89
111
|
span.add_event(
|
90
112
|
name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
|
91
113
|
attributes={
|
92
|
-
SemanticConvetion.GEN_AI_CONTENT_PROMPT: str(kwargs.get(
|
114
|
+
SemanticConvetion.GEN_AI_CONTENT_PROMPT: str(kwargs.get('text', '')),
|
93
115
|
},
|
94
116
|
)
|
95
117
|
|
96
118
|
span.set_status(Status(StatusCode.OK))
|
97
119
|
|
98
120
|
if disable_metrics is False:
|
99
|
-
attributes =
|
100
|
-
|
101
|
-
|
102
|
-
SemanticConvetion.
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
metrics[
|
115
|
-
metrics["genai_cost"].record(cost, attributes)
|
121
|
+
attributes = create_metrics_attributes(
|
122
|
+
service_name=application_name,
|
123
|
+
deployment_environment=environment,
|
124
|
+
operation=SemanticConvetion.GEN_AI_OPERATION_TYPE_AUDIO,
|
125
|
+
system=SemanticConvetion.GEN_AI_SYSTEM_ELEVENLABS,
|
126
|
+
request_model=request_model,
|
127
|
+
server_address=server_address,
|
128
|
+
server_port=server_port,
|
129
|
+
response_model=request_model,
|
130
|
+
)
|
131
|
+
|
132
|
+
metrics['genai_client_operation_duration'].record(
|
133
|
+
end_time - start_time, attributes
|
134
|
+
)
|
135
|
+
metrics['genai_requests'].add(1, attributes)
|
136
|
+
metrics['genai_cost'].record(cost, attributes)
|
116
137
|
|
117
138
|
# Return original response
|
118
139
|
return response
|
119
140
|
|
120
141
|
except Exception as e:
|
121
142
|
handle_exception(span, e)
|
122
|
-
logger.error(
|
143
|
+
logger.error('Error in trace creation: %s', e)
|
123
144
|
|
124
145
|
# Return original response
|
125
146
|
return response
|
@@ -65,8 +65,8 @@ def evaluate(gen_ai_endpoint, version, environment, application_name,
|
|
65
65
|
gen_ai_endpoint)
|
66
66
|
span.set_attribute(SemanticConvetion.GEN_AI_ENVIRONMENT,
|
67
67
|
environment)
|
68
|
-
span.set_attribute(SemanticConvetion.
|
69
|
-
SemanticConvetion.
|
68
|
+
span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
|
69
|
+
SemanticConvetion.GEN_AI_OPERATION_TYPE_FRAMEWORK)
|
70
70
|
span.set_attribute(SemanticConvetion.GEN_AI_APPLICATION_NAME,
|
71
71
|
application_name)
|
72
72
|
span.set_attribute(SemanticConvetion.GEN_AI_EVAL_CONTEXT_RELEVANCY,
|
@@ -143,8 +143,8 @@ def get_data_sources(gen_ai_endpoint, version, environment, application_name,
|
|
143
143
|
gen_ai_endpoint)
|
144
144
|
span.set_attribute(SemanticConvetion.GEN_AI_ENVIRONMENT,
|
145
145
|
environment)
|
146
|
-
span.set_attribute(SemanticConvetion.
|
147
|
-
SemanticConvetion.
|
146
|
+
span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
|
147
|
+
SemanticConvetion.GEN_AI_OPERATION_TYPE_FRAMEWORK)
|
148
148
|
span.set_attribute(SemanticConvetion.GEN_AI_APPLICATION_NAME,
|
149
149
|
application_name)
|
150
150
|
span.set_attribute(SemanticConvetion.GEN_AI_DATA_SOURCES,
|
@@ -58,8 +58,8 @@ def wrap_crawl(gen_ai_endpoint, version, environment, application_name,
|
|
58
58
|
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
|
59
59
|
span.set_attribute(SemanticConvetion.GEN_AI_SYSTEM,
|
60
60
|
SemanticConvetion.GEN_AI_SYSTEM_FIRECRAWL)
|
61
|
-
span.set_attribute(SemanticConvetion.
|
62
|
-
SemanticConvetion.
|
61
|
+
span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
|
62
|
+
SemanticConvetion.GEN_AI_OPERATION_TYPE_AGENT)
|
63
63
|
span.set_attribute(SemanticConvetion.GEN_AI_ENDPOINT,
|
64
64
|
gen_ai_endpoint)
|
65
65
|
span.set_attribute(SemanticConvetion.GEN_AI_APPLICATION_NAME,
|
@@ -14,11 +14,11 @@ from openlit.instrumentation.google_ai_studio.async_google_ai_studio import (
|
|
14
14
|
async_generate
|
15
15
|
)
|
16
16
|
|
17
|
-
_instruments = ("google-
|
17
|
+
_instruments = ("google-genai >= 1.3.0",)
|
18
18
|
|
19
19
|
class GoogleAIStudioInstrumentor(BaseInstrumentor):
|
20
20
|
"""
|
21
|
-
An instrumentor for google-
|
21
|
+
An instrumentor for google-genai's client library.
|
22
22
|
"""
|
23
23
|
|
24
24
|
def instrumentation_dependencies(self) -> Collection[str]:
|
@@ -32,21 +32,21 @@ class GoogleAIStudioInstrumentor(BaseInstrumentor):
|
|
32
32
|
pricing_info = kwargs.get("pricing_info", {})
|
33
33
|
trace_content = kwargs.get("trace_content", False)
|
34
34
|
disable_metrics = kwargs.get("disable_metrics")
|
35
|
-
version = importlib.metadata.version("google-
|
35
|
+
version = importlib.metadata.version("google-genai")
|
36
36
|
|
37
37
|
# sync generate
|
38
38
|
wrap_function_wrapper(
|
39
|
-
"google.
|
40
|
-
"
|
41
|
-
generate(
|
39
|
+
"google.genai.models",
|
40
|
+
"Models.generate_content",
|
41
|
+
generate(version, environment, application_name,
|
42
42
|
tracer, pricing_info, trace_content, metrics, disable_metrics),
|
43
43
|
)
|
44
44
|
|
45
45
|
# async generate
|
46
46
|
wrap_function_wrapper(
|
47
|
-
"google.
|
48
|
-
"
|
49
|
-
async_generate(
|
47
|
+
"google.genai.models",
|
48
|
+
"AsyncModels.generate_content",
|
49
|
+
async_generate(version, environment,
|
50
50
|
application_name, tracer, pricing_info, trace_content, metrics,
|
51
51
|
disable_metrics),
|
52
52
|
)
|