General installation
To install the WhaTap monitoring agent on a Go application in a Linux environment, follow these steps:
- Step 1. Apply Go library
- Step 2. Set monitoring environment variables
- Step 3. Install data relay agent
Before starting the installation, prepare the following information:
- WhaTap project access key (check from [Project menu] > [Management] > [Agent installation])
- WhaTap collection server IP address
Apply Go library
The following are methods to add the WhaTap Go Library to the application to be monitored. Automatic instrumentation is recommended.
Library configuration methods
| Category | Configuration method | Description | Note |
|---|---|---|---|
| Automatic instrumentation | Using whatap-go-inst | Automatic code insertion with whatap-go-inst tool | Recommended |
| Manual instrumentation | Direct use of go-api | Add API directly to code | When fine-grained control is needed |
Automatic instrumentation (Recommended)
Automatically insert monitoring code into source code using the whatap-go-inst tool.
1. Install whatap-go-inst
| Go Version | Installation method |
|---|---|
| Go 1.21+ (Recommended) | Use go install |
| Go 1.18~1.20 | Download binary |
- Go 1.21+ (Recommended)
go install github.com/whatap/go-api-inst/cmd/whatap-go-inst@latest
-
Go 1.18~1.20
Download pre-built binaries.
Linux x86_64:
wget https://github.com/whatap/go-api-inst/releases/latest/download/whatap-go-inst_linux_amd64.tar.gz
tar -xvzf whatap-go-inst_linux_amd64.tar.gz
sudo mv whatap-go-inst /usr/local/bin/
Linux ARM64:
wget https://github.com/whatap/go-api-inst/releases/latest/download/whatap-go-inst_linux_arm64.tar.gz
tar -xvzf whatap-go-inst_linux_arm64.tar.gz
sudo mv whatap-go-inst /usr/local/bin/
2. Initialize project and build
Run the following commands in the project root directory where go.mod is located.
If you are installing whatap-go-inst for the first time, you need to set the PATH environment variable first.
# Add environment variable (only needed for first installation)
export PATH=$PATH:$(go env GOPATH)/bin
# Download and install go-api package
go get github.com/whatap/go-api@latest
go mod tidy
# Build (automatically insert monitoring code)
whatap-go-inst go build -o myapp .
For detailed usage, see the Automatic instrumentation guide.
Manual instrumentation
Download go-api directly and manually insert monitoring code into source code.
1. Download go-api
go get github.com/whatap/go-api
2. Add monitoring code
import "github.com/whatap/go-api/trace"
func main(){
trace.Init(nil)
defer trace.Shutdown()
ctx, _ := trace.Start(context.Background(), "Start Tx")
...
trace.End(ctx, err)
}
For detailed API usage, see the Manual instrumentation guide.
Set monitoring environment variables
Monitoring environment variables are configured in the whatap.conf file.
whatap.conf must be created in the working directory where the application runs.
Key settings
| Environment variable | Description |
|---|---|
license | Project access key |
whatap.server.host | WhaTap collection server address |
app_name | Application name |
whatap.conf location by execution method
| Execution method | Working Directory | whatap.conf location |
|---|---|---|
./myapp | Current directory | ./whatap.conf |
/home/user/app/myapp | /home/user/app | /home/user/app/whatap.conf |
| Run with absolute path | / (root) | Requires WHATAP_HOME setting |
Configuration methods
Basic execution
echo "license={access key}" >> ./whatap.conf
echo "whatap.server.host={collection server IP address}" >> ./whatap.conf
echo "app_name={application name}" >> ./whatap.conf
./app
WHATAP_HOME environment variable setting
mkdir ./whatap_home
echo "license={access key}" >> ./whatap_home/whatap.conf
echo "whatap.server.host={collection server IP address}" >> ./whatap_home/whatap.conf
echo "app_name={application name}" >> ./whatap_home/whatap.conf
WHATAP_HOME=./whatap_home ./app
Agent name setting per process
For applications running with two or more processes, it is recommended to configure a separate whatap.conf file for each process.
# Application 1
mkdir ./whatap_home
echo "license={access key}" >> ./whatap_home/whatap.conf
echo "whatap.server.host={collection server IP address}" >> ./whatap_home/whatap.conf
echo "app_name={application name-1}" >> ./whatap_home/whatap.conf
WHATAP_HOME=./whatap_home ./app
# Application 2
mkdir ./whatap_home1
echo "license={access key}" >> ./whatap_home1/whatap.conf
echo "whatap.server.host={collection server IP address}" >> ./whatap_home1/whatap.conf
echo "app_name={application name-2}" >> ./whatap_home1/whatap.conf
WHATAP_HOME=./whatap_home1 ./app
app_name is a component for determining the agent name. For more information, see the following documentation.
Install data relay agent
Once you have obtained the access key, download the agent using the following commands:
- Red Hat/CentOS
- Debian/Ubuntu
- Amazon Linux
- Alpine Linux
## Register package repository
$ sudo rpm -Uvh https://repo.whatap.io/centos/5/noarch/whatap-repo-1.0-1.noarch.rpm
## Install package
$ sudo yum install whatap-agent
## Register package repository
$ wget https://repo.whatap.io/debian/release.gpg -O -|sudo apt-key add -
$ wget https://repo.whatap.io/debian/whatap-repo_1.0_all.deb
$ sudo dpkg -i whatap-repo_1.0_all.deb
$ sudo apt-get update
## Install package
$ sudo apt-get install whatap-agent
sudo rpm --import https://repo.whatap.io/centos/release.gpg
echo "[whatap]" | sudo tee /etc/yum.repos.d/whatap.repo
echo "name=whatap packages for enterprise linux" | sudo tee -a /etc/yum.repos.d/whatap.repo
echo "baseurl=https://repo.whatap.io/centos/latest/\$basearch" | sudo tee -a /etc/yum.repos.d/whatap.repo
echo "enabled=1" | sudo tee -a /etc/yum.repos.d/whatap.repo
echo "gpgcheck=0" | sudo tee -a /etc/yum.repos.d/whatap.repo
sudo yum install whatap-agent
- x64
- AArch64
wget https://s3.ap-northeast-2.amazonaws.com/repo.whatap.io/alpine/x86_64/whatap-agent.tar.gz
tar -xvzf whatap-agent.tar.gz -C /
wget https://s3.ap-northeast-2.amazonaws.com/repo.whatap.io/alpine/aarch64/whatap-agent.tar.gz
tar -xvzf whatap-agent.tar.gz -C /
Start monitoring
When you restart the application server, the agent starts collecting information.