openlit 1.13.0__tar.gz → 1.14.0__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.13.0 → openlit-1.14.0}/PKG-INFO +4 -1
- {openlit-1.13.0 → openlit-1.14.0}/README.md +1 -0
- {openlit-1.13.0 → openlit-1.14.0}/pyproject.toml +3 -1
- {openlit-1.13.0 → openlit-1.14.0}/src/openlit/__init__.py +14 -18
- openlit-1.14.0/src/openlit/instrumentation/gpu/__init__.py +132 -0
- {openlit-1.13.0 → openlit-1.14.0}/src/openlit/semcov/__init__.py +17 -0
- {openlit-1.13.0 → openlit-1.14.0}/LICENSE +0 -0
- {openlit-1.13.0 → openlit-1.14.0}/src/openlit/__helpers.py +0 -0
- {openlit-1.13.0 → openlit-1.14.0}/src/openlit/instrumentation/anthropic/__init__.py +0 -0
- {openlit-1.13.0 → openlit-1.14.0}/src/openlit/instrumentation/anthropic/anthropic.py +0 -0
- {openlit-1.13.0 → openlit-1.14.0}/src/openlit/instrumentation/anthropic/async_anthropic.py +0 -0
- {openlit-1.13.0 → openlit-1.14.0}/src/openlit/instrumentation/bedrock/__init__.py +0 -0
- {openlit-1.13.0 → openlit-1.14.0}/src/openlit/instrumentation/bedrock/bedrock.py +0 -0
- {openlit-1.13.0 → openlit-1.14.0}/src/openlit/instrumentation/chroma/__init__.py +0 -0
- {openlit-1.13.0 → openlit-1.14.0}/src/openlit/instrumentation/chroma/chroma.py +0 -0
- {openlit-1.13.0 → openlit-1.14.0}/src/openlit/instrumentation/cohere/__init__.py +0 -0
- {openlit-1.13.0 → openlit-1.14.0}/src/openlit/instrumentation/cohere/cohere.py +0 -0
- {openlit-1.13.0 → openlit-1.14.0}/src/openlit/instrumentation/embedchain/__init__.py +0 -0
- {openlit-1.13.0 → openlit-1.14.0}/src/openlit/instrumentation/embedchain/embedchain.py +0 -0
- {openlit-1.13.0 → openlit-1.14.0}/src/openlit/instrumentation/gpt4all/__init__.py +0 -0
- {openlit-1.13.0 → openlit-1.14.0}/src/openlit/instrumentation/gpt4all/gpt4all.py +0 -0
- {openlit-1.13.0 → openlit-1.14.0}/src/openlit/instrumentation/groq/__init__.py +0 -0
- {openlit-1.13.0 → openlit-1.14.0}/src/openlit/instrumentation/groq/async_groq.py +0 -0
- {openlit-1.13.0 → openlit-1.14.0}/src/openlit/instrumentation/groq/groq.py +0 -0
- {openlit-1.13.0 → openlit-1.14.0}/src/openlit/instrumentation/haystack/__init__.py +0 -0
- {openlit-1.13.0 → openlit-1.14.0}/src/openlit/instrumentation/haystack/haystack.py +0 -0
- {openlit-1.13.0 → openlit-1.14.0}/src/openlit/instrumentation/langchain/__init__.py +0 -0
- {openlit-1.13.0 → openlit-1.14.0}/src/openlit/instrumentation/langchain/langchain.py +0 -0
- {openlit-1.13.0 → openlit-1.14.0}/src/openlit/instrumentation/llamaindex/__init__.py +0 -0
- {openlit-1.13.0 → openlit-1.14.0}/src/openlit/instrumentation/llamaindex/llamaindex.py +0 -0
- {openlit-1.13.0 → openlit-1.14.0}/src/openlit/instrumentation/milvus/__init__.py +0 -0
- {openlit-1.13.0 → openlit-1.14.0}/src/openlit/instrumentation/milvus/milvus.py +0 -0
- {openlit-1.13.0 → openlit-1.14.0}/src/openlit/instrumentation/mistral/__init__.py +0 -0
- {openlit-1.13.0 → openlit-1.14.0}/src/openlit/instrumentation/mistral/async_mistral.py +0 -0
- {openlit-1.13.0 → openlit-1.14.0}/src/openlit/instrumentation/mistral/mistral.py +0 -0
- {openlit-1.13.0 → openlit-1.14.0}/src/openlit/instrumentation/ollama/__init__.py +0 -0
- {openlit-1.13.0 → openlit-1.14.0}/src/openlit/instrumentation/ollama/async_ollama.py +0 -0
- {openlit-1.13.0 → openlit-1.14.0}/src/openlit/instrumentation/ollama/ollama.py +0 -0
- {openlit-1.13.0 → openlit-1.14.0}/src/openlit/instrumentation/openai/__init__.py +0 -0
- {openlit-1.13.0 → openlit-1.14.0}/src/openlit/instrumentation/openai/async_azure_openai.py +0 -0
- {openlit-1.13.0 → openlit-1.14.0}/src/openlit/instrumentation/openai/async_openai.py +0 -0
- {openlit-1.13.0 → openlit-1.14.0}/src/openlit/instrumentation/openai/azure_openai.py +0 -0
- {openlit-1.13.0 → openlit-1.14.0}/src/openlit/instrumentation/openai/openai.py +0 -0
- {openlit-1.13.0 → openlit-1.14.0}/src/openlit/instrumentation/pinecone/__init__.py +0 -0
- {openlit-1.13.0 → openlit-1.14.0}/src/openlit/instrumentation/pinecone/pinecone.py +0 -0
- {openlit-1.13.0 → openlit-1.14.0}/src/openlit/instrumentation/qdrant/__init__.py +0 -0
- {openlit-1.13.0 → openlit-1.14.0}/src/openlit/instrumentation/qdrant/qdrant.py +0 -0
- {openlit-1.13.0 → openlit-1.14.0}/src/openlit/instrumentation/transformers/__init__.py +0 -0
- {openlit-1.13.0 → openlit-1.14.0}/src/openlit/instrumentation/transformers/transformers.py +0 -0
- {openlit-1.13.0 → openlit-1.14.0}/src/openlit/instrumentation/vertexai/__init__.py +0 -0
- {openlit-1.13.0 → openlit-1.14.0}/src/openlit/instrumentation/vertexai/async_vertexai.py +0 -0
- {openlit-1.13.0 → openlit-1.14.0}/src/openlit/instrumentation/vertexai/vertexai.py +0 -0
- {openlit-1.13.0 → openlit-1.14.0}/src/openlit/otel/metrics.py +0 -0
- {openlit-1.13.0 → openlit-1.14.0}/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.14.0
|
4
4
|
Summary: OpenTelemetry-native Auto instrumentation library for monitoring LLM Applications, 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
|
@@ -14,11 +14,13 @@ Classifier: Programming Language :: Python :: 3.11
|
|
14
14
|
Classifier: Programming Language :: Python :: 3.12
|
15
15
|
Requires-Dist: boto3 (>=1.34.0,<2.0.0)
|
16
16
|
Requires-Dist: botocore (>=1.34.0,<2.0.0)
|
17
|
+
Requires-Dist: gpustat (>=1.1.1,<2.0.0)
|
17
18
|
Requires-Dist: opentelemetry-api (>=1.24.0,<2.0.0)
|
18
19
|
Requires-Dist: opentelemetry-exporter-otlp (>=1.24.0,<2.0.0)
|
19
20
|
Requires-Dist: opentelemetry-instrumentation (>=0.45b0,<0.46)
|
20
21
|
Requires-Dist: opentelemetry-sdk (>=1.24.0,<2.0.0)
|
21
22
|
Requires-Dist: requests (>=2.26.0,<3.0.0)
|
23
|
+
Requires-Dist: schedule (>=1.2.2,<2.0.0)
|
22
24
|
Requires-Dist: tiktoken (>=0.6.0,<0.7.0)
|
23
25
|
Project-URL: Repository, https://github.com/openlit/openlit/tree/main/openlit/python
|
24
26
|
Description-Content-Type: text/markdown
|
@@ -185,6 +187,7 @@ Below is a detailed overview of the configuration options available, allowing yo
|
|
185
187
|
| `disabled_instrumentors`| List of instrumentors to disable. | `None` | No |
|
186
188
|
| `disable_metrics` | If set, disables the collection of metrics. | `False` | No |
|
187
189
|
| `pricing_json` | URL or file path of the pricing JSON file. | `https://github.com/openlit/openlit/blob/main/assets/pricing.json` | No |
|
190
|
+
| `collect_gpu_stats` | Flag to enable or disable GPU metrics collection. | `False` | No |
|
188
191
|
|
189
192
|
## 🌱 Contributing
|
190
193
|
|
@@ -160,6 +160,7 @@ Below is a detailed overview of the configuration options available, allowing yo
|
|
160
160
|
| `disabled_instrumentors`| List of instrumentors to disable. | `None` | No |
|
161
161
|
| `disable_metrics` | If set, disables the collection of metrics. | `False` | No |
|
162
162
|
| `pricing_json` | URL or file path of the pricing JSON file. | `https://github.com/openlit/openlit/blob/main/assets/pricing.json` | No |
|
163
|
+
| `collect_gpu_stats` | Flag to enable or disable GPU metrics collection. | `False` | No |
|
163
164
|
|
164
165
|
## 🌱 Contributing
|
165
166
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
[tool.poetry]
|
2
2
|
name = "openlit"
|
3
|
-
version = "1.
|
3
|
+
version = "1.14.0"
|
4
4
|
description = "OpenTelemetry-native Auto instrumentation library for monitoring LLM Applications, 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"
|
@@ -11,7 +11,9 @@ keywords = ["OpenTelemetry", "otel", "otlp","llm", "tracing", "openai", "anthrop
|
|
11
11
|
[tool.poetry.dependencies]
|
12
12
|
python = "^3.7.1"
|
13
13
|
requests = "^2.26.0"
|
14
|
+
schedule = "^1.2.2"
|
14
15
|
tiktoken = "^0.6.0"
|
16
|
+
gpustat = "^1.1.1"
|
15
17
|
boto3 = "^1.34.0"
|
16
18
|
botocore = "^1.34.0"
|
17
19
|
opentelemetry-api = "^1.24.0"
|
@@ -40,6 +40,7 @@ from openlit.instrumentation.pinecone import PineconeInstrumentor
|
|
40
40
|
from openlit.instrumentation.qdrant import QdrantInstrumentor
|
41
41
|
from openlit.instrumentation.milvus import MilvusInstrumentor
|
42
42
|
from openlit.instrumentation.transformers import TransformersInstrumentor
|
43
|
+
from openlit.instrumentation.gpu import NvidiaGPUInstrumentor
|
43
44
|
|
44
45
|
# Set up logging for error and information messages.
|
45
46
|
logger = logging.getLogger(__name__)
|
@@ -155,20 +156,9 @@ def instrument_if_available(
|
|
155
156
|
except Exception as e:
|
156
157
|
logger.error("Failed to instrument %s: %s", instrumentor_name, e)
|
157
158
|
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
application_name="default",
|
162
|
-
tracer=None,
|
163
|
-
otlp_endpoint=None,
|
164
|
-
otlp_headers=None,
|
165
|
-
disable_batch=False,
|
166
|
-
trace_content=True,
|
167
|
-
disabled_instrumentors=None,
|
168
|
-
meter=None,
|
169
|
-
disable_metrics=False,
|
170
|
-
pricing_json=None,
|
171
|
-
):
|
159
|
+
def init(environment="default", application_name="default", tracer=None, otlp_endpoint=None,
|
160
|
+
otlp_headers=None, disable_batch=False, trace_content=True, disabled_instrumentors=None,
|
161
|
+
meter=None, disable_metrics=False, pricing_json=None, collect_gpu_stats=False):
|
172
162
|
"""
|
173
163
|
Initializes the openLIT configuration and setups tracing.
|
174
164
|
|
@@ -185,8 +175,9 @@ def init(
|
|
185
175
|
disable_batch (bool): Flag to disable batch span processing (Optional).
|
186
176
|
trace_content (bool): Flag to trace content (Optional).
|
187
177
|
disabled_instrumentors (List[str]): Optional. List of instrumentor names to disable.
|
188
|
-
disable_metrics (bool): Flag to disable metrics (Optional)
|
189
|
-
pricing_json(str): File path or url to the pricing json (Optional)
|
178
|
+
disable_metrics (bool): Flag to disable metrics (Optional).
|
179
|
+
pricing_json(str): File path or url to the pricing json (Optional).
|
180
|
+
collect_gpu_stats (bool): Flag to enable or disable GPU metrics collection.
|
190
181
|
"""
|
191
182
|
disabled_instrumentors = disabled_instrumentors if disabled_instrumentors else []
|
192
183
|
# Check for invalid instrumentor names
|
@@ -289,8 +280,13 @@ def init(
|
|
289
280
|
|
290
281
|
# Initialize and instrument only the enabled instrumentors
|
291
282
|
for name, instrumentor in instrumentor_instances.items():
|
292
|
-
instrument_if_available(
|
293
|
-
|
283
|
+
instrument_if_available(name, instrumentor, config,
|
284
|
+
disabled_instrumentors, module_name_map)
|
285
|
+
|
286
|
+
if (disable_metrics is False) and (collect_gpu_stats is True):
|
287
|
+
NvidiaGPUInstrumentor().instrument(
|
288
|
+
environment=config.environment,
|
289
|
+
application_name=config.application_name,
|
294
290
|
)
|
295
291
|
|
296
292
|
except Exception as e:
|
@@ -0,0 +1,132 @@
|
|
1
|
+
# pylint: disable=useless-return, bad-staticmethod-argument, duplicate-code, import-outside-toplevel, broad-exception-caught, unused-argument
|
2
|
+
"""Initializer of Auto Instrumentation of GPU Metrics"""
|
3
|
+
|
4
|
+
from typing import Collection, Iterable
|
5
|
+
import logging
|
6
|
+
from functools import partial
|
7
|
+
|
8
|
+
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
|
9
|
+
from opentelemetry.sdk.resources import TELEMETRY_SDK_NAME
|
10
|
+
from opentelemetry.metrics import get_meter, CallbackOptions, Observation
|
11
|
+
|
12
|
+
from openlit.semcov import SemanticConvetion
|
13
|
+
|
14
|
+
# Initialize logger for logging potential issues and operations
|
15
|
+
logger = logging.getLogger(__name__)
|
16
|
+
|
17
|
+
class NvidiaGPUInstrumentor(BaseInstrumentor):
|
18
|
+
"""
|
19
|
+
An instrumentor for collecting NVIDIA GPU metrics.
|
20
|
+
"""
|
21
|
+
|
22
|
+
def instrumentation_dependencies(self) -> Collection[str]:
|
23
|
+
return []
|
24
|
+
|
25
|
+
def _instrument(self, **kwargs):
|
26
|
+
|
27
|
+
application_name = kwargs.get("application_name", "default")
|
28
|
+
environment = kwargs.get("environment", "default")
|
29
|
+
|
30
|
+
meter = get_meter(
|
31
|
+
__name__,
|
32
|
+
"0.1.0",
|
33
|
+
schema_url="https://opentelemetry.io/schemas/1.11.0",
|
34
|
+
)
|
35
|
+
|
36
|
+
def check_and_record(value):
|
37
|
+
return value if value is not None else 0
|
38
|
+
|
39
|
+
meter.create_observable_gauge(
|
40
|
+
name=SemanticConvetion.GPU_UTILIZATION,
|
41
|
+
callbacks=[partial(self._collect_metric, environment,
|
42
|
+
application_name, check_and_record, "utilization")],
|
43
|
+
description="GPU Utilization",
|
44
|
+
)
|
45
|
+
meter.create_observable_gauge(
|
46
|
+
name=SemanticConvetion.GPU_UTILIZATION_ENC,
|
47
|
+
callbacks=[partial(self._collect_metric, environment,
|
48
|
+
application_name, check_and_record, "utilization_enc")],
|
49
|
+
description="GPU Encoder Utilization",
|
50
|
+
)
|
51
|
+
meter.create_observable_gauge(
|
52
|
+
name=SemanticConvetion.GPU_UTILIZATION_DEC,
|
53
|
+
callbacks=[partial(self._collect_metric, environment,
|
54
|
+
application_name, check_and_record, "utilization_dec")],
|
55
|
+
description="GPU Decoder Utilization",
|
56
|
+
)
|
57
|
+
meter.create_observable_gauge(
|
58
|
+
name=SemanticConvetion.GPU_TEMPERATURE,
|
59
|
+
callbacks=[partial(self._collect_metric, environment,
|
60
|
+
application_name, check_and_record, "temperature")],
|
61
|
+
description="GPU Temperature",
|
62
|
+
)
|
63
|
+
meter.create_observable_gauge(
|
64
|
+
name=SemanticConvetion.GPU_FAN_SPEED,
|
65
|
+
callbacks=[partial(self._collect_metric, environment,
|
66
|
+
application_name, check_and_record, "fan_speed")],
|
67
|
+
description="GPU Fan Speed",
|
68
|
+
)
|
69
|
+
meter.create_observable_gauge(
|
70
|
+
name=SemanticConvetion.GPU_MEMORY_AVAILABLE,
|
71
|
+
callbacks=[partial(self._collect_metric, environment,
|
72
|
+
application_name, check_and_record, "memory_available")],
|
73
|
+
description="GPU Memory Available",
|
74
|
+
)
|
75
|
+
meter.create_observable_gauge(
|
76
|
+
name=SemanticConvetion.GPU_MEMORY_TOTAL,
|
77
|
+
callbacks=[partial(self._collect_metric, environment,
|
78
|
+
application_name, check_and_record, "memory_total")],
|
79
|
+
description="GPU Memory Total",
|
80
|
+
)
|
81
|
+
meter.create_observable_gauge(
|
82
|
+
name=SemanticConvetion.GPU_MEMORY_USED,
|
83
|
+
callbacks=[partial(self._collect_metric, environment,
|
84
|
+
application_name, check_and_record, "memory_used")],
|
85
|
+
description="GPU Memory Used",
|
86
|
+
)
|
87
|
+
meter.create_observable_gauge(
|
88
|
+
name=SemanticConvetion.GPU_MEMORY_FREE,
|
89
|
+
callbacks=[partial(self._collect_metric, environment,
|
90
|
+
application_name, check_and_record, "memory_free")],
|
91
|
+
description="GPU Memory Free",
|
92
|
+
)
|
93
|
+
meter.create_observable_gauge(
|
94
|
+
name=SemanticConvetion.GPU_POWER_DRAW,
|
95
|
+
callbacks=[partial(self._collect_metric, environment,
|
96
|
+
application_name, check_and_record, "power_draw")],
|
97
|
+
description="GPU Power Draw",
|
98
|
+
)
|
99
|
+
meter.create_observable_gauge(
|
100
|
+
name=SemanticConvetion.GPU_POWER_LIMIT,
|
101
|
+
callbacks=[partial(self._collect_metric, environment,
|
102
|
+
application_name, check_and_record, "power_limit")],
|
103
|
+
description="GPU Power Limit",
|
104
|
+
)
|
105
|
+
|
106
|
+
def _uninstrument(self, **kwargs):
|
107
|
+
# Proper uninstrumentation logic to revert patched methods
|
108
|
+
pass
|
109
|
+
|
110
|
+
def _collect_metric(self, environment, application_name,
|
111
|
+
check_and_record, metric_name,
|
112
|
+
options: CallbackOptions) -> Iterable[Observation]:
|
113
|
+
|
114
|
+
import gpustat
|
115
|
+
|
116
|
+
try:
|
117
|
+
gpu_stats = gpustat.GPUStatCollection.new_query()
|
118
|
+
|
119
|
+
for gpu in gpu_stats.gpus:
|
120
|
+
attributes = {
|
121
|
+
TELEMETRY_SDK_NAME: "openlit",
|
122
|
+
SemanticConvetion.GEN_AI_APPLICATION_NAME: application_name,
|
123
|
+
SemanticConvetion.GEN_AI_ENVIRONMENT: environment,
|
124
|
+
SemanticConvetion.GPU_INDEX: gpu.index,
|
125
|
+
SemanticConvetion.GPU_UUID: gpu.uuid,
|
126
|
+
SemanticConvetion.GPU_NAME: gpu.name,
|
127
|
+
}
|
128
|
+
|
129
|
+
yield Observation(check_and_record(getattr(gpu, metric_name, 0)), attributes)
|
130
|
+
|
131
|
+
except Exception as e:
|
132
|
+
logger.error("Error in GPU metrics collection: %s", e)
|
@@ -145,3 +145,20 @@ class SemanticConvetion:
|
|
145
145
|
DB_SYSTEM_PINECONE = "pinecone"
|
146
146
|
DB_SYSTEM_QDRANT = "qdrant"
|
147
147
|
DB_SYSTEM_MILVUS = "milvus"
|
148
|
+
|
149
|
+
# GPU
|
150
|
+
GPU_INDEX = "gpu.index"
|
151
|
+
GPU_UUID = "gpu.uuid"
|
152
|
+
GPU_NAME = "gpu.name"
|
153
|
+
|
154
|
+
GPU_UTILIZATION = "gpu.utilization"
|
155
|
+
GPU_UTILIZATION_ENC = "gpu.enc.utilization"
|
156
|
+
GPU_UTILIZATION_DEC = "gpu.dec.utilization"
|
157
|
+
GPU_TEMPERATURE = "gpu.temperature"
|
158
|
+
GPU_FAN_SPEED = "gpu.fan_speed"
|
159
|
+
GPU_MEMORY_AVAILABLE = "gpu.memory.available"
|
160
|
+
GPU_MEMORY_TOTAL = "gpu.memory.total"
|
161
|
+
GPU_MEMORY_USED = "gpu.memory.used"
|
162
|
+
GPU_MEMORY_FREE = "gpu.memory.free"
|
163
|
+
GPU_POWER_DRAW = "gpu.power.draw"
|
164
|
+
GPU_POWER_LIMIT = "gpu.power.limit"
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|