# kaligo/event_tracer architecture

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

- Interactive diagram: https://gitdiagram.com/kaligo/event_tracer
- Repository: https://github.com/kaligo/event_tracer

## Overview

##### Main Components

a. Core EventTracer Component:
- Configuration module
- Registry mechanism
- Buffer component for optimization

b. Logger Implementations:
- Base Logger
- Appsignal Logger
- Datadog Logger
- DynamoDB Logger
- Prometheus Logger

c. Supporting Components:
- Error Handling System
- Buffering System
- Result Processing

##### Relationship Flows

**┌─────────────────────────────────────────────────────────────────┐**
- External Services                           │
- ┌──────────┐  ┌──────────┐  ┌──────────┐  ┌──────────┐       │
- AppSignal │  │ Datadog  │  │ DynamoDB │  │Prometheus│       │
- ┬─────┘  └────┬─────┘  └────┬─────┘  └────┬─────┘       │
- ┼──────────────┼──────────────┼──────────────┼───────────┘

**┌───────┼──────────────┼──────────────┼──────────────┼───────────┐**
- EventTracer Core          │              │           │
- ┌───▼───────────────▼───────────────▼──────────────▼──┐     │
- Registry                           │     │
- (Manages logger registration and access)        │     │
- ┬───────────────────────────────┬─┘     │

- ┌───────────────────▼───────────────┐   ┌──────────▼──┐    │
- Logger Implementations      │   │   Buffer    │    │
- ┌─────────┐ ┌─────────┐ ┌───────┐ │   │  System    │    │
- Base   │ │ Metric  │ │DynamoDB│ │   └───────────┘    │
- Logger  │ │ Loggers │ │Logger  │ │                     │
- ┘ └─────────┘ └───────┘ │                     │
- ┘                     │

- ┌───────────────────▼───────────────┐                     │
- Error Handling System       │                     │
- (Configurable Error Handler)   │                     │
- ┘                     │
- ┘

##### Important Details

a. Configuration Layer:
- How EventTracer.Config interfaces with all components
- Configuration options (app_name, table_name, etc.)

b. Buffer System:
- Buffer_size and flush_interval parameters
- Relationship with DynamoDB logger

c. Metric Types:
- Counter
- Gauge
- Distribution
- Histogram
- Set

##### Implementation Notes

- Use standardized UML notation where appropriate
- A notes section explaining the async nature of the buffer system
- Annotations for required dependencies (Sidekiq, AWS SDK)
- Error handling flow with the Result object pattern

##### Integration Points

Clearly mark:
- External service connection points
- Configuration injection points
- Custom logger extension points
- Error handler customization points

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph External["External Services"]
        direction TB
        AppSignal["AppSignal Service"]:::external
        Datadog["Datadog Service"]:::external
        DynamoDBService["DynamoDB Service"]:::external
        PrometheusService["Prometheus Service"]:::external
    end

    subgraph Core["EventTracer Core"]
        direction TB
        EventTracer["EventTracer"]:::core
        Config["Configuration"]:::core
        Registry["Registry"]:::core
        Buffer["Buffer System"]:::buffer
    end

    subgraph Loggers["Logger Implementations"]
        direction TB
        BaseLogger["Base Logger"]:::logger
        MetricLogger["Metric Logger"]:::logger
        BufferedLogger["Buffered Logger"]:::logger
        AppSignalLogger["AppSignal Logger"]:::logger
        DatadogLogger["Datadog Logger"]:::logger
        DynamoLogger["DynamoDB Logger"]:::logger
        PrometheusLogger["Prometheus Logger"]:::logger
    end

    subgraph DynamoDB["DynamoDB Components"]
        direction TB
        DynamoClient["DynamoDB Client"]:::dynamo
        DynamoWorker["DynamoDB Worker"]:::dynamo
        DynamoProcessor["DynamoDB Processor"]:::dynamo
    end

    subgraph Support["Supporting Components"]
        direction TB
        ErrorHandler["Error Handler"]:::support
        ResultProcessor["Result Processor"]:::support
        BasicDecorator["Basic Decorator"]:::support
    end

    %% Core Relationships
    EventTracer --> Config
    EventTracer --> Registry
    Registry --> Buffer
    Registry --> Loggers

    %% Logger Inheritance
    BaseLogger --> MetricLogger
    MetricLogger --> BufferedLogger
    BufferedLogger --> DynamoLogger
    MetricLogger --> AppSignalLogger
    MetricLogger --> DatadogLogger
    MetricLogger --> PrometheusLogger

    %% External Service Connections
    AppSignalLogger --> AppSignal
    DatadogLogger --> Datadog
    PrometheusLogger --> PrometheusService
    DynamoLogger --> DynamoDBService

    %% DynamoDB Components
    DynamoLogger --> DynamoClient
    DynamoClient --> DynamoWorker
    DynamoWorker --> DynamoProcessor

    %% Support Integration
    Loggers --> ErrorHandler
    Loggers --> ResultProcessor
    Loggers --> BasicDecorator

    %% Styling
    classDef core fill:#b3e0ff,stroke:#333,stroke-width:2px
    classDef logger fill:#d9f2d9,stroke:#333,stroke-width:2px
    classDef buffer fill:#fff2cc,stroke:#333,stroke-width:2px
    classDef external fill:#cccccc,stroke:#333,stroke-width:2px
    classDef dynamo fill:#ffcccc,stroke:#333,stroke-width:2px
    classDef support fill:#e6ccff,stroke:#333,stroke-width:2px

    %% Click Events
    click EventTracer "https://github.com/Kaligo/event_tracer/blob/master/lib/event_tracer.rb"
    click Config "https://github.com/Kaligo/event_tracer/blob/master/lib/event_tracer/config.rb"
    click Buffer "https://github.com/Kaligo/event_tracer/blob/master/lib/event_tracer/buffer.rb"
    click BaseLogger "https://github.com/Kaligo/event_tracer/blob/master/lib/event_tracer/base_logger.rb"
    click AppSignalLogger "https://github.com/Kaligo/event_tracer/blob/master/lib/event_tracer/appsignal_logger.rb"
    click DatadogLogger "https://github.com/Kaligo/event_tracer/blob/master/lib/event_tracer/datadog_logger.rb"
    click DynamoLogger "https://github.com/Kaligo/event_tracer/blob/master/lib/event_tracer/dynamo_db/logger.rb"
    click PrometheusLogger "https://github.com/Kaligo/event_tracer/blob/master/lib/event_tracer/prometheus_logger.rb"
    click MetricLogger "https://github.com/Kaligo/event_tracer/blob/master/lib/event_tracer/metric_logger.rb"
    click BufferedLogger "https://github.com/Kaligo/event_tracer/blob/master/lib/event_tracer/buffered_logger.rb"
    click DynamoClient "https://github.com/Kaligo/event_tracer/blob/master/lib/event_tracer/dynamo_db/client.rb"
    click DynamoWorker "https://github.com/Kaligo/event_tracer/blob/master/lib/event_tracer/dynamo_db/worker.rb"
    click DynamoProcessor "https://github.com/Kaligo/event_tracer/blob/master/lib/event_tracer/dynamo_db/default_processor.rb"
    click ErrorHandler "https://github.com/Kaligo/event_tracer/blob/master/lib/event_tracer/error_with_payload.rb"
    click ResultProcessor "https://github.com/Kaligo/event_tracer/blob/master/lib/event_tracer/log_result.rb"
    click BasicDecorator "https://github.com/Kaligo/event_tracer/blob/master/lib/event_tracer/basic_decorator.rb"
```
