# micrometer-metrics/micrometer architecture

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

- Interactive diagram: https://gitdiagram.com/micrometer-metrics/micrometer
- Repository: https://github.com/micrometer-metrics/micrometer

## Overview

##### Main Architectural Components
- Core Metrics API:
– Represent the micrometer-core and micrometer-commons modules as the “core library”. These encapsulate common abstractions such as Counters, Gauges, Timers, and APIs used for instrumentation.
- Integration/Registry Modules:
- BOM and Versioning:
– Include the micrometer-bom module which aggregates dependencies and versions. This plays a central role in dependency management.
- Samples and Examples:
– Illustrate sample sub-projects (e.g., samples/micrometer-samples-boot2-reactive, samples/micrometer-samples-core, and others) that demonstrate the use of Micrometer in real-world applications.
- Testing and Benchmarks:
– There are dedicated modules for concurrency tests, benchmarks, and extensive unit/integration tests (with directories like concurrency-tests, benchmarks, docs/src/test, and micrometer-test). Include these to show how the system verifies behavior.
- Build and CI/CD Infrastructure:
– Show the build scripts (build.gradle, settings.gradle) and CI/CD directories (.github, .circleci, gradle, scripts) that manage automated builds, testing, documentation, and deployment pipelines.

##### Relationships and Data Flow
- The core API modules are consumed by both end users (via samples and direct usage) and by the integration modules to translate vendor-neutral metrics into registry-specific formats.
- From the integration modules, show outgoing flow to “External Monitoring Systems” (e.g., Prometheus, New Relic, Datadog) to illustrate that metrics are pushed or exposed to external backends.
- The build system and CI components (GitHub workflows, Gradle scripts, and shell scripts in the scripts directory) orchestrate testing, benchmarking, and publication. Represent these as an orchestration layer feeding into the different modules.

##### Highlighted Patterns and Design Principles
- Modular & Pluggable Architecture: The clear separation between the core API, integrations (registry implementations), and sample/test modules.
- Vendor-Neutral Abstraction: The Micrometer core library provides a facade that decouples the application’s instrumentation from the specific monitoring backend.
- Dependency Injection and AOP: Support for annotation-based metrics (Counted, Timed) and aspects (as seen in the aop directories), which help in automatic instrumentation.
- Continuous Integration/Delivery: The presence of extensive CI configuration, automated testing, and benchmarking emphasize the project’s commitment to quality and stability.

##### Technologies/Frameworks
- Java (with modules for Java8, Java11, Java21, Java Jakarta, etc.)
- Gradle as the build system (with gradlew, gradle.properties, and build.gradle scripts)
- GitHub and CircleCI for version control and CI/CD.
- AOP (AspectJ), and annotations for metrics.
- Multiple vendor-specific libraries/drivers used in various integration modules.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core Libraries
    subgraph "Core Libraries"
        A1["Micrometer Core (API)"]:::core
        A2["Micrometer Commons"]:::core
        B["Micrometer BOM & Versioning"]:::core
    end

    %% Registry Implementations
    subgraph "Registry Implementations"
        C["Integration/Registry Modules"]:::integration
    end

    %% Samples & Tests
    subgraph "Samples & Tests"
        D["Samples and Examples"]:::samples
        E["Testing and Benchmarks"]:::samples
    end

    %% Infrastructure and External Systems
    F["Build & CI/CD Infrastructure"]:::infra
    G["External Monitoring Systems"]:::external

    %% Relationships
    A1 -->|"feeds"| C
    A2 -->|"feeds"| C

    A1 -->|"used_by"| D
    A2 -->|"used_by"| D

    A1 -->|"tested_by"| E
    A2 -->|"tested_by"| E

    C -->|"exposes"| G

    F -->|"orchestrates"| A1
    F -->|"orchestrates"| A2
    F -->|"orchestrates"| B
    F -->|"orchestrates"| D
    F -->|"orchestrates"| E

    %% Click Events for Core Metrics API
    click A1 "https://github.com/micrometer-metrics/micrometer/tree/main/micrometer-core/"
    click A1 "https://github.com/micrometer-metrics/micrometer/blob/main/micrometer-core/build.gradle"
    click A2 "https://github.com/micrometer-metrics/micrometer/tree/main/micrometer-commons/"
    click A2 "https://github.com/micrometer-metrics/micrometer/blob/main/micrometer-commons/build.gradle"

    %% Click Events for BOM and Versioning
    click B "https://github.com/micrometer-metrics/micrometer/tree/main/micrometer-bom/"
    click B "https://github.com/micrometer-metrics/micrometer/blob/main/micrometer-bom/build.gradle"

    %% Click Event for Integration/Registry Modules
    click C "https://github.com/micrometer-metrics/micrometer/tree/main/implementations/"

    %% Click Event for Samples and Examples
    click D "https://github.com/micrometer-metrics/micrometer/tree/main/samples/"

    %% Click Events for Testing and Benchmarks
    click E "https://github.com/micrometer-metrics/micrometer/tree/main/benchmarks/"
    click E "https://github.com/micrometer-metrics/micrometer/tree/main/concurrency-tests/"
    click E "https://github.com/micrometer-metrics/micrometer/tree/main/docs/src/test/"
    click E "https://github.com/micrometer-metrics/micrometer/tree/main/micrometer-test/"

    %% Click Events for Build and CI/CD Infrastructure
    click F "https://github.com/micrometer-metrics/micrometer/tree/main/.github/"
    click F "https://github.com/micrometer-metrics/micrometer/tree/main/.circleci/"
    click F "https://github.com/micrometer-metrics/micrometer/tree/main/gradle/"
    click F "https://github.com/micrometer-metrics/micrometer/tree/main/gradlew"
    click F "https://github.com/micrometer-metrics/micrometer/blob/main/gradlew.bat"
    click F "https://github.com/micrometer-metrics/micrometer/tree/main/scripts/"
    click F "https://github.com/micrometer-metrics/micrometer/blob/main/build.gradle"
    click F "https://github.com/micrometer-metrics/micrometer/blob/main/settings.gradle"

    %% Styles
    classDef core fill:#f9e79f,stroke:#c0392b,stroke-width:2px;
    classDef integration fill:#aed6f1,stroke:#2874a6,stroke-width:2px;
    classDef samples fill:#abebc6,stroke:#239b56,stroke-width:2px;
    classDef infra fill:#f9cfd1,stroke:#a93226,stroke-width:2px;
    classDef external fill:#f5cba7,stroke:#d35400,stroke-width:2px;
```
