# aileron-projects/aileron-observability architecture

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

- Interactive diagram: https://gitdiagram.com/aileron-projects/aileron-observability
- Repository: https://github.com/aileron-projects/aileron-observability

## Overview

##### Project Type and Purpose
- This is an *open-source Go library* (Go module) providing **observability** building blocks—specifically **logging**, **metrics**, **tracing**, and a placeholder for **profiling**.
- It’s not a standalone service, but a toolkit that user applications import to instrument their code and emit telemetry to various backends (Prometheus, OpenTelemetry, Jaeger, Zipkin, etc.).

##### File Structure Analysis
- Top-level packages:
- `logging/` – (currently empty placeholder)
- `metrics/` – core facade (`metrics.go`) plus subpackages:
– `metrics/prom` (Prometheus exporter)
– `metrics/otel` (OpenTelemetry metrics)
- `tracing/` – facade (`tracing.go`) plus subpackages:
– `tracing/jaeger`
– `tracing/otel`
– `tracing/zipkin`
- `profiling/` – placeholder for future profiling code
- `docs/website/` – a set of example applications (client/server) demonstrating how to wire the library into real services and run them via Docker Compose alongside Prometheus, Jaeger, Zipkin, or OTEL Collector.
- Infra/config: Makefile, GitHub Actions workflows, Go module files, linters, license.

##### Key README Insights
- “Provides observability features”
- Installs as a Go module
- Code documentation lives on GoDoc; usage is via `go get`
- No built-in service; it’s an SDK to integrate into other apps

a. Main Components
- **User Application** – the service or microservice that imports `github.com/aileron-projects/aileron-observability`.
- **AILERON Observability Library** – comprising subcomponents:
– Logging API
– Metrics API → Prometheus & OTEL implementations
– Tracing API → Jaeger, OTEL, Zipkin implementations
– (Profiling API – future)
- **External Observability Backends**: Prometheus Server, OTEL Collector (and its exporters), Jaeger, Zipkin
- **Example Apps** (in `docs/website`) – demo client/server illustrating typical flows
- **DevOps/CI** – GitHub Actions, Makefile (build & test pipelines)

b. Relationships and Interactions
1. **User App** calls **Logging API** → outputs structured logs (stdout, file, etc.).
2. **User App** calls **Metrics API** → collects counters, histograms; these are exposed via HTTP `/metrics` for Prometheus or pushed to OTEL Collector.
3. **User App** calls **Tracing API** → starts spans, propagates context; exporters send to Jaeger, Zipkin, or OTEL Collector.
4. **Example Apps** wire all of the above up and run in Docker Compose with real backends.

c. Architectural Patterns & Principles
- **Facade Pattern**: a thin, unified API for logging, metrics, tracing.
- **Provider Pattern**: subpackage implementations are swappable via configuration.
- **Plug-in/Extension Points**: each subpackage exports config objects that the user application can override.
- **Separation of Concerns**: core business logic stays in user code; observability concerns are isolated in this library.

d. Key Technologies & Frameworks
- Go Modules
- Prometheus client library (HTTP exporter)
- OpenTelemetry Go SDK
- Jaeger/Zipkin Go clients
- Docker Compose for examples
- GitHub Actions for CI

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Application
    UserApp["User Application"]:::user

    %% AILERON Observability Library
    subgraph "AILERON Observability Library"
        direction TB
        LoggingAPI["Logging API"]:::library
        click LoggingAPI "https://github.com/aileron-projects/aileron-observability/blob/main/logging/.gitkeep"

        MetricsAPI["Metrics API"]:::library
        click MetricsAPI "https://github.com/aileron-projects/aileron-observability/blob/main/metrics/metrics.go"

        subgraph "Prometheus Implementation"
            direction TB
            PromConfig["config.go"]:::library
            click PromConfig "https://github.com/aileron-projects/aileron-observability/blob/main/metrics/prom/config.go"
            PromMetrics["metrics.go"]:::library
            click PromMetrics "https://github.com/aileron-projects/aileron-observability/blob/main/metrics/prom/metrics.go"
        end

        subgraph "OTEL Metrics Implementation"
            direction TB
            OTelMetricsConfig["config.go"]:::library
            click OTelMetricsConfig "https://github.com/aileron-projects/aileron-observability/blob/main/metrics/otel/config.go"
            OTelMetrics["metrics.go"]:::library
            click OTelMetrics "https://github.com/aileron-projects/aileron-observability/blob/main/metrics/otel/metrics.go"
        end

        TracingAPI["Tracing API"]:::library
        click TracingAPI "https://github.com/aileron-projects/aileron-observability/blob/main/tracing/tracing.go"

        subgraph "Jaeger Implementation"
            direction TB
            JaegerConfig["config.go"]:::library
            click JaegerConfig "https://github.com/aileron-projects/aileron-observability/blob/main/tracing/jaeger/config.go"
            JaegerTracer["tracer.go"]:::library
            click JaegerTracer "https://github.com/aileron-projects/aileron-observability/blob/main/tracing/jaeger/tracer.go"
        end

        subgraph "OTEL Tracing Implementation"
            direction TB
            OTelTracingConfig["config.go"]:::library
            click OTelTracingConfig "https://github.com/aileron-projects/aileron-observability/blob/main/tracing/otel/config.go"
            OTelTracer["tracer.go"]:::library
            click OTelTracer "https://github.com/aileron-projects/aileron-observability/blob/main/tracing/otel/tracer.go"
        end

        subgraph "Zipkin Implementation"
            direction TB
            ZipkinConfig["config.go"]:::library
            click ZipkinConfig "https://github.com/aileron-projects/aileron-observability/blob/main/tracing/zipkin/config.go"
            ZipkinMW["middleware.go"]:::library
            click ZipkinMW "https://github.com/aileron-projects/aileron-observability/blob/main/tracing/zipkin/middleware.go"
        end

        ProfilingAPI["Profiling API"]:::library
        click ProfilingAPI "https://github.com/aileron-projects/aileron-observability/blob/main/profiling/.gitkeep"
    end

    %% External Observability Backends
    PromServer["Prometheus Server"]:::external
    OTELCollector["OTEL Collector"]:::external
    Jaeger["Jaeger"]:::external
    Zipkin["Zipkin"]:::external
    StdoutFile["Stdout/File"]:::external

    %% Example Apps
    subgraph "Docs / Examples" 
        direction TB
        classDef example stroke-dasharray: 5 5;
        ExamplesLogging["Logging Examples"]:::example
        click ExamplesLogging "https://github.com/aileron-projects/aileron-observability/tree/main/docs/website/logging/"
        ExamplesProm["Prometheus Metrics Examples"]:::example
        click ExamplesProm "https://github.com/aileron-projects/aileron-observability/tree/main/docs/website/metrics/prometheus/"
        ExamplesOTelMetrics["OTEL Metrics Examples"]:::example
        click ExamplesOTelMetrics "https://github.com/aileron-projects/aileron-observability/tree/main/docs/website/metrics/opentelemetry/"
        ExamplesJaeger["Jaeger Tracing Examples"]:::example
        click ExamplesJaeger "https://github.com/aileron-projects/aileron-observability/tree/main/docs/website/tracing/jaeger/"
        ExamplesOTelTracing["OTEL Tracing Examples"]:::example
        click ExamplesOTelTracing "https://github.com/aileron-projects/aileron-observability/tree/main/docs/website/tracing/opentelemetry/"
        ExamplesZipkin["Zipkin Tracing Examples"]:::example
        click ExamplesZipkin "https://github.com/aileron-projects/aileron-observability/tree/main/docs/website/tracing/zipkin/"
    end

    %% CI/CD and Build Scripts
    subgraph "CI/CD & Infra"
        direction TB
        Makefile["Makefile"]:::infra
        Workflow["GitHub Actions workflows"]:::infra
        GoModules["go.mod / go.sum"]:::infra
        Linter["Linter Configs"]:::infra
        License["LICENSE"]:::infra
    end

    %% Relationships
    UserApp -->|"calls"| LoggingAPI
    LoggingAPI -->|"outputs logs"| StdoutFile

    UserApp -->|"uses"| MetricsAPI
    MetricsAPI -->|"Prometheus endpoint"| PromServer
    MetricsAPI -->|"OTEL Push"| OTELCollector

    UserApp -->|"uses"| TracingAPI
    TracingAPI -->|"Jaeger spans"| Jaeger
    TracingAPI -->|"Zipkin spans"| Zipkin
    TracingAPI -->|"OTEL Push"| OTELCollector

    %% Examples flows (dashed)
    ExamplesLogging -.-> LoggingAPI
    ExamplesProm -.-> MetricsAPI
    ExamplesOTelMetrics -.-> MetricsAPI
    ExamplesJaeger -.-> TracingAPI
    ExamplesOTelTracing -.-> TracingAPI
    ExamplesZipkin -.-> TracingAPI

    %% CI/CD dependency
    Makefile -->|build/test| MetricsAPI
    Workflow -->|CI| TracingAPI
    GoModules -->|dependencies| LibraryDependencies[/"Library Packages"/]:::library
    Linter -->|lint| LoggingAPI
    License -->|governance| LibraryDependencies

    %% Styles
    classDef library fill:#cce5ff,stroke:#004085,color:#004085;
    classDef user fill:#d4edda,stroke:#155724,color:#155724;
    classDef external fill:#ffe5b4,stroke:#cc8400,color:#cc8400;
    classDef example fill:#fdfd96,stroke:#adb200,color:#adb200; 
    classDef infra fill:#e2e3e5,stroke:#6c757d,color:#6c757d;
```
