Same agent Smaller bill. The tools and infrastructure to get more work from your AI. Fewer tokens. Less compute. Lower cost.
TypeScript agent-harnessagent-harness-engineeringai-engineeringai-observabilityamd-gpuclaude-codeclickhousecodexcoding-agentcoding-agentscursorgenaigpu-monitoringllm-observabilityllmopsnvidia-smiobservabilityopen-sourceopenaiopentelemetry
[Feat]: OpenTelemetry GPU Collector (#289)
patcher9452a3e63e5a1
diff --git a/.github/workflows/gpu-collector-release.yml b/.github/workflows/gpu-collector-release.ymlnew file mode 100644index 00000000..7c0acf52--- /dev/null+++ b/.github/workflows/gpu-collector-release.yml@@ -0,0 +1,83 @@+name: Release OTel GPU Collector++on:+ push:+ tags: [ 'otel-gpu-collector-*.*.*' ]++env:+ REGISTRY: ghcr.io++permissions:+ contents: write++jobs:+ release:+ name: Docker+ runs-on: ubuntu-latest+ permissions:+ contents: write+ packages: write+ id-token: write+ env:+ IMAGE_NAME: otel-gpu-collector++ steps:+ - name: Checkout repository+ uses: actions/checkout@v4++ - name: Install cosign+ uses: sigstore/cosign-installer@59acb6260d9c0ba8f4a2f9d9b48431a222b68e20 #v3.5.0+ with:+ cosign-release: 'v2.2.2'++ - name: Extract version from tag+ id: extract_version+ run: echo "version=${GITHUB_REF#refs/tags/otel-gpu-collector-}" >> $GITHUB_ENV+ env:+ GITHUB_REF: ${{ github.ref }}++ - name: Set up Docker Buildx+ uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0++ - name: Log into registry ${{ env.REGISTRY }}+ uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # v3.1.0+ with:+ registry: ${{ env.REGISTRY }}+ username: ${{ github.actor }}+ password: ${{ secrets.GITHUB_TOKEN }}++ - name: Extract Docker metadata+ id: meta+ uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1+ with:+ images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}+ tags: |+ type=semver,pattern={{version}},value=${{ env.version }}+ env:+ DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index++ - name: Build and push Docker image+ id: build-and-push+ uses: docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 # v5.4.0+ with:+ context: ./otel-gpu-collector/+ provenance: false+ file: ./otel-gpu-collector/Dockerfile+ push: ${{ github.event_name != 'pull_request' }}+ tags: ${{ steps.meta.outputs.tags }}+ labels: ${{ steps.meta.outputs.labels }}+ platforms: linux/amd64,linux/arm64/v8, linux/arm/v7, linux/386+ annotations: |+ ${{ steps.meta.outputs.annotations }},+ io.artifacthub.package.logo-url=https://github.com/openlit/.github/blob/main/profile/assets/favicon.png?raw=true,+ io.artifacthub.package.readme-url=https://github.com/openlit/openlit/blob/main/otel-gpu-collector/README.md,+ io.artifacthub.package.license=Apache-2.0,+ org.opencontainers.image.vendor=OpenLIT,+ io.artifacthub.package.maintainers=[{'name':'OpenLIT','email':'[email protected]'}],+ io.artifacthub.package.keywords='Monitoring, Observability, GPUs, NVIDIA, OpenTelemetry, Metrics, LLMs, AI'++ - name: Sign the published Docker image+ env:+ TAGS: ${{ steps.meta.outputs.tags }}+ DIGEST: ${{ steps.build-and-push.outputs.digest }}+ run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}diff --git a/.github/workflows/openlit-release.yml b/.github/workflows/openlit-release.ymlindex 2c4f9ff1..b41276f5 100644--- a/.github/workflows/openlit-release.yml+++ b/.github/workflows/openlit-release.yml@@ -39,14 +39,6 @@ jobs:- name: Set up Docker Buildxuses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0- - name: Code Format Check (gofmt)- run: |- if [ -n "$(gofmt -l .)" ]; then- echo "Go code is not formatted:"- gofmt -d .- exit 1- fi-- name: Log into registry ${{ env.REGISTRY }}uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # v3.1.0with:@@ -77,7 +69,7 @@ jobs:platforms: linux/amd64,linux/arm64/v8annotations: |${{ steps.meta.outputs.annotations }},- io.artifacthub.package.logo-url=https://github.com/openlit/.github/blob/main/profile/assets/logo-orange-bg.jpg?raw=true,+ io.artifacthub.package.logo-url=https://github.com/openlit/.github/blob/main/profile/assets/favicon.png?raw=true,io.artifacthub.package.readme-url=https://raw.githubusercontent.com/openlit/openlit/main/README.md,io.artifacthub.package.license=Apache-2.0,org.opencontainers.image.vendor=OpenLIT,diff --git a/docs/latest/features/gpu.mdx b/docs/latest/features/gpu.mdxnew file mode 100644index 00000000..9f55772d--- /dev/null+++ b/docs/latest/features/gpu.mdx@@ -0,0 +1,118 @@+---+title: 'GPU Performance Monitoring'+sidebarTitle: 'GPU Monitoring'+---++OpenLIT uses OpenTelemetry to help you monitor NVIDIA GPUs. This includes tracking GPU metrics like utilization, temperature, memory usage and power consumption.++## Get Started++<CardGroup cols={2}>+ <Card title="Using the SDK" href="#using-the-sdk" icon="file-code">+ Collect and send GPU performance metrics directly from your application to an OpenTelemetry endpoint.+ </Card>+ <Card title="Using the Collector" href="#using-the-collector" icon="robot">+ Install the OpenTelemetry GPU Collector as a Docker container to collect and send GPU performance metrics to an OpenTelemetry endpoint.+ </Card>+</CardGroup>+++<AccordionGroup>+ <Accordion title="Using the SDK">+ <Steps>+ <Step title="Install OpenLIT">+ Open your command line or terminal and run:+ ```shell+ pip install openlit+ ```+ </Step>+ <Step title="Initialize OpenLIT in your Application">+ You can set up OpenLIT in your application using either function arguments directly in your code or by using environment variables.+ <Tabs>+ <Tab title="Setup using function arguments">++ Add the following two lines to your application code:++ ```python+ import openlit++ openlit.init(+ otlp_endpoint="YOUR_OTEL_ENDPOINT", otlp_headers="YOUR_OTEL_HEADERS"+ collect_gpu_stats=True+ )+ ```++ Replace:+ 1. `YOUR_OTEL_ENDPOINT` with the URL of your OpenTelemetry backend, such as `http://127.0.0.1:4318` if you are using OpenLIT and a local OTel Collector.+ </Tab>+ <Tab title="Setup using Environment Variables">++ Add the following two lines to your application code:++ ```python+ import openlit++ openlit.init(collect_gpu_stats=True)+ ```++ Then, configure the your OTLP endpoint using environment variable:+ ```shell+ export OTEL_EXPORTER_OTLP_ENDPOINT = "YOUR_OTEL_ENDPOINT"+ export OTEL_EXPORTER_OTLP_HEADERS= "YOUR_OTEL_HEADERS"+ ```++ Replace:+ 1. `YOUR_OTEL_ENDPOINT` with the URL of your OpenTelemetry backend, such as `http://127.0.0.1:4318` if you are using OpenLIT and a local OTel Collector.+ </Tab>+ </Tabs>+ To send metrics to other Observability tools, refer to the [Connections Guide](/latest/connections/intro).++ For more advanced configurations and application use cases, visit the [OpenLIT Python repository](https://github.com/openlit/openlit/tree/main/sdk/python).+ </Step>+ </Steps>+ </Accordion>+ <Accordion title="Using the Collector">+ <Steps>+ <Step title="Pull `otel-gpu-collector` Docker Image">++ You can quickly start using the OTel GPU Collector by pulling the Docker image:++ ```sh+ docker pull ghcr.io/openlit/otel-gpu-collector:latest+ ```+ </Step>+ <Step title="Run `otel-gpu-collector` Docker container">++ You can quickly start using the OTel GPU Collector by pulling the Docker image:+ Here's a quick example showing how to run the container with the required environment variables:++ ```sh+ docker run --gpus all \+ -e GPU_APPLICATION_NAME='chatbot' \+ -e GPU_ENVIRONMENT='staging' \+ -e OTEL_EXPORTER_OTLP_ENDPOINT="YOUR_OTEL_ENDPOINT" \+ -e OTEL_EXPORTER_OTLP_HEADERS="YOUR_OTEL_HEADERS" \+ ghcr.io/openlit/otel-gpu-collector:latest+ ```++ For more advanced configurations of the collector, visit the [OTel GPU Collector repository](https://github.com/openlit/openlit/tree/main/otel-gpu-collector/).++ </Step>+ </Steps>+ </Accordion>+</AccordionGroup>++<Card title="Collected Metrics" href="/latest/features/metrics#gpu-metrics" icon='table'>+Details on the types of metrics collected and their descriptions.+</Card>++---++<CardGroup cols={2}>+<Card title="Connections" href="/latest/connections/intro" icon='link'>+Connect to your existing Observablity Stack+</Card>+<Card title="SDK configuration" href="/latest/sdk-configuration" icon='file-code'>+Documentation of the configuration options for the OpenLIT SDK.+</Card>+</CardGroup>\ No newline at end of filediff --git a/docs/latest/integrations/anthropic.mdx b/docs/latest/integrations/anthropic.mdxindex 18ac95dd..fa062866 100644--- a/docs/latest/integrations/anthropic.mdx+++ b/docs/latest/integrations/anthropic.mdx@@ -9,7 +9,7 @@ sidebarTitle: 'Anthropic'OpenLIT uses OpenTelemetry Auto-Instrumentation to help you monitor LLM applications built using Anthropic models. This includes tracking performance, token usage, costs, and how users interact with the application.-Auto-instrumentation means you don't have to set up monitoring manually for different LLMs, frameworks, or databases. By simply adding the OpenLIT in your application, all the necessary monitoring configurations are automatically set up.+Auto-instrumentation means you don't have to set up monitoring manually for different LLMs, frameworks, or databases. By simply adding OpenLIT in your application, all the necessary monitoring configurations are automatically set up.The integration is compatible with- Anthropic Python SDK client `>= 0.21.0`@@ -24,7 +24,7 @@ The integration is compatible with```</Step><Step title="Initialize OpenLIT in your Application">- You can set up the OpenLIT in your application using either function arguments directly in your code or by using environment variables.+ You can set up OpenLIT in your application using either function arguments directly in your code or by using environment variables.<Tabs><Tab title="Setup using function arguments">diff --git a/docs/latest/integrations/azure-openai.mdx b/docs/latest/integrations/azure-openai.mdxindex 82a2d0ca..ec3cbcc1 100644--- a/docs/latest/integrations/azure-openai.mdx+++ b/docs/latest/integrations/azure-openai.mdx@@ -9,7 +9,7 @@ sidebarTitle: 'Azure OpenAI'OpenLIT uses OpenTelemetry Auto-Instrumentation to help you monitor LLM applications built using Azure OpenAI models. This includes tracking performance, token usage, costs, and how users interact with the application.-Auto-instrumentation means you don't have to set up monitoring manually for different LLMs, frameworks, or databases. By simply adding the OpenLIT in your application, all the necessary monitoring configurations are automatically set up.+Auto-instrumentation means you don't have to set up monitoring manually for different LLMs, frameworks, or databases. By simply adding OpenLIT in your application, all the necessary monitoring configurations are automatically set up.The integration is compatible with- OpenAI Python SDK client `>=1.13.0`@@ -24,7 +24,7 @@ The integration is compatible with```</Step><Step title="Initialize OpenLIT in your Application">- You can set up the OpenLIT in your application using either function arguments directly in your code or by using environment variables.+ You can set up OpenLIT in your application using either function arguments directly in your code or by using environment variables.<Tabs><Tab title="Setup using function arguments">diff --git a/docs/latest/integrations/bedrock.mdx b/docs/latest/integrations/bedrock.mdxindex 0b5f901f..70a2ed62 100644--- a/docs/latest/integrations/bedrock.mdx+++ b/docs/latest/integrations/bedrock.mdx@@ -9,7 +9,7 @@ sidebarTitle: 'Amazon Bedrock'OpenLIT uses OpenTelemetry Auto-Instrumentation to help you monitor LLM applications built using models from Amazon Bedrock. This includes tracking performance, token usage, costs, and how users interact with the application.-Auto-instrumentation means you don't have to set up monitoring manually for different LLMs, frameworks, or databases. By simply adding the OpenLIT in your application, all the necessary monitoring configurations are automatically set up.+Auto-instrumentation means you don't have to set up monitoring manually for different LLMs, frameworks, or databases. By simply adding OpenLIT in your application, all the necessary monitoring configurations are automatically set up.The integration is compatible with- Boto3 Python SDK client `>= 1.34.93`@@ -24,7 +24,7 @@ The integration is compatible with```</Step><Step title="Initialize OpenLIT in your Application">- You can set up the OpenLIT in your application using either function arguments directly in your code or by using environment variables.+ You can set up OpenLIT in your application using either function arguments directly in your code or by using environment variables.<Tabs><Tab title="Setup using function arguments">diff --git a/docs/latest/integrations/chromadb.mdx b/docs/latest/integrations/chromadb.mdxindex cde2222f..4651f16b 100644--- a/docs/latest/integrations/chromadb.mdx+++ b/docs/latest/integrations/chromadb.mdx@@ -9,7 +9,7 @@ sidebarTitle: 'ChromaDB'OpenLIT uses OpenTelemetry Auto-Instrumentation to help you monitor LLM applications using ChromaDB as the vector store. This includes tracking performance, operation stats and more.-Auto-instrumentation means you don't have to set up monitoring manually for different LLMs, frameworks, or databases. By simply adding the OpenLIT in your application, all the necessary monitoring configurations are automatically set up.+Auto-instrumentation means you don't have to set up monitoring manually for different LLMs, frameworks, or databases. By simply adding OpenLIT in your application, all the necessary monitoring configurations are automatically set up.The integration is compatible with- ChromaDB Python SDK client `>= 0.4.0`@@ -24,7 +24,7 @@ The integration is compatible with```</Step><Step title="Initialize OpenLIT in your Application">- You can set up the OpenLIT in your application using either function arguments directly in your code or by using environment variables.+ You can set up OpenLIT in your application using either function arguments directly in your code or by using environment variables.<Tabs><Tab title="Setup using function arguments">diff --git a/docs/latest/integrations/cohere.mdx b/docs/latest/integrations/cohere.mdxindex bad5702e..b9bdfa94 100644--- a/docs/latest/integrations/cohere.mdx+++ b/docs/latest/integrations/cohere.mdx@@ -9,7 +9,7 @@ sidebarTitle: 'Cohere'OpenLIT uses OpenTelemetry Auto-Instrumentation to help you monitor LLM applications built using Cohere models. This includes tracking performance, token usage, costs, and how users interact with the application.-Auto-instrumentation means you don't have to set up monitoring manually for different LLMs, frameworks, or databases. By simply adding the OpenLIT in your application, all the necessary monitoring configurations are automatically set up.+Auto-instrumentation means you don't have to set up monitoring manually for different LLMs, frameworks, or databases. By simply adding OpenLIT in your application, all the necessary monitoring configurations are automatically set up.The integration is compatible with- Cohere Python SDK client `>= 5.3.0`@@ -24,7 +24,7 @@ The integration is compatible with```</Step><Step title="Initialize OpenLIT in your Application">- You can set up the OpenLIT in your application using either function arguments directly in your code or by using environment variables.+ You can set up OpenLIT in your application using either function arguments directly in your code or by using environment variables.<Tabs><Tab title="Setup using function arguments">diff --git a/docs/latest/integrations/embedchain.mdx b/docs/latest/integrations/embedchain.mdxindex 98127f8e..32056c2e 100644--- a/docs/latest/integrations/embedchain.mdx+++ b/docs/latest/integrations/embedchain.mdx@@ -9,7 +9,7 @@ sidebarTitle: 'EmbedChain'OpenLIT uses OpenTelemetry Auto-Instrumentation to help you monitor LLM applications built using EmbedChain. This includes tracking performance and operation stats.-Auto-instrumentation means you don't have to set up monitoring manually for different LLMs, frameworks, or databases. By simply adding the OpenLIT in your application, all the necessary monitoring configurations are automatically set up.+Auto-instrumentation means you don't have to set up monitoring manually for different LLMs, frameworks, or databases. By simply adding OpenLIT in your application, all the necessary monitoring configurations are automatically set up.The integration is compatible with- EmbedChain Python SDK client `>= 0.1.104`@@ -24,7 +24,7 @@ The integration is compatible with```</Step><Step title="Initialize OpenLIT in your Application">- You can set up the OpenLIT in your application using either function arguments directly in your code or by using environment variables.+ You can set up OpenLIT in your application using either function arguments directly in your code or by using environment variables.<Tabs><Tab title="Setup using function arguments">diff --git a/docs/latest/integrations/gpt4all.mdx b/docs/latest/integrations/gpt4all.mdxindex 30e32b5d..27c1d142 100644--- a/docs/latest/integrations/gpt4all.mdx+++ b/docs/latest/integrations/gpt4all.mdx@@ -9,7 +9,7 @@ sidebarTitle: 'GPT4All'OpenLIT uses OpenTelemetry Auto-Instrumentation to help you monitor LLM applications built using models from GPT4All. This includes tracking performance, token usage, and how users interact with the application.-Auto-instrumentation means you don't have to set up monitoring manually for different LLMs, frameworks, or databases. By simply adding the OpenLIT in your application, all the necessary monitoring configurations are automatically set up.+Auto-instrumentation means you don't have to set up monitoring manually for different LLMs, frameworks, or databases. By simply adding OpenLIT in your application, all the necessary monitoring configurations are automatically set up.The integration is compatible with- GPT4All Python SDK client `>=2.6.0`@@ -24,7 +24,7 @@ The integration is compatible with```</Step><Step title="Initialize OpenLIT in your Application">- You can set up the OpenLIT in your application using either function arguments directly in your code or by using environment variables.+ You can set up OpenLIT in your application using either function arguments directly in your code or by using environment variables.<Tabs><Tab title="Setup using function arguments">diff --git a/docs/latest/integrations/groq.mdx b/docs/latest/integrations/groq.mdxindex 9bbf010e..aef5f798 100644--- a/docs/latest/integrations/groq.mdx+++ b/docs/latest/integrations/groq.mdx@@ -9,7 +9,7 @@ sidebarTitle: 'Groq'OpenLIT uses OpenTelemetry Auto-Instrumentation to help you monitor LLM applications built using models from Groq. This includes tracking performance, token usage, costs, and how users interact with the application.-Auto-instrumentation means you don't have to set up monitoring manually for different LLMs, frameworks, or databases. By simply adding the OpenLIT in your application, all the necessary monitoring configurations are automatically set up.+Auto-instrumentation means you don't have to set up monitoring manually for different LLMs, frameworks, or databases. By simply adding OpenLIT in your application, all the necessary monitoring configurations are automatically set up.The integration is compatible with- Groq Python SDK client `>= 0.5.0`@@ -24,7 +24,7 @@ The integration is compatible with```</Step><Step title="Initialize OpenLIT in your Application">- You can set up the OpenLIT in your application using either function arguments directly in your code or by using environment variables.+ You can set up OpenLIT in your application using either function arguments directly in your code or by using environment variables.<Tabs><Tab title="Setup using function arguments">diff --git a/docs/latest/integrations/haystack.mdx b/docs/latest/integrations/haystack.mdxindex efe98b16..19a922ae 100644--- a/docs/latest/integrations/haystack.mdx+++ b/docs/latest/integrations/haystack.mdx@@ -9,7 +9,7 @@ sidebarTitle: 'Haystack'OpenLIT uses OpenTelemetry Auto-Instrumentation to help you monitor LLM applications built using Haystack. This includes tracking performance and operation stats.-Auto-instrumentation means you don't have to set up monitoring manually for different LLMs, frameworks, or databases. By simply adding the OpenLIT in your application, all the necessary monitoring configurations are automatically set up.+Auto-instrumentation means you don't have to set up monitoring manually for different LLMs, frameworks, or databases. By simply adding OpenLIT in your application, all the necessary monitoring configurations are automatically set up.## Get Started@@ -21,7 +21,7 @@ Auto-instrumentation means you don't have to set up monitoring manually for diff```</Step><Step title="Initialize OpenLIT in your Application">- You can set up the OpenLIT in your application using either function arguments directly in your code or by using environment variables.+ You can set up OpenLIT in your application using either function arguments directly in your code or by using environment variables.<Tabs><Tab title="Setup using function arguments">diff --git a/docs/latest/integrations/huggingface.mdx b/docs/latest/integrations/huggingface.mdxindex 18275019..5a2d7e00 100644--- a/docs/latest/integrations/huggingface.mdx+++ b/docs/latest/integrations/huggingface.mdx@@ -9,7 +9,7 @@ sidebarTitle: 'HuggingFace'OpenLIT uses OpenTelemetry Auto-Instrumentation to help you monitor LLM applications built using models from HuggingFace. This includes tracking performance, token usage, costs, and how users interact with the application.-Auto-instrumentation means you don't have to set up monitoring manually for different LLMs, frameworks, or databases. By simply adding the OpenLIT in your application, all the necessary monitoring configurations are automatically set up.+Auto-instrumentation means you don't have to set up monitoring manually for different LLMs, frameworks, or databases. By simply adding OpenLIT in your application, all the necessary monitoring configurations are automatically set up.The integration is compatible with- HuggingFace Trasnformers Python SDK client `>= 4.39.3`@@ -24,7 +24,7 @@ The integration is compatible with```</Step><Step title="Initialize OpenLIT in your Application">- You can set up the OpenLIT in your application using either function arguments directly in your code or by using environment variables.+ You can set up OpenLIT in your application using either function arguments directly in your code or by using environment variables.<Tabs><Tab title="Setup using function arguments">diff --git a/docs/latest/integrations/langchain.mdx b/docs/latest/integrations/langchain.mdxindex 9bece21f..af3050df 100644--- a/docs/latest/integrations/langchain.mdx+++ b/docs/latest/integrations/langchain.mdx@@ -9,7 +9,7 @@ sidebarTitle: 'LangChain'OpenLIT uses OpenTelemetry Auto-Instrumentation to help you monitor LLM applications built using LangChain. This includes tracking performance and operation stats.-Auto-instrumentation means you don't have to set up monitoring manually for different LLMs, frameworks, or databases. By simply adding the OpenLIT in your application, all the necessary monitoring configurations are automatically set up.+Auto-instrumentation means you don't have to set up monitoring manually for different LLMs, frameworks, or databases. By simply adding OpenLIT in your application, all the necessary monitoring configurations are automatically set up.The integration is compatible with- LangChain Python SDK client `>= 0.1.1`@@ -24,7 +24,7 @@ The integration is compatible with```</Step><Step title="Initialize OpenLIT in your Application">- You can set up the OpenLIT in your application using either function arguments directly in your code or by using environment variables.+ You can set up OpenLIT in your application using either function arguments directly in your code or by using environment variables.<Tabs><Tab title="Setup using function arguments">diff --git a/docs/latest/integrations/litellm.mdx b/docs/latest/integrations/litellm.mdxindex 61e15b64..33f69137 100644--- a/docs/latest/integrations/litellm.mdx+++ b/docs/latest/integrations/litellm.mdx@@ -9,7 +9,7 @@ sidebarTitle: 'LiteLLM'OpenLIT uses OpenTelemetry Auto-Instrumentation to help you monitor LLM applications built using LiteLLM. This includes tracking performance and operation stats.-Auto-instrumentation means you don't have to set up monitoring manually for different LLMs, frameworks, or databases. By simply adding the OpenLIT in your application, all the necessary monitoring configurations are automatically set up.+Auto-instrumentation means you don't have to set up monitoring manually for different LLMs, frameworks, or databases. By simply adding OpenLIT in your application, all the necessary monitoring configurations are automatically set up.## Get Started@@ -21,7 +21,7 @@ Auto-instrumentation means you don't have to set up monitoring manually for diff```</Step><Step title="Initialize OpenLIT in your Application">- You can set up the OpenLIT in your application using either function arguments directly in your code or by using environment variables.+ You can set up OpenLIT in your application using either function arguments directly in your code or by using environment variables.<Tabs><Tab title="Setup using function arguments">diff --git a/docs/latest/integrations/llama-index.mdx b/docs/latest/integrations/llama-index.mdxindex c7018fdf..2e950040 100644--- a/docs/latest/integrations/llama-index.mdx+++ b/docs/latest/integrations/llama-index.mdx@@ -9,7 +9,7 @@ sidebarTitle: 'LlamaIndex'OpenLIT uses OpenTelemetry Auto-Instrumentation to help you monitor LLM applications built using LlamaIndex. This includes tracking performance and operation stats.-Auto-instrumentation means you don't have to set up monitoring manually for different LLMs, frameworks, or databases. By simply adding the OpenLIT in your application, all the necessary monitoring configurations are automatically set up.+Auto-instrumentation means you don't have to set up monitoring manually for different LLMs, frameworks, or databases. By simply adding OpenLIT in your application, all the necessary monitoring configurations are automatically set up.## Get Started@@ -21,7 +21,7 @@ Auto-instrumentation means you don't have to set up monitoring manually for diff```</Step><Step title="Initialize OpenLIT in your Application">- You can set up the OpenLIT in your application using either function arguments directly in your code or by using environment variables.+ You can set up OpenLIT in your application using either function arguments directly in your code or by using environment variables.<Tabs><Tab title="Setup using function arguments">diff --git a/docs/latest/integrations/milvus.mdx b/docs/latest/integrations/milvus.mdxindex b84b160e..a690d212 100644--- a/docs/latest/integrations/milvus.mdx+++ b/docs/latest/integrations/milvus.mdx@@ -9,7 +9,7 @@ sidebarTitle: 'Milvus'OpenLIT uses OpenTelemetry Auto-Instrumentation to help you monitor LLM applications using Milvus as the vector store. This includes tracking performance, operation stats and more.-Auto-instrumentation means you don't have to set up monitoring manually for different LLMs, frameworks, or databases. By simply adding the OpenLIT in your application, all the necessary monitoring configurations are automatically set up.+Auto-instrumentation means you don't have to set up monitoring manually for different LLMs, frameworks, or databases. By simply adding OpenLIT in your application, all the necessary monitoring configurations are automatically set up.The integration is compatible with- Milvus Python SDK client `>= 2.4.3`@@ -24,7 +24,7 @@ The integration is compatible with```</Step><Step title="Initialize OpenLIT in your Application">- You can set up the OpenLIT in your application using either function arguments directly in your code or by using environment variables.+ You can set up OpenLIT in your application using either function arguments directly in your code or by using environment variables.<Tabs><Tab title="Setup using function arguments">diff --git a/docs/latest/integrations/mistral.mdx b/docs/latest/integrations/mistral.mdxindex eb28b5e5..f5e32d6e 100644--- a/docs/latest/integrations/mistral.mdx+++ b/docs/latest/integrations/mistral.mdx@@ -9,7 +9,7 @@ sidebarTitle: 'Mistral'OpenLIT uses OpenTelemetry Auto-Instrumentation to help you monitor LLM applications built using Mistral models. This includes tracking performance, token usage, costs, and how users interact with the application.-Auto-instrumentation means you don't have to set up monitoring manually for different LLMs, frameworks, or databases. By simply adding the OpenLIT in your application, all the necessary monitoring configurations are automatically set up.+Auto-instrumentation means you don't have to set up monitoring manually for different LLMs, frameworks, or databases. By simply adding OpenLIT in your application, all the necessary monitoring configurations are automatically set up.The integration is compatible with- Mistral Python SDK client `>= 0.1.0`@@ -24,7 +24,7 @@ The integration is compatible with```</Step><Step title="Initialize OpenLIT in your Application">- You can set up the OpenLIT in your application using either function arguments directly in your code or by using environment variables.+ You can set up OpenLIT in your application using either function arguments directly in your code or by using environment variables.<Tabs><Tab title="Setup using function arguments">diff --git a/docs/latest/integrations/nvidia-gpu.mdx b/docs/latest/integrations/nvidia-gpu.mdxindex 73c11fb6..36b052b1 100644--- a/docs/latest/integrations/nvidia-gpu.mdx+++ b/docs/latest/integrations/nvidia-gpu.mdx@@ -9,60 +9,107 @@ sidebarTitle: 'NVIDIA GPUs'OpenLIT uses OpenTelemetry to help you monitor NVIDIA GPUs. This includes tracking GPU metrics like utilization, temperature, memory usage and power consumption.-Auto-instrumentation means you don't have to set up monitoring manually. By simply adding the OpenLIT in your application, all the necessary monitoring configurations are automatically set up for you.## Get Started-<Steps>- <Step title="Install OpenLIT">- Open your command line or terminal and run:- ```shell- pip install openlit- ```- </Step>- <Step title="Initialize OpenLIT in your Application">- You can set up the OpenLIT in your application using either function arguments directly in your code or by using environment variables.- <Tabs>- <Tab title="Setup using function arguments">-- Add the following two lines to your application code:-- ```python- import openlit-- openlit.init(- otlp_endpoint="YOUR_OTEL_ENDPOINT",- collect_gpu_stats=True- )- ```-- Replace:- 1. `YOUR_OTEL_ENDPOINT` with the URL of your OpenTelemetry backend, such as `http://127.0.0.1:4318` if you are using OpenLIT and a local OTel Collector.- </Tab>- <Tab title="Setup using Environment Variables">-- Add the following two lines to your application code:-- ```python- import openlit-- openlit.init(collect_gpu_stats=True)- ```-- Then, configure the your OTLP endpoint using environment variable:- ```shell- export OTEL_EXPORTER_OTLP_ENDPOINT = "YOUR_OTEL_ENDPOINT"- ```-- Replace:- 1. `YOUR_OTEL_ENDPOINT` with the URL of your OpenTelemetry backend, such as `http://127.0.0.1:4318` if you are using OpenLIT and a local OTel Collector.- </Tab>- </Tabs>- To send metrics to other Observability tools, refer to the [Connections Guide](/latest/connections/intro).-- For more advanced configurations and application use cases, visit the [OpenLIT Python repository](https://github.com/openlit/openlit/tree/main/sdk/python).- </Step>-</Steps>+<CardGroup cols={2}>+ <Card title="Using the SDK" href="#using-the-sdk" icon="file-code">+ Collect and send GPU performance metrics directly from your application to an OpenTelemetry endpoint.+ </Card>+ <Card title="Using the Collector" href="#using-the-collector" icon="robot">+ Install the OpenTelemetry GPU Collector as a Docker container to collect and send GPU performance metrics to an OpenTelemetry endpoint.+ </Card>+</CardGroup>+++<AccordionGroup>+ <Accordion title="Using the SDK">+ <Steps>+ <Step title="Install OpenLIT">+ Open your command line or terminal and run:+ ```shell+ pip install openlit+ ```+ </Step>+ <Step title="Initialize OpenLIT in your Application">+ You can set up OpenLIT in your application using either function arguments directly in your code or by using environment variables.+ <Tabs>+ <Tab title="Setup using function arguments">++ Add the following two lines to your application code:++ ```python+ import openlit++ openlit.init(+ otlp_endpoint="YOUR_OTEL_ENDPOINT", otlp_headers="YOUR_OTEL_HEADERS"+ collect_gpu_stats=True+ )+ ```++ Replace:+ 1. `YOUR_OTEL_ENDPOINT` with the URL of your OpenTelemetry backend, such as `http://127.0.0.1:4318` if you are using OpenLIT and a local OTel Collector.+ </Tab>+ <Tab title="Setup using Environment Variables">++ Add the following two lines to your application code:++ ```python+ import openlit++ openlit.init(collect_gpu_stats=True)+ ```++ Then, configure the your OTLP endpoint using environment variable:+ ```shell+ export OTEL_EXPORTER_OTLP_ENDPOINT = "YOUR_OTEL_ENDPOINT"+ export OTEL_EXPORTER_OTLP_HEADERS= "YOUR_OTEL_HEADERS"+ ```++ Replace:+ 1. `YOUR_OTEL_ENDPOINT` with the URL of your OpenTelemetry backend, such as `http://127.0.0.1:4318` if you are using OpenLIT and a local OTel Collector.+ </Tab>+ </Tabs>+ To send metrics to other Observability tools, refer to the [Connections Guide](/latest/connections/intro).++ For more advanced configurations and application use cases, visit the [OpenLIT Python repository](https://github.com/openlit/openlit/tree/main/sdk/python).+ </Step>+ </Steps>+ </Accordion>+ <Accordion title="Using the Collector">+ <Steps>+ <Step title="Pull `otel-gpu-collector` Docker Image">++ You can quickly start using the OTel GPU Collector by pulling the Docker image:++ ```sh+ docker pull ghcr.io/openlit/otel-gpu-collector:latest+ ```+ </Step>+ <Step title="Run `otel-gpu-collector` Docker container">++ You can quickly start using the OTel GPU Collector by pulling the Docker image:+ Here's a quick example showing how to run the container with the required environment variables:++ ```sh+ docker run --gpus all \+ -e GPU_APPLICATION_NAME='chatbot' \+ -e GPU_ENVIRONMENT='staging' \+ -e OTEL_EXPORTER_OTLP_ENDPOINT="YOUR_OTEL_ENDPOINT" \+ -e OTEL_EXPORTER_OTLP_HEADERS="YOUR_OTEL_HEADERS" \+ ghcr.io/openlit/otel-gpu-collector:latest+ ```++ For more advanced configurations of the collector, visit the [OTel GPU Collector repository](https://github.com/openlit/openlit/tree/main/otel-gpu-collector/).++ </Step>+ </Steps>+ </Accordion>+</AccordionGroup>++<Card title="Collected Metrics" href="/latest/features/metrics#gpu-metrics" icon='table'>+Details on the types of metrics collected and their descriptions.+</Card>---diff --git a/docs/latest/integrations/ollama.mdx b/docs/latest/integrations/ollama.mdxindex 2c2942a2..90a9f88b 100644--- a/docs/latest/integrations/ollama.mdx+++ b/docs/latest/integrations/ollama.mdx@@ -9,7 +9,7 @@ sidebarTitle: 'Ollama'OpenLIT uses OpenTelemetry Auto-Instrumentation to help you monitor LLM applications built using models from Ollama. This includes tracking performance, token usage, and how users interact with the application.-Auto-instrumentation means you don't have to set up monitoring manually for different LLMs, frameworks, or databases. By simply adding the OpenLIT in your application, all the necessary monitoring configurations are automatically set up.+Auto-instrumentation means you don't have to set up monitoring manually for different LLMs, frameworks, or databases. By simply adding OpenLIT in your application, all the necessary monitoring configurations are automatically set up.The integration is compatible with- Ollama Python SDK client `>=0.2.0`@@ -24,7 +24,7 @@ The integration is compatible with```</Step><Step title="Initialize OpenLIT in your Application">- You can set up the OpenLIT in your application using either function arguments directly in your code or by using environment variables.+ You can set up OpenLIT in your application using either function arguments directly in your code or by using environment variables.<Tabs><Tab title="Setup using function arguments">diff --git a/docs/latest/integrations/openai.mdx b/docs/latest/integrations/openai.mdxindex 1e25803e..0b6a413d 100644--- a/docs/latest/integrations/openai.mdx+++ b/docs/latest/integrations/openai.mdx@@ -9,7 +9,7 @@ sidebarTitle: 'OpenAI'OpenLIT uses OpenTelemetry Auto-Instrumentation to help you monitor LLM applications built using OpenAI models. This includes tracking performance, token usage, costs, and how users interact with the application.-Auto-instrumentation means you don't have to set up monitoring manually for different LLMs, frameworks, or databases. By simply adding the OpenLIT in your application, all the necessary monitoring configurations are automatically set up.+Auto-instrumentation means you don't have to set up monitoring manually for different LLMs, frameworks, or databases. By simply adding OpenLIT in your application, all the necessary monitoring configurations are automatically set up.The integration is compatible with- OpenAI Python SDK client `>=1.13.0`@@ -24,7 +24,7 @@ The integration is compatible with```</Step><Step title="Initialize OpenLIT in your Application">- You can set up the OpenLIT in your application using either function arguments directly in your code or by using environment variables.+ You can set up OpenLIT in your application using either function arguments directly in your code or by using environment variables.<Tabs><Tab title="Setup using function arguments">diff --git a/docs/latest/integrations/pinecone.mdx b/docs/latest/integrations/pinecone.mdxindex eee4a555..78e0206e 100644--- a/docs/latest/integrations/pinecone.mdx+++ b/docs/latest/integrations/pinecone.mdx@@ -9,7 +9,7 @@ sidebarTitle: 'Pinecone'OpenLIT uses OpenTelemetry Auto-Instrumentation to help you monitor LLM applications using Pinecone as the vector store. This includes tracking performance, operation stats and more.-Auto-instrumentation means you don't have to set up monitoring manually for different LLMs, frameworks, or databases. By simply adding the OpenLIT in your application, all the necessary monitoring configurations are automatically set up.+Auto-instrumentation means you don't have to set up monitoring manually for different LLMs, frameworks, or databases. By simply adding OpenLIT in your application, all the necessary monitoring configurations are automatically set up.The integration is compatible with- PineCone Python SDK client `>=2.2.0`@@ -24,7 +24,7 @@ The integration is compatible with```</Step><Step title="Initialize OpenLIT in your Application">- You can set up the OpenLIT in your application using either function arguments directly in your code or by using environment variables.+ You can set up OpenLIT in your application using either function arguments directly in your code or by using environment variables.<Tabs><Tab title="Setup using function arguments">diff --git a/docs/latest/integrations/qdrant.mdx b/docs/latest/integrations/qdrant.mdxindex 0c312f30..4a3cfec4 100644--- a/docs/latest/integrations/qdrant.mdx+++ b/docs/latest/integrations/qdrant.mdx@@ -9,7 +9,7 @@ sidebarTitle: 'Qdrant'OpenLIT uses OpenTelemetry Auto-Instrumentation to help you monitor LLM applications using Qdrant as the vector store. This includes tracking performance, operation stats and more.-Auto-instrumentation means you don't have to set up monitoring manually for different LLMs, frameworks, or databases. By simply adding the OpenLIT in your application, all the necessary monitoring configurations are automatically set up.+Auto-instrumentation means you don't have to set up monitoring manually for different LLMs, frameworks, or databases. By simply adding OpenLIT in your application, all the necessary monitoring configurations are automatically set up.The integration is compatible with- Qdrant Python SDK client `>= 1.9.0`@@ -24,7 +24,7 @@ The integration is compatible with```</Step><Step title="Initialize OpenLIT in your Application">- You can set up the OpenLIT in your application using either function arguments directly in your code or by using environment variables.+ You can set up OpenLIT in your application using either function arguments directly in your code or by using environment variables.<Tabs><Tab title="Setup using function arguments">diff --git a/docs/latest/integrations/vertexai.mdx b/docs/latest/integrations/vertexai.mdxindex 7973c736..ff4c41da 100644--- a/docs/latest/integrations/vertexai.mdx+++ b/docs/latest/integrations/vertexai.mdx@@ -9,7 +9,7 @@ sidebarTitle: 'Vertex AI'OpenLIT uses OpenTelemetry Auto-Instrumentation to help you monitor LLM applications built using models from Vertex AI. This includes tracking performance, token usage, costs, and how users interact with the application.-Auto-instrumentation means you don't have to set up monitoring manually for different LLMs, frameworks, or databases. By simply adding the OpenLIT in your application, all the necessary monitoring configurations are automatically set up.+Auto-instrumentation means you don't have to set up monitoring manually for different LLMs, frameworks, or databases. By simply adding OpenLIT in your application, all the necessary monitoring configurations are automatically set up.The integration is compatible with- google-cloud-aiplatform `>= 1.38.1`@@ -24,7 +24,7 @@ The integration is compatible with```</Step><Step title="Initialize OpenLIT in your Application">- You can set up the OpenLIT in your application using either function arguments directly in your code or by using environment variables.+ You can set up OpenLIT in your application using either function arguments directly in your code or by using environment variables.<Tabs><Tab title="Setup using function arguments">diff --git a/docs/mint.json b/docs/mint.jsonindex 644be248..c8bc7cd7 100644--- a/docs/mint.json+++ b/docs/mint.json@@ -113,6 +113,7 @@"pages": ["latest/features/tracing","latest/features/metrics",+ "latest/features/gpu","latest/features/pricing","latest/features/multiple-db"],diff --git a/otel-gpu-collector/README.md b/otel-gpu-collector/README.mdnew file mode 100644index 00000000..1b4e43e2--- /dev/null+++ b/otel-gpu-collector/README.md@@ -0,0 +1,129 @@+<div align="center">+<img src="https://github.com/openlit/.github/blob/main/profile/assets/wide-logo-no-bg.png?raw=true" alt="OpenLIT Logo" width="30%"><h1>+OpenTelemetry GPU Collector</h1>++**[Documentation](https://docs.openlit.io/) | [Quickstart](#-getting-started) | [Python SDK](https://github.com/openlit/openlit/tree/main/sdk/python) | [Metrics](#metrics)**++[](https://github.com/openlit/openlit)+[](https://github.com/openlit/openlit/blob/main/LICENSE)+[](https://github.com/openlit/openlit/pulse)+[](https://github.com/openlit/openlit/graphs/contributors)++[](https://join.slack.com/t/openlit/shared_invite/zt-2etnfttwg-TjP_7BZXfYg84oAukY8QRQ)+[](https://discord.gg/rjvTm6zd)+[](https://twitter.com/openlit_io)++</div>++OpenTelemetry GPU Collector is a lightweight, efficient tool designed to collect GPU performancemetrics and send them to an OpenTelemetry-compatible endpoint for monitoring and observability. This tool is particularly useful for monitoring GPUs in high-performance computing environments, AI/ML tasks, and LLMs.++## Features++- Collects detailed GPU performance metrics+- OpenTelemetry-native+- Lightweight and efficient+- Supports multiple GPU and system architectures++## Quick Start++### Prerequisites++- Docker installed on your GPU system++### Installation++You can quickly start using the OTel GPU Collector by pulling the Docker image:++```sh+docker pull ghcr.io/openlit/otel-gpu-collector:latest+```++### Running the Container++Here's a quick example showing how to run the container with the required environment variables:++```sh+docker run --gpus all \+ -e GPU_APPLICATION_NAME='chatbot' \+ -e GPU_ENVIRONMENT='staging' \+ -e OTEL_EXPORTER_OTLP_ENDPOINT="YOUR_OTEL_ENDPOINT" \+ -e OTEL_EXPORTER_OTLP_HEADERS="YOUR_OTEL_HEADERS" \+ ghcr.io/openlit/otel-gpu-collector:latest+```++### Environment Variables++OTel GPU Collector supports several environment variables for configuration. Below is a table that describes each variable:++| Environment Variable | Description | Default Value |+|---------------------------------|---------------------------------------------------------------|-------------------------|+| `GPU_APPLICATION_NAME` | Name of the application running on the GPU | `default_app` |+| `GPU_ENVIRONMENT` | Environment name (e.g., staging, production) | `production` |+| `OTEL_EXPORTER_OTLP_ENDPOINT` | OpenTelemetry OTLP endpoint URL | (required) |+| `OTEL_EXPORTER_OTLP_HEADERS` | Headers for authenticating with the OTLP endpoint | (required) |++## Alternative: Using OpenLIT SDK++You can also collect GPU metrics directly using the OpenLIT SDK in your Python application. Here’s an example:++```python+import openlit++openlit.init(collect_gpu_stats=True)+```++For more details, check out the [OpenLIT documentation](https://docs.openlit.io/) or the [SDK source code](https://github.com/openlit/openlit/tree/main/sdk/python).++## Metrics++| Metric Name | Description | Unit | Type | Attributes |+|-------------------------------------|------------------------------------------|------------|-------|------------------------------------------------------------------------------------------------------------|+| `gpu.utilization_percentage` | GPU Utilization in percentage | `percent` | Gauge | `telemetry.sdk.name`, `gen_ai.application_name`, `gen_ai.environment`, `gpu_index`, `gpu_name`, `gpu_uuid` |+| `gpu.enc.utilization_percentage` | GPU encoder Utilization in percentage | `percent` | Gauge | `telemetry.sdk.name`, `gen_ai.application_name`, `gen_ai.environment`, `gpu_index`, `gpu_name`, `gpu_uuid` |+| `gpu.dec.utilization_percentage` | GPU decoder Utilization in percentage | `percent` | Gauge | `telemetry.sdk.name`, `gen_ai.application_name`, `gen_ai.environment`, `gpu_index`, `gpu_name`, `gpu_uuid` |+| `gpu.temperature` | GPU Temperature in Celsius | `Celcius` | Gauge | `telemetry.sdk.name`, `gen_ai.application_name`, `gen_ai.environment`, `gpu_index`, `gpu_name`, `gpu_uuid` |+| `gpu.fan_speed` | GPU Fan Speed (0-100) as an integer | `Integer` | Gauge | `telemetry.sdk.name`, `gen_ai.application_name`, `gen_ai.environment`, `gpu_index`, `gpu_name`, `gpu_uuid` |+| `gpu.memory.available` | Available GPU Memory in MB | `MB` | Gauge | `telemetry.sdk.name`, `gen_ai.application_name`, `gen_ai.environment`, `gpu_index`, `gpu_name`, `gpu_uuid` |+| `gpu.memory.total` | Total GPU Memory in MB | `MB` | Gauge | `telemetry.sdk.name`, `gen_ai.application_name`, `gen_ai.environment`, `gpu_index`, `gpu_name`, `gpu_uuid` |+| `gpu.memory.used` | Used GPU Memory in MB | `MB` | Gauge | `telemetry.sdk.name`, `gen_ai.application_name`, `gen_ai.environment`, `gpu_index`, `gpu_name`, `gpu_uuid` |+| `gpu.memory.free` | Free GPU Memory in MB | `MB` | Gauge | `telemetry.sdk.name`, `gen_ai.application_name`, `gen_ai.environment`, `gpu_index`, `gpu_name`, `gpu_uuid` |+| `gpu.power.draw` | GPU Power Draw in Watts | `Watt` | Gauge | `telemetry.sdk.name`, `gen_ai.application_name`, `gen_ai.environment`, `gpu_index`, `gpu_name`, `gpu_uuid` |+| `gpu.power.limit` | GPU Power Limit in Watts | `Watt` | Gauge | `telemetry.sdk.name`, `gen_ai.application_name`, `gen_ai.environment`, `gpu_index`, `gpu_name`, `gpu_uuid` |++## Building the Docker Image++To build the Docker image yourself, you can clone the repository and execute the following commands:++```sh+git clone https://github.com/openlit/openlit.git+cd otel-gpu-collector+docker build -t otel-gpu-collector .+```+++## 🌱 Contributing++Whether it's big or small, we love contributions 💚. Check out our [Contribution guide](../../CONTRIBUTING.md) to get started++Unsure where to start? Here are a few ways to get involved:++- Join our [Slack](https://join.slack.com/t/openlit/shared_invite/zt-2etnfttwg-TjP_7BZXfYg84oAukY8QRQ) or [Discord](https://discord.gg/rjvTm6zd) community to discuss ideas, share feedback, and connect with both our team and the wider OpenLIT community.++Your input helps us grow and improve, and we're here to support you every step of the way.++## 💚 Community & Support++Connect with OpenLIT community and maintainers for support, discussions, and updates:++- 🌟 If you like it, Leave a star on our [GitHub](https://github.com/openlit/openlit/)+- 🌍 Join our [Slack](https://join.slack.com/t/openlit/shared_invite/zt-2etnfttwg-TjP_7BZXfYg84oAukY8QRQ) or [Discord](https://discord.gg/rjvTm6zd) community for live interactions and questions.+- 🐞 Report bugs on our [GitHub Issues](https://github.com/openlit/openlit/issues) to help us improve OpenLIT.+- 𝕏 Follow us on [X](https://twitter.com/openlit_io) for the latest updates and news.++## License++OpenLIT is available under the [Apache-2.0 license](LICENSE).++## Visualize! Analyze! Optimize!++Join us on this voyage to reshape the future of AI Observability. Share your thoughts, suggest features, and explore contributions. Engage with us on [GitHub](https://github.com/openlit/openlit) and be part of OpenLIT's community-led innovation.diff --git a/otel-gpu-collector/collector.py b/otel-gpu-collector/collector.pynew file mode 100644index 00000000..3a17761b--- /dev/null+++ b/otel-gpu-collector/collector.py@@ -0,0 +1,96 @@+import openlit+import os+import logging+import sys+import json+import signal+import time++# Create a JSON logger+class JSONFormatter(logging.Formatter):+ def format(self, record):+ log_record = {+ "level": record.levelname,+ "message": record.getMessage(),+ "timestamp": time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(record.created)),+ "name": record.name,+ "application_name": record.application_name,+ "environment": record.environment+ }+ if record.exc_info:+ log_record["exception"] = self.formatException(record.exc_info)+ return json.dumps(log_record)++# Custom filter to add fixed information to log records+class ContextFilter(logging.Filter):+ def __init__(self, application_name, environment):+ super().__init__()+ self.application_name = application_name+ self.environment = environment++ def filter(self, record):+ record.application_name = self.application_name+ record.environment = self.environment+ return True++def setup_logger(application_name, environment):+ logger = logging.getLogger("otel-gpu-collector")+ logger.setLevel(logging.INFO)++ # Log to stdout+ handler = logging.StreamHandler(sys.stdout)+ handler.setFormatter(JSONFormatter())++ logger.addHandler(handler)++ # Add context filter to logger+ logger.addFilter(ContextFilter(application_name, environment))++ return logger++# Load environment variables+application_name = os.getenv('GPU_APPLICATION_NAME', 'default')+environment = os.getenv('GPU_ENVIRONMENT', 'default')++# Initialize logger+logger = setup_logger(application_name, environment)++# Flag to control the infinite loop+keep_running = True++def signal_handler(sig, frame):+ global keep_running+ logger.info("Received termination signal", extra={"signal": sig})+ keep_running = False++def main():+ logger.info("Starting otel-gpu-collector")++ try:+ # Log environment variables+ logger.info("Environment variables loaded")++ # Initialize OpenLit with provided parameters+ logger.info("Initializing GPU OpenTelemetry Instrumentation library OpenLIT")+ openlit.init(collect_gpu_stats=True, application_name=application_name, environment=environment)+ logger.info("Initialization complete")++ # Register signal handlers+ signal.signal(signal.SIGTERM, signal_handler)+ signal.signal(signal.SIGINT, signal_handler)++ # Log that signal handlers are registered+ logger.info("Signal handlers registered", extra={"signals": ["SIGTERM", "SIGINT"]})++ # Keep the script running indefinitely+ global keep_running+ while keep_running:+ pass++ except Exception as e:+ logger.error("An unexpected error occurred", exc_info=True)+ finally:+ logger.info("Shutting down GPU Monitor Service")++if __name__ == "__main__":+ main()\ No newline at end of filediff --git a/otel-gpu-collector/dockerfile b/otel-gpu-collector/dockerfilenew file mode 100644index 00000000..d3db96d3--- /dev/null+++ b/otel-gpu-collector/dockerfile@@ -0,0 +1,21 @@+# Use an official Python runtime as a parent image+FROM python:3.9-slim++# Set the working directory in the container+WORKDIR /usr/src/app++# Copy the current directory contents into the container at /usr/src/app+COPY . .++# Install openlit library+RUN pip install --no-cache-dir openlit++# Expose any required ports, if necessary+EXPOSE 80++# Define default values for the environment variables+ENV GPU_APPLICATION_NAME=default+ENV GPU_ENVIRONMENT=default++# Run the script continuously+CMD ["python", "collector.py"]