The Golang auto-instrument Agent for Apache SkyWalking, providing non-intrusive distributed tracing, metrics, and logging via compile-time enhancement.
Overview#
Apache SkyWalking Go is a Golang APM agent under the Apache Foundation, serving as an official subproject of Apache SkyWalking. It aims to address the lack of mature, non-intrusive APM solutions in the Go ecosystem. The project leverages the Go compiler's -toolexec mechanism to inject code at compile time, enabling auto-instrumentation for mainstream web frameworks and database drivers.
Core Capabilities#
- Auto-Instrumentation: Transparent enhancement via
-toolexechybrid compilation, injecting interception logic without modifying business source code - Multi-Framework Support: Built-in plugins directory supporting automatic instrumentation for popular frameworks like Gin, Echo, gRPC
- Three Observability Signals:
- Tracing: Distributed call chain tracing with sampling and ignore strategies
- Metrics: Golang Runtime metrics (GC, Goroutine, etc.) and custom business metrics
- Logging: logrus/zap log framework adapters with automatic TraceID correlation
- Data Reporting: Supports both gRPC and Kafka reporters to send data to SkyWalking OAP
- Performance Diagnostics: Integrated pprof support for performance profiling
Architecture#
The project adopts a compile-time static injection strategy with core modules:
agent/: Agent core implementation, including bootstrapping, configuration loading, and core interception logicplugins/: Plugin architecture organized by framework/library, handling specific function interception and context propagationtoolkit/: Developer-facing manual API library providing trace/metric/logging interfacesprotocols/collect: Defines data transmission protocols for backend OAP interaction
Installation & Usage#
Prerequisites: Go environment, SkyWalking OAP backend service
Integration Methods:
Method 1 (Recommended, Zero Code Intrusion):
/path/to/agent -inject /path/to/your/project [-all]
Method 2 (Code Dependency):
go get github.com/apache/skywalking-go
import _ "github.com/apache/skywalking-go"
Build Application:
go build -toolexec="/path/to/go-agent" -a
# Optional custom configuration
go build -toolexec="/path/to/go-agent -config /path/to/config.yaml" -a
Note: The
-aflag forces full recompilation to ensure all dependencies are processed by the Agent.
Configuration Management#
- Fine-grained management via YAML configuration files
- Service-level settings override support
- Environment variable override support for containerized deployments
Typical Use Cases#
- Full-link call chain tracing and performance bottleneck identification in Go microservice architectures
- Observability implementation with zero or low code intrusion
- Correlating application logs with call chain TraceIDs for unified troubleshooting views
- Manual instrumentation for custom business logic tracing and metrics