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
- 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
- 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
- Setup Docker file containing .netrc file at the root of the filesystem.
- 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
- 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
)
- 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:
// For connectivity to backend using onecloud private network: 100.99.116.221:80
// For connectivity to backend using intra public network: 133.237.176.44:80
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)
}
- Instrument transactions by wrapping HTTP Server.
go func() {
logger.Log("transport", "HTTP", "port", *port)
errc <- http.ListenAndServe(":"+*port, serverMiddleWare(handler))
}()
- Instrument other transactions which use gin, go-resty, and so on. For more information, see Supported technologies.
Supported frameworks and plugins
Language | Frameworks Supported |
---|---|
GO | http 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+) |
Scheduler | Elastic Job 2.x Apache ShardingSphere-Elasticjob 3.0.0-alpha Spring @Scheduled 3.1+ Quartz Scheduler 2.x (Optional²) XXL Job 2.x |
GraphQL | Graphql 8.0 -> 15.x |
Pool | Apache Commons DBCP 2.x |
Related Links: