# signalfx/splunk-otel-go architecture

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

- Interactive diagram: https://gitdiagram.com/signalfx/splunk-otel-go
- Repository: https://github.com/signalfx/splunk-otel-go

## Overview

##### Main Components
- Build & CI/CD Infrastructure:
- Components: • Build directory (all.go, bump.go, clean.go, etc.), Makefile, and GitHub workflow files (.github/workflows/ci.yml, cla.yml).
- Role: These files/scripts automate building, testing, linting, and releasing the distribution. They are the “infrastructure” side of the project.

- Distribution Package:
- Components: The “distro” directory contains code that is specific to the Splunk distribution (configuration, limits, logging, OTEL exporter integration, version management, etc.).
- Role: Acts as a wrapper/adaptor that modifies or extends standard OpenTelemetry functionality to meet Splunk’s needs.

- Instrumentation Libraries:
- Components: The large “instrumentation” directory with custom packages for different integrations and technologies (e.g., databases like sql, Kafka client integrations, HTTP wrappers, DNS, etc.). Each vendor-specific instrumentation (e.g., go-sql-driver/mysql/splunkmysql, confluent-kafka-go/splunkkafka, etc.) is a separate module.
- Role: They provide the “glue” that intercepts or extends existing Go libraries and frameworks to capture and forward telemetry data per Splunk’s requirements.

- Examples:
- Components: The “example” directory contains smaller, developer-focused examples (e.g., a docker-compose file, sample main.go, otel-config.yaml) that demonstrate how to use the distribution.
- Role: Serve as a usage guide and proof of concept, showing how an application would integrate with the instrumentation offered.

- Core Versioning & Configuration:
- Components: Files like go.mod, go.sum, version.go, and a versions.yaml provide dependency management and version tracking.
- Role: Ensure consistency, define the project’s external dependencies, and mark releases.

##### Relationships & Interactions
- The external Go application (that uses this package) would import components from the distro and instrumentation libraries.
- The distro package sits in the middle: it wraps core OpenTelemetry functions and integrates with various instrumentation modules.
- Each instrumentation module (for databases, messaging, HTTP, etc.) intercepts calls or sets up connections to capture telemetry, potentially forwarding it to Splunk endpoints.
- The build layer and CI/CD pipelines integrate with the whole codebase, ensuring that tests (including integration tests in the instrumentation packages) are run consistently, code style is enforced, and releases are generated.
- The examples package acts as a guide by showing end-to-end integration in a sample application.

##### Architectural Patterns & Design Principles
- Modular Design: The project is split into many modules/pkgs (each with its own go.mod) so that individual instrumentation libraries can evolve independently.
- Wrapper/Adapter Pattern: The distro package adapts and extends the OpenTelemetry Go core functionality for Splunk’s usage.
- Extensibility: The instrumentation folders for various vendors (databases, Kafka, HTTP, etc.) illustrate a clear separation of concerns and a plug-in-like approach.
- CI/CD & Automated Testing: Integration via GitHub workflows, Makefile targets, and testing directories ensures code quality and reproducibility.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Build & CI/CD Infrastructure"
        BS1("Build Scripts"):::build
        BS2("Makefile"):::build
        BS3("GitHub Workflows"):::build
    end

    subgraph "Distribution Package"
        D1("Splunk Distribution"):::distro
    end

    subgraph "Instrumentation Libraries"
        I1("Instrumentation Modules"):::instr
    end

    subgraph "Examples"
        E1("Usage Examples"):::examples
    end

    subgraph "Core Versioning & Configuration"
        C2("go.mod"):::core
        C3("go.sum"):::core
        C4("Version Files"):::core
    end

    EA("External Applications"):::external

    %% Relationships - Bidirectional connections with Build & CI/CD
    BS1 <--> D1
    BS1 <--> I1
    BS1 <--> E1
    BS1 <--> C2

    %% Instrumentation integrates into Distribution
    I1 -->|"integrates"| D1

    %% Examples demonstrate usage of the Distribution Package
    E1 -->|"demonstrates"| D1

    %% Distribution Package is imported by External Applications
    D1 -->|"imported_by"| EA

    %% Click Events
    click BS1 "https://github.com/signalfx/splunk-otel-go/tree/main/build"
    click BS2 "https://github.com/signalfx/splunk-otel-go/tree/main/Makefile"
    click BS3 "https://github.com/signalfx/splunk-otel-go/tree/main/.github/workflows"
    click D1 "https://github.com/signalfx/splunk-otel-go/tree/main/distro"
    click I1 "https://github.com/signalfx/splunk-otel-go/tree/main/instrumentation"
    click E1 "https://github.com/signalfx/splunk-otel-go/tree/main/example"
    click C2 "https://github.com/signalfx/splunk-otel-go/blob/main/go.mod"
    click C3 "https://github.com/signalfx/splunk-otel-go/blob/main/go.sum"
    click C4 "https://github.com/signalfx/splunk-otel-go/blob/main/version.go"

    %% Styles
    classDef build fill:#f9e79f,stroke:#f39c12,stroke-width:2px;
    classDef distro fill:#aed6f1,stroke:#3498db,stroke-width:2px;
    classDef instr fill:#abebc6,stroke:#28b463,stroke-width:2px;
    classDef examples fill:#f5b7b1,stroke:#e74c3c,stroke-width:2px;
    classDef core fill:#d7bde2,stroke:#8e44ad,stroke-width:2px;
    classDef external fill:#f0b27a,stroke:#d35400,stroke-width:2px;
```
