openlit 1.21.0__tar.gz → 1.22.1__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.21.0 → openlit-1.22.1}/PKG-INFO +21 -18
- {openlit-1.21.0 → openlit-1.22.1}/README.md +20 -17
- {openlit-1.21.0 → openlit-1.22.1}/pyproject.toml +1 -1
- {openlit-1.21.0 → openlit-1.22.1}/src/openlit/__init__.py +21 -14
- openlit-1.22.1/src/openlit/instrumentation/azure_ai_inference/__init__.py +71 -0
- openlit-1.22.1/src/openlit/instrumentation/azure_ai_inference/async_azure_ai_inference.py +432 -0
- openlit-1.22.1/src/openlit/instrumentation/azure_ai_inference/azure_ai_inference.py +432 -0
- {openlit-1.21.0 → openlit-1.22.1}/src/openlit/instrumentation/google_ai_studio/__init__.py +1 -1
- {openlit-1.21.0 → openlit-1.22.1}/src/openlit/semcov/__init__.py +1 -0
- {openlit-1.21.0 → openlit-1.22.1}/LICENSE +0 -0
- {openlit-1.21.0 → openlit-1.22.1}/src/openlit/__helpers.py +0 -0
- {openlit-1.21.0 → openlit-1.22.1}/src/openlit/instrumentation/anthropic/__init__.py +0 -0
- {openlit-1.21.0 → openlit-1.22.1}/src/openlit/instrumentation/anthropic/anthropic.py +0 -0
- {openlit-1.21.0 → openlit-1.22.1}/src/openlit/instrumentation/anthropic/async_anthropic.py +0 -0
- {openlit-1.21.0 → openlit-1.22.1}/src/openlit/instrumentation/bedrock/__init__.py +0 -0
- {openlit-1.21.0 → openlit-1.22.1}/src/openlit/instrumentation/bedrock/bedrock.py +0 -0
- {openlit-1.21.0 → openlit-1.22.1}/src/openlit/instrumentation/chroma/__init__.py +0 -0
- {openlit-1.21.0 → openlit-1.22.1}/src/openlit/instrumentation/chroma/chroma.py +0 -0
- {openlit-1.21.0 → openlit-1.22.1}/src/openlit/instrumentation/cohere/__init__.py +0 -0
- {openlit-1.21.0 → openlit-1.22.1}/src/openlit/instrumentation/cohere/cohere.py +0 -0
- {openlit-1.21.0 → openlit-1.22.1}/src/openlit/instrumentation/elevenlabs/__init__.py +0 -0
- {openlit-1.21.0 → openlit-1.22.1}/src/openlit/instrumentation/elevenlabs/async_elevenlabs.py +0 -0
- {openlit-1.21.0 → openlit-1.22.1}/src/openlit/instrumentation/elevenlabs/elevenlabs.py +0 -0
- {openlit-1.21.0 → openlit-1.22.1}/src/openlit/instrumentation/embedchain/__init__.py +0 -0
- {openlit-1.21.0 → openlit-1.22.1}/src/openlit/instrumentation/embedchain/embedchain.py +0 -0
- {openlit-1.21.0 → openlit-1.22.1}/src/openlit/instrumentation/google_ai_studio/async_google_ai_studio.py +0 -0
- {openlit-1.21.0 → openlit-1.22.1}/src/openlit/instrumentation/google_ai_studio/google_ai_studio.py +0 -0
- {openlit-1.21.0 → openlit-1.22.1}/src/openlit/instrumentation/gpt4all/__init__.py +0 -0
- {openlit-1.21.0 → openlit-1.22.1}/src/openlit/instrumentation/gpt4all/gpt4all.py +0 -0
- {openlit-1.21.0 → openlit-1.22.1}/src/openlit/instrumentation/gpu/__init__.py +0 -0
- {openlit-1.21.0 → openlit-1.22.1}/src/openlit/instrumentation/groq/__init__.py +0 -0
- {openlit-1.21.0 → openlit-1.22.1}/src/openlit/instrumentation/groq/async_groq.py +0 -0
- {openlit-1.21.0 → openlit-1.22.1}/src/openlit/instrumentation/groq/groq.py +0 -0
- {openlit-1.21.0 → openlit-1.22.1}/src/openlit/instrumentation/haystack/__init__.py +0 -0
- {openlit-1.21.0 → openlit-1.22.1}/src/openlit/instrumentation/haystack/haystack.py +0 -0
- {openlit-1.21.0 → openlit-1.22.1}/src/openlit/instrumentation/langchain/__init__.py +0 -0
- {openlit-1.21.0 → openlit-1.22.1}/src/openlit/instrumentation/langchain/langchain.py +0 -0
- {openlit-1.21.0 → openlit-1.22.1}/src/openlit/instrumentation/llamaindex/__init__.py +0 -0
- {openlit-1.21.0 → openlit-1.22.1}/src/openlit/instrumentation/llamaindex/llamaindex.py +0 -0
- {openlit-1.21.0 → openlit-1.22.1}/src/openlit/instrumentation/milvus/__init__.py +0 -0
- {openlit-1.21.0 → openlit-1.22.1}/src/openlit/instrumentation/milvus/milvus.py +0 -0
- {openlit-1.21.0 → openlit-1.22.1}/src/openlit/instrumentation/mistral/__init__.py +0 -0
- {openlit-1.21.0 → openlit-1.22.1}/src/openlit/instrumentation/mistral/async_mistral.py +0 -0
- {openlit-1.21.0 → openlit-1.22.1}/src/openlit/instrumentation/mistral/mistral.py +0 -0
- {openlit-1.21.0 → openlit-1.22.1}/src/openlit/instrumentation/ollama/__init__.py +0 -0
- {openlit-1.21.0 → openlit-1.22.1}/src/openlit/instrumentation/ollama/async_ollama.py +0 -0
- {openlit-1.21.0 → openlit-1.22.1}/src/openlit/instrumentation/ollama/ollama.py +0 -0
- {openlit-1.21.0 → openlit-1.22.1}/src/openlit/instrumentation/openai/__init__.py +0 -0
- {openlit-1.21.0 → openlit-1.22.1}/src/openlit/instrumentation/openai/async_azure_openai.py +0 -0
- {openlit-1.21.0 → openlit-1.22.1}/src/openlit/instrumentation/openai/async_openai.py +0 -0
- {openlit-1.21.0 → openlit-1.22.1}/src/openlit/instrumentation/openai/azure_openai.py +0 -0
- {openlit-1.21.0 → openlit-1.22.1}/src/openlit/instrumentation/openai/openai.py +0 -0
- {openlit-1.21.0 → openlit-1.22.1}/src/openlit/instrumentation/pinecone/__init__.py +0 -0
- {openlit-1.21.0 → openlit-1.22.1}/src/openlit/instrumentation/pinecone/pinecone.py +0 -0
- {openlit-1.21.0 → openlit-1.22.1}/src/openlit/instrumentation/qdrant/__init__.py +0 -0
- {openlit-1.21.0 → openlit-1.22.1}/src/openlit/instrumentation/qdrant/qdrant.py +0 -0
- {openlit-1.21.0 → openlit-1.22.1}/src/openlit/instrumentation/transformers/__init__.py +0 -0
- {openlit-1.21.0 → openlit-1.22.1}/src/openlit/instrumentation/transformers/transformers.py +0 -0
- {openlit-1.21.0 → openlit-1.22.1}/src/openlit/instrumentation/vertexai/__init__.py +0 -0
- {openlit-1.21.0 → openlit-1.22.1}/src/openlit/instrumentation/vertexai/async_vertexai.py +0 -0
- {openlit-1.21.0 → openlit-1.22.1}/src/openlit/instrumentation/vertexai/vertexai.py +0 -0
- {openlit-1.21.0 → openlit-1.22.1}/src/openlit/instrumentation/vllm/__init__.py +0 -0
- {openlit-1.21.0 → openlit-1.22.1}/src/openlit/instrumentation/vllm/vllm.py +0 -0
- {openlit-1.21.0 → openlit-1.22.1}/src/openlit/otel/metrics.py +0 -0
- {openlit-1.21.0 → openlit-1.22.1}/src/openlit/otel/tracing.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: openlit
|
3
|
-
Version: 1.
|
3
|
+
Version: 1.22.1
|
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
|
Home-page: https://github.com/openlit/openlit/tree/main/openlit/python
|
6
6
|
Keywords: OpenTelemetry,otel,otlp,llm,tracing,openai,anthropic,claude,cohere,llm monitoring,observability,monitoring,gpt,Generative AI,chatGPT,gpu
|
@@ -54,23 +54,26 @@ This project adheres to the [Semantic Conventions](https://github.com/open-telem
|
|
54
54
|
|
55
55
|
## Auto Instrumentation Capabilities
|
56
56
|
|
57
|
-
| LLMs
|
58
|
-
|
59
|
-
| [✅ OpenAI](https://docs.openlit.io/latest/integrations/openai)
|
60
|
-
| [✅ Ollama](https://docs.openlit.io/latest/integrations/ollama)
|
61
|
-
| [✅ Anthropic](https://docs.openlit.io/latest/integrations/anthropic)
|
62
|
-
| [✅ GPT4All](https://docs.openlit.io/latest/integrations/gpt4all)
|
63
|
-
| [✅ Cohere](https://docs.openlit.io/latest/integrations/cohere)
|
64
|
-
| [✅ Mistral](https://docs.openlit.io/latest/integrations/mistral)
|
65
|
-
| [✅ Azure OpenAI](https://docs.openlit.io/latest/integrations/azure-openai)
|
66
|
-
| [✅
|
67
|
-
| [✅
|
68
|
-
| [✅
|
69
|
-
| [✅
|
70
|
-
| [✅
|
71
|
-
| [✅
|
72
|
-
| [✅
|
73
|
-
| [✅
|
57
|
+
| LLMs | Vector DBs | Frameworks | GPUs |
|
58
|
+
|--------------------------------------------------------------------------|----------------------------------------------|----------------------------------------------|---------------|
|
59
|
+
| [✅ OpenAI](https://docs.openlit.io/latest/integrations/openai) | [✅ ChromaDB](https://docs.openlit.io/latest/integrations/chromadb) | [✅ Langchain](https://docs.openlit.io/latest/integrations/langchain) | [✅ NVIDIA GPUs](https://docs.openlit.io/latest/integrations/nvidia-gpu) |
|
60
|
+
| [✅ Ollama](https://docs.openlit.io/latest/integrations/ollama) | [✅ Pinecone](https://docs.openlit.io/latest/integrations/pinecone) | [✅ LiteLLM](https://docs.openlit.io/latest/integrations/litellm) | |
|
61
|
+
| [✅ Anthropic](https://docs.openlit.io/latest/integrations/anthropic) | [✅ Qdrant](https://docs.openlit.io/latest/integrations/qdrant) | [✅ LlamaIndex](https://docs.openlit.io/latest/integrations/llama-index) | |
|
62
|
+
| [✅ GPT4All](https://docs.openlit.io/latest/integrations/gpt4all) | [✅ Milvus](https://docs.openlit.io/latest/integrations/milvus) | [✅ Haystack](https://docs.openlit.io/latest/integrations/haystack) | |
|
63
|
+
| [✅ Cohere](https://docs.openlit.io/latest/integrations/cohere) | | [✅ EmbedChain](https://docs.openlit.io/latest/integrations/embedchain) | |
|
64
|
+
| [✅ Mistral](https://docs.openlit.io/latest/integrations/mistral) | | [✅ Guardrails](https://docs.openlit.io/latest/integrations/guardrails) | |
|
65
|
+
| [✅ Azure OpenAI](https://docs.openlit.io/latest/integrations/azure-openai) | | | |
|
66
|
+
| [✅ Azure AI Inference](https://docs.openlit.io/latest/integrations/azure-ai-inference) | | | |
|
67
|
+
| [✅ GitHub AI Models](https://docs.openlit.io/latest/integrations/github-models) | | | |
|
68
|
+
| [✅ HuggingFace Transformers](https://docs.openlit.io/latest/integrations/huggingface) | | | |
|
69
|
+
| [✅ Amazon Bedrock](https://docs.openlit.io/latest/integrations/bedrock) | | | |
|
70
|
+
| [✅ Vertex AI](https://docs.openlit.io/latest/integrations/vertexai) | | | |
|
71
|
+
| [✅ Groq](https://docs.openlit.io/latest/integrations/groq) | | | |
|
72
|
+
| [✅ ElevenLabs](https://docs.openlit.io/latest/integrations/elevenlabs) | | | |
|
73
|
+
| [✅ vLLM](https://docs.openlit.io/latest/integrations/vllm) | | | |
|
74
|
+
| [✅ OLA Krutrim](https://docs.openlit.io/latest/integrations/krutrim) | | | |
|
75
|
+
| [✅ Google AI Studio](https://docs.openlit.io/latest/integrations/google-ai-studio) | | | |
|
76
|
+
| [✅ NVIDIA NIM](https://docs.openlit.io/latest/integrations/nvidia-nim) | | | |
|
74
77
|
|
75
78
|
## Supported Destinations
|
76
79
|
- [✅ OpenTelemetry Collector](https://docs.openlit.io/latest/connections/otelcol)
|
@@ -27,23 +27,26 @@ This project adheres to the [Semantic Conventions](https://github.com/open-telem
|
|
27
27
|
|
28
28
|
## Auto Instrumentation Capabilities
|
29
29
|
|
30
|
-
| LLMs
|
31
|
-
|
32
|
-
| [✅ OpenAI](https://docs.openlit.io/latest/integrations/openai)
|
33
|
-
| [✅ Ollama](https://docs.openlit.io/latest/integrations/ollama)
|
34
|
-
| [✅ Anthropic](https://docs.openlit.io/latest/integrations/anthropic)
|
35
|
-
| [✅ GPT4All](https://docs.openlit.io/latest/integrations/gpt4all)
|
36
|
-
| [✅ Cohere](https://docs.openlit.io/latest/integrations/cohere)
|
37
|
-
| [✅ Mistral](https://docs.openlit.io/latest/integrations/mistral)
|
38
|
-
| [✅ Azure OpenAI](https://docs.openlit.io/latest/integrations/azure-openai)
|
39
|
-
| [✅
|
40
|
-
| [✅
|
41
|
-
| [✅
|
42
|
-
| [✅
|
43
|
-
| [✅
|
44
|
-
| [✅
|
45
|
-
| [✅
|
46
|
-
| [✅
|
30
|
+
| LLMs | Vector DBs | Frameworks | GPUs |
|
31
|
+
|--------------------------------------------------------------------------|----------------------------------------------|----------------------------------------------|---------------|
|
32
|
+
| [✅ OpenAI](https://docs.openlit.io/latest/integrations/openai) | [✅ ChromaDB](https://docs.openlit.io/latest/integrations/chromadb) | [✅ Langchain](https://docs.openlit.io/latest/integrations/langchain) | [✅ NVIDIA GPUs](https://docs.openlit.io/latest/integrations/nvidia-gpu) |
|
33
|
+
| [✅ Ollama](https://docs.openlit.io/latest/integrations/ollama) | [✅ Pinecone](https://docs.openlit.io/latest/integrations/pinecone) | [✅ LiteLLM](https://docs.openlit.io/latest/integrations/litellm) | |
|
34
|
+
| [✅ Anthropic](https://docs.openlit.io/latest/integrations/anthropic) | [✅ Qdrant](https://docs.openlit.io/latest/integrations/qdrant) | [✅ LlamaIndex](https://docs.openlit.io/latest/integrations/llama-index) | |
|
35
|
+
| [✅ GPT4All](https://docs.openlit.io/latest/integrations/gpt4all) | [✅ Milvus](https://docs.openlit.io/latest/integrations/milvus) | [✅ Haystack](https://docs.openlit.io/latest/integrations/haystack) | |
|
36
|
+
| [✅ Cohere](https://docs.openlit.io/latest/integrations/cohere) | | [✅ EmbedChain](https://docs.openlit.io/latest/integrations/embedchain) | |
|
37
|
+
| [✅ Mistral](https://docs.openlit.io/latest/integrations/mistral) | | [✅ Guardrails](https://docs.openlit.io/latest/integrations/guardrails) | |
|
38
|
+
| [✅ Azure OpenAI](https://docs.openlit.io/latest/integrations/azure-openai) | | | |
|
39
|
+
| [✅ Azure AI Inference](https://docs.openlit.io/latest/integrations/azure-ai-inference) | | | |
|
40
|
+
| [✅ GitHub AI Models](https://docs.openlit.io/latest/integrations/github-models) | | | |
|
41
|
+
| [✅ HuggingFace Transformers](https://docs.openlit.io/latest/integrations/huggingface) | | | |
|
42
|
+
| [✅ Amazon Bedrock](https://docs.openlit.io/latest/integrations/bedrock) | | | |
|
43
|
+
| [✅ Vertex AI](https://docs.openlit.io/latest/integrations/vertexai) | | | |
|
44
|
+
| [✅ Groq](https://docs.openlit.io/latest/integrations/groq) | | | |
|
45
|
+
| [✅ ElevenLabs](https://docs.openlit.io/latest/integrations/elevenlabs) | | | |
|
46
|
+
| [✅ vLLM](https://docs.openlit.io/latest/integrations/vllm) | | | |
|
47
|
+
| [✅ OLA Krutrim](https://docs.openlit.io/latest/integrations/krutrim) | | | |
|
48
|
+
| [✅ Google AI Studio](https://docs.openlit.io/latest/integrations/google-ai-studio) | | | |
|
49
|
+
| [✅ NVIDIA NIM](https://docs.openlit.io/latest/integrations/nvidia-nim) | | | |
|
47
50
|
|
48
51
|
## Supported Destinations
|
49
52
|
- [✅ OpenTelemetry Collector](https://docs.openlit.io/latest/connections/otelcol)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
[tool.poetry]
|
2
2
|
name = "openlit"
|
3
|
-
version = "1.
|
3
|
+
version = "1.22.1"
|
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
|
repository = "https://github.com/openlit/openlit/tree/main/openlit/python"
|
@@ -34,6 +34,7 @@ from openlit.instrumentation.gpt4all import GPT4AllInstrumentor
|
|
34
34
|
from openlit.instrumentation.elevenlabs import ElevenLabsInstrumentor
|
35
35
|
from openlit.instrumentation.vllm import VLLMInstrumentor
|
36
36
|
from openlit.instrumentation.google_ai_studio import GoogleAIStudioInstrumentor
|
37
|
+
from openlit.instrumentation.azure_ai_inference import AzureAIInferenceInstrumentor
|
37
38
|
from openlit.instrumentation.langchain import LangChainInstrumentor
|
38
39
|
from openlit.instrumentation.llamaindex import LlamaIndexInstrumentor
|
39
40
|
from openlit.instrumentation.haystack import HaystackInstrumentor
|
@@ -139,12 +140,17 @@ def instrument_if_available(
|
|
139
140
|
):
|
140
141
|
"""Instruments the specified instrumentor if its library is available."""
|
141
142
|
if instrumentor_name in disabled_instrumentors:
|
143
|
+
logger.info("Instrumentor %s is disabled", instrumentor_name)
|
142
144
|
return
|
143
145
|
|
144
146
|
module_name = module_name_map.get(instrumentor_name)
|
145
147
|
|
146
|
-
if not module_name
|
147
|
-
|
148
|
+
if not module_name:
|
149
|
+
logger.error("No module mapping for %s", instrumentor_name)
|
150
|
+
return
|
151
|
+
|
152
|
+
try:
|
153
|
+
if find_spec(module_name) is not None:
|
148
154
|
instrumentor_instance.instrument(
|
149
155
|
environment=config.environment,
|
150
156
|
application_name=config.application_name,
|
@@ -154,10 +160,12 @@ def instrument_if_available(
|
|
154
160
|
metrics_dict=config.metrics_dict,
|
155
161
|
disable_metrics=config.disable_metrics,
|
156
162
|
)
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
logger.
|
163
|
+
logger.info("Instrumented %s", instrumentor_name)
|
164
|
+
else:
|
165
|
+
# pylint: disable=line-too-long
|
166
|
+
logger.info("Library for %s (%s) not found. Skipping instrumentation", instrumentor_name, module_name)
|
167
|
+
except Exception as e:
|
168
|
+
logger.error("Failed to instrument %s: %s", instrumentor_name, e)
|
161
169
|
|
162
170
|
def init(environment="default", application_name="default", tracer=None, otlp_endpoint=None,
|
163
171
|
otlp_headers=None, disable_batch=False, trace_content=True, disabled_instrumentors=None,
|
@@ -183,7 +191,7 @@ def init(environment="default", application_name="default", tracer=None, otlp_en
|
|
183
191
|
collect_gpu_stats (bool): Flag to enable or disable GPU metrics collection.
|
184
192
|
"""
|
185
193
|
disabled_instrumentors = disabled_instrumentors if disabled_instrumentors else []
|
186
|
-
|
194
|
+
logger.info("Starting openLIT initialization...")
|
187
195
|
|
188
196
|
module_name_map = {
|
189
197
|
"openai": "openai",
|
@@ -198,6 +206,7 @@ def init(environment="default", application_name="default", tracer=None, otlp_en
|
|
198
206
|
"elevenlabs": "elevenlabs",
|
199
207
|
"vllm": "vllm",
|
200
208
|
"google-ai-studio": "google.generativeai",
|
209
|
+
"azure-ai-inference": "azure.ai.inference",
|
201
210
|
"langchain": "langchain",
|
202
211
|
"llama_index": "llama_index",
|
203
212
|
"haystack": "haystack",
|
@@ -213,9 +222,7 @@ def init(environment="default", application_name="default", tracer=None, otlp_en
|
|
213
222
|
name for name in disabled_instrumentors if name not in module_name_map
|
214
223
|
]
|
215
224
|
for invalid_name in invalid_instrumentors:
|
216
|
-
logger.warning(
|
217
|
-
"Invalid instrumentor name detected and ignored: '%s'", invalid_name
|
218
|
-
)
|
225
|
+
logger.warning("Invalid instrumentor name detected and ignored: '%s'", invalid_name)
|
219
226
|
|
220
227
|
try:
|
221
228
|
# Retrieve or create the single configuration instance.
|
@@ -235,7 +242,7 @@ def init(environment="default", application_name="default", tracer=None, otlp_en
|
|
235
242
|
logger.error("openLIT tracing setup failed. Tracing will not be available.")
|
236
243
|
return
|
237
244
|
|
238
|
-
# Setup meter and receive metrics_dict instead of meter
|
245
|
+
# Setup meter and receive metrics_dict instead of meter.
|
239
246
|
metrics_dict = setup_meter(
|
240
247
|
application_name=application_name,
|
241
248
|
environment=environment,
|
@@ -276,6 +283,7 @@ def init(environment="default", application_name="default", tracer=None, otlp_en
|
|
276
283
|
"elevenlabs": ElevenLabsInstrumentor(),
|
277
284
|
"vllm": VLLMInstrumentor(),
|
278
285
|
"google-ai-studio": GoogleAIStudioInstrumentor(),
|
286
|
+
"azure-ai-inference": AzureAIInferenceInstrumentor(),
|
279
287
|
"langchain": LangChainInstrumentor(),
|
280
288
|
"llama_index": LlamaIndexInstrumentor(),
|
281
289
|
"haystack": HaystackInstrumentor(),
|
@@ -290,14 +298,13 @@ def init(environment="default", application_name="default", tracer=None, otlp_en
|
|
290
298
|
# Initialize and instrument only the enabled instrumentors
|
291
299
|
for name, instrumentor in instrumentor_instances.items():
|
292
300
|
instrument_if_available(name, instrumentor, config,
|
293
|
-
|
301
|
+
disabled_instrumentors, module_name_map)
|
294
302
|
|
295
|
-
if
|
303
|
+
if not disable_metrics and collect_gpu_stats:
|
296
304
|
NvidiaGPUInstrumentor().instrument(
|
297
305
|
environment=config.environment,
|
298
306
|
application_name=config.application_name,
|
299
307
|
)
|
300
|
-
|
301
308
|
except Exception as e:
|
302
309
|
logger.error("Error during openLIT initialization: %s", e)
|
303
310
|
|
@@ -0,0 +1,71 @@
|
|
1
|
+
# pylint: disable=useless-return, bad-staticmethod-argument, disable=duplicate-code
|
2
|
+
"""Initializer of Auto Instrumentation of Azure AI Inference Functions"""
|
3
|
+
|
4
|
+
from typing import Collection
|
5
|
+
import importlib.metadata
|
6
|
+
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
|
7
|
+
from wrapt import wrap_function_wrapper
|
8
|
+
|
9
|
+
from openlit.instrumentation.azure_ai_inference.azure_ai_inference import (
|
10
|
+
complete, embedding
|
11
|
+
)
|
12
|
+
|
13
|
+
from openlit.instrumentation.azure_ai_inference.async_azure_ai_inference import (
|
14
|
+
async_complete, async_embedding
|
15
|
+
)
|
16
|
+
|
17
|
+
_instruments = ("azure-ai-inference >= 1.0.0b4",)
|
18
|
+
|
19
|
+
class AzureAIInferenceInstrumentor(BaseInstrumentor):
|
20
|
+
"""
|
21
|
+
An instrumentor for azure-ai-inference's client library.
|
22
|
+
"""
|
23
|
+
|
24
|
+
def instrumentation_dependencies(self) -> Collection[str]:
|
25
|
+
return _instruments
|
26
|
+
|
27
|
+
def _instrument(self, **kwargs):
|
28
|
+
application_name = kwargs.get("application_name", "default_application")
|
29
|
+
environment = kwargs.get("environment", "default_environment")
|
30
|
+
tracer = kwargs.get("tracer")
|
31
|
+
metrics = kwargs.get("metrics_dict")
|
32
|
+
pricing_info = kwargs.get("pricing_info", {})
|
33
|
+
trace_content = kwargs.get("trace_content", False)
|
34
|
+
disable_metrics = kwargs.get("disable_metrics")
|
35
|
+
version = importlib.metadata.version("azure-ai-inference")
|
36
|
+
|
37
|
+
# sync generate
|
38
|
+
wrap_function_wrapper(
|
39
|
+
"azure.ai.inference",
|
40
|
+
"ChatCompletionsClient.complete",
|
41
|
+
complete("azure_ai.complete", version, environment, application_name,
|
42
|
+
tracer, pricing_info, trace_content, metrics, disable_metrics),
|
43
|
+
)
|
44
|
+
|
45
|
+
# sync embedding
|
46
|
+
wrap_function_wrapper(
|
47
|
+
"azure.ai.inference",
|
48
|
+
"EmbeddingsClient.embed",
|
49
|
+
embedding("azure_ai.embed", version, environment, application_name,
|
50
|
+
tracer, pricing_info, trace_content, metrics, disable_metrics),
|
51
|
+
)
|
52
|
+
|
53
|
+
# async generate
|
54
|
+
wrap_function_wrapper(
|
55
|
+
"azure.ai.inference.aio",
|
56
|
+
"ChatCompletionsClient.complete",
|
57
|
+
async_complete("azure_ai.complete", version, environment, application_name,
|
58
|
+
tracer, pricing_info, trace_content, metrics, disable_metrics),
|
59
|
+
)
|
60
|
+
|
61
|
+
# async embedding
|
62
|
+
wrap_function_wrapper(
|
63
|
+
"azure.ai.inference.aio",
|
64
|
+
"EmbeddingsClient.embed",
|
65
|
+
async_embedding("azure_ai.embed", version, environment, application_name,
|
66
|
+
tracer, pricing_info, trace_content, metrics, disable_metrics),
|
67
|
+
)
|
68
|
+
|
69
|
+
def _uninstrument(self, **kwargs):
|
70
|
+
# Proper uninstrumentation logic to revert patched methods
|
71
|
+
pass
|