Skip to main content

General installation

To install the WhaTap monitoring agent on a Go application in a Linux environment, follow these steps:

Tip

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

CategoryConfiguration methodDescriptionNote
Automatic instrumentationUsing whatap-go-instAutomatic code insertion with whatap-go-inst toolRecommended
Manual instrumentationDirect use of go-apiAdd API directly to codeWhen fine-grained control is needed

Automatically insert monitoring code into source code using the whatap-go-inst tool.

1. Install whatap-go-inst

Go VersionInstallation method
Go 1.21+ (Recommended)Use go install
Go 1.18~1.20Download 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.

When installing for the first time

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 .
Note

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)
}
Note

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 variableDescription
licenseProject access key
whatap.server.hostWhaTap collection server address
app_nameApplication name

whatap.conf location by execution method

Execution methodWorking Directorywhatap.conf location
./myappCurrent 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
Note

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:

SH
## 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

Start monitoring

When you restart the application server, the agent starts collecting information.