openlit 1.34.7__tar.gz → 1.34.8__tar.gz
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-1.34.7 → openlit-1.34.8}/PKG-INFO +1 -1
- {openlit-1.34.7 → openlit-1.34.8}/pyproject.toml +1 -1
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/gpt4all/__init__.py +3 -6
- openlit-1.34.8/src/openlit/instrumentation/gpt4all/gpt4all.py +189 -0
- openlit-1.34.8/src/openlit/instrumentation/gpt4all/utils.py +281 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/premai/__init__.py +2 -2
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/premai/utils.py +4 -3
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/reka/utils.py +3 -3
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/together/utils.py +3 -3
- openlit-1.34.7/src/openlit/instrumentation/gpt4all/gpt4all.py +0 -497
- {openlit-1.34.7 → openlit-1.34.8}/LICENSE +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/README.md +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/__helpers.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/evals/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/evals/all.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/evals/bias_detection.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/evals/hallucination.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/evals/toxicity.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/evals/utils.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/guard/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/guard/all.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/guard/prompt_injection.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/guard/restrict_topic.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/guard/sensitive_topic.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/guard/utils.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/ag2/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/ag2/ag2.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/ai21/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/ai21/ai21.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/ai21/async_ai21.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/ai21/utils.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/anthropic/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/anthropic/anthropic.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/anthropic/async_anthropic.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/anthropic/utils.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/assemblyai/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/assemblyai/assemblyai.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/astra/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/astra/astra.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/astra/async_astra.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/astra/utils.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/azure_ai_inference/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/azure_ai_inference/async_azure_ai_inference.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/azure_ai_inference/azure_ai_inference.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/azure_ai_inference/utils.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/bedrock/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/bedrock/bedrock.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/bedrock/utils.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/chroma/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/chroma/chroma.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/cohere/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/cohere/async_cohere.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/cohere/cohere.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/controlflow/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/controlflow/controlflow.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/crawl4ai/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/crawl4ai/async_crawl4ai.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/crawl4ai/crawl4ai.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/crewai/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/crewai/crewai.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/dynamiq/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/dynamiq/dynamiq.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/elevenlabs/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/elevenlabs/async_elevenlabs.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/elevenlabs/elevenlabs.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/embedchain/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/embedchain/embedchain.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/firecrawl/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/firecrawl/firecrawl.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/google_ai_studio/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/google_ai_studio/async_google_ai_studio.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/google_ai_studio/google_ai_studio.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/google_ai_studio/utils.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/gpu/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/groq/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/groq/async_groq.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/groq/groq.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/haystack/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/haystack/haystack.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/julep/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/julep/async_julep.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/julep/julep.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/langchain/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/langchain/async_langchain.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/langchain/langchain.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/letta/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/letta/letta.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/litellm/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/litellm/async_litellm.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/litellm/litellm.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/llamaindex/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/llamaindex/llamaindex.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/mem0/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/mem0/mem0.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/milvus/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/milvus/milvus.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/mistral/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/mistral/async_mistral.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/mistral/mistral.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/multion/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/multion/async_multion.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/multion/multion.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/ollama/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/ollama/async_ollama.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/ollama/ollama.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/ollama/utils.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/openai/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/openai/async_openai.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/openai/openai.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/openai_agents/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/openai_agents/openai_agents.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/phidata/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/phidata/phidata.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/pinecone/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/pinecone/pinecone.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/premai/premai.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/pydantic_ai/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/pydantic_ai/pydantic_ai.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/pydantic_ai/utils.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/qdrant/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/qdrant/async_qdrant.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/qdrant/qdrant.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/reka/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/reka/async_reka.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/reka/reka.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/together/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/together/async_together.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/together/together.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/transformers/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/transformers/transformers.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/transformers/utils.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/vertexai/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/vertexai/async_vertexai.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/vertexai/vertexai.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/vllm/__init__.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/vllm/utils.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/instrumentation/vllm/vllm.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/otel/events.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/otel/metrics.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/otel/tracing.py +0 -0
- {openlit-1.34.7 → openlit-1.34.8}/src/openlit/semcov/__init__.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: openlit
|
3
|
-
Version: 1.34.
|
3
|
+
Version: 1.34.8
|
4
4
|
Summary: OpenTelemetry-native Auto instrumentation library for monitoring LLM Applications and GPUs, facilitating the integration of observability into your GenAI-driven projects
|
5
5
|
License: Apache-2.0
|
6
6
|
Keywords: OpenTelemetry,otel,otlp,llm,tracing,openai,anthropic,claude,cohere,llm monitoring,observability,monitoring,gpt,Generative AI,chatGPT,gpu
|
@@ -1,6 +1,6 @@
|
|
1
1
|
[tool.poetry]
|
2
2
|
name = "openlit"
|
3
|
-
version = "1.34.
|
3
|
+
version = "1.34.8"
|
4
4
|
description = "OpenTelemetry-native Auto instrumentation library for monitoring LLM Applications and GPUs, facilitating the integration of observability into your GenAI-driven projects"
|
5
5
|
authors = ["OpenLIT"]
|
6
6
|
license = "Apache-2.0"
|
@@ -1,4 +1,3 @@
|
|
1
|
-
# pylint: disable=useless-return, bad-staticmethod-argument, disable=duplicate-code
|
2
1
|
"""Initializer of Auto Instrumentation of GPT4All Functions"""
|
3
2
|
|
4
3
|
from typing import Collection
|
@@ -14,15 +13,15 @@ _instruments = ("gpt4all >= 2.6.0",)
|
|
14
13
|
|
15
14
|
class GPT4AllInstrumentor(BaseInstrumentor):
|
16
15
|
"""
|
17
|
-
An instrumentor for GPT4All
|
16
|
+
An instrumentor for GPT4All client library.
|
18
17
|
"""
|
19
18
|
|
20
19
|
def instrumentation_dependencies(self) -> Collection[str]:
|
21
20
|
return _instruments
|
22
21
|
|
23
22
|
def _instrument(self, **kwargs):
|
24
|
-
application_name = kwargs.get("application_name", "
|
25
|
-
environment = kwargs.get("environment", "
|
23
|
+
application_name = kwargs.get("application_name", "default")
|
24
|
+
environment = kwargs.get("environment", "default")
|
26
25
|
tracer = kwargs.get("tracer")
|
27
26
|
metrics = kwargs.get("metrics_dict")
|
28
27
|
pricing_info = kwargs.get("pricing_info", {})
|
@@ -46,7 +45,5 @@ class GPT4AllInstrumentor(BaseInstrumentor):
|
|
46
45
|
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
47
46
|
)
|
48
47
|
|
49
|
-
|
50
48
|
def _uninstrument(self, **kwargs):
|
51
|
-
# Proper uninstrumentation logic to revert patched methods
|
52
49
|
pass
|
@@ -0,0 +1,189 @@
|
|
1
|
+
"""
|
2
|
+
Module for monitoring GPT4All API calls.
|
3
|
+
"""
|
4
|
+
|
5
|
+
import time
|
6
|
+
from opentelemetry.trace import SpanKind
|
7
|
+
from openlit.__helpers import (
|
8
|
+
handle_exception,
|
9
|
+
set_server_address_and_port
|
10
|
+
)
|
11
|
+
from openlit.instrumentation.gpt4all.utils import (
|
12
|
+
process_generate_response,
|
13
|
+
process_chunk,
|
14
|
+
process_streaming_generate_response,
|
15
|
+
process_embedding_response
|
16
|
+
)
|
17
|
+
from openlit.semcov import SemanticConvention
|
18
|
+
|
19
|
+
def generate(version, environment, application_name,
|
20
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics):
|
21
|
+
"""
|
22
|
+
Generates a telemetry wrapper for GenAI function call
|
23
|
+
"""
|
24
|
+
|
25
|
+
class TracedSyncStream:
|
26
|
+
"""
|
27
|
+
Wrapper for streaming responses to collect telemetry.
|
28
|
+
"""
|
29
|
+
|
30
|
+
def __init__(
|
31
|
+
self,
|
32
|
+
wrapped,
|
33
|
+
span,
|
34
|
+
span_name,
|
35
|
+
args,
|
36
|
+
kwargs,
|
37
|
+
server_address,
|
38
|
+
server_port,
|
39
|
+
request_model,
|
40
|
+
):
|
41
|
+
self.__wrapped__ = wrapped
|
42
|
+
self._span = span
|
43
|
+
self._span_name = span_name
|
44
|
+
self._llmresponse = ""
|
45
|
+
self._request_model = request_model
|
46
|
+
self._args = args
|
47
|
+
self._kwargs = kwargs
|
48
|
+
self._start_time = time.time()
|
49
|
+
self._end_time = None
|
50
|
+
self._timestamps = []
|
51
|
+
self._ttft = 0
|
52
|
+
self._tbt = 0
|
53
|
+
self._server_address = server_address
|
54
|
+
self._server_port = server_port
|
55
|
+
self._tools = None
|
56
|
+
|
57
|
+
def __enter__(self):
|
58
|
+
self.__wrapped__.__enter__()
|
59
|
+
return self
|
60
|
+
|
61
|
+
def __exit__(self, exc_type, exc_value, traceback):
|
62
|
+
self.__wrapped__.__exit__(exc_type, exc_value, traceback)
|
63
|
+
|
64
|
+
def __iter__(self):
|
65
|
+
return self
|
66
|
+
|
67
|
+
def __getattr__(self, name):
|
68
|
+
"""Delegate attribute access to the wrapped object."""
|
69
|
+
return getattr(self.__wrapped__, name)
|
70
|
+
|
71
|
+
def __next__(self):
|
72
|
+
try:
|
73
|
+
chunk = self.__wrapped__.__next__()
|
74
|
+
process_chunk(self, chunk)
|
75
|
+
return chunk
|
76
|
+
except StopIteration:
|
77
|
+
try:
|
78
|
+
with tracer.start_as_current_span(self._span_name, kind=SpanKind.CLIENT) as self._span:
|
79
|
+
process_streaming_generate_response(
|
80
|
+
self,
|
81
|
+
pricing_info=pricing_info,
|
82
|
+
environment=environment,
|
83
|
+
application_name=application_name,
|
84
|
+
metrics=metrics,
|
85
|
+
capture_message_content=capture_message_content,
|
86
|
+
disable_metrics=disable_metrics,
|
87
|
+
version=version
|
88
|
+
)
|
89
|
+
|
90
|
+
except Exception as e:
|
91
|
+
handle_exception(self._span, e)
|
92
|
+
|
93
|
+
raise
|
94
|
+
|
95
|
+
def wrapper(wrapped, instance, args, kwargs):
|
96
|
+
"""
|
97
|
+
Wraps the GenAI function call.
|
98
|
+
"""
|
99
|
+
|
100
|
+
# Check if streaming is enabled for the API call
|
101
|
+
streaming = kwargs.get("streaming", False)
|
102
|
+
|
103
|
+
server_address, server_port = set_server_address_and_port(instance, "127.0.0.1", 80)
|
104
|
+
request_model = str(instance.model.model_path).rsplit("/", maxsplit=1)[-1] or "orca-mini-3b-gguf2-q4_0.gguf"
|
105
|
+
|
106
|
+
span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
|
107
|
+
|
108
|
+
if streaming:
|
109
|
+
# Special handling for streaming response to accommodate the nature of data flow
|
110
|
+
awaited_wrapped = wrapped(*args, **kwargs)
|
111
|
+
span = tracer.start_span(span_name, kind=SpanKind.CLIENT)
|
112
|
+
return TracedSyncStream(awaited_wrapped, span, span_name, args, kwargs, server_address, server_port, request_model)
|
113
|
+
|
114
|
+
# Handling for non-streaming responses
|
115
|
+
else:
|
116
|
+
with tracer.start_as_current_span(span_name, kind=SpanKind.CLIENT) as span:
|
117
|
+
start_time = time.time()
|
118
|
+
response = wrapped(*args, **kwargs)
|
119
|
+
|
120
|
+
try:
|
121
|
+
response = process_generate_response(
|
122
|
+
response=response,
|
123
|
+
request_model=request_model,
|
124
|
+
pricing_info=pricing_info,
|
125
|
+
server_port=server_port,
|
126
|
+
server_address=server_address,
|
127
|
+
environment=environment,
|
128
|
+
application_name=application_name,
|
129
|
+
metrics=metrics,
|
130
|
+
start_time=start_time,
|
131
|
+
span=span,
|
132
|
+
args=args,
|
133
|
+
kwargs=kwargs,
|
134
|
+
capture_message_content=capture_message_content,
|
135
|
+
disable_metrics=disable_metrics,
|
136
|
+
version=version
|
137
|
+
)
|
138
|
+
|
139
|
+
except Exception as e:
|
140
|
+
handle_exception(span, e)
|
141
|
+
|
142
|
+
return response
|
143
|
+
|
144
|
+
return wrapper
|
145
|
+
|
146
|
+
def embed(version, environment, application_name,
|
147
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics):
|
148
|
+
"""
|
149
|
+
Generates a telemetry wrapper for GenAI function call
|
150
|
+
"""
|
151
|
+
|
152
|
+
def wrapper(wrapped, instance, args, kwargs):
|
153
|
+
"""
|
154
|
+
Wraps the GenAI function call.
|
155
|
+
"""
|
156
|
+
|
157
|
+
server_address, server_port = set_server_address_and_port(instance, "127.0.0.1", 80)
|
158
|
+
request_model = str(instance.gpt4all.model.model_path).rsplit("/", maxsplit=1)[-1] or "all-MiniLM-L6-v2.gguf2.f16.gguf"
|
159
|
+
|
160
|
+
span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING} {request_model}"
|
161
|
+
|
162
|
+
with tracer.start_as_current_span(span_name, kind=SpanKind.CLIENT) as span:
|
163
|
+
start_time = time.time()
|
164
|
+
response = wrapped(*args, **kwargs)
|
165
|
+
|
166
|
+
try:
|
167
|
+
response = process_embedding_response(
|
168
|
+
response=response,
|
169
|
+
request_model=request_model,
|
170
|
+
pricing_info=pricing_info,
|
171
|
+
server_port=server_port,
|
172
|
+
server_address=server_address,
|
173
|
+
environment=environment,
|
174
|
+
application_name=application_name,
|
175
|
+
metrics=metrics,
|
176
|
+
start_time=start_time,
|
177
|
+
span=span,
|
178
|
+
capture_message_content=capture_message_content,
|
179
|
+
disable_metrics=disable_metrics,
|
180
|
+
version=version,
|
181
|
+
**kwargs
|
182
|
+
)
|
183
|
+
|
184
|
+
except Exception as e:
|
185
|
+
handle_exception(span, e)
|
186
|
+
|
187
|
+
return response
|
188
|
+
|
189
|
+
return wrapper
|
@@ -0,0 +1,281 @@
|
|
1
|
+
"""
|
2
|
+
GPT4All OpenTelemetry instrumentation utility functions
|
3
|
+
"""
|
4
|
+
import time
|
5
|
+
|
6
|
+
from opentelemetry.sdk.resources import SERVICE_NAME, TELEMETRY_SDK_NAME, DEPLOYMENT_ENVIRONMENT
|
7
|
+
from opentelemetry.trace import Status, StatusCode
|
8
|
+
|
9
|
+
from openlit.__helpers import (
|
10
|
+
calculate_ttft,
|
11
|
+
calculate_tbt,
|
12
|
+
general_tokens,
|
13
|
+
create_metrics_attributes,
|
14
|
+
get_chat_model_cost,
|
15
|
+
get_embed_model_cost,
|
16
|
+
)
|
17
|
+
from openlit.semcov import SemanticConvention
|
18
|
+
|
19
|
+
def format_content(prompt):
|
20
|
+
"""
|
21
|
+
Process a prompt to extract content.
|
22
|
+
"""
|
23
|
+
return str(prompt) if prompt else ""
|
24
|
+
|
25
|
+
def process_chunk(scope, chunk):
|
26
|
+
"""
|
27
|
+
Process a chunk of response data and update state.
|
28
|
+
"""
|
29
|
+
|
30
|
+
end_time = time.time()
|
31
|
+
# Record the timestamp for the current chunk
|
32
|
+
scope._timestamps.append(end_time)
|
33
|
+
|
34
|
+
if len(scope._timestamps) == 1:
|
35
|
+
# Calculate time to first chunk
|
36
|
+
scope._ttft = calculate_ttft(scope._timestamps, scope._start_time)
|
37
|
+
|
38
|
+
scope._llmresponse += chunk
|
39
|
+
scope._end_time = time.time()
|
40
|
+
|
41
|
+
def common_span_attributes(scope, gen_ai_operation, gen_ai_system, server_address, server_port,
|
42
|
+
request_model, response_model, environment, application_name, is_stream, tbt, ttft, version):
|
43
|
+
"""
|
44
|
+
Set common span attributes for both generate and embed operations.
|
45
|
+
"""
|
46
|
+
|
47
|
+
scope._span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
|
48
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_OPERATION, gen_ai_operation)
|
49
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_SYSTEM, gen_ai_system)
|
50
|
+
scope._span.set_attribute(SemanticConvention.SERVER_ADDRESS, server_address)
|
51
|
+
scope._span.set_attribute(SemanticConvention.SERVER_PORT, server_port)
|
52
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL, request_model)
|
53
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL, response_model)
|
54
|
+
scope._span.set_attribute(DEPLOYMENT_ENVIRONMENT, environment)
|
55
|
+
scope._span.set_attribute(SERVICE_NAME, application_name)
|
56
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, is_stream)
|
57
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TBT, tbt)
|
58
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT, ttft)
|
59
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION, version)
|
60
|
+
|
61
|
+
def record_completion_metrics(metrics, gen_ai_operation, gen_ai_system, server_address, server_port,
|
62
|
+
request_model, response_model, environment, application_name, start_time, end_time,
|
63
|
+
input_tokens, output_tokens, cost, tbt=None, ttft=None):
|
64
|
+
"""
|
65
|
+
Record completion-specific metrics for the operation.
|
66
|
+
"""
|
67
|
+
|
68
|
+
attributes = create_metrics_attributes(
|
69
|
+
operation=gen_ai_operation,
|
70
|
+
system=gen_ai_system,
|
71
|
+
server_address=server_address,
|
72
|
+
server_port=server_port,
|
73
|
+
request_model=request_model,
|
74
|
+
response_model=response_model,
|
75
|
+
service_name=application_name,
|
76
|
+
deployment_environment=environment,
|
77
|
+
)
|
78
|
+
metrics["genai_client_operation_duration"].record(end_time - start_time, attributes)
|
79
|
+
metrics["genai_requests"].add(1, attributes)
|
80
|
+
metrics["genai_prompt_tokens"].add(input_tokens, attributes)
|
81
|
+
metrics["genai_completion_tokens"].add(output_tokens, attributes)
|
82
|
+
metrics["genai_client_usage_tokens"].record(input_tokens + output_tokens, attributes)
|
83
|
+
metrics["genai_cost"].record(cost, attributes)
|
84
|
+
if tbt is not None:
|
85
|
+
metrics["genai_server_tbt"].record(tbt, attributes)
|
86
|
+
if ttft is not None:
|
87
|
+
metrics["genai_server_ttft"].record(ttft, attributes)
|
88
|
+
|
89
|
+
def record_embedding_metrics(metrics, gen_ai_operation, gen_ai_system, server_address, server_port,
|
90
|
+
request_model, response_model, environment, application_name, start_time, end_time,
|
91
|
+
input_tokens, cost):
|
92
|
+
"""
|
93
|
+
Record embedding-specific metrics for the operation.
|
94
|
+
"""
|
95
|
+
|
96
|
+
attributes = create_metrics_attributes(
|
97
|
+
operation=gen_ai_operation,
|
98
|
+
system=gen_ai_system,
|
99
|
+
server_address=server_address,
|
100
|
+
server_port=server_port,
|
101
|
+
request_model=request_model,
|
102
|
+
response_model=response_model,
|
103
|
+
service_name=application_name,
|
104
|
+
deployment_environment=environment,
|
105
|
+
)
|
106
|
+
metrics["genai_client_usage_tokens"].record(input_tokens, attributes)
|
107
|
+
metrics["genai_client_operation_duration"].record(end_time - start_time, attributes)
|
108
|
+
metrics["genai_requests"].add(1, attributes)
|
109
|
+
metrics["genai_prompt_tokens"].add(input_tokens, attributes)
|
110
|
+
metrics["genai_cost"].record(cost, attributes)
|
111
|
+
|
112
|
+
def common_generate_logic(scope, pricing_info, environment, application_name, metrics,
|
113
|
+
capture_message_content, disable_metrics, version, is_stream):
|
114
|
+
"""
|
115
|
+
Process generate request and generate Telemetry
|
116
|
+
"""
|
117
|
+
|
118
|
+
if len(scope._timestamps) > 1:
|
119
|
+
scope._tbt = calculate_tbt(scope._timestamps)
|
120
|
+
|
121
|
+
prompt = format_content(scope._kwargs.get("prompt") or (scope._args[0] if scope._args else "") or "")
|
122
|
+
request_model = scope._request_model
|
123
|
+
|
124
|
+
# Calculate tokens using input prompt and aggregated response
|
125
|
+
input_tokens = general_tokens(prompt)
|
126
|
+
output_tokens = general_tokens(scope._llmresponse)
|
127
|
+
|
128
|
+
cost = get_chat_model_cost(request_model, pricing_info, input_tokens, output_tokens)
|
129
|
+
|
130
|
+
# Common Span Attributes
|
131
|
+
common_span_attributes(scope,
|
132
|
+
SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT, SemanticConvention.GEN_AI_SYSTEM_GPT4ALL,
|
133
|
+
scope._server_address, scope._server_port, request_model, request_model,
|
134
|
+
environment, application_name, is_stream, scope._tbt, scope._ttft, version)
|
135
|
+
|
136
|
+
# Span Attributes for Request parameters
|
137
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_FREQUENCY_PENALTY, scope._kwargs.get("repeat_penalty", 1.18))
|
138
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MAX_TOKENS, scope._kwargs.get("max_tokens", 200))
|
139
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_PRESENCE_PENALTY, scope._kwargs.get("presence_penalty", 0.0))
|
140
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TEMPERATURE, scope._kwargs.get("temp", 0.7))
|
141
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_P, scope._kwargs.get("top_p", 0.4))
|
142
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_TOP_K, scope._kwargs.get("top_k", 40))
|
143
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_OUTPUT_TYPE, "text" if isinstance(scope._llmresponse, str) else "json")
|
144
|
+
|
145
|
+
# Span Attributes for Cost and Tokens
|
146
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, input_tokens)
|
147
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_USAGE_OUTPUT_TOKENS, output_tokens)
|
148
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_CLIENT_TOKEN_USAGE, input_tokens + output_tokens)
|
149
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST, cost)
|
150
|
+
|
151
|
+
# Span Attributes for Tools
|
152
|
+
if scope._tools:
|
153
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_TOOL_NAME, scope._tools.get("function","")).get("name","")
|
154
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_TOOL_CALL_ID, str(scope._tools.get("id","")))
|
155
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_TOOL_ARGS, str(scope._tools.get("function","").get("arguments","")))
|
156
|
+
|
157
|
+
# Span Attributes for Content
|
158
|
+
if capture_message_content:
|
159
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_CONTENT_PROMPT, prompt)
|
160
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_CONTENT_COMPLETION, scope._llmresponse)
|
161
|
+
|
162
|
+
# To be removed one the change to span_attributes (from span events) is complete
|
163
|
+
scope._span.add_event(
|
164
|
+
name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
|
165
|
+
attributes={
|
166
|
+
SemanticConvention.GEN_AI_CONTENT_PROMPT: prompt,
|
167
|
+
},
|
168
|
+
)
|
169
|
+
scope._span.add_event(
|
170
|
+
name=SemanticConvention.GEN_AI_CONTENT_COMPLETION_EVENT,
|
171
|
+
attributes={
|
172
|
+
SemanticConvention.GEN_AI_CONTENT_COMPLETION: scope._llmresponse,
|
173
|
+
},
|
174
|
+
)
|
175
|
+
|
176
|
+
scope._span.set_status(Status(StatusCode.OK))
|
177
|
+
|
178
|
+
# Metrics
|
179
|
+
if not disable_metrics:
|
180
|
+
record_completion_metrics(metrics, SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT, SemanticConvention.GEN_AI_SYSTEM_GPT4ALL,
|
181
|
+
scope._server_address, scope._server_port, request_model, request_model, environment,
|
182
|
+
application_name, scope._start_time, scope._end_time, input_tokens, output_tokens,
|
183
|
+
cost, scope._tbt, scope._ttft)
|
184
|
+
|
185
|
+
def common_embedding_logic(scope, pricing_info, environment, application_name, metrics,
|
186
|
+
capture_message_content, disable_metrics, version):
|
187
|
+
"""
|
188
|
+
Process embedding request and generate Telemetry
|
189
|
+
"""
|
190
|
+
|
191
|
+
prompt = format_content(scope._kwargs.get("text") or "")
|
192
|
+
request_model = scope._request_model
|
193
|
+
|
194
|
+
input_tokens = general_tokens(prompt)
|
195
|
+
|
196
|
+
cost = get_embed_model_cost(request_model, pricing_info, input_tokens)
|
197
|
+
|
198
|
+
# Common Span Attributes
|
199
|
+
common_span_attributes(scope,
|
200
|
+
SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING, SemanticConvention.GEN_AI_SYSTEM_GPT4ALL,
|
201
|
+
scope._server_address, scope._server_port, request_model, request_model,
|
202
|
+
environment, application_name, False, scope._tbt, scope._ttft, version)
|
203
|
+
|
204
|
+
# Embedding-specific span attributes
|
205
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_USAGE_INPUT_TOKENS, input_tokens)
|
206
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_CLIENT_TOKEN_USAGE, input_tokens)
|
207
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_USAGE_COST, cost)
|
208
|
+
|
209
|
+
# Span Attributes for Content
|
210
|
+
if capture_message_content:
|
211
|
+
scope._span.add_event(
|
212
|
+
name=SemanticConvention.GEN_AI_CONTENT_PROMPT_EVENT,
|
213
|
+
attributes={
|
214
|
+
SemanticConvention.GEN_AI_CONTENT_PROMPT: str(scope._kwargs.get("input", "")),
|
215
|
+
},
|
216
|
+
)
|
217
|
+
|
218
|
+
scope._span.set_status(Status(StatusCode.OK))
|
219
|
+
|
220
|
+
# Metrics
|
221
|
+
if not disable_metrics:
|
222
|
+
record_embedding_metrics(metrics, SemanticConvention.GEN_AI_OPERATION_TYPE_EMBEDDING, SemanticConvention.GEN_AI_SYSTEM_GPT4ALL,
|
223
|
+
scope._server_address, scope._server_port, request_model, request_model, environment,
|
224
|
+
application_name, scope._start_time, scope._end_time, input_tokens, cost)
|
225
|
+
|
226
|
+
def process_streaming_generate_response(scope, pricing_info, environment, application_name, metrics,
|
227
|
+
capture_message_content=False, disable_metrics=False, version=""):
|
228
|
+
"""
|
229
|
+
Process generate request and generate Telemetry
|
230
|
+
"""
|
231
|
+
common_generate_logic(scope, pricing_info, environment, application_name, metrics,
|
232
|
+
capture_message_content, disable_metrics, version, is_stream=True)
|
233
|
+
|
234
|
+
def process_generate_response(response, request_model, pricing_info, server_port, server_address,
|
235
|
+
environment, application_name, metrics, start_time, span, args, kwargs, capture_message_content=False,
|
236
|
+
disable_metrics=False, version="1.0.0"):
|
237
|
+
"""
|
238
|
+
Process generate request and generate Telemetry
|
239
|
+
"""
|
240
|
+
|
241
|
+
scope = type("GenericScope", (), {})()
|
242
|
+
|
243
|
+
scope._start_time = start_time
|
244
|
+
scope._end_time = time.time()
|
245
|
+
scope._span = span
|
246
|
+
scope._llmresponse = str(response)
|
247
|
+
scope._request_model = request_model
|
248
|
+
scope._timestamps = []
|
249
|
+
scope._ttft, scope._tbt = scope._end_time - scope._start_time, 0
|
250
|
+
scope._server_address, scope._server_port = server_address, server_port
|
251
|
+
scope._kwargs = kwargs
|
252
|
+
scope._args = args
|
253
|
+
scope._tools = None
|
254
|
+
|
255
|
+
common_generate_logic(scope, pricing_info, environment, application_name, metrics,
|
256
|
+
capture_message_content, disable_metrics, version, is_stream=False)
|
257
|
+
|
258
|
+
return response
|
259
|
+
|
260
|
+
def process_embedding_response(response, request_model, pricing_info, server_port, server_address,
|
261
|
+
environment, application_name, metrics, start_time, span, capture_message_content=False,
|
262
|
+
disable_metrics=False, version="1.0.0", **kwargs):
|
263
|
+
"""
|
264
|
+
Process embedding request and generate Telemetry
|
265
|
+
"""
|
266
|
+
|
267
|
+
scope = type("GenericScope", (), {})()
|
268
|
+
|
269
|
+
scope._start_time = start_time
|
270
|
+
scope._end_time = time.time()
|
271
|
+
scope._span = span
|
272
|
+
scope._request_model = request_model
|
273
|
+
scope._timestamps = []
|
274
|
+
scope._ttft, scope._tbt = scope._end_time - scope._start_time, 0
|
275
|
+
scope._server_address, scope._server_port = server_address, server_port
|
276
|
+
scope._kwargs = kwargs
|
277
|
+
|
278
|
+
common_embedding_logic(scope, pricing_info, environment, application_name, metrics,
|
279
|
+
capture_message_content, disable_metrics, version)
|
280
|
+
|
281
|
+
return response
|
@@ -20,8 +20,8 @@ class PremAIInstrumentor(BaseInstrumentor):
|
|
20
20
|
return _instruments
|
21
21
|
|
22
22
|
def _instrument(self, **kwargs):
|
23
|
-
application_name = kwargs.get("application_name", "
|
24
|
-
environment = kwargs.get("environment", "
|
23
|
+
application_name = kwargs.get("application_name", "default")
|
24
|
+
environment = kwargs.get("environment", "default")
|
25
25
|
tracer = kwargs.get("tracer")
|
26
26
|
metrics = kwargs.get("metrics_dict")
|
27
27
|
pricing_info = kwargs.get("pricing_info", {})
|
@@ -64,6 +64,7 @@ def process_chunk(scope, chunk):
|
|
64
64
|
scope._finish_reason = chunked.get("choices")[0].get("finish_reason")
|
65
65
|
scope._response_id = chunked.get("id")
|
66
66
|
scope._response_model = chunked.get("model")
|
67
|
+
scope._end_time = time.time()
|
67
68
|
|
68
69
|
def common_span_attributes(scope, gen_ai_operation, gen_ai_system, server_address, server_port,
|
69
70
|
request_model, response_model, environment, application_name, is_stream, tbt, ttft, version):
|
@@ -77,12 +78,12 @@ def common_span_attributes(scope, gen_ai_operation, gen_ai_system, server_addres
|
|
77
78
|
scope._span.set_attribute(SemanticConvention.SERVER_ADDRESS, server_address)
|
78
79
|
scope._span.set_attribute(SemanticConvention.SERVER_PORT, server_port)
|
79
80
|
scope._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL, request_model)
|
80
|
-
scope._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
|
81
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL, response_model)
|
81
82
|
scope._span.set_attribute(DEPLOYMENT_ENVIRONMENT, environment)
|
82
83
|
scope._span.set_attribute(SERVICE_NAME, application_name)
|
83
84
|
scope._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, is_stream)
|
84
|
-
scope._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TBT,
|
85
|
-
scope._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
|
85
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TBT, tbt)
|
86
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT, ttft)
|
86
87
|
scope._span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION, version)
|
87
88
|
|
88
89
|
def record_completion_metrics(metrics, gen_ai_operation, gen_ai_system, server_address, server_port,
|
@@ -48,12 +48,12 @@ def common_span_attributes(scope, gen_ai_operation, gen_ai_system, server_addres
|
|
48
48
|
scope._span.set_attribute(SemanticConvention.SERVER_ADDRESS, server_address)
|
49
49
|
scope._span.set_attribute(SemanticConvention.SERVER_PORT, server_port)
|
50
50
|
scope._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL, request_model)
|
51
|
-
scope._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
|
51
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL, response_model)
|
52
52
|
scope._span.set_attribute(DEPLOYMENT_ENVIRONMENT, environment)
|
53
53
|
scope._span.set_attribute(SERVICE_NAME, application_name)
|
54
54
|
scope._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, is_stream)
|
55
|
-
scope._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TBT,
|
56
|
-
scope._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
|
55
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TBT, tbt)
|
56
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT, ttft)
|
57
57
|
scope._span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION, version)
|
58
58
|
|
59
59
|
def record_common_metrics(metrics, gen_ai_operation, gen_ai_system, server_address, server_port,
|
@@ -80,12 +80,12 @@ def common_span_attributes(scope, gen_ai_operation, gen_ai_system, server_addres
|
|
80
80
|
scope._span.set_attribute(SemanticConvention.SERVER_ADDRESS, server_address)
|
81
81
|
scope._span.set_attribute(SemanticConvention.SERVER_PORT, server_port)
|
82
82
|
scope._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_MODEL, request_model)
|
83
|
-
scope._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL,
|
83
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_RESPONSE_MODEL, response_model)
|
84
84
|
scope._span.set_attribute(DEPLOYMENT_ENVIRONMENT, environment)
|
85
85
|
scope._span.set_attribute(SERVICE_NAME, application_name)
|
86
86
|
scope._span.set_attribute(SemanticConvention.GEN_AI_REQUEST_IS_STREAM, is_stream)
|
87
|
-
scope._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TBT,
|
88
|
-
scope._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT,
|
87
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TBT, tbt)
|
88
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_SERVER_TTFT, ttft)
|
89
89
|
scope._span.set_attribute(SemanticConvention.GEN_AI_SDK_VERSION, version)
|
90
90
|
|
91
91
|
def record_common_metrics(metrics, gen_ai_operation, gen_ai_system, server_address, server_port,
|