# traceloop/openllmetry architecture

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

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

## Overview

##### Main Components

a. Core Components:
- OpenTelemetry SDK Integration Layer
- Traceloop SDK
- Instrumentation Modules
- Telemetry Collection System
- Export Pipeline

b. Integration Components:
- LLM Provider Instrumentations
- Vector DB Instrumentations
- Framework Instrumentations
- Observability Platform Connectors

**┌─────────────────────────────────────────────────────────────┐**
- Client Applications                       │
- ┬─────────────────────────────────┘
- ↓
**┌─────────────────────────────────────────────────────────────┐**
- Traceloop SDK Layer                     │
- ┌─────────────┐  ┌──────────────┐  ┌───────────────────┐  │
- Config    │  │  Decorators  │  │  Context Manager  │  │
- ┘  └──────────────┘  └───────────────────┘  │
- ┬─────────────────────────────────┘
- ↓
**┌─────────────────────────────────────────────────────────────┐**
- Instrumentation Layer                       │
- ┌─────────────┐  ┌──────────────┐  ┌───────────────────┐  │
- LLM Providers│  │  Vector DBs  │  │    Frameworks     │  │
- ┘  └──────────────┘  └───────────────────┘  │
- ┬─────────────────────────────────┘
- ↓
**┌─────────────────────────────────────────────────────────────┐**
- OpenTelemetry Core                          │
- ┌─────────────┐  ┌──────────────┐  ┌───────────────────┐  │
- Traces    │  │   Metrics    │  │      Context      │  │
- ┘  └──────────────┘  └───────────────────┘  │
- ┬─────────────────────────────────┘
- ↓
**┌─────────────────────────────────────────────────────────────┐**
- Export Backends                         │
- ┌─────────────┐  ┌──────────────┐  ┌───────────────────┐  │
- Datadog    │  │   Honeycomb  │  │  Other Services   │  │
- ┘  └──────────────┘  └───────────────────┘  │
- ┘

##### Key Relationships

- Bidirectional flow between SDK and instrumentations
- One-way flow from instrumentations to OpenTelemetry core
- Data flow from OpenTelemetry to export backends
- Control flow from client applications through the stack

##### Important Details

- Supported LLM providers (OpenAI, Anthropic, etc.)
- Supported Vector DBs (Chroma, Pinecone, etc.)
- Framework support (LangChain, LlamaIndex)
- Export destinations (Datadog, Honeycomb, etc.)
- Telemetry collection path (optional component)

##### Implementation Notes

- Numbered sequence indicators for key flows
- Error handling paths

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client["Client Applications"]
        App[Client Code]
    end

    subgraph SDK["Traceloop SDK Layer"]
        Config["Configuration Management"]:::config
        Decorators["Decorators"]:::sdk
        Context["Context Manager"]:::sdk
        Prompts["Prompt Management"]:::sdk
        Metrics["Metrics Collection"]:::metrics
    end

    subgraph Inst["Instrumentation Layer"]
        direction TB
        subgraph LLM["LLM Providers"]
            OpenAI["OpenAI"]:::llm
            Anthropic["Anthropic"]:::llm
            Cohere["Cohere"]:::llm
        end
        
        subgraph VDB["Vector DBs"]
            Chroma["ChromaDB"]:::vdb
            Pinecone["Pinecone"]:::vdb
            Weaviate["Weaviate"]:::vdb
        end
        
        subgraph FW["Frameworks"]
            LangChain["LangChain"]:::framework
            LlamaIndex["LlamaIndex"]:::framework
        end
    end

    subgraph OTel["OpenTelemetry Core"]
        Traces["Traces"]:::otel
        OTelMetrics["Metrics"]:::otel
        OTelContext["Context"]:::otel
    end

    subgraph Export["Export Backends"]
        Datadog["Datadog"]:::export
        Honeycomb["Honeycomb"]:::export
        Others["Other Services"]:::export
    end

    %% Connections
    App --> SDK
    SDK --> Inst
    Inst --> OTel
    OTel --> Export

    %% Click Events
    click Config "https://github.com/traceloop/openllmetry/tree/main/packages/traceloop-sdk/traceloop/sdk/config/"
    click Metrics "https://github.com/traceloop/openllmetry/tree/main/packages/traceloop-sdk/traceloop/sdk/metrics/"
    click Prompts "https://github.com/traceloop/openllmetry/tree/main/packages/traceloop-sdk/traceloop/sdk/prompts/"
    click OpenAI "https://github.com/traceloop/openllmetry/tree/main/packages/opentelemetry-instrumentation-openai/"
    click Anthropic "https://github.com/traceloop/openllmetry/tree/main/packages/opentelemetry-instrumentation-anthropic/"
    click Cohere "https://github.com/traceloop/openllmetry/tree/main/packages/opentelemetry-instrumentation-cohere/"
    click Chroma "https://github.com/traceloop/openllmetry/tree/main/packages/opentelemetry-instrumentation-chromadb/"
    click Pinecone "https://github.com/traceloop/openllmetry/tree/main/packages/opentelemetry-instrumentation-pinecone/"
    click Weaviate "https://github.com/traceloop/openllmetry/tree/main/packages/opentelemetry-instrumentation-weaviate/"
    click LangChain "https://github.com/traceloop/openllmetry/tree/main/packages/opentelemetry-instrumentation-langchain/"
    click LlamaIndex "https://github.com/traceloop/openllmetry/tree/main/packages/opentelemetry-instrumentation-llamaindex/"

    %% Styles
    classDef sdk fill:#2374ab
    classDef config fill:#2374ab,stroke:#333
    classDef metrics fill:#2374ab,stroke:#333
    classDef llm fill:#57a773
    classDef vdb fill:#57a773
    classDef framework fill:#57a773
    classDef otel fill:#7d3cff
    classDef export fill:#ff9f1c
    
    %% Legend
    subgraph Legend
        L1["SDK Components"]:::sdk
        L2["Instrumentations"]:::llm
        L3["OpenTelemetry"]:::otel
        L4["Export Services"]:::export
    end
```
