# open-telemetry/opentelemetry-go-contrib architecture

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

- Interactive diagram: https://gitdiagram.com/open-telemetry/opentelemetry-go-contrib
- Repository: https://github.com/open-telemetry/opentelemetry-go-contrib

## Overview

This project is an open-source contribution repository for the OpenTelemetry-Go ecosystem. Its purpose is to extend the core OpenTelemetry-Go project by providing third‐party integrations, instrumentations, exporters, detectors, propagators, bridges, processors, and additional samplers. In other words, it is a modular library repository that “plugs into” the main OpenTelemetry framework and enables users to add instrumentation for various third-party systems and platforms.

##### Main Components
- Inside this container, show the major modules as separate components:
– Instrumentation: Contains packages that add observability to 3rd-party libraries (find it under the “instrumentation” directory with subdirectories for AWS Lambda, Gin, Gorilla, etc.)
– Exporters: Components that convert and send telemetry data to external systems (located under “exporters”).
– Propagators: Modules for context propagation across services (refer to the “propagators” folder, which includes variants like B3, Jaeger, OpenCensus, OT, etc.).
– Detectors: Modules that detect resource attributes when running in cloud environments (categorized under “detectors”, with submodules for AWS, Azure, GCP, etc.).
– Samplers: Additional implementations that determine which traces to collect (present under “samplers” with different strategies).
– Bridges: Adapters that allow integration with other frameworks or logging libraries (in “bridges”).
– Processors: Components to process and modify telemetry data (under “processors”).

##### Supporting Items and Cross-Cutting Concerns
- “Examples” as an external reference that demonstrates how the core components are used. There are several example directories (e.g., dice, namedtracer, opencensus, otel-collector, etc.) which indicate practical implementations.
- “Configuration” (e.g., otelconf) that provides configuration management and testing facilities for the various modules.
- “Internal/Shared Utilities” (located under “internal/shared”) that provide common functions, shared templates, and utilities used across multiple modules.

##### Relationships and Interactions
- “Tests”, “.github/workflows”, and other CI/CD-related files as a separate area that interacts with each module to indicate continuous integration and quality assurance.

##### Architectural Patterns and Design Principles
- The project follows a modular design where each directory represents a standalone module (or family of modules) that can be developed, released, and versioned independently.
- It employs separation of concerns – each module is responsible for one aspect (e.g., propagation, exporting, detecting cloud resources) of the complete telemetry collection and processing pipeline.

- Check that all essential components mentioned in the README (such as purpose and stability status) are represented.
- That the interactions – especially how examples and the shared utilities serve the core modules – are clearly indicated.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core Container
    subgraph "Core"
        OTContrib["OpenTelemetry-Go Contrib"]:::core
    end

    %% Modules within the Core
    subgraph "Modules"
        Instr["Instrumentation"]:::instrumentation
        Expo["Exporters"]:::exporters
        Prop["Propagators"]:::propagators
        Det["Detectors"]:::detectors
        Samp["Samplers"]:::samplers
        Brid["Bridges"]:::bridgesProcessors
        Proc["Processors"]:::bridgesProcessors
    end

    %% Supporting Items
    subgraph "Supporting Items"
        Ex["Examples"]:::examples
        Conf["Configuration"]:::configuration
        IntShared["Internal/Shared Utilities"]:::internal
        CIT["CI/CD & Tests"]:::cicd
    end

    %% Core Relationships: Modules plugging into the core
    Instr -->|"plugs-into"| OTContrib
    Expo -->|"plugs-into"| OTContrib
    Prop -->|"plugs-into"| OTContrib
    Det -->|"plugs-into"| OTContrib
    Samp -->|"plugs-into"| OTContrib
    Brid -->|"plugs-into"| OTContrib
    Proc -->|"plugs-into"| OTContrib

    %% Inter-module interaction
    Instr -->|"calls"| Expo

    %% Supporting Items Relationships
    Ex -->|"demonstrates"| Instr
    Ex -->|"demonstrates"| Expo
    Ex -->|"demonstrates"| Prop

    Conf -->|"configures"| OTContrib

    Instr -->|"uses"| IntShared
    Expo -->|"uses"| IntShared
    Prop -->|"uses"| IntShared
    Det -->|"uses"| IntShared
    Samp -->|"uses"| IntShared
    Brid -->|"uses"| IntShared
    Proc -->|"uses"| IntShared

    CIT -->|"validates"| OTContrib

    %% Click Events for Module Components
    click Instr "https://github.com/open-telemetry/opentelemetry-go-contrib/tree/main/instrumentation/"
    click Expo "https://github.com/open-telemetry/opentelemetry-go-contrib/tree/main/exporters/"
    click Prop "https://github.com/open-telemetry/opentelemetry-go-contrib/tree/main/propagators/"
    click Det "https://github.com/open-telemetry/opentelemetry-go-contrib/tree/main/detectors/"
    click Samp "https://github.com/open-telemetry/opentelemetry-go-contrib/tree/main/samplers/"
    click Brid "https://github.com/open-telemetry/opentelemetry-go-contrib/tree/main/bridges/"
    click Proc "https://github.com/open-telemetry/opentelemetry-go-contrib/tree/main/processors/"

    %% Click Events for Supporting Components
    click Ex "https://github.com/open-telemetry/opentelemetry-go-contrib/tree/main/examples/"
    click Conf "https://github.com/open-telemetry/opentelemetry-go-contrib/tree/main/otelconf/"
    click IntShared "https://github.com/open-telemetry/opentelemetry-go-contrib/tree/main/internal/shared/"
    click CIT "https://github.com/open-telemetry/opentelemetry-go-contrib/tree/main/.github/workflows/"

    %% Styles
    classDef core fill:#E0FFFF,stroke:#000,stroke-width:1px;
    classDef instrumentation fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef exporters fill:#90EE90,stroke:#000,stroke-width:1px;
    classDef propagators fill:#FFA500,stroke:#000,stroke-width:1px;
    classDef detectors fill:#9370DB,stroke:#000,stroke-width:1px;
    classDef samplers fill:#20B2AA,stroke:#000,stroke-width:1px;
    classDef bridgesProcessors fill:#FFFF99,stroke:#000,stroke-width:1px;
    classDef examples fill:#F0E68C,stroke:#000,stroke-width:1px;
    classDef configuration fill:#FFC0CB,stroke:#000,stroke-width:1px;
    classDef internal fill:#D3D3D3,stroke:#000,stroke-width:1px;
    classDef cicd fill:#FFB6C1,stroke:#000,stroke-width:1px;
```
