# parca-dev/opentelemetry-ebpf-profiler architecture

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

- Interactive diagram: https://gitdiagram.com/parca-dev/opentelemetry-ebpf-profiler
- Repository: https://github.com/parca-dev/opentelemetry-ebpf-profiler

## Overview

##### Main Components

a) Core System Components:
- eBPF Programs (Kernel Space)
- Host Agent (User Space)
- Backend Collector
- Visualization Layer (devfiler)

b) Key Subsystems:
- Tracer
- Process Manager
- Trace Handler
- Reporter
- Interpreter Handlers
- Stack Delta Provider

**[Kernel Space]**
- ↑↓
**[User Space Agent]**
- ↑↓
**[Collection & Visualization]**

##### Component Relationships

a) Kernel Space Layer:
- EBPF Programs attached to kernel probes
- BPF maps for data sharing
- Unwinder components for different languages

b) User Space Layer:
- Process Manager's connections to interpreters
- Trace processing pipeline
- Conversion flow from BPF to user-space trace format

c) Collection Layer:
- GRPC communication with the backend
- OTLP protocol integration
- Devfiler visualization connection

##### Detailed Component Representation

**[Kernel Space]**
- BPF Programs
- Native Unwinder
- Language-specific Unwinders
- PID Event Tracking
- BPF Maps
- Kernel Probes

**[User Space Agent]**
- Tracer
- Event Pump
- BPF Program Manager
- Process Manager
- Executable Mapping
- Interpreter Handlers
- Trace Handler
- Format Converter
- Hash Cache
- Reporter
- Trace Aggregator
- gRPC Client

**[Collection & Visualization]**
- Backend Collector
- OTLP Receiver
- Symbolization Service
- devfiler UI

##### Data Flow Representation

- Stack trace collection flow
- Process creation/termination events
- Symbolization requests
- Trace conversion and enrichment
- Data reporting to backend

##### Additional Elements

- Version compatibility notes
- Supported language interpreters
- Configuration points
- Critical monitoring paths

##### Implementation Notes

- Nested components
- Export to standard formats

This system design should emphasize:

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Kernel["Kernel Space"]
        BPF["eBPF Programs"]:::kernel
        BPFMaps["BPF Maps"]:::kernel
        KProbes["Kernel Probes"]:::kernel
        NativeUnwind["Native Unwinder"]:::kernel
        LangUnwind["Language Unwinders"]:::kernel
    end

    subgraph Agent["User Space Agent"]
        direction TB
        subgraph TracerComp["Tracer Component"]
            EventPump["Event Pump"]:::agent
            BPFManager["BPF Program Manager"]:::agent
        end

        subgraph ProcMgr["Process Manager"]
            ExecMap["Executable Mapping"]:::agent
            InterpHandlers["Interpreter Handlers"]:::agent
        end

        subgraph TraceComp["Trace Handler"]
            FormatConv["Format Converter"]:::agent
            HashCache["Hash Cache"]:::agent
        end

        subgraph ReportComp["Reporter"]
            TraceAgg["Trace Aggregator"]:::agent
            GRPCClient["gRPC Client"]:::agent
        end

        HostAgent["Host Agent"]:::agent
        StackDelta["Stack Delta Provider"]:::agent
    end

    subgraph Collection["Collection & Visualization"]
        Backend["Backend Collector"]:::collection
        OTLP["OTLP Receiver"]:::collection
        Symbolizer["Symbolization Service"]:::collection
        UI["devfiler UI"]:::visualization
    end

    %% Connections
    BPF --> BPFMaps
    KProbes --> BPF
    BPF --> NativeUnwind
    BPF --> LangUnwind
    BPFMaps --> EventPump
    EventPump --> BPFManager
    BPFManager --> TraceComp
    ProcMgr --> InterpHandlers
    InterpHandlers --> TraceComp
    TraceComp --> HashCache
    HashCache --> FormatConv
    FormatConv --> ReportComp
    TraceAgg --> GRPCClient
    GRPCClient --> OTLP
    OTLP --> Backend
    Backend --> Symbolizer
    Backend --> UI
    HostAgent --> ProcMgr
    StackDelta --> TraceComp

    %% Click Events
    click BPF "https://github.com/parca-dev/opentelemetry-ebpf-profiler/tree/main/support/ebpf/"
    click TracerComp "https://github.com/parca-dev/opentelemetry-ebpf-profiler/tree/main/tracer/"
    click ProcMgr "https://github.com/parca-dev/opentelemetry-ebpf-profiler/tree/main/processmanager/"
    click TraceComp "https://github.com/parca-dev/opentelemetry-ebpf-profiler/tree/main/tracehandler/"
    click ReportComp "https://github.com/parca-dev/opentelemetry-ebpf-profiler/tree/main/reporter/"
    click InterpHandlers "https://github.com/parca-dev/opentelemetry-ebpf-profiler/tree/main/interpreter/"
    click StackDelta "https://github.com/parca-dev/opentelemetry-ebpf-profiler/tree/main/nativeunwind/elfunwindinfo/"
    click HostAgent "https://github.com/parca-dev/opentelemetry-ebpf-profiler/tree/main/host/"
    click ExecMap "https://github.com/parca-dev/opentelemetry-ebpf-profiler/tree/main/processmanager/ebpf/"

    %% Styles
    classDef kernel fill:#1e88e5,color:white
    classDef agent fill:#43a047,color:white
    classDef collection fill:#fdd835,color:black
    classDef visualization fill:#e53935,color:white

    %% Legend
    subgraph Legend
        K["Kernel Component"]:::kernel
        A["Agent Component"]:::agent
        C["Collection Component"]:::collection
        V["Visualization Component"]:::visualization
    end
```
