# open-telemetry/weaver architecture

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

- Interactive diagram: https://gitdiagram.com/open-telemetry/weaver
- Repository: https://github.com/open-telemetry/weaver

## Overview

##### Main Components Structure
- Create three main vertical layers representing the core functionalities:
a. Input Layer (Top)
b. Processing Layer (Middle)
c. Output Layer (Bottom)

a. Core Processing:
- weaver_resolver: Schema resolution component
- weaver_checker: Policy enforcement component
- weaver_forge: Documentation and code generation component

b. Supporting Components:
- weaver_semconv: Semantic convention handling
- weaver_cache: Caching functionality
- weaver_common: Shared utilities
- weaver_version: Version management

- Resolved Schemas
- Validation Reports
- Generated Documentation
- Generated Code
- Statistics Reports

##### Special Elements
- A "Cache Store" component connected to weaver_cache
- An "Error Handling & Diagnostics" component that spans across all layers

##### Component Details
- Input/Output formats
- Key responsibilities
- Dependencies on other components

##### Technical Stack Indicators
- Rust implementation
- Rego policy language
- Jinja2 templating
- JQ compatibility

##### Cross-Cutting Concerns
Vertical bars on the side showing:
- Memory Safety
- Error Reporting
- Parallel Processing
- Cross-Platform Support

##### Performance Characteristics
- Processing time indicators
- Memory usage patterns
- Scalability characteristics

- Input Components: #4A90E2
- Processing Components: #2ECC71
- Output Components: #E67E22
- Future Components: #95A5A6
- Critical Paths: #E74C3C
- Support Systems: #8E44AD

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Style Definitions
    classDef input fill:#4A90E2,stroke:#2A70C2,color:white
    classDef processing fill:#2ECC71,stroke:#0EAC51,color:white
    classDef output fill:#E67E22,stroke:#C65E02,color:white
    classDef future fill:#95A5A6,stroke:#758586,color:white,stroke-dasharray: 5 5
    classDef support fill:#8E44AD,stroke:#6E248D,color:white
    
    %% Input Layer
    subgraph InputLayer
        SemConvReg["Semantic Convention Registry"]:::input
        TelSchema["Application Telemetry Schema"]:::input
        PolicyRules["Policy Rules (Rego)"]:::input
        Templates["Template Files"]:::input
    end

    %% Processing Layer
    subgraph CoreProcessing
        Resolver["Schema Resolution\nweaver_resolver"]:::processing
        Checker["Policy Enforcement\nweaver_checker"]:::processing
        Forge["Documentation & Code Generation\nweaver_forge"]:::processing
    end

    subgraph SupportComponents
        SemConvHandler["Semantic Convention Handler\nweaver_semconv"]:::support
        Cache["Cache Component\nweaver_cache"]:::support
        Common["Shared Utilities\nweaver_common"]:::support
        Version["Version Management\nweaver_version"]:::support
    end

    %% Output Layer
    subgraph OutputLayer
        ResolvedSchemas["Resolved Schemas"]:::output
        ValidationReports["Validation Reports"]:::output
        GeneratedDocs["Generated Documentation"]:::output
        GeneratedCode["Generated Code"]:::output
        Stats["Statistics Reports"]:::output
    end

    %% Cross-Cutting Components
    ErrorHandling["Error Handling & Diagnostics"]:::support
    WASMPlugin["Future WASM Plugin System"]:::future
    CacheStore[(Cache Store)]:::support
    CLI["Core CLI Interface"]:::processing

    %% Connections
    SemConvReg --> Resolver
    TelSchema --> Resolver
    PolicyRules --> Checker
    Templates --> Forge

    Resolver --> Checker
    Checker --> Forge
    
    SemConvHandler --> Resolver
    Cache --> CacheStore
    Common --> ErrorHandling
    Version --> Resolver

    Forge --> ResolvedSchemas
    Forge --> GeneratedDocs
    Forge --> GeneratedCode
    Checker --> ValidationReports
    Resolver --> Stats

    %% Click Events
    click SemConvReg "https://github.com/open-telemetry/weaver/tree/main/crates/weaver_semconv/data/"
    click PolicyRules "https://github.com/open-telemetry/weaver/tree/main/crates/weaver_checker/data/policies/"
    click Templates "https://github.com/open-telemetry/weaver/tree/main/crates/weaver_forge/templates/"
    click Resolver "https://github.com/open-telemetry/weaver/tree/main/crates/weaver_resolver/"
    click Checker "https://github.com/open-telemetry/weaver/tree/main/crates/weaver_checker/"
    click Forge "https://github.com/open-telemetry/weaver/tree/main/crates/weaver_forge/"
    click SemConvHandler "https://github.com/open-telemetry/weaver/tree/main/crates/weaver_semconv/"
    click Cache "https://github.com/open-telemetry/weaver/tree/main/crates/weaver_cache/"
    click Common "https://github.com/open-telemetry/weaver/tree/main/crates/weaver_common/"
    click Version "https://github.com/open-telemetry/weaver/tree/main/crates/weaver_version/"
    click ResolvedSchemas "https://github.com/open-telemetry/weaver/tree/main/crates/weaver_resolved_schema/"
    click GeneratedDocs "https://github.com/open-telemetry/weaver/tree/main/crates/weaver_forge/expected_output/"
    click ErrorHandling "https://github.com/open-telemetry/weaver/blob/main/crates/weaver_common/src/diagnostic.rs"
    click CLI "https://github.com/open-telemetry/weaver/blob/main/src/cli.rs"
```
