# saran1to5ai/openllmetry architecture

> Architecture diagram of the GitHub repository saran1to5ai/openllmetry, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/saran1to5ai/openllmetry
- Repository: https://github.com/saran1to5ai/openllmetry

## Overview

#### Purpose and entry points
OpenLLMetry is a Python monorepo of OpenTelemetry extensions for LLM applications: provider, framework, vector-database, and MCP instrumentation plus the Traceloop SDK. Primary consumer entry point is `Traceloop.init()` from `packages/traceloop-sdk/traceloop/sdk/__init__.py`; individual instrumentations expose provider-specific OpenTelemetry instrumentors through their package `__init__.py` files, e.g. `packages/opentelemetry-instrumentation-openai/opentelemetry/instrumentation/openai/__init__.py`.

#### SDK orchestration
The SDK configures tracing, metrics, logging, SDK-managed instrumentations, and context behavior around an application.
- Initialization and public API: `packages/traceloop-sdk/traceloop/sdk/__init__.py`
- Instrumentation selection/activation: `packages/traceloop-sdk/traceloop/sdk/instruments.py`
- OpenTelemetry tracing setup and manual spans: `packages/traceloop-sdk/traceloop/sdk/tracing/tracing.py`, `packages/traceloop-sdk/traceloop/sdk/tracing/manual.py`
- Metrics setup: `packages/traceloop-sdk/traceloop/sdk/metrics/metrics.py`

Control flow is application → SDK initialization → OpenTelemetry providers/processors/exporters plus enabled instrumentations → configured observability destination.

#### Provider instrumentation layer
Provider packages wrap SDK calls, translate request/response and token/model metadata into OpenTelemetry spans/events/metrics, and support synchronous, asynchronous, and often streaming calls. OpenAI is a representative complex implementation:
- Registration and version-specific patching: `packages/opentelemetry-instrumentation-openai/opentelemetry/instrumentation/openai/__init__.py`, `packages/opentelemetry-instrumentation-openai/opentelemetry/instrumentation/openai/v1/__init__.py`
- Shared chat/completion/embedding wrappers: `packages/opentelemetry-instrumentation-openai/opentelemetry/instrumentation/openai/shared/chat_wrappers.py`, `packages/opentelemetry-instrumentation-openai/opentelemetry/instrumentation/openai/shared/embeddings_wrappers.py`
- Responses, assistants, and realtime boundaries: `packages/opentelemetry-instrumentation-openai/opentelemetry/instrumentation/openai/v1/responses_wrappers.py`

Parallel packages cover Anthropic, Bedrock, Cohere, Gemini, Groq, Mistral, Ollama, Replicate, SageMaker, Together, Vertex AI, Watsonx, Writer, and others.

#### Framework, agent, and protocol instrumentation
Framework packages capture higher-level execution topology—chains, agents, tools, retrieval, handoffs, and workflows—rather than only underlying model calls.
- LangChain callbacks, patching, LangGraph support: `packages/opentelemetry-instrumentation-langchain/opentelemetry/instrumentation/langchain/callback_handler.py`, `packages/opentelemetry-instrumentation-langchain/opentelemetry/instrumentation/langchain/patch.py`
- LlamaIndex dispatcher and specialized instrumentors: `packages/opentelemetry-instrumentation-llamaindex/opentelemetry/instrumentation/llamaindex/dispatcher_wrapper.py`, `packages/opentelemetry-instrumentation-llamaindex/opentelemetry/instrumentation/llamaindex/base_agent_instrumentor.py`
- OpenAI Agents hooks/realtime wrappers: `packages/opentelemetry-instrumentation-openai-agents/opentelemetry/instrumentation/openai_agents/_hooks.py`
- MCP/FastMCP instrumentation: `packages/opentelemetry-instrumentation-mcp/opentelemetry/instrumentation/mcp/instrumentation.py`

#### Retrieval and vector-store boundary
Vector DB packages wrap client operations to emit retrieval/indexing spans while preserving the application’s native client behavior. Implementations are adapter-specific rather than centralized:
- Chroma: `packages/opentelemetry-instrumentation-chromadb/opentelemetry/instrumentation/chromadb/wrapper.py`
- Qdrant: `packages/opentelemetry-instrumentation-qdrant/opentelemetry/instrumentation/qdrant/wrapper.py`
- Pinecone query handling: `packages/opentelemetry-instrumentation-pinecone/opentelemetry/instrumentation/pinecone/query_handlers.py`
- Weaviate: `packages/opentelemetry-instrumentation-weaviate/opentelemetry/instrumentation/weaviate/wrapper.py`

#### Semantic, product, and remote-service APIs
A semantic-conventions package supplies shared AI telemetry semantics: `packages/opentelemetry-semantic-conventions-ai/opentelemetry/semconv_ai/__init__.py`. The SDK additionally has HTTP-backed product features:
- Prompt registry client/models: `packages/traceloop-sdk/traceloop/sdk/prompts/client.py`
- Dataset CRUD and attachments: `packages/traceloop-sdk/traceloop/sdk/datasets/datasets.py`, `packages/traceloop-sdk/traceloop/sdk/datasets/attachment.py`
- Experiments/evaluators and streamed evaluation: `packages/traceloop-sdk/traceloop/sdk/experiment/experiment.py`, `packages/traceloop-sdk/traceloop/sdk/evaluator/stream_client.py`
- Guardrails and failure policy: `packages/traceloop-sdk/traceloop/sdk/guardrail/guardrail.py`, `packages/traceloop-sdk/traceloop/sdk/guardrail/on_failure.py`

#### Runtime and delivery
Runtime code is Python, packaged independently with `pyproject.toml`/Poetry metadata per package. The repository is coordinated as an Nx workspace (`nx.json`, `package.json`), with CI and release workflows at `.github/workflows/ci.yml` and `.github/workflows/release.yml`. External integrations include OpenTelemetry-compatible exporters/collectors and observability backends, LLM providers, agent frameworks, and vector databases; the repository itself is a library collection, not a deployed web service.

Main entry points: [`packages/traceloop-sdk/traceloop/sdk/instruments.py`](https://github.com/saran1to5ai/openllmetry/blob/main/packages/traceloop-sdk/traceloop/sdk/instruments.py) (Instrumentation activation), [`packages/traceloop-sdk/traceloop/sdk/__init__.py`](https://github.com/saran1to5ai/openllmetry/blob/main/packages/traceloop-sdk/traceloop/sdk/__init__.py) (Traceloop.init()), [`packages/opentelemetry-instrumentation-openai/opentelemetry/instrumentation/openai/shared/chat_wrappers.py`](https://github.com/saran1to5ai/openllmetry/blob/main/packages/opentelemetry-instrumentation-openai/opentelemetry/instrumentation/openai/shared/chat_wrappers.py) (OpenAI call wrappers), [`packages/opentelemetry-instrumentation-langchain/opentelemetry/instrumentation/langchain/callback_handler.py`](https://github.com/saran1to5ai/openllmetry/blob/main/packages/opentelemetry-instrumentation-langchain/opentelemetry/instrumentation/langchain/callback_handler.py) (Framework and agent adapters)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_sdk["Traceloop SDK"]
  node_sdk_init["Traceloop.init&#40;&#41;<br/>SDK entry point<br/>[__init__.py]"]
  node_instrument_selection["Instrumentation activation<br/>SDK instrument manager<br/>[instruments.py]"]
  node_tracing["Tracing and manual spans<br/>SDK tracing<br/>[tracing.py]"]
  node_metrics["Metrics setup<br/>SDK metrics<br/>[metrics.py]"]
  node_product_apis["Prompts, datasets, experiments<br/>SDK product APIs<br/>[client.py]"]
  node_otel_pipeline["OpenTelemetry pipeline<br/>providers, processors, exporters"]
end

subgraph group_instrumentation["Instrumentation packages"]
  node_semconv["AI semantic conventions<br/>shared telemetry semantics<br/>[__init__.py]"]
  node_openai_instrumentor["OpenAI instrumentor<br/>provider instrumentation<br/>[__init__.py]"]
  node_openai_wrappers["OpenAI call wrappers<br/>chat, embeddings, responses<br/>[chat_wrappers.py]"]
  node_other_providers["Other LLM providers<br/>provider instrumentation packages"]
  node_framework_instrumentation["Framework and agent adapters<br/>framework instrumentation"]
  node_mcp_instrumentation["MCP and FastMCP adapter<br/>protocol instrumentation<br/>[instrumentation.py]"]
  node_vector_instrumentation["Vector-store adapters<br/>retrieval instrumentation<br/>[wrapper.py]"]
end

subgraph group_external["External runtimes"]
  node_application["Instrumented application<br/>consumer application"]
  node_llm_services["LLM provider services<br/>external model APIs"]
  node_framework_runtimes["Agent and framework runtimes<br/>external libraries"]
  node_vector_databases[("Vector databases<br/>external retrieval services")]
  node_product_service["Traceloop product service<br/>remote HTTP API"]
  node_observability_backend[("OTel collector or backend<br/>telemetry destination")]
end

node_application -->|"initializes"| node_sdk_init
node_sdk_init -->|"selects"| node_instrument_selection
node_sdk_init -->|"configures"| node_tracing
node_sdk_init -->|"configures"| node_metrics
node_sdk_init -->|"exposes"| node_product_apis
node_instrument_selection -->|"enables"| node_openai_instrumentor
node_instrument_selection -->|"enables"| node_other_providers
node_instrument_selection -->|"enables"| node_framework_instrumentation
node_instrument_selection -->|"enables"| node_mcp_instrumentation
node_instrument_selection -->|"enables"| node_vector_instrumentation
node_openai_instrumentor -->|"patches with"| node_openai_wrappers
node_openai_wrappers -->|"wraps calls to"| node_llm_services
node_other_providers -->|"wraps calls to"| node_llm_services
node_framework_instrumentation -->|"observes"| node_framework_runtimes
node_mcp_instrumentation -->|"observes"| node_framework_runtimes
node_vector_instrumentation -->|"wraps operations to"| node_vector_databases
node_semconv -.->|"defines attributes for"| node_openai_wrappers
node_semconv -.->|"defines attributes for"| node_framework_instrumentation
node_tracing -->|"creates telemetry through"| node_otel_pipeline
node_metrics -->|"emits through"| node_otel_pipeline
node_otel_pipeline -->|"exports to"| node_observability_backend
node_product_apis -->|"uses HTTP API"| node_product_service

click node_sdk_init "https://github.com/saran1to5ai/openllmetry/blob/main/packages/traceloop-sdk/traceloop/sdk/__init__.py"
click node_instrument_selection "https://github.com/saran1to5ai/openllmetry/blob/main/packages/traceloop-sdk/traceloop/sdk/instruments.py"
click node_tracing "https://github.com/saran1to5ai/openllmetry/blob/main/packages/traceloop-sdk/traceloop/sdk/tracing/tracing.py"
click node_metrics "https://github.com/saran1to5ai/openllmetry/blob/main/packages/traceloop-sdk/traceloop/sdk/metrics/metrics.py"
click node_product_apis "https://github.com/saran1to5ai/openllmetry/blob/main/packages/traceloop-sdk/traceloop/sdk/prompts/client.py"
click node_semconv "https://github.com/saran1to5ai/openllmetry/blob/main/packages/opentelemetry-semantic-conventions-ai/opentelemetry/semconv_ai/__init__.py"
click node_openai_instrumentor "https://github.com/saran1to5ai/openllmetry/blob/main/packages/opentelemetry-instrumentation-openai/opentelemetry/instrumentation/openai/__init__.py"
click node_openai_wrappers "https://github.com/saran1to5ai/openllmetry/blob/main/packages/opentelemetry-instrumentation-openai/opentelemetry/instrumentation/openai/shared/chat_wrappers.py"
click node_framework_instrumentation "https://github.com/saran1to5ai/openllmetry/blob/main/packages/opentelemetry-instrumentation-langchain/opentelemetry/instrumentation/langchain/callback_handler.py"
click node_mcp_instrumentation "https://github.com/saran1to5ai/openllmetry/blob/main/packages/opentelemetry-instrumentation-mcp/opentelemetry/instrumentation/mcp/instrumentation.py"
click node_vector_instrumentation "https://github.com/saran1to5ai/openllmetry/blob/main/packages/opentelemetry-instrumentation-chromadb/opentelemetry/instrumentation/chromadb/wrapper.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_sdk_init,node_instrument_selection,node_tracing,node_metrics,node_product_apis,node_otel_pipeline toneBlue
class node_semconv,node_openai_instrumentor,node_openai_wrappers,node_other_providers,node_framework_instrumentation,node_mcp_instrumentation,node_vector_instrumentation toneAmber
class node_application,node_llm_services,node_framework_runtimes,node_vector_databases,node_product_service,node_observability_backend toneMint
```

## Components

### Traceloop SDK

Application-facing orchestration and product APIs.

- [Traceloop.init()](https://github.com/saran1to5ai/openllmetry/blob/main/packages/traceloop-sdk/traceloop/sdk/__init__.py): SDK entry point · Configures application observability. · `packages/traceloop-sdk/traceloop/sdk/__init__.py`
- [Instrumentation activation](https://github.com/saran1to5ai/openllmetry/blob/main/packages/traceloop-sdk/traceloop/sdk/instruments.py): SDK instrument manager · `packages/traceloop-sdk/traceloop/sdk/instruments.py`
- [Tracing and manual spans](https://github.com/saran1to5ai/openllmetry/blob/main/packages/traceloop-sdk/traceloop/sdk/tracing/tracing.py): SDK tracing · `packages/traceloop-sdk/traceloop/sdk/tracing/tracing.py`
- [Metrics setup](https://github.com/saran1to5ai/openllmetry/blob/main/packages/traceloop-sdk/traceloop/sdk/metrics/metrics.py): SDK metrics · `packages/traceloop-sdk/traceloop/sdk/metrics/metrics.py`
- [Prompts, datasets, experiments](https://github.com/saran1to5ai/openllmetry/blob/main/packages/traceloop-sdk/traceloop/sdk/prompts/client.py): SDK product APIs · HTTP-backed registry, dataset, evaluation, and guardrail features. · `packages/traceloop-sdk/traceloop/sdk/prompts/client.py`
- **OpenTelemetry pipeline**: providers, processors, exporters

### Instrumentation packages

OpenTelemetry adapters for model, framework, protocol, and retrieval calls.

- [AI semantic conventions](https://github.com/saran1to5ai/openllmetry/blob/main/packages/opentelemetry-semantic-conventions-ai/opentelemetry/semconv_ai/__init__.py): shared telemetry semantics · `packages/opentelemetry-semantic-conventions-ai/opentelemetry/semconv_ai/__init__.py`
- [OpenAI instrumentor](https://github.com/saran1to5ai/openllmetry/blob/main/packages/opentelemetry-instrumentation-openai/opentelemetry/instrumentation/openai/__init__.py): provider instrumentation · Registers version-specific OpenAI patching. · `packages/opentelemetry-instrumentation-openai/opentelemetry/instrumentation/openai/__init__.py`
- [OpenAI call wrappers](https://github.com/saran1to5ai/openllmetry/blob/main/packages/opentelemetry-instrumentation-openai/opentelemetry/instrumentation/openai/shared/chat_wrappers.py): chat, embeddings, responses · Captures sync, async, streaming, and specialized OpenAI calls. · `packages/opentelemetry-instrumentation-openai/opentelemetry/instrumentation/openai/shared/chat_wrappers.py`
- **Other LLM providers**: provider instrumentation packages · Adapters for Anthropic, Bedrock, Gemini, and other providers.
- [Framework and agent adapters](https://github.com/saran1to5ai/openllmetry/blob/main/packages/opentelemetry-instrumentation-langchain/opentelemetry/instrumentation/langchain/callback_handler.py): framework instrumentation · Captures chains, agents, tools, retrieval, handoffs, and workflows. · `packages/opentelemetry-instrumentation-langchain/opentelemetry/instrumentation/langchain/callback_handler.py`
- [MCP and FastMCP adapter](https://github.com/saran1to5ai/openllmetry/blob/main/packages/opentelemetry-instrumentation-mcp/opentelemetry/instrumentation/mcp/instrumentation.py): protocol instrumentation · `packages/opentelemetry-instrumentation-mcp/opentelemetry/instrumentation/mcp/instrumentation.py`
- [Vector-store adapters](https://github.com/saran1to5ai/openllmetry/blob/main/packages/opentelemetry-instrumentation-chromadb/opentelemetry/instrumentation/chromadb/wrapper.py): retrieval instrumentation · Wraps native vector client operations without changing behavior. · `packages/opentelemetry-instrumentation-chromadb/opentelemetry/instrumentation/chromadb/wrapper.py`

### External runtimes

Services and libraries observed by this repository.

- **Instrumented application**: consumer application
- **LLM provider services**: external model APIs
- **Agent and framework runtimes**: external libraries
- **Vector databases**: external retrieval services
- **Traceloop product service**: remote HTTP API
- **OTel collector or backend**: telemetry destination

## Connections

- Instrumented application → Traceloop.init(): initializes
- Traceloop.init() → Instrumentation activation: selects
- Traceloop.init() → Tracing and manual spans: configures
- Traceloop.init() → Metrics setup: configures
- Traceloop.init() → Prompts, datasets, experiments: exposes
- Instrumentation activation → OpenAI instrumentor: enables
- Instrumentation activation → Other LLM providers: enables
- Instrumentation activation → Framework and agent adapters: enables
- Instrumentation activation → MCP and FastMCP adapter: enables
- Instrumentation activation → Vector-store adapters: enables
- OpenAI instrumentor → OpenAI call wrappers: patches with
- OpenAI call wrappers → LLM provider services: wraps calls to
- Other LLM providers → LLM provider services: wraps calls to
- Framework and agent adapters → Agent and framework runtimes: observes
- MCP and FastMCP adapter → Agent and framework runtimes: observes
- Vector-store adapters → Vector databases: wraps operations to
- AI semantic conventions → OpenAI call wrappers: defines attributes for
- AI semantic conventions → Framework and agent adapters: defines attributes for
- Tracing and manual spans → OpenTelemetry pipeline: creates telemetry through
- Metrics setup → OpenTelemetry pipeline: emits through
- OpenTelemetry pipeline → OTel collector or backend: exports to
- Prompts, datasets, experiments → Traceloop product service: uses HTTP API
