# alexrios/opentelemetry-go architecture

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

- Interactive diagram: https://gitdiagram.com/alexrios/opentelemetry-go
- Repository: https://github.com/alexrios/opentelemetry-go

## Overview

##### Project type and purpose
- This is a Go library (not an end-user application) that implements the OpenTelemetry specification. It provides:
- API packages for tracing, metrics, baggage, attributes, and propagation
- An SDK that implements these APIs, buffer and batch processing, and exporters
- Bridges to legacy systems (OpenCensus, OpenTracing)
- A suite of exporters (OTLP/gRPC, OTLP/HTTP, Prometheus, Jaeger, Zipkin, stdout)
- Example applications demonstrating usage

##### File structure
- Top-level API modules:
- attribute/, baggage/, propagation/, trace.go, metric/
- SDK implementation:
- sdk/ (providers, processors, controllers, exporters interface)
- Exporters:
- exporters/metric/prometheus, exporters/otlp, exporters/trace/{jaeger, zipkin}, exporters/stdout
- Bridges:
- bridge/opencensus, bridge/opentracing
- Examples:
- example/* demonstrating full pipelines
- Internal tooling:
- internal/ (global state, test harnesses)
- internal/tools (semconv code generator, crosslink)
- Build and CI:
- go.mod/go.sum, Makefile, GitHub workflows

##### README for additional insights
- Core functionality: instrument an application via API → configure exporter → send telemetry
- Relationship between API, SDK, and exporters is central
- Examples show end-to-end pipelines

##### Diagramming conventions and required elements
- Use clear, descriptive labels for each component (e.g., “BatchSpanProcessor”, “OTLP/gRPC Exporter”)
- Application → API → Provider → SDK Processor → Exporter → External System
- API packages (e.g., blue rectangles)
- SDK components (e.g., green rectangles)
- Exporters (e.g., orange trapezoids)
- Related modules into containers:
- “Core API”, “SDK”, “Exporters”, “Bridges”, “Examples/Tools”

##### Final advice
- Every logical component, even if it’s a small utility (propagators, attribute sets)
- How global state ties API calls to concrete implementations

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Application
    App["Instrumented Application"]:::external

    %% Core API
    subgraph "Core API"
        A1["Attributes API"]:::api
        A2["Baggage API"]:::api
        A3["Propagation API"]:::api
        A4["Trace API"]:::api
        A5["Metric API"]:::api
    end

    %% Global State & Providers
    subgraph "Global State & Providers"
        G1["Global TracerProvider"]:::sdk
        G2["Global MeterProvider"]:::sdk
    end

    %% SDK Layer
    subgraph "SDK"
        subgraph "Trace SDK"
            S1["TracerProvider Impl"]:::sdk
            S2["BatchSpanProcessor"]:::sdk
            S3["SimpleSpanProcessor"]:::sdk
            S4["Samplers"]:::sdk
            S5["ID Generators"]:::sdk
        end
        subgraph "Metric SDK"
            M1["MeterProvider Impl"]:::sdk
            M2["Controllers"]:::sdk
            M3["Metric Processors"]:::sdk
            M4["Aggregators"]:::sdk
        end
        subgraph "Export Interfaces"
            EI["SDK Export Interfaces"]:::sdk
        end
    end

    %% Exporters
    subgraph "Exporters"
        E1["OTLP/gRPC Exporter"]:::exporter
        E2["OTLP/HTTP Exporter"]:::exporter
        E3["Prometheus Exporter"]:::exporter
        E4["Jaeger Exporter"]:::exporter
        E5["Zipkin Exporter"]:::exporter
        E6["Stdout Exporter"]:::exporter
    end

    %% Bridges
    subgraph "Bridges"
        B1["OpenCensus Bridge"]:::bridge
        B2["OpenTracing Bridge"]:::bridge
    end

    %% Examples & Tools
    subgraph "Examples & Tools"
        X1["Example Applications"]:::tools
        X2["Semconv Generator"]:::tools
        X3["Crosslink Utility"]:::tools
    end

    %% External Systems
    subgraph "External Systems"
        EX1["OTLP Collector"]:::external
        EX2["Prometheus Server"]:::external
        EX3["Jaeger Agent"]:::external
        EX4["Zipkin Server"]:::external
        EX5["Stdout Console"]:::external
    end

    %% Connections
    App -->|"Uses API"| A1 & A2 & A3 & A4 & A5
    A1 & A2 & A3 & A4 & A5 -->|"Get Provider"| G1 & G2
    G1 -->|"Create Spans"| S1
    G2 -->|"Create Instruments"| M1
    S1 -->|"SpanData"| S2
    S1 -->|"SpanData"| S3
    S2 & S3 -->|"Export(SpanData)"| EI
    M1 -->|"Metrics"| M2
    M2 -->|"Process(Metrics)"| M3
    M3 -->|"Aggregate"| M4
    M4 -->|"Export(Metrics)"| EI
    EI -->|"Send"| E1 & E2 & E3 & E4 & E5 & E6
    E1 -->|"gRPC"| EX1
    E2 -->|"HTTP"| EX1
    E3 -->|"Scrape"| EX2
    E4 -->|"UDP/Thrift"| EX3
    E5 -->|"HTTP"| EX4
    E6 -->|"Print"| EX5
    A4 -->|"OC API Calls"| B1
    A4 -->|"OT API Calls"| B2

    %% Click Events
    click A1 "https://github.com/alexrios/opentelemetry-go/tree/main/attribute/"
    click A2 "https://github.com/alexrios/opentelemetry-go/tree/main/baggage/"
    click A3 "https://github.com/alexrios/opentelemetry-go/tree/main/propagation/"
    click A4 "https://github.com/alexrios/opentelemetry-go/tree/main/trace/"
    click A5 "https://github.com/alexrios/opentelemetry-go/tree/main/metric/"
    click G1 "https://github.com/alexrios/opentelemetry-go/blob/main/internal/global/trace.go"
    click G2 "https://github.com/alexrios/opentelemetry-go/blob/main/internal/global/meter.go"
    click S1 "https://github.com/alexrios/opentelemetry-go/blob/main/sdk/trace/provider.go"
    click S2 "https://github.com/alexrios/opentelemetry-go/blob/main/sdk/trace/batch_span_processor.go"
    click S3 "https://github.com/alexrios/opentelemetry-go/blob/main/sdk/trace/simple_span_processor.go"
    click S4 "https://github.com/alexrios/opentelemetry-go/blob/main/sdk/trace/sampling.go"
    click S5 "https://github.com/alexrios/opentelemetry-go/blob/main/sdk/trace/id_generator.go"
    click M2 "https://github.com/alexrios/opentelemetry-go/blob/main/sdk/metric/processor/basic/basic.go"
    click M4 "https://github.com/alexrios/opentelemetry-go/blob/main/sdk/metric/aggregator/sum/sum.go"
    click EI "https://github.com/alexrios/opentelemetry-go/tree/main/sdk/export/"
    click B1 "https://github.com/alexrios/opentelemetry-go/tree/main/bridge/opencensus/"
    click B2 "https://github.com/alexrios/opentelemetry-go/tree/main/bridge/opentracing/"
    click E1 "https://github.com/alexrios/opentelemetry-go/blob/main/exporters/otlp/otlpgrpc/driver.go"
    click E2 "https://github.com/alexrios/opentelemetry-go/blob/main/exporters/otlp/otlphttp/driver.go"
    click E3 "https://github.com/alexrios/opentelemetry-go/blob/main/exporters/metric/prometheus/prometheus.go"
    click E4 "https://github.com/alexrios/opentelemetry-go/blob/main/exporters/trace/jaeger/jaeger.go"
    click E5 "https://github.com/alexrios/opentelemetry-go/blob/main/exporters/trace/zipkin/zipkin.go"
    click E6 "https://github.com/alexrios/opentelemetry-go/blob/main/exporters/stdout/exporter.go"
    click X1 "https://github.com/alexrios/opentelemetry-go/tree/main/example/"
    click X2 "https://github.com/alexrios/opentelemetry-go/tree/main/internal/tools/semconv-gen/"
    click X3 "https://github.com/alexrios/opentelemetry-go/tree/main/internal/tools/crosslink/"

    %% Styles
    classDef api fill:#D6EAF8,stroke:#2980B9;
    classDef sdk fill:#D5F5E3,stroke:#27AE60;
    classDef exporter fill:#FAD7A0,stroke:#D68910;
    classDef bridge fill:#E8DAEF,stroke:#8E44AD;
    classDef tools fill:#F2F3F4,stroke:#B3B6B7;
    classDef external fill:#D5D8DC,stroke:#7F8C8D;
```
