openlit 1.33.9__py3-none-any.whl → 1.33.11__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 +78 -0
- openlit/__init__.py +41 -13
- openlit/instrumentation/ag2/__init__.py +9 -10
- openlit/instrumentation/ag2/ag2.py +134 -69
- openlit/instrumentation/ai21/__init__.py +6 -5
- openlit/instrumentation/ai21/ai21.py +71 -534
- openlit/instrumentation/ai21/async_ai21.py +71 -534
- openlit/instrumentation/ai21/utils.py +407 -0
- openlit/instrumentation/anthropic/__init__.py +3 -3
- openlit/instrumentation/anthropic/anthropic.py +5 -5
- openlit/instrumentation/anthropic/async_anthropic.py +5 -5
- openlit/instrumentation/assemblyai/__init__.py +2 -2
- openlit/instrumentation/assemblyai/assemblyai.py +3 -3
- openlit/instrumentation/astra/__init__.py +25 -25
- openlit/instrumentation/astra/astra.py +7 -7
- openlit/instrumentation/astra/async_astra.py +7 -7
- openlit/instrumentation/azure_ai_inference/__init__.py +5 -5
- openlit/instrumentation/azure_ai_inference/async_azure_ai_inference.py +11 -11
- openlit/instrumentation/azure_ai_inference/azure_ai_inference.py +11 -11
- openlit/instrumentation/bedrock/__init__.py +2 -2
- openlit/instrumentation/bedrock/bedrock.py +3 -3
- openlit/instrumentation/chroma/__init__.py +9 -9
- openlit/instrumentation/chroma/chroma.py +7 -7
- openlit/instrumentation/cohere/__init__.py +7 -7
- openlit/instrumentation/cohere/async_cohere.py +10 -10
- openlit/instrumentation/cohere/cohere.py +11 -11
- openlit/instrumentation/controlflow/__init__.py +4 -4
- openlit/instrumentation/controlflow/controlflow.py +5 -5
- openlit/instrumentation/crawl4ai/__init__.py +3 -3
- openlit/instrumentation/crawl4ai/async_crawl4ai.py +5 -5
- openlit/instrumentation/crawl4ai/crawl4ai.py +5 -5
- openlit/instrumentation/crewai/__init__.py +3 -3
- openlit/instrumentation/crewai/crewai.py +6 -4
- openlit/instrumentation/dynamiq/__init__.py +5 -5
- openlit/instrumentation/dynamiq/dynamiq.py +5 -5
- openlit/instrumentation/elevenlabs/__init__.py +5 -5
- openlit/instrumentation/elevenlabs/async_elevenlabs.py +4 -5
- openlit/instrumentation/elevenlabs/elevenlabs.py +4 -5
- openlit/instrumentation/embedchain/__init__.py +2 -2
- openlit/instrumentation/embedchain/embedchain.py +9 -9
- openlit/instrumentation/firecrawl/__init__.py +3 -3
- openlit/instrumentation/firecrawl/firecrawl.py +5 -5
- openlit/instrumentation/google_ai_studio/__init__.py +3 -3
- openlit/instrumentation/google_ai_studio/async_google_ai_studio.py +3 -3
- openlit/instrumentation/google_ai_studio/google_ai_studio.py +3 -3
- openlit/instrumentation/gpt4all/__init__.py +5 -5
- openlit/instrumentation/gpt4all/gpt4all.py +350 -225
- openlit/instrumentation/gpu/__init__.py +5 -5
- openlit/instrumentation/groq/__init__.py +5 -5
- openlit/instrumentation/groq/async_groq.py +359 -243
- openlit/instrumentation/groq/groq.py +359 -243
- openlit/instrumentation/haystack/__init__.py +2 -2
- openlit/instrumentation/haystack/haystack.py +5 -5
- openlit/instrumentation/julep/__init__.py +7 -7
- openlit/instrumentation/julep/async_julep.py +6 -6
- openlit/instrumentation/julep/julep.py +6 -6
- openlit/instrumentation/langchain/__init__.py +15 -9
- openlit/instrumentation/langchain/async_langchain.py +388 -0
- openlit/instrumentation/langchain/langchain.py +110 -497
- openlit/instrumentation/letta/__init__.py +7 -7
- openlit/instrumentation/letta/letta.py +10 -8
- openlit/instrumentation/litellm/__init__.py +9 -10
- openlit/instrumentation/litellm/async_litellm.py +321 -250
- openlit/instrumentation/litellm/litellm.py +319 -248
- openlit/instrumentation/llamaindex/__init__.py +2 -2
- openlit/instrumentation/llamaindex/llamaindex.py +5 -5
- openlit/instrumentation/mem0/__init__.py +2 -2
- openlit/instrumentation/mem0/mem0.py +5 -5
- openlit/instrumentation/milvus/__init__.py +2 -2
- openlit/instrumentation/milvus/milvus.py +7 -7
- openlit/instrumentation/mistral/__init__.py +13 -13
- openlit/instrumentation/mistral/async_mistral.py +426 -253
- openlit/instrumentation/mistral/mistral.py +424 -250
- openlit/instrumentation/multion/__init__.py +7 -7
- openlit/instrumentation/multion/async_multion.py +9 -7
- openlit/instrumentation/multion/multion.py +9 -7
- openlit/instrumentation/ollama/__init__.py +19 -39
- openlit/instrumentation/ollama/async_ollama.py +137 -563
- openlit/instrumentation/ollama/ollama.py +136 -563
- openlit/instrumentation/ollama/utils.py +333 -0
- openlit/instrumentation/openai/__init__.py +11 -11
- openlit/instrumentation/openai/async_openai.py +25 -27
- openlit/instrumentation/openai/openai.py +25 -27
- openlit/instrumentation/phidata/__init__.py +2 -2
- openlit/instrumentation/phidata/phidata.py +6 -4
- openlit/instrumentation/pinecone/__init__.py +6 -6
- openlit/instrumentation/pinecone/pinecone.py +7 -7
- openlit/instrumentation/premai/__init__.py +5 -5
- openlit/instrumentation/premai/premai.py +268 -219
- openlit/instrumentation/qdrant/__init__.py +2 -2
- openlit/instrumentation/qdrant/async_qdrant.py +7 -7
- openlit/instrumentation/qdrant/qdrant.py +7 -7
- openlit/instrumentation/reka/__init__.py +5 -5
- openlit/instrumentation/reka/async_reka.py +93 -55
- openlit/instrumentation/reka/reka.py +93 -55
- openlit/instrumentation/together/__init__.py +9 -9
- openlit/instrumentation/together/async_together.py +284 -242
- openlit/instrumentation/together/together.py +284 -242
- openlit/instrumentation/transformers/__init__.py +3 -3
- openlit/instrumentation/transformers/transformers.py +79 -48
- openlit/instrumentation/vertexai/__init__.py +19 -69
- openlit/instrumentation/vertexai/async_vertexai.py +333 -990
- openlit/instrumentation/vertexai/vertexai.py +333 -990
- openlit/instrumentation/vllm/__init__.py +3 -3
- openlit/instrumentation/vllm/vllm.py +65 -35
- openlit/otel/events.py +85 -0
- openlit/otel/tracing.py +3 -13
- openlit/semcov/__init__.py +16 -4
- {openlit-1.33.9.dist-info → openlit-1.33.11.dist-info}/METADATA +2 -2
- openlit-1.33.11.dist-info/RECORD +125 -0
- openlit-1.33.9.dist-info/RECORD +0 -121
- {openlit-1.33.9.dist-info → openlit-1.33.11.dist-info}/LICENSE +0 -0
- {openlit-1.33.9.dist-info → openlit-1.33.11.dist-info}/WHEEL +0 -0
@@ -29,7 +29,7 @@ class ElevenLabsInstrumentor(BaseInstrumentor):
|
|
29
29
|
tracer = kwargs.get("tracer")
|
30
30
|
metrics = kwargs.get("metrics_dict")
|
31
31
|
pricing_info = kwargs.get("pricing_info", {})
|
32
|
-
|
32
|
+
capture_message_content = kwargs.get("capture_message_content", False)
|
33
33
|
disable_metrics = kwargs.get("disable_metrics")
|
34
34
|
version = importlib.metadata.version("elevenlabs")
|
35
35
|
|
@@ -38,7 +38,7 @@ class ElevenLabsInstrumentor(BaseInstrumentor):
|
|
38
38
|
"elevenlabs.client",
|
39
39
|
"ElevenLabs.generate",
|
40
40
|
generate("elevenlabs.generate", version, environment, application_name,
|
41
|
-
tracer, pricing_info,
|
41
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
42
42
|
)
|
43
43
|
|
44
44
|
# sync text_to_speech.convert
|
@@ -46,7 +46,7 @@ class ElevenLabsInstrumentor(BaseInstrumentor):
|
|
46
46
|
"elevenlabs.text_to_speech.client",
|
47
47
|
"TextToSpeechClient.convert",
|
48
48
|
generate("elevenlabs.text_to_speech", version, environment, application_name,
|
49
|
-
tracer, pricing_info,
|
49
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
50
50
|
)
|
51
51
|
|
52
52
|
# async generate
|
@@ -54,7 +54,7 @@ class ElevenLabsInstrumentor(BaseInstrumentor):
|
|
54
54
|
"elevenlabs.client",
|
55
55
|
"AsyncElevenLabs.generate",
|
56
56
|
async_generate("elevenlabs.generate", version, environment, application_name,
|
57
|
-
tracer, pricing_info,
|
57
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
58
58
|
)
|
59
59
|
|
60
60
|
# sync text_to_speech.convert
|
@@ -62,7 +62,7 @@ class ElevenLabsInstrumentor(BaseInstrumentor):
|
|
62
62
|
"elevenlabs.text_to_speech.client",
|
63
63
|
"AsyncTextToSpeechClient.convert",
|
64
64
|
generate("elevenlabs.text_to_speech", version, environment, application_name,
|
65
|
-
tracer, pricing_info,
|
65
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
66
66
|
)
|
67
67
|
|
68
68
|
def _uninstrument(self, **kwargs):
|
@@ -18,7 +18,7 @@ from openlit.semcov import SemanticConvetion
|
|
18
18
|
logger = logging.getLogger(__name__)
|
19
19
|
|
20
20
|
def async_generate(gen_ai_endpoint, version, environment, application_name,
|
21
|
-
tracer, pricing_info,
|
21
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics):
|
22
22
|
"""
|
23
23
|
Generates a telemetry wrapper for creating speech audio to collect metrics.
|
24
24
|
|
@@ -28,7 +28,7 @@ def async_generate(gen_ai_endpoint, version, environment, application_name,
|
|
28
28
|
application_name: Name of the application using the ElevenLabs API.
|
29
29
|
tracer: OpenTelemetry tracer for creating spans.
|
30
30
|
pricing_info: Information used for calculating the cost of generating speech audio.
|
31
|
-
|
31
|
+
capture_message_content: Flag indicating whether to trace the input text and generated audio.
|
32
32
|
|
33
33
|
Returns:
|
34
34
|
A function that wraps the speech audio creation method to add telemetry.
|
@@ -60,8 +60,7 @@ def async_generate(gen_ai_endpoint, version, environment, application_name,
|
|
60
60
|
start_time = time.time()
|
61
61
|
response = await wrapped(*args, **kwargs)
|
62
62
|
end_time = time.time()
|
63
|
-
|
64
|
-
print(f'{key}: {value}')
|
63
|
+
|
65
64
|
try:
|
66
65
|
# Calculate cost of the operation
|
67
66
|
cost = get_audio_model_cost(request_model,
|
@@ -106,7 +105,7 @@ def async_generate(gen_ai_endpoint, version, environment, application_name,
|
|
106
105
|
cost)
|
107
106
|
span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
|
108
107
|
version)
|
109
|
-
if
|
108
|
+
if capture_message_content:
|
110
109
|
span.add_event(
|
111
110
|
name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
|
112
111
|
attributes={
|
@@ -18,7 +18,7 @@ from openlit.semcov import SemanticConvetion
|
|
18
18
|
logger = logging.getLogger(__name__)
|
19
19
|
|
20
20
|
def generate(gen_ai_endpoint, version, environment, application_name,
|
21
|
-
tracer, pricing_info,
|
21
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics):
|
22
22
|
"""
|
23
23
|
Generates a telemetry wrapper for creating speech audio to collect metrics.
|
24
24
|
|
@@ -28,7 +28,7 @@ def generate(gen_ai_endpoint, version, environment, application_name,
|
|
28
28
|
application_name: Name of the application using the ElevenLabs API.
|
29
29
|
tracer: OpenTelemetry tracer for creating spans.
|
30
30
|
pricing_info: Information used for calculating the cost of generating speech audio.
|
31
|
-
|
31
|
+
capture_message_content: Flag indicating whether to trace the input text and generated audio.
|
32
32
|
|
33
33
|
Returns:
|
34
34
|
A function that wraps the speech audio creation method to add telemetry.
|
@@ -61,8 +61,7 @@ def generate(gen_ai_endpoint, version, environment, application_name,
|
|
61
61
|
start_time = time.time()
|
62
62
|
response = wrapped(*args, **kwargs)
|
63
63
|
end_time = time.time()
|
64
|
-
|
65
|
-
print(f'{key}: {value}')
|
64
|
+
|
66
65
|
try:
|
67
66
|
# Calculate cost of the operation
|
68
67
|
cost = get_audio_model_cost(request_model,
|
@@ -107,7 +106,7 @@ def generate(gen_ai_endpoint, version, environment, application_name,
|
|
107
106
|
cost)
|
108
107
|
span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
|
109
108
|
version)
|
110
|
-
if
|
109
|
+
if capture_message_content:
|
111
110
|
span.add_event(
|
112
111
|
name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
|
113
112
|
attributes={
|
@@ -35,7 +35,7 @@ class EmbedChainInstrumentor(BaseInstrumentor):
|
|
35
35
|
environment = kwargs.get("environment")
|
36
36
|
tracer = kwargs.get("tracer")
|
37
37
|
pricing_info = kwargs.get("pricing_info")
|
38
|
-
|
38
|
+
capture_message_content = kwargs.get("capture_message_content")
|
39
39
|
version = importlib.metadata.version("embedchain")
|
40
40
|
|
41
41
|
for wrapped_method in WRAPPED_METHODS:
|
@@ -47,7 +47,7 @@ class EmbedChainInstrumentor(BaseInstrumentor):
|
|
47
47
|
wrap_package,
|
48
48
|
wrap_object,
|
49
49
|
wrapper(gen_ai_endpoint, version, environment, application_name,
|
50
|
-
tracer, pricing_info,
|
50
|
+
tracer, pricing_info, capture_message_content),
|
51
51
|
)
|
52
52
|
|
53
53
|
@staticmethod
|
@@ -5,7 +5,7 @@ Module for monitoring EmbedChain applications.
|
|
5
5
|
|
6
6
|
import logging
|
7
7
|
from opentelemetry.trace import SpanKind, Status, StatusCode
|
8
|
-
from opentelemetry.sdk.resources import TELEMETRY_SDK_NAME
|
8
|
+
from opentelemetry.sdk.resources import SERVICE_NAME, TELEMETRY_SDK_NAME, DEPLOYMENT_ENVIRONMENT
|
9
9
|
from openlit.__helpers import handle_exception
|
10
10
|
from openlit.semcov import SemanticConvetion
|
11
11
|
|
@@ -13,7 +13,7 @@ from openlit.semcov import SemanticConvetion
|
|
13
13
|
logger = logging.getLogger(__name__)
|
14
14
|
|
15
15
|
def evaluate(gen_ai_endpoint, version, environment, application_name,
|
16
|
-
tracer, pricing_info,
|
16
|
+
tracer, pricing_info, capture_message_content):
|
17
17
|
"""
|
18
18
|
Creates a wrapper around a function call to trace and log its execution metrics.
|
19
19
|
|
@@ -27,7 +27,7 @@ def evaluate(gen_ai_endpoint, version, environment, application_name,
|
|
27
27
|
- application_name (str): Name of the EmbedChain application.
|
28
28
|
- tracer (opentelemetry.trace.Tracer): The tracer object used for OpenTelemetry tracing.
|
29
29
|
- pricing_info (dict): Information about the pricing for internal metrics (currently not used).
|
30
|
-
-
|
30
|
+
- capture_message_content (bool): Flag indicating whether to trace the content of the response.
|
31
31
|
|
32
32
|
Returns:
|
33
33
|
- function: A higher-order function that takes a function 'wrapped' and returns
|
@@ -63,11 +63,11 @@ def evaluate(gen_ai_endpoint, version, environment, application_name,
|
|
63
63
|
SemanticConvetion.GEN_AI_SYSTEM_EMBEDCHAIN)
|
64
64
|
span.set_attribute(SemanticConvetion.GEN_AI_ENDPOINT,
|
65
65
|
gen_ai_endpoint)
|
66
|
-
span.set_attribute(
|
66
|
+
span.set_attribute(DEPLOYMENT_ENVIRONMENT,
|
67
67
|
environment)
|
68
68
|
span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
|
69
69
|
SemanticConvetion.GEN_AI_OPERATION_TYPE_FRAMEWORK)
|
70
|
-
span.set_attribute(
|
70
|
+
span.set_attribute(SERVICE_NAME,
|
71
71
|
application_name)
|
72
72
|
span.set_attribute(SemanticConvetion.GEN_AI_EVAL_CONTEXT_RELEVANCY,
|
73
73
|
response["context_relevancy"])
|
@@ -91,7 +91,7 @@ def evaluate(gen_ai_endpoint, version, environment, application_name,
|
|
91
91
|
return wrapper
|
92
92
|
|
93
93
|
def get_data_sources(gen_ai_endpoint, version, environment, application_name,
|
94
|
-
tracer, pricing_info,
|
94
|
+
tracer, pricing_info, capture_message_content):
|
95
95
|
"""
|
96
96
|
Creates a wrapper around a function call to trace and log its execution metrics.
|
97
97
|
|
@@ -105,7 +105,7 @@ def get_data_sources(gen_ai_endpoint, version, environment, application_name,
|
|
105
105
|
- application_name (str): Name of the EmbedChain application.
|
106
106
|
- tracer (opentelemetry.trace.Tracer): The tracer object used for OpenTelemetry tracing.
|
107
107
|
- pricing_info (dict): Information about the pricing for internal metrics (currently not used).
|
108
|
-
-
|
108
|
+
- capture_message_content (bool): Flag indicating whether to trace the content of the response.
|
109
109
|
|
110
110
|
Returns:
|
111
111
|
- function: A higher-order function that takes a function 'wrapped' and returns
|
@@ -141,11 +141,11 @@ def get_data_sources(gen_ai_endpoint, version, environment, application_name,
|
|
141
141
|
SemanticConvetion.GEN_AI_SYSTEM_EMBEDCHAIN)
|
142
142
|
span.set_attribute(SemanticConvetion.GEN_AI_ENDPOINT,
|
143
143
|
gen_ai_endpoint)
|
144
|
-
span.set_attribute(
|
144
|
+
span.set_attribute(DEPLOYMENT_ENVIRONMENT,
|
145
145
|
environment)
|
146
146
|
span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
|
147
147
|
SemanticConvetion.GEN_AI_OPERATION_TYPE_FRAMEWORK)
|
148
|
-
span.set_attribute(
|
148
|
+
span.set_attribute(SERVICE_NAME,
|
149
149
|
application_name)
|
150
150
|
span.set_attribute(SemanticConvetion.GEN_AI_DATA_SOURCES,
|
151
151
|
len(response))
|
@@ -26,7 +26,7 @@ class FireCrawlInstrumentor(BaseInstrumentor):
|
|
26
26
|
tracer = kwargs.get("tracer")
|
27
27
|
metrics = kwargs.get("metrics_dict")
|
28
28
|
pricing_info = kwargs.get("pricing_info", {})
|
29
|
-
|
29
|
+
capture_message_content = kwargs.get("capture_message_content", False)
|
30
30
|
disable_metrics = kwargs.get("disable_metrics")
|
31
31
|
version = importlib.metadata.version("firecrawl-py")
|
32
32
|
|
@@ -34,14 +34,14 @@ class FireCrawlInstrumentor(BaseInstrumentor):
|
|
34
34
|
"firecrawl.firecrawl",
|
35
35
|
"FirecrawlApp.scrape_url",
|
36
36
|
wrap_crawl("firecrawl.scrape_url", version, environment, application_name,
|
37
|
-
tracer, pricing_info,
|
37
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
38
38
|
)
|
39
39
|
|
40
40
|
wrap_function_wrapper(
|
41
41
|
"firecrawl.firecrawl",
|
42
42
|
"FirecrawlApp.crawl_url",
|
43
43
|
wrap_crawl("firecrawl.crawl_url", version, environment, application_name,
|
44
|
-
tracer, pricing_info,
|
44
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
45
45
|
)
|
46
46
|
|
47
47
|
def _uninstrument(self, **kwargs):
|
@@ -5,7 +5,7 @@ Module for monitoring FireCrawl calls.
|
|
5
5
|
|
6
6
|
import logging
|
7
7
|
from opentelemetry.trace import SpanKind, Status, StatusCode
|
8
|
-
from opentelemetry.sdk.resources import TELEMETRY_SDK_NAME
|
8
|
+
from opentelemetry.sdk.resources import SERVICE_NAME, TELEMETRY_SDK_NAME, DEPLOYMENT_ENVIRONMENT
|
9
9
|
from openlit.__helpers import (
|
10
10
|
handle_exception,
|
11
11
|
)
|
@@ -15,7 +15,7 @@ from openlit.semcov import SemanticConvetion
|
|
15
15
|
logger = logging.getLogger(__name__)
|
16
16
|
|
17
17
|
def wrap_crawl(gen_ai_endpoint, version, environment, application_name,
|
18
|
-
tracer, pricing_info,
|
18
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics):
|
19
19
|
"""
|
20
20
|
Generates a telemetry wrapper for chat completions to collect metrics.
|
21
21
|
|
@@ -26,7 +26,7 @@ def wrap_crawl(gen_ai_endpoint, version, environment, application_name,
|
|
26
26
|
application_name: Name of the application using the FireCrawl Agent.
|
27
27
|
tracer: OpenTelemetry tracer for creating spans.
|
28
28
|
pricing_info: Information used for calculating the cost of FireCrawl usage.
|
29
|
-
|
29
|
+
capture_message_content: Flag indicating whether to trace the actual content.
|
30
30
|
|
31
31
|
Returns:
|
32
32
|
A function that wraps the chat completions method to add telemetry.
|
@@ -62,9 +62,9 @@ def wrap_crawl(gen_ai_endpoint, version, environment, application_name,
|
|
62
62
|
SemanticConvetion.GEN_AI_OPERATION_TYPE_AGENT)
|
63
63
|
span.set_attribute(SemanticConvetion.GEN_AI_ENDPOINT,
|
64
64
|
gen_ai_endpoint)
|
65
|
-
span.set_attribute(
|
65
|
+
span.set_attribute(SERVICE_NAME,
|
66
66
|
application_name)
|
67
|
-
span.set_attribute(
|
67
|
+
span.set_attribute(DEPLOYMENT_ENVIRONMENT,
|
68
68
|
environment)
|
69
69
|
span.set_attribute(SemanticConvetion.GEN_AI_AGENT_TYPE,
|
70
70
|
SemanticConvetion.GEN_AI_AGENT_TYPE_BROWSER)
|
@@ -30,7 +30,7 @@ class GoogleAIStudioInstrumentor(BaseInstrumentor):
|
|
30
30
|
tracer = kwargs.get("tracer")
|
31
31
|
metrics = kwargs.get("metrics_dict")
|
32
32
|
pricing_info = kwargs.get("pricing_info", {})
|
33
|
-
|
33
|
+
capture_message_content = kwargs.get("capture_message_content", False)
|
34
34
|
disable_metrics = kwargs.get("disable_metrics")
|
35
35
|
version = importlib.metadata.version("google-genai")
|
36
36
|
|
@@ -39,7 +39,7 @@ class GoogleAIStudioInstrumentor(BaseInstrumentor):
|
|
39
39
|
"google.genai.models",
|
40
40
|
"Models.generate_content",
|
41
41
|
generate(version, environment, application_name,
|
42
|
-
tracer, pricing_info,
|
42
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
43
43
|
)
|
44
44
|
|
45
45
|
# async generate
|
@@ -47,7 +47,7 @@ class GoogleAIStudioInstrumentor(BaseInstrumentor):
|
|
47
47
|
"google.genai.models",
|
48
48
|
"AsyncModels.generate_content",
|
49
49
|
async_generate(version, environment,
|
50
|
-
application_name, tracer, pricing_info,
|
50
|
+
application_name, tracer, pricing_info, capture_message_content, metrics,
|
51
51
|
disable_metrics),
|
52
52
|
)
|
53
53
|
|
@@ -19,7 +19,7 @@ from openlit.semcov import SemanticConvetion
|
|
19
19
|
logger = logging.getLogger(__name__)
|
20
20
|
|
21
21
|
def async_generate(version, environment, application_name,
|
22
|
-
tracer, pricing_info,
|
22
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics):
|
23
23
|
"""
|
24
24
|
Generates a telemetry wrapper for chat to collect metrics.
|
25
25
|
|
@@ -30,7 +30,7 @@ def async_generate(version, environment, application_name,
|
|
30
30
|
application_name: Name of the application using the Google AI Studio API.
|
31
31
|
tracer: OpenTelemetry tracer for creating spans.
|
32
32
|
pricing_info: Information used for calculating the cost of Google AI Studio usage.
|
33
|
-
|
33
|
+
capture_message_content: Flag indicating whether to trace the actual content.
|
34
34
|
|
35
35
|
Returns:
|
36
36
|
A function that wraps the chat method to add telemetry.
|
@@ -165,7 +165,7 @@ def async_generate(version, environment, application_name,
|
|
165
165
|
end_time - start_time)
|
166
166
|
span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
|
167
167
|
version)
|
168
|
-
if
|
168
|
+
if capture_message_content:
|
169
169
|
span.add_event(
|
170
170
|
name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
|
171
171
|
attributes={
|
@@ -19,7 +19,7 @@ from openlit.semcov import SemanticConvetion
|
|
19
19
|
logger = logging.getLogger(__name__)
|
20
20
|
|
21
21
|
def generate(version, environment, application_name,
|
22
|
-
tracer, pricing_info,
|
22
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics):
|
23
23
|
"""
|
24
24
|
Generates a telemetry wrapper for chat to collect metrics.
|
25
25
|
|
@@ -30,7 +30,7 @@ def generate(version, environment, application_name,
|
|
30
30
|
application_name: Name of the application using the Google AI Studio API.
|
31
31
|
tracer: OpenTelemetry tracer for creating spans.
|
32
32
|
pricing_info: Information used for calculating the cost of Google AI Studio usage.
|
33
|
-
|
33
|
+
capture_message_content: Flag indicating whether to trace the actual content.
|
34
34
|
|
35
35
|
Returns:
|
36
36
|
A function that wraps the chat method to add telemetry.
|
@@ -165,7 +165,7 @@ def generate(version, environment, application_name,
|
|
165
165
|
end_time - start_time)
|
166
166
|
span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
|
167
167
|
version)
|
168
|
-
if
|
168
|
+
if capture_message_content:
|
169
169
|
span.add_event(
|
170
170
|
name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
|
171
171
|
attributes={
|
@@ -26,7 +26,7 @@ class GPT4AllInstrumentor(BaseInstrumentor):
|
|
26
26
|
tracer = kwargs.get("tracer")
|
27
27
|
metrics = kwargs.get("metrics_dict")
|
28
28
|
pricing_info = kwargs.get("pricing_info", {})
|
29
|
-
|
29
|
+
capture_message_content = kwargs.get("capture_message_content", False)
|
30
30
|
disable_metrics = kwargs.get("disable_metrics")
|
31
31
|
version = importlib.metadata.version("gpt4all")
|
32
32
|
|
@@ -34,16 +34,16 @@ class GPT4AllInstrumentor(BaseInstrumentor):
|
|
34
34
|
wrap_function_wrapper(
|
35
35
|
"gpt4all",
|
36
36
|
"GPT4All.generate",
|
37
|
-
generate(
|
38
|
-
tracer, pricing_info,
|
37
|
+
generate(version, environment, application_name,
|
38
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
39
39
|
)
|
40
40
|
|
41
41
|
# embed
|
42
42
|
wrap_function_wrapper(
|
43
43
|
"gpt4all",
|
44
44
|
"Embed4All.embed",
|
45
|
-
embed(
|
46
|
-
tracer, pricing_info,
|
45
|
+
embed(version, environment, application_name,
|
46
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
47
47
|
)
|
48
48
|
|
49
49
|
|