# apache/skywalking-go architecture

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

- Interactive diagram: https://gitdiagram.com/apache/skywalking-go
- Repository: https://github.com/apache/skywalking-go

## Overview

##### Main components
- Agent Core: Represent the core agent components found under the “agent” directory. This includes submodules for compile-time instrumentation, metrics (agent/core/metrics), tracing (agent/core/tracing), and operator logic.
- Plugin Framework: An extensive “plugins” folder contains multiple directories for different integrations (e.g., “amqp”, “dubbo”, “gin”, “grpc”, “sql”, and many more). Show that these plugins extend the agent’s functionality to various frameworks by using a central “Plugin Manager” or “Plugin Interface” concept.
- Reporter: The “agent/reporter” and plugins subdirectories (like plugins/core/reporter) handle sending the collected data (traces/metrics/logs) to external systems (Apache SkyWalking backend, for instance).
- API/Integration Layer: Locate files such as “api.go” and supporting API implementations to present the communication endpoints for external applications or for integration into client code.
- Test and Documentation: Although not part of the runtime architecture, indicating the “test” and “docs” directory can provide context for how the agent is validated and documented.

##### Architectural principles & patterns
- Modular & Extensible Design: Emphasize that the architecture is heavily modular with reusable components. Distinct layers (instrumentation core, plugin framework, reporting layer) should be visually separated.
- Plugin Pattern and Interceptors: Indicate that many plugins implement instrumentation by intercepting function calls (observed by directories like plugins/core/operator and plugins/core/instrument) – effectively a chain-of-responsibility pattern.
- Separation of Concerns: Clearly separate build-time (static code instrumentation via compile modules) and runtime instrumentation components (reporting, plugin handlers).

- Instrumentation Core
- Plugin System (with various external integrations)
- Reporter & API Communication
- Tooling/Configuration management

##### Elements
– Instrumentation process: Application Code → Agent Core (compile/rewrite) → Plugin Interceptors
– Reporting process: Plugin/Agent Core → Reporter → External SkyWalking Backend
- Notation for external dependencies: Show external systems (i.e., SkyWalking backend collectors, third-party logging/monitoring systems) as separate entities.

##### Additional details
- Mention usage of dependency management and build configuration (files like go.mod, Makefile, Dockerfile) to indicate how the project is built and deployed.

Happy diagramming!

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Application
    A["Application Code"]:::external

    %% SkyWalking Go Agent Subgraph
    subgraph "SkyWalking Go Agent"
        AC["Agent Core (Compile, Metrics, Tracing, Operator)"]:::agent
        PF["Plugin Framework (Plugin Manager, Gin, gRPC, SQL, AMQP)"]:::plugin
        R["Reporter (agent/reporter & plugins/core/reporter)"]:::reporter
        T["Toolkit & Tools (CLI, Config)"]:::tool
        TA["Toolkit API (toolkit)"]:::tool
        API["API/Integration (api.go)"]:::api
    end

    %% External Backend
    SB["SkyWalking Backend"]:::external

    %% Development Support Subgraph
    subgraph "Dev Support"
        D["Docs"]:::support
        TE["Test"]:::support
    end

    %% Data Flow Arrows
    A -->|"wrappedInstruments"| AC
    AC -->|"triggers"| PF
    AC -->|"reportsData"| R
    PF -->|"reportsData"| R
    T -->|"configures"| AC
    T -->|"configures"| PF
    T -->|"providesAPI"| TA
    API -->|"integratesWith"| AC
    API -->|"integratesWith"| PF
    R -->|"sends"| SB

    %% Click Events
    click AC "https://github.com/apache/skywalking-go/tree/main/agent/core"
    click PF "https://github.com/apache/skywalking-go/tree/main/plugins"
    click R "https://github.com/apache/skywalking-go/tree/main/agent/reporter"
    click T "https://github.com/apache/skywalking-go/tree/main/tools/go-agent"
    click TA "https://github.com/apache/skywalking-go/tree/main/toolkit"
    click API "https://github.com/apache/skywalking-go/blob/main/api.go"
    click D "https://github.com/apache/skywalking-go/tree/main/docs"
    click TE "https://github.com/apache/skywalking-go/tree/main/test"

    %% Class Definitions for Colors and Styles
    classDef external fill:#FEE,stroke:#333,stroke-width:2px;
    classDef agent fill:#F9C,stroke:#333,stroke-width:2px;
    classDef plugin fill:#BBF,stroke:#333,stroke-width:2px;
    classDef reporter fill:#BFB,stroke:#333,stroke-width:2px;
    classDef tool fill:#FFB,stroke:#333,stroke-width:2px;
    classDef api fill:#CDF,stroke:#333,stroke-width:2px;
    classDef support fill:#DFD,stroke:#333,stroke-width:2px;
```
