# showroomprive/opentelemetry-swift-wrapper architecture

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

- Interactive diagram: https://gitdiagram.com/showroomprive/opentelemetry-swift-wrapper
- Repository: https://github.com/showroomprive/opentelemetry-swift-wrapper

## Overview

##### Main Components

a) Core Wrapper Layer:
- Base OpenTelemetryWrapper and ContextPropagatorWrapper
- ResourceWrapper and SemanticAttributesWrapper as supporting components

b) Three Pillar Architecture (arrange these as parallel subsystems):
##### Traces Subsystem
- TracerProviderWrapper
- TracerWrapper
- SpanWrapper
- SpanProcessorWrapper
- Exporters (HTTP and StdOut)

##### Metrics Subsystem
- MeterProviderWrapper
- MeterWrapper
- MetricReaderWrapper
- Different metric types (Counter, Gauge, Histogram, UpDownCounter)
- HttpMetricExporterWrapper

##### Logs Subsystem
- LoggerProviderWrapper
- LoggerWrapper
- LogProcessorWrapper
- HttpLogExporterWrapper

**┌─ Client Applications (KMP) ─┐**

- OpenTelemetry Wrapper ────┤
- ┌────┬────┬────┐         │
- Logs│Metrics│Traces│    │
- ┴────┴────┘         │
- OpenTelemetry SDK ───────┤
- ┘

##### Connection and Flow Representation

- Double lines (⇒) for export paths

##### Detailed Component Relationships

- Provider initialization flow
- Resource and context propagation
- Telemetry data flow through processors to exporters
- Integration points with the underlying OpenTelemetry SDK

##### Additional Elements

Include:
- Version compatibility notes (iOS 15.0+, Swift 5.9+)
- External dependency relationships
- Configuration flow
- Error handling paths

##### Notes for Implementation

- Maintain consistent spacing and alignment
- Clear labels for all components
- Brief descriptions for complex interactions
- Creating separate detailed views for each pillar (traces, metrics, logs)

Create multiple views:

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client["Client Applications (KMP)"]
        KMP[Kotlin Multiplatform Project]
    end

    subgraph Wrapper["OpenTelemetry Wrapper Layer"]
        OTW["OpenTelemetryWrapper"]:::core
        CPW["ContextPropagatorWrapper"]:::core
        RW["ResourceWrapper"]:::core
        SAW["SemanticAttributesWrapper"]:::core
    end

    subgraph Traces["Traces Subsystem"]
        TPW["TracerProviderWrapper"]:::trace
        TW["TracerWrapper"]:::trace
        SW["SpanWrapper"]:::trace
        SPW["SpanProcessorWrapper"]:::trace
        subgraph TraceExporters["Trace Exporters"]
            HSE["HTTP Span Exporter"]:::exporter
            SSE["StdOut Span Exporter"]:::exporter
        end
    end

    subgraph Metrics["Metrics Subsystem"]
        MPW["MeterProviderWrapper"]:::metric
        MW["MeterWrapper"]:::metric
        MRW["MetricReaderWrapper"]:::metric
        subgraph MetricTypes["Metric Types"]
            CW["CounterWrapper"]:::metric
            GW["GaugeWrapper"]:::metric
            HW["HistogramWrapper"]:::metric
            UCW["UpDownCounterWrapper"]:::metric
        end
        HME["HTTP Metric Exporter"]:::exporter
    end

    subgraph Logs["Logs Subsystem"]
        LPW["LoggerProviderWrapper"]:::log
        LW["LoggerWrapper"]:::log
        LOGP["LogProcessorWrapper"]:::log
        HLE["HTTP Log Exporter"]:::exporter
    end

    subgraph SDK["OpenTelemetry SDK"]
        OTSDK[OpenTelemetry Swift SDK]
    end

    %% Connections
    KMP --> OTW
    OTW --> CPW
    OTW --> RW
    OTW --> SAW

    %% Traces
    OTW --> TPW
    TPW --> TW
    TW --> SW
    SW --> SPW
    SPW --> HSE
    SPW --> SSE

    %% Metrics
    OTW --> MPW
    MPW --> MW
    MW --> MRW
    MW --> CW & GW & HW & UCW
    MRW --> HME

    %% Logs
    OTW --> LPW
    LPW --> LW
    LW --> LOGP
    LOGP --> HLE

    %% SDK Integration
    HSE & SSE & HME & HLE --> OTSDK

    %% Click Events
    click OTW "https://github.com/showroomprive/opentelemetry-swift-wrapper/blob/main/Sources/OpenTelemetryWrapper.swift"
    click CPW "https://github.com/showroomprive/opentelemetry-swift-wrapper/blob/main/Sources/ContextPropagatorWrapper.swift"
    click RW "https://github.com/showroomprive/opentelemetry-swift-wrapper/blob/main/Sources/ResourceWrapper.swift"
    click SAW "https://github.com/showroomprive/opentelemetry-swift-wrapper/blob/main/Sources/SemanticAttributesWrapper.swift"
    click TPW "https://github.com/showroomprive/opentelemetry-swift-wrapper/blob/main/Sources/traces/TracerProviderWrapper.swift"
    click TW "https://github.com/showroomprive/opentelemetry-swift-wrapper/blob/main/Sources/traces/TracerWrapper.swift"
    click SW "https://github.com/showroomprive/opentelemetry-swift-wrapper/blob/main/Sources/traces/SpanWrapper.swift"
    click SPW "https://github.com/showroomprive/opentelemetry-swift-wrapper/blob/main/Sources/traces/SpanProcessorWrapper.swift"
    click HSE "https://github.com/showroomprive/opentelemetry-swift-wrapper/blob/main/Sources/traces/HttpSpanExporterWrapper.swift"
    click SSE "https://github.com/showroomprive/opentelemetry-swift-wrapper/blob/main/Sources/traces/StdOutSpanExporterWrapper.swift"
    click MPW "https://github.com/showroomprive/opentelemetry-swift-wrapper/blob/main/Sources/metrics/MeterProviderWrapper.swift"
    click MW "https://github.com/showroomprive/opentelemetry-swift-wrapper/blob/main/Sources/metrics/MeterWrapper.swift"
    click MRW "https://github.com/showroomprive/opentelemetry-swift-wrapper/blob/main/Sources/metrics/MetricReaderWrapper.swift"
    click CW "https://github.com/showroomprive/opentelemetry-swift-wrapper/blob/main/Sources/metrics/CounterWrapper.swift"
    click GW "https://github.com/showroomprive/opentelemetry-swift-wrapper/blob/main/Sources/metrics/GaugeWrapper.swift"
    click HW "https://github.com/showroomprive/opentelemetry-swift-wrapper/blob/main/Sources/metrics/HistogramWrapper.swift"
    click UCW "https://github.com/showroomprive/opentelemetry-swift-wrapper/blob/main/Sources/metrics/UpDownCounterWrapper.swift"
    click HME "https://github.com/showroomprive/opentelemetry-swift-wrapper/blob/main/Sources/metrics/HttpMetricExporterWrapper.swift"
    click LPW "https://github.com/showroomprive/opentelemetry-swift-wrapper/blob/main/Sources/logs/LoggerProviderWrapper.swift"
    click LW "https://github.com/showroomprive/opentelemetry-swift-wrapper/blob/main/Sources/logs/LoggerWrapper.swift"
    click LOGP "https://github.com/showroomprive/opentelemetry-swift-wrapper/blob/main/Sources/logs/LogProcessorWrapper.swift"
    click HLE "https://github.com/showroomprive/opentelemetry-swift-wrapper/blob/main/Sources/logs/HttpLogExporterWrapper.swift"

    %% Styles
    classDef core fill:#3498db,stroke:#2980b9,color:white
    classDef trace fill:#2ecc71,stroke:#27ae60,color:white
    classDef metric fill:#e67e22,stroke:#d35400,color:white
    classDef log fill:#9b59b6,stroke:#8e44ad,color:white
    classDef exporter fill:#95a5a6,stroke:#7f8c8d,color:white

    %% Legend
    subgraph Legend
        L1[Core Components]:::core
        L2[Trace Components]:::trace
        L3[Metric Components]:::metric
        L4[Log Components]:::log
        L5[Exporters]:::exporter
    end
```
