When you want to integrate the Agent using the original go build command, you need to follow these steps.
Download the Agent from the official website.
SkyWalking Go offers two ways for integration into your project.
Agent injector is recommended when you only want to include SkyWalking Go agent in the compiling pipeline or shell.
Please execute the following command, which would automatically import SkyWalking Go into your project.
/path/to/agent -inject /path/to/your/project [-all]
/path/to/agent
is the path to the agent which your downloaded./path/to/your/project
is the home path to your project, support absolute and related with current directory path.-all
is the parameter for injecting all submodules in your project.Use go get
to import the skywalking-go
program.
go get github.com/apache/skywalking-go
Also, import the module to your main
package:
import _ "github.com/apache/skywalking-go"
NOTICE: Please ensure that the version of the Agent you downloaded is consistent with the version installed via go get
in the previous section, to prevent errors such as missing package references during compilation.
Add the following parameters in go build
:
-toolexec="/path/to/go-agent" -a
-toolexec
is the path to the Golang enhancement program.-a
is the parameter for rebuilding all packages forcibly.If you want to customize the configuration information for the current service, please add the following parameters, read more please refer the settings override documentation):
-toolexec="/path/to/go-agent -config /path/to/config.yaml" -a
The binary would be weaved and instrumented by SkyWalking Go.