openlit 1.33.10__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 +73 -0
- openlit/__init__.py +38 -11
- openlit/instrumentation/ag2/__init__.py +9 -10
- openlit/instrumentation/ag2/ag2.py +133 -68
- 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 +4 -4
- openlit/instrumentation/anthropic/async_anthropic.py +4 -4
- 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 +2 -2
- openlit/instrumentation/astra/async_astra.py +2 -2
- openlit/instrumentation/azure_ai_inference/__init__.py +5 -5
- openlit/instrumentation/azure_ai_inference/async_azure_ai_inference.py +8 -8
- openlit/instrumentation/azure_ai_inference/azure_ai_inference.py +8 -8
- 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 +2 -2
- openlit/instrumentation/cohere/__init__.py +7 -7
- openlit/instrumentation/cohere/async_cohere.py +9 -9
- openlit/instrumentation/cohere/cohere.py +9 -9
- openlit/instrumentation/controlflow/__init__.py +4 -4
- openlit/instrumentation/controlflow/controlflow.py +2 -2
- openlit/instrumentation/crawl4ai/__init__.py +3 -3
- openlit/instrumentation/crawl4ai/async_crawl4ai.py +2 -2
- openlit/instrumentation/crawl4ai/crawl4ai.py +2 -2
- openlit/instrumentation/crewai/__init__.py +3 -3
- openlit/instrumentation/crewai/crewai.py +2 -2
- openlit/instrumentation/dynamiq/__init__.py +5 -5
- openlit/instrumentation/dynamiq/dynamiq.py +2 -2
- openlit/instrumentation/elevenlabs/__init__.py +5 -5
- openlit/instrumentation/elevenlabs/async_elevenlabs.py +3 -3
- openlit/instrumentation/elevenlabs/elevenlabs.py +3 -3
- openlit/instrumentation/embedchain/__init__.py +2 -2
- openlit/instrumentation/embedchain/embedchain.py +4 -4
- openlit/instrumentation/firecrawl/__init__.py +3 -3
- openlit/instrumentation/firecrawl/firecrawl.py +2 -2
- 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 +3 -3
- openlit/instrumentation/gpt4all/gpt4all.py +7 -7
- openlit/instrumentation/groq/__init__.py +3 -3
- openlit/instrumentation/groq/async_groq.py +5 -5
- openlit/instrumentation/groq/groq.py +5 -5
- openlit/instrumentation/haystack/__init__.py +2 -2
- openlit/instrumentation/haystack/haystack.py +2 -2
- openlit/instrumentation/julep/__init__.py +7 -7
- openlit/instrumentation/julep/async_julep.py +3 -3
- openlit/instrumentation/julep/julep.py +3 -3
- openlit/instrumentation/langchain/__init__.py +2 -2
- openlit/instrumentation/langchain/async_langchain.py +13 -9
- openlit/instrumentation/langchain/langchain.py +13 -8
- openlit/instrumentation/letta/__init__.py +7 -7
- openlit/instrumentation/letta/letta.py +5 -5
- openlit/instrumentation/litellm/__init__.py +5 -5
- openlit/instrumentation/litellm/async_litellm.py +8 -8
- openlit/instrumentation/litellm/litellm.py +8 -8
- openlit/instrumentation/llamaindex/__init__.py +2 -2
- openlit/instrumentation/llamaindex/llamaindex.py +2 -2
- openlit/instrumentation/mem0/__init__.py +2 -2
- openlit/instrumentation/mem0/mem0.py +2 -2
- openlit/instrumentation/milvus/__init__.py +2 -2
- openlit/instrumentation/milvus/milvus.py +2 -2
- openlit/instrumentation/mistral/__init__.py +7 -7
- openlit/instrumentation/mistral/async_mistral.py +10 -10
- openlit/instrumentation/mistral/mistral.py +10 -10
- openlit/instrumentation/multion/__init__.py +7 -7
- openlit/instrumentation/multion/async_multion.py +5 -5
- openlit/instrumentation/multion/multion.py +5 -5
- openlit/instrumentation/ollama/__init__.py +11 -9
- openlit/instrumentation/ollama/async_ollama.py +71 -465
- openlit/instrumentation/ollama/ollama.py +71 -465
- openlit/instrumentation/ollama/utils.py +333 -0
- openlit/instrumentation/openai/__init__.py +11 -11
- openlit/instrumentation/openai/async_openai.py +18 -18
- openlit/instrumentation/openai/openai.py +18 -18
- openlit/instrumentation/phidata/__init__.py +2 -2
- openlit/instrumentation/phidata/phidata.py +2 -2
- openlit/instrumentation/pinecone/__init__.py +6 -6
- openlit/instrumentation/pinecone/pinecone.py +2 -2
- openlit/instrumentation/premai/__init__.py +3 -3
- openlit/instrumentation/premai/premai.py +7 -7
- openlit/instrumentation/qdrant/__init__.py +2 -2
- openlit/instrumentation/qdrant/async_qdrant.py +2 -2
- openlit/instrumentation/qdrant/qdrant.py +2 -2
- openlit/instrumentation/reka/__init__.py +3 -3
- openlit/instrumentation/reka/async_reka.py +3 -3
- openlit/instrumentation/reka/reka.py +3 -3
- openlit/instrumentation/together/__init__.py +5 -5
- openlit/instrumentation/together/async_together.py +8 -8
- openlit/instrumentation/together/together.py +8 -8
- openlit/instrumentation/transformers/__init__.py +2 -2
- openlit/instrumentation/transformers/transformers.py +4 -4
- openlit/instrumentation/vertexai/__init__.py +9 -9
- openlit/instrumentation/vertexai/async_vertexai.py +4 -4
- openlit/instrumentation/vertexai/vertexai.py +4 -4
- openlit/instrumentation/vllm/__init__.py +2 -2
- openlit/instrumentation/vllm/vllm.py +3 -3
- openlit/otel/events.py +85 -0
- openlit/otel/tracing.py +3 -13
- openlit/semcov/__init__.py +13 -1
- {openlit-1.33.10.dist-info → openlit-1.33.11.dist-info}/METADATA +2 -2
- openlit-1.33.11.dist-info/RECORD +125 -0
- openlit-1.33.10.dist-info/RECORD +0 -122
- {openlit-1.33.10.dist-info → openlit-1.33.11.dist-info}/LICENSE +0 -0
- {openlit-1.33.10.dist-info → openlit-1.33.11.dist-info}/WHEEL +0 -0
@@ -25,7 +25,7 @@ from openlit.semcov import SemanticConvetion
|
|
25
25
|
logger = logging.getLogger(__name__)
|
26
26
|
|
27
27
|
def chat_completions(version, environment, application_name,
|
28
|
-
tracer, pricing_info,
|
28
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics):
|
29
29
|
"""
|
30
30
|
Generates a telemetry wrapper for chat completions to collect metrics.
|
31
31
|
|
@@ -35,7 +35,7 @@ def chat_completions(version, environment, application_name,
|
|
35
35
|
application_name: Name of the application using the OpenAI API.
|
36
36
|
tracer: OpenTelemetry tracer for creating spans.
|
37
37
|
pricing_info: Information used for calculating the cost of OpenAI usage.
|
38
|
-
|
38
|
+
capture_message_content: Flag indicating whether to trace the actual content.
|
39
39
|
|
40
40
|
Returns:
|
41
41
|
A function that wraps the chat completions method to add telemetry.
|
@@ -229,7 +229,7 @@ def chat_completions(version, environment, application_name,
|
|
229
229
|
self._ttft)
|
230
230
|
self._span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
|
231
231
|
version)
|
232
|
-
if
|
232
|
+
if capture_message_content:
|
233
233
|
self._span.add_event(
|
234
234
|
name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
|
235
235
|
attributes={
|
@@ -387,7 +387,7 @@ def chat_completions(version, environment, application_name,
|
|
387
387
|
span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_SERVICE_TIER,
|
388
388
|
response_dict.get('service_tier'))
|
389
389
|
span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_SYSTEM_FINGERPRINT,
|
390
|
-
response_dict.get('system_fingerprint'))
|
390
|
+
str(response_dict.get('system_fingerprint', '')))
|
391
391
|
|
392
392
|
# Set base span attribues (Extras)
|
393
393
|
span.set_attribute(DEPLOYMENT_ENVIRONMENT,
|
@@ -406,7 +406,7 @@ def chat_completions(version, environment, application_name,
|
|
406
406
|
end_time - start_time)
|
407
407
|
span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
|
408
408
|
version)
|
409
|
-
if
|
409
|
+
if capture_message_content:
|
410
410
|
span.add_event(
|
411
411
|
name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
|
412
412
|
attributes={
|
@@ -417,7 +417,7 @@ def chat_completions(version, environment, application_name,
|
|
417
417
|
for i in range(kwargs.get('n',1)):
|
418
418
|
span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON,
|
419
419
|
[response_dict.get('choices')[i].get('finish_reason')])
|
420
|
-
if
|
420
|
+
if capture_message_content:
|
421
421
|
span.add_event(
|
422
422
|
name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
|
423
423
|
attributes={
|
@@ -477,7 +477,7 @@ def chat_completions(version, environment, application_name,
|
|
477
477
|
return wrapper
|
478
478
|
|
479
479
|
def embedding(version, environment, application_name,
|
480
|
-
tracer, pricing_info,
|
480
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics):
|
481
481
|
"""
|
482
482
|
Generates a telemetry wrapper for embeddings to collect metrics.
|
483
483
|
|
@@ -487,7 +487,7 @@ def embedding(version, environment, application_name,
|
|
487
487
|
application_name: Name of the application using the OpenAI API.
|
488
488
|
tracer: OpenTelemetry tracer for creating spans.
|
489
489
|
pricing_info: Information used for calculating the cost of OpenAI usage.
|
490
|
-
|
490
|
+
capture_message_content: Flag indicating whether to trace the actual content.
|
491
491
|
|
492
492
|
Returns:
|
493
493
|
A function that wraps the embeddings method to add telemetry.
|
@@ -561,7 +561,7 @@ def embedding(version, environment, application_name,
|
|
561
561
|
span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
|
562
562
|
version)
|
563
563
|
|
564
|
-
if
|
564
|
+
if capture_message_content:
|
565
565
|
span.add_event(
|
566
566
|
name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
|
567
567
|
attributes={
|
@@ -605,7 +605,7 @@ def embedding(version, environment, application_name,
|
|
605
605
|
return wrapper
|
606
606
|
|
607
607
|
def image_generate(version, environment, application_name,
|
608
|
-
tracer, pricing_info,
|
608
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics):
|
609
609
|
"""
|
610
610
|
Generates a telemetry wrapper for image generation to collect metrics.
|
611
611
|
|
@@ -615,7 +615,7 @@ def image_generate(version, environment, application_name,
|
|
615
615
|
application_name: Name of the application using the OpenAI API.
|
616
616
|
tracer: OpenTelemetry tracer for creating spans.
|
617
617
|
pricing_info: Information used for calculating the cost of OpenAI image generation.
|
618
|
-
|
618
|
+
capture_message_content: Flag indicating whether to trace the input prompt and generated images.
|
619
619
|
|
620
620
|
Returns:
|
621
621
|
A function that wraps the image generation method to add telemetry.
|
@@ -700,7 +700,7 @@ def image_generate(version, environment, application_name,
|
|
700
700
|
span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
|
701
701
|
version)
|
702
702
|
|
703
|
-
if
|
703
|
+
if capture_message_content:
|
704
704
|
span.add_event(
|
705
705
|
name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
|
706
706
|
attributes={
|
@@ -752,7 +752,7 @@ def image_generate(version, environment, application_name,
|
|
752
752
|
return wrapper
|
753
753
|
|
754
754
|
def image_variatons(version, environment, application_name,
|
755
|
-
tracer, pricing_info,
|
755
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics):
|
756
756
|
"""
|
757
757
|
Generates a telemetry wrapper for creating image variations to collect metrics.
|
758
758
|
|
@@ -762,7 +762,7 @@ def image_variatons(version, environment, application_name,
|
|
762
762
|
application_name: Name of the application using the OpenAI API.
|
763
763
|
tracer: OpenTelemetry tracer for creating spans.
|
764
764
|
pricing_info: Information used for calculating the cost of generating image variations.
|
765
|
-
|
765
|
+
capture_message_content: Flag indicating whether to trace the input image and generated variations.
|
766
766
|
|
767
767
|
Returns:
|
768
768
|
A function that wraps the image variations creation method to add telemetry.
|
@@ -842,7 +842,7 @@ def image_variatons(version, environment, application_name,
|
|
842
842
|
span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
|
843
843
|
version)
|
844
844
|
|
845
|
-
if
|
845
|
+
if capture_message_content:
|
846
846
|
attribute_name = f"{SemanticConvetion.GEN_AI_RESPONSE_IMAGE}.{images_count}"
|
847
847
|
span.add_event(
|
848
848
|
name=attribute_name,
|
@@ -888,7 +888,7 @@ def image_variatons(version, environment, application_name,
|
|
888
888
|
return wrapper
|
889
889
|
|
890
890
|
def audio_create(version, environment, application_name,
|
891
|
-
tracer, pricing_info,
|
891
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics):
|
892
892
|
"""
|
893
893
|
Generates a telemetry wrapper for creating speech audio to collect metrics.
|
894
894
|
|
@@ -898,7 +898,7 @@ def audio_create(version, environment, application_name,
|
|
898
898
|
application_name: Name of the application using the OpenAI API.
|
899
899
|
tracer: OpenTelemetry tracer for creating spans.
|
900
900
|
pricing_info: Information used for calculating the cost of generating speech audio.
|
901
|
-
|
901
|
+
capture_message_content: Flag indicating whether to trace the input text and generated audio.
|
902
902
|
|
903
903
|
Returns:
|
904
904
|
A function that wraps the speech audio creation method to add telemetry.
|
@@ -967,7 +967,7 @@ def audio_create(version, environment, application_name,
|
|
967
967
|
cost)
|
968
968
|
span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
|
969
969
|
version)
|
970
|
-
if
|
970
|
+
if capture_message_content:
|
971
971
|
span.add_event(
|
972
972
|
name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
|
973
973
|
attributes={
|
@@ -26,7 +26,7 @@ class PhidataInstrumentor(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("phidata")
|
32
32
|
|
@@ -34,7 +34,7 @@ class PhidataInstrumentor(BaseInstrumentor):
|
|
34
34
|
"phi.agent",
|
35
35
|
"Agent.print_response",
|
36
36
|
phidata_wrap("phidata.print_response", version, environment, application_name,
|
37
|
-
tracer, pricing_info,
|
37
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
38
38
|
)
|
39
39
|
|
40
40
|
def _uninstrument(self, **kwargs):
|
@@ -15,7 +15,7 @@ from openlit.semcov import SemanticConvetion
|
|
15
15
|
logger = logging.getLogger(__name__)
|
16
16
|
|
17
17
|
def phidata_wrap(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 phidata_wrap(gen_ai_endpoint, version, environment, application_name,
|
|
26
26
|
application_name: Name of the application using the Phidata Agent.
|
27
27
|
tracer: OpenTelemetry tracer for creating spans.
|
28
28
|
pricing_info: Information used for calculating the cost of Phidata 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.
|
@@ -21,7 +21,7 @@ class PineconeInstrumentor(BaseInstrumentor):
|
|
21
21
|
tracer = kwargs.get("tracer")
|
22
22
|
metrics = kwargs.get("metrics_dict")
|
23
23
|
pricing_info = kwargs.get("pricing_info")
|
24
|
-
|
24
|
+
capture_message_content = kwargs.get("capture_message_content")
|
25
25
|
disable_metrics = kwargs.get("disable_metrics")
|
26
26
|
version = importlib.metadata.version("pinecone-client")
|
27
27
|
|
@@ -29,35 +29,35 @@ class PineconeInstrumentor(BaseInstrumentor):
|
|
29
29
|
"pinecone.control.pinecone",
|
30
30
|
"Pinecone.create_index",
|
31
31
|
general_wrap("pinecone.create_index", version, environment, application_name,
|
32
|
-
tracer, pricing_info,
|
32
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
33
33
|
)
|
34
34
|
|
35
35
|
wrap_function_wrapper(
|
36
36
|
"pinecone.data.index",
|
37
37
|
"Index.upsert",
|
38
38
|
general_wrap("pinecone.upsert", version, environment, application_name,
|
39
|
-
tracer, pricing_info,
|
39
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
40
40
|
)
|
41
41
|
|
42
42
|
wrap_function_wrapper(
|
43
43
|
"pinecone.data.index",
|
44
44
|
"Index.query",
|
45
45
|
general_wrap("pinecone.query", version, environment, application_name,
|
46
|
-
tracer, pricing_info,
|
46
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
47
47
|
)
|
48
48
|
|
49
49
|
wrap_function_wrapper(
|
50
50
|
"pinecone.data.index",
|
51
51
|
"Index.update",
|
52
52
|
general_wrap("pinecone.update", version, environment, application_name,
|
53
|
-
tracer, pricing_info,
|
53
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
54
54
|
)
|
55
55
|
|
56
56
|
wrap_function_wrapper(
|
57
57
|
"pinecone.data.index",
|
58
58
|
"Index.delete",
|
59
59
|
general_wrap("pinecone.delete", version, environment, application_name,
|
60
|
-
tracer, pricing_info,
|
60
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
61
61
|
)
|
62
62
|
|
63
63
|
|
@@ -23,7 +23,7 @@ def object_count(obj):
|
|
23
23
|
return None
|
24
24
|
|
25
25
|
def general_wrap(gen_ai_endpoint, version, environment, application_name,
|
26
|
-
tracer, pricing_info,
|
26
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics):
|
27
27
|
"""
|
28
28
|
Wraps a Pinecone operation to trace and log its execution metrics.
|
29
29
|
|
@@ -40,7 +40,7 @@ def general_wrap(gen_ai_endpoint, version, environment, application_name,
|
|
40
40
|
- application_name (str): The name of the application performing the Pinecone operation.
|
41
41
|
- tracer (opentelemetry.trace.Tracer): An object used for OpenTelemetry tracing.
|
42
42
|
- pricing_info (dict): Information about pricing, not used in current implementation.
|
43
|
-
-
|
43
|
+
- capture_message_content (bool): A flag indicating whether the content of responses should be traced.
|
44
44
|
|
45
45
|
Returns:
|
46
46
|
- function: A decorator function that, when applied, wraps the target function with
|
@@ -26,7 +26,7 @@ class PremAIInstrumentor(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("premai")
|
32
32
|
|
@@ -35,7 +35,7 @@ class PremAIInstrumentor(BaseInstrumentor):
|
|
35
35
|
"premai.api",
|
36
36
|
"ChatCompletionsModule.create",
|
37
37
|
chat(version, environment, application_name,
|
38
|
-
tracer, pricing_info,
|
38
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
39
39
|
)
|
40
40
|
|
41
41
|
# sync embedding
|
@@ -43,7 +43,7 @@ class PremAIInstrumentor(BaseInstrumentor):
|
|
43
43
|
"premai.api",
|
44
44
|
"EmbeddingsModule.create",
|
45
45
|
embedding(version, environment, application_name,
|
46
|
-
tracer, pricing_info,
|
46
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
47
47
|
)
|
48
48
|
|
49
49
|
def _uninstrument(self, **kwargs):
|
@@ -22,7 +22,7 @@ from openlit.semcov import SemanticConvetion
|
|
22
22
|
logger = logging.getLogger(__name__)
|
23
23
|
|
24
24
|
def chat(version, environment, application_name,
|
25
|
-
tracer, pricing_info,
|
25
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics):
|
26
26
|
"""
|
27
27
|
Generates a telemetry wrapper for chat completions to collect metrics.
|
28
28
|
|
@@ -32,7 +32,7 @@ def chat(version, environment, application_name,
|
|
32
32
|
application_name: Name of the application using the PremAI API.
|
33
33
|
tracer: OpenTelemetry tracer for creating spans.
|
34
34
|
pricing_info: Information used for calculating the cost of PremAI usage.
|
35
|
-
|
35
|
+
capture_message_content: Flag indicating whether to trace the actual content.
|
36
36
|
|
37
37
|
Returns:
|
38
38
|
A function that wraps the chat completions method to add telemetry.
|
@@ -199,7 +199,7 @@ def chat(version, environment, application_name,
|
|
199
199
|
self._ttft)
|
200
200
|
self._span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
|
201
201
|
version)
|
202
|
-
if
|
202
|
+
if capture_message_content:
|
203
203
|
self._span.add_event(
|
204
204
|
name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
|
205
205
|
attributes={
|
@@ -363,7 +363,7 @@ def chat(version, environment, application_name,
|
|
363
363
|
end_time - start_time)
|
364
364
|
span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
|
365
365
|
version)
|
366
|
-
if
|
366
|
+
if capture_message_content:
|
367
367
|
span.add_event(
|
368
368
|
name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
|
369
369
|
attributes={
|
@@ -429,7 +429,7 @@ def chat(version, environment, application_name,
|
|
429
429
|
return wrapper
|
430
430
|
|
431
431
|
def embedding(version, environment, application_name,
|
432
|
-
tracer, pricing_info,
|
432
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics):
|
433
433
|
"""
|
434
434
|
Generates a telemetry wrapper for embeddings to collect metrics.
|
435
435
|
|
@@ -439,7 +439,7 @@ def embedding(version, environment, application_name,
|
|
439
439
|
application_name: Name of the application using the PremAI API.
|
440
440
|
tracer: OpenTelemetry tracer for creating spans.
|
441
441
|
pricing_info: Information used for calculating the cost of PremAI usage.
|
442
|
-
|
442
|
+
capture_message_content: Flag indicating whether to trace the actual content.
|
443
443
|
|
444
444
|
Returns:
|
445
445
|
A function that wraps the embeddings method to add telemetry.
|
@@ -512,7 +512,7 @@ def embedding(version, environment, application_name,
|
|
512
512
|
span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
|
513
513
|
version)
|
514
514
|
|
515
|
-
if
|
515
|
+
if capture_message_content:
|
516
516
|
span.add_event(
|
517
517
|
name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
|
518
518
|
attributes={
|
@@ -273,7 +273,7 @@ class QdrantInstrumentor(BaseInstrumentor):
|
|
273
273
|
tracer = kwargs.get("tracer")
|
274
274
|
metrics = kwargs.get("metrics_dict")
|
275
275
|
pricing_info = kwargs.get("pricing_info")
|
276
|
-
|
276
|
+
capture_message_content = kwargs.get("capture_message_content")
|
277
277
|
disable_metrics = kwargs.get("disable_metrics")
|
278
278
|
version = importlib.metadata.version("qdrant-client")
|
279
279
|
|
@@ -286,7 +286,7 @@ class QdrantInstrumentor(BaseInstrumentor):
|
|
286
286
|
wrap_package,
|
287
287
|
wrap_object,
|
288
288
|
wrapper(gen_ai_endpoint, version, environment, application_name,
|
289
|
-
tracer, pricing_info,
|
289
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
290
290
|
)
|
291
291
|
|
292
292
|
|
@@ -25,7 +25,7 @@ def object_count(obj):
|
|
25
25
|
return cnt
|
26
26
|
|
27
27
|
def async_general_wrap(gen_ai_endpoint, version, environment, application_name,
|
28
|
-
tracer, pricing_info,
|
28
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics):
|
29
29
|
"""
|
30
30
|
Creates a wrapper around a function call to trace and log its execution metrics.
|
31
31
|
|
@@ -39,7 +39,7 @@ def async_general_wrap(gen_ai_endpoint, version, environment, application_name,
|
|
39
39
|
- application_name (str): Name of the Langchain application.
|
40
40
|
- tracer (opentelemetry.trace.Tracer): The tracer object used for OpenTelemetry tracing.
|
41
41
|
- pricing_info (dict): Information about the pricing for internal metrics (currently not used).
|
42
|
-
-
|
42
|
+
- capture_message_content (bool): Flag indicating whether to trace the content of the response.
|
43
43
|
|
44
44
|
Returns:
|
45
45
|
- function: A higher-order function that takes a function 'wrapped' and returns
|
@@ -25,7 +25,7 @@ def object_count(obj):
|
|
25
25
|
return cnt
|
26
26
|
|
27
27
|
def general_wrap(gen_ai_endpoint, version, environment, application_name,
|
28
|
-
tracer, pricing_info,
|
28
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics):
|
29
29
|
"""
|
30
30
|
Creates a wrapper around a function call to trace and log its execution metrics.
|
31
31
|
|
@@ -39,7 +39,7 @@ def general_wrap(gen_ai_endpoint, version, environment, application_name,
|
|
39
39
|
- application_name (str): Name of the Langchain application.
|
40
40
|
- tracer (opentelemetry.trace.Tracer): The tracer object used for OpenTelemetry tracing.
|
41
41
|
- pricing_info (dict): Information about the pricing for internal metrics (currently not used).
|
42
|
-
-
|
42
|
+
- capture_message_content (bool): Flag indicating whether to trace the content of the response.
|
43
43
|
|
44
44
|
Returns:
|
45
45
|
- function: A higher-order function that takes a function 'wrapped' and returns
|
@@ -29,7 +29,7 @@ class RekaInstrumentor(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("reka-api")
|
35
35
|
|
@@ -38,7 +38,7 @@ class RekaInstrumentor(BaseInstrumentor):
|
|
38
38
|
"reka.chat.client",
|
39
39
|
"ChatClient.create",
|
40
40
|
chat(version, environment, application_name,
|
41
|
-
tracer, pricing_info,
|
41
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
42
42
|
)
|
43
43
|
|
44
44
|
# async chat
|
@@ -46,7 +46,7 @@ class RekaInstrumentor(BaseInstrumentor):
|
|
46
46
|
"reka.chat.client",
|
47
47
|
"AsyncChatClient.create",
|
48
48
|
async_chat(version, environment, application_name,
|
49
|
-
tracer, pricing_info,
|
49
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
50
50
|
)
|
51
51
|
|
52
52
|
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_chat(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 chat to collect metrics.
|
24
24
|
|
@@ -28,7 +28,7 @@ def async_chat(version, environment, application_name,
|
|
28
28
|
application_name: Name of the application using the Reka API.
|
29
29
|
tracer: OpenTelemetry tracer for creating spans.
|
30
30
|
pricing_info: Information used for calculating the cost of Reka usage.
|
31
|
-
|
31
|
+
capture_message_content: Flag indicating whether to trace the actual content.
|
32
32
|
|
33
33
|
Returns:
|
34
34
|
A function that wraps the chat method to add telemetry.
|
@@ -142,7 +142,7 @@ def async_chat(version, environment, application_name,
|
|
142
142
|
span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
|
143
143
|
version)
|
144
144
|
|
145
|
-
if
|
145
|
+
if capture_message_content:
|
146
146
|
span.add_event(
|
147
147
|
name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
|
148
148
|
attributes={
|
@@ -18,7 +18,7 @@ from openlit.semcov import SemanticConvetion
|
|
18
18
|
logger = logging.getLogger(__name__)
|
19
19
|
|
20
20
|
def chat(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 chat to collect metrics.
|
24
24
|
|
@@ -28,7 +28,7 @@ def chat(version, environment, application_name,
|
|
28
28
|
application_name: Name of the application using the Reka API.
|
29
29
|
tracer: OpenTelemetry tracer for creating spans.
|
30
30
|
pricing_info: Information used for calculating the cost of Reka usage.
|
31
|
-
|
31
|
+
capture_message_content: Flag indicating whether to trace the actual content.
|
32
32
|
|
33
33
|
Returns:
|
34
34
|
A function that wraps the chat method to add telemetry.
|
@@ -142,7 +142,7 @@ def chat(version, environment, application_name,
|
|
142
142
|
span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
|
143
143
|
version)
|
144
144
|
|
145
|
-
if
|
145
|
+
if capture_message_content:
|
146
146
|
span.add_event(
|
147
147
|
name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
|
148
148
|
attributes={
|
@@ -29,7 +29,7 @@ class TogetherInstrumentor(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("together")
|
35
35
|
|
@@ -38,7 +38,7 @@ class TogetherInstrumentor(BaseInstrumentor):
|
|
38
38
|
"together.resources.chat.completions",
|
39
39
|
"ChatCompletions.create",
|
40
40
|
completion(version, environment, application_name,
|
41
|
-
tracer, pricing_info,
|
41
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
42
42
|
)
|
43
43
|
|
44
44
|
# Image generate
|
@@ -46,7 +46,7 @@ class TogetherInstrumentor(BaseInstrumentor):
|
|
46
46
|
"together.resources.images",
|
47
47
|
"Images.generate",
|
48
48
|
image_generate(version, environment, application_name,
|
49
|
-
tracer, pricing_info,
|
49
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
50
50
|
)
|
51
51
|
|
52
52
|
# Chat completions
|
@@ -54,7 +54,7 @@ class TogetherInstrumentor(BaseInstrumentor):
|
|
54
54
|
"together.resources.chat.completions",
|
55
55
|
"AsyncChatCompletions.create",
|
56
56
|
async_completion(version, environment, application_name,
|
57
|
-
tracer, pricing_info,
|
57
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
58
58
|
)
|
59
59
|
|
60
60
|
# Image generate
|
@@ -62,7 +62,7 @@ class TogetherInstrumentor(BaseInstrumentor):
|
|
62
62
|
"together.resources.images",
|
63
63
|
"AsyncImages.generate",
|
64
64
|
async_image_generate(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):
|
@@ -22,7 +22,7 @@ from openlit.semcov import SemanticConvetion
|
|
22
22
|
logger = logging.getLogger(__name__)
|
23
23
|
|
24
24
|
def async_completion(version, environment, application_name,
|
25
|
-
tracer, pricing_info,
|
25
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics):
|
26
26
|
"""
|
27
27
|
Generates a telemetry wrapper for chat completions to collect metrics.
|
28
28
|
|
@@ -32,7 +32,7 @@ def async_completion(version, environment, application_name,
|
|
32
32
|
application_name: Name of the application using the Together AI API.
|
33
33
|
tracer: OpenTelemetry tracer for creating spans.
|
34
34
|
pricing_info: Information used for calculating the cost of Together AI usage.
|
35
|
-
|
35
|
+
capture_message_content: Flag indicating whether to trace the actual content.
|
36
36
|
|
37
37
|
Returns:
|
38
38
|
A function that wraps the chat completions method to add telemetry.
|
@@ -218,7 +218,7 @@ def async_completion(version, environment, application_name,
|
|
218
218
|
self._ttft)
|
219
219
|
self._span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
|
220
220
|
version)
|
221
|
-
if
|
221
|
+
if capture_message_content:
|
222
222
|
self._span.add_event(
|
223
223
|
name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
|
224
224
|
attributes={
|
@@ -388,7 +388,7 @@ def async_completion(version, environment, application_name,
|
|
388
388
|
end_time - start_time)
|
389
389
|
span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
|
390
390
|
version)
|
391
|
-
if
|
391
|
+
if capture_message_content:
|
392
392
|
span.add_event(
|
393
393
|
name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
|
394
394
|
attributes={
|
@@ -399,7 +399,7 @@ def async_completion(version, environment, application_name,
|
|
399
399
|
for i in range(kwargs.get('n',1)):
|
400
400
|
span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON,
|
401
401
|
[str(response_dict.get('choices')[i].get('finish_reason'))])
|
402
|
-
if
|
402
|
+
if capture_message_content:
|
403
403
|
span.add_event(
|
404
404
|
name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
|
405
405
|
attributes={
|
@@ -459,7 +459,7 @@ def async_completion(version, environment, application_name,
|
|
459
459
|
return wrapper
|
460
460
|
|
461
461
|
def async_image_generate(version, environment, application_name,
|
462
|
-
tracer, pricing_info,
|
462
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics):
|
463
463
|
"""
|
464
464
|
Generates a telemetry wrapper for image generation to collect metrics.
|
465
465
|
|
@@ -469,7 +469,7 @@ def async_image_generate(version, environment, application_name,
|
|
469
469
|
application_name: Name of the application using the Together AI API.
|
470
470
|
tracer: OpenTelemetry tracer for creating spans.
|
471
471
|
pricing_info: Information used for calculating the cost of Together AI image generation.
|
472
|
-
|
472
|
+
capture_message_content: Flag indicating whether to trace the input prompt and generated images.
|
473
473
|
|
474
474
|
Returns:
|
475
475
|
A function that wraps the image generation method to add telemetry.
|
@@ -548,7 +548,7 @@ def async_image_generate(version, environment, application_name,
|
|
548
548
|
span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
|
549
549
|
version)
|
550
550
|
|
551
|
-
if
|
551
|
+
if capture_message_content:
|
552
552
|
span.add_event(
|
553
553
|
name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
|
554
554
|
attributes={
|