GO agent

GO agents monitor your GO language applications and microservices and helps to identify and find the root cause of performance issues.

Prerequisites

  • For prerequisite checks for agent installation, see Prerequisite checks for agent installation.
  • Golang Version 1.11 or higher on Linux.
  • ACCESS_TOKEN - Environment variable that is required for including in .netrc.
  • USERNAME - Environment variable that is required for including in .netrc.
  • SIXTHSENSE_TOKEN - For accessing the token, see Accessing your access token.

Installing GO agent

The following procedures help you install the GO agent on a VM and on a Docker.

Installing on a VM

  1. Configure .netrc file in root for authenticating to SixthSense Registry.
nano ~/.netrc
echo "machine artifacts-observability.sixthsense.rakuten.com login ${USERNAME} password ${ACCESS_TOKEN}" > ~/.netrc
  1. Install the package.

a. Installing the package requires some environment variables which should be exported i.e. GONOSUMDB and GOPROXY.

export GONOSUMDB=artifacts-observability.sixthsense.rakuten.com/sixthsense
export GOPROXY="direct"

b. Install using go get/ go install

go get artifacts-observability.sixthsense.rakuten.com/sixthsense/sixthsenseGoAgent

Install the package directly without exporting any global environments using ENVs as arguments prior to executing go get.

GONOSUMDB=artifacts-observability.sixthsense.rakuten.com/sixthsense GOPROXY="direct" go get artifacts-observability.sixthsense.rakuten.com/sixthsense/sixthsenseGoAgent

Installing on Docker

  1. Setup Docker file containing .netrc file at the root of the filesystem.
  2. Download the agent using go get/go mod.

Docker configuration example:

FROM golang:1.14
WORKDIR /src
COPY . .
RUN apt-get update
RUN apt-get install -y git
# SixthSense Setup
ENV GONOSUMDB=artifacts-observability.sixthsense.rakuten.com/sixthsense
ARG ACCESS_TOKEN
ARG USERNAME
RUN echo "machine artifacts-observability.sixthsense.rakuten.com login ${USERNAME} password ${ACCESS_TOKEN}" > ~/.netrc
# Setup netrc in local, then copy the configuration
# COPY .netrc /root/.netrc
RUN go mod download
RUN go build -o /app /src/cmd/cataloguesvc/main.go
ENTRYPOINT ["/app", "-port=8080"]
EXPOSE 8080

Setup the application

  1. Import the artifacts-observability.sixthsense.rakuten.com/sixthsense/sixthsenseGoAgent package/plugins in the main function of the application. For supported plugins, see Supported frameworks and plugins.
import (
"artifacts-observability.sixthsense.rakuten.com/sixthsense/sixthsenseGoAgent"
httpPlugin "artifacts-observability.sixthsense.rakuten.com/sixthsense/sixthsenseGoAgent/plugins/http" // If using http plugin of sixthsense
)
  1. Initialize the agent in main function. Here http plugin is used for the setup.
const (
OAP_TOKEN = "$SIXTHSENSE_TOKEN"
OAP_ADDRESS = "grpc-collector-observability.sixthsense.rakuten.com:443"
API_USER_NAME = "APPLICATION_NAME"
)
re, err := reporter.NewGRPCReporter(OAP_ADDRESS, reporter.WithAuthentication(OAP_TOKEN))
if err != nil {
log.Fatalf("new reporter error %v \n", err)
}
// add the application name and send the tracer to ConnectDatabase
tracer, err := sixthsenseGoAgent.NewTracer(API_USER_NAME, sixthsenseGoAgent.WithReporter(re))
if err != nil {
log.Fatalf("create tracer error %v \n", err)
}
serverMiddleWare, err := httpPlugin.NewServerMiddleware(tracer)
if err != nil {
log.Fatalf("create server middleware error %v \n", err)
}

For OneCloud Platform use the following command:

const (
OAP_TOKEN = "$SIXTHSENSE_TOKEN"
OAP_ADDRESS = "133.237.176.44:80"
API_USER_NAME = "APPLICATION_NAME"
)
re, err := reporter.NewGRPCReporter(OAP_ADDRESS, reporter.WithAuthentication(OAP_TOKEN))e, err := reporter.NewGRPCReporter(OAP_ADDRESS, reporter.WithAuthentication(OAP_TOKEN), reporter.WithTransportInsecure(true))
if err != nil {
log.Fatalf("new reporter error %v \n", err)
}
// add the application name and send the tracer to ConnectDatabase
tracer, err := sixthsenseGoAgent.NewTracer(API_USER_NAME, sixthsenseGoAgent.WithReporter(re))
if err != nil {
log.Fatalf("create tracer error %v \n", err)
}
serverMiddleWare, err := httpPlugin.NewServerMiddleware(tracer)
if err != nil {
log.Fatalf("create tracer error %v \n", err)
}
serverMiddleWare, err := httpPlugin.NewServerMiddleware(tracer)
if err != nil {
log.Fatalf("create server middleware error %v \n", err)
}
  1. Instrument transactions by wrapping HTTP Server.
go func() {
logger.Log("transport", "HTTP", "port", *port)
errc <- http.ListenAndServe(":"+*port, serverMiddleWare(handler))
}()
  1. Instrument other transactions which use gin, go-resty, and so on. For more information, see Supported technologies.

Supported frameworks and plugins

LanguageFrameworks Supported
GOhttp server and client, Gin(v1.5.0), Gear(v1.21.0), go-resty(v2.2.0), go-micro(<=v1.8) (v2.x is not supported), go-restful(v3+)
SchedulerElastic Job 2.x Apache ShardingSphere-Elasticjob 3.0.0-alpha Spring @Scheduled 3.1+ Quartz Scheduler 2.x (Optional²) XXL Job 2.x
GraphQLGraphql 8.0 -> 15.x
PoolApache Commons DBCP 2.x

Related Links:

APM Metrics