Monitoring Go

The Go Collector provides automated code instrumentation for supported technologies, zero configuration health monitoring of Go services, and end-to-end traces of requests across all systems.

Support

Supported Runtimes

  • Go Collector 1.64 or later supports Go 1.22 and 1.23.
  • Go Collector 1.62 or later supports the latest two major Go releases.
  • Go 1.13 or later for Go Collector versions from 1.47.0 to 1.61.0
  • Go 1.9 or later for Go Collector versions earlier than 1.47.0

Supported Frameworks and Libraries

To avoid adding unnecessary dependencies, Instana main github.com/instana/go-sensor module provides only instrumentation for packages that are a part of the Go standard library. Third-party package instrumentations are provided as separate modules found in github.com/instana/go-sensor/instrumentation/... and need to be added to go.mod separately.

Trace continuity is not applicable to database and logging libraries.

HTTP

Target library Support policy Version Instrumentation package Version Trace continuity
net/http 0 day github.com/instana/go-sensor 1.64.0
github.com/labstack/echo 45 days 4.12.0 github.com/instana/go-sensor/instrumentation/instaecho 1.21.0
github.com/gin-gonic/gin 45 days 1.10.0 github.com/instana/go-sensor/instrumentation/instagin 1.20.0
github.com/gorilla/mux 45 days 1.8.1 github.com/instana/go-sensor/instrumentation/instamux 1.19.0
github.com/julienschmidt/httprouter 45 days 1.3.0 github.com/instana/go-sensor/instrumentation/instahttprouter 1.17.0
github.com/gofiber/fiber 45 days 2.52.5 github.com/instana/go-sensor/instrumentation/instafiber 0.15.0
github.com/beego/beego 45 days 2.3.0 github.com/instana/go-sensor/instrumentation/instabeego 0.11.0

RPC

Target library Support policy Version Instrumentation package Version Trace continuity
google.golang.org/grpc 45 days 1.66.0 github.com/instana/go-sensor/instrumentation/instagrpc 1.26.0

Databases

Target library Support policy Version Instrumentation package Version
database/sql 0 day github.com/instana/go-sensor 1.64.0
go.mongodb.org/mongo-driver 45 days 1.16.1 github.com/instana/go-sensor/instrumentation/instamongo 1.21.0
jackc/pgx 45 days 5.6.0 github.com/instana/go-sensor/instrumentation/instapgx 2.2.0
go-redis 45 days 9.6.1 github.com/instana/go-sensor/instrumentation/instaredis 2.13.0
redigo 45 days 1.9.2 github.com/instana/go-sensor/instrumentation/instaredigo 0.19.0
gorm 45 days 1.25.11 github.com/instana/go-sensor/instrumentation/instagorm 1.13.0
gocb 45 days 2.9.1 github.com/instana/go-sensor/instrumentation/instagocb 1.9.0
azcosmos 45 days 1.0.3 github.com/instana/go-sensor/instrumentation/instacosmos 1.3.0

Messaging

Target library Support policy Version Instrumentation package Version Trace continuity
cloud.google.com/go/pubsub 45 days 1.42.0 github.com/instana/go-sensor/instrumentation/cloud.google.com/go/pubsub 1.38.0
github.com/IBM/sarama 45 days 1.43.3 github.com/instana/go-sensor/instrumentation/instasarama 1.26.0
github.com/rabbitmq/amqp091-go 45 days 1.10.0 github.com/instana/go-sensor/instrumentation/instaamqp091 0.18.0

GraphQL

Target library Support policy Version Instrumentation package Version Trace continuity
graphql-go/graphql 45 days 0.8.1 github.com/instana/go-sensor/instrumentation/instagraphql 1.14.0

Other

Target library Support policy Version Instrumentation package Version Trace continuity
cloud.google.com/go/storage 45 days 1.43.0 github.com/instana/go-sensor/instrumentation/cloud.google.com/go/storage 1.38.0
github.com/aws/aws-sdk-go 45 days 1.55.5 github.com/instana/go-sensor/instrumentation/instaawssdk 1.31.0
github.com/aws/aws-lambda-go 45 days 1.47.0 github.com/instana/go-sensor/instrumentation/instalambda 1.25.0
github.com/sirupsen/logrus 45 days 1.9.3 github.com/instana/go-sensor/instrumentation/instalogrus 1.19.0
github.com/aws/aws-sdk-go-v2 45 days 1.30.4 github.com/instana/go-sensor/instrumentation/instaawsv2 0.16.0

Runtime Metrics

Following metrics are collected and displayed on the Go process dashboard:

  • Memory usage
  • Heap usage
  • GC activity
  • Goroutines

Health Signatures

  • Calls
  • Response time
  • Scaling

Installation

The installation of the Instana Go collector is a simple two-step process. First, add github.com/instana/go-sensor module to your go.mod file:

go get github.com/instana/go-sensor

After the go-sensor module is added to your application dependencies, you can use the go-sensor module to instrument your application code. For more information, see Installation.

Starting from version 1.53.0, Go Collector uses fsm v1.0.1 internally. If you are using fsm version before v1 in your projects, you might face compilation issues, and you need to update fsm version to v1.

Tracers Logs

The Go Collector uses a leveled logger to log internal errors and diagnostic information. The default logger.Logger uses log.Logger configured with log.Lstdflags as a backend and writes messages to os.Stderr. By default, this logger only prints out the ERROR level messages unless the environment variable INSTANA_DEBUG is set.

To change the min log level in runtime it is recommended to configure and inject an instance of instana.LeveledLogger:

l := logger.New(log.New(os.Stderr, "", os.Lstdflags))
instana.SetLogger(l)

// ...

l.SetLevel(logger.WarnLevel)

The logger.LeveledLogger interface is implemented by such popular logging libraries as github.com/sirupsen/logrus and go.uber.org/zap, so they can be used as a replacement.

Alternatively, since version 1.39.0 of the Go sensor, the INSTANA_LOG_LEVEL environment variable can be used to set the log level.

Note: the value of INSTANA_DEBUG environment variable does not affect custom loggers. You'd need to explicitly check whether it's set and enable the debug logging while configuring your logger:

import (
	instana "github.com/instana/go-sensor"
	"github.com/sirupsen/logrus"
)

func main() {
	// initialize Instana sensor
	instana.InitSensor(&instana.Options{Service: SERVICE})

	// initialize and configure the logger
	logger := logrus.New()
	logger.Level = logrus.InfoLevel

	// check if INSTANA_DEBUG is set and set the log level to DEBUG if needed
	if _, ok := os.LookupEnv("INSTANA_DEBUG"); ok {
		logger.Level = logrus.DebugLevel
	}

	// use logrus to log the Instana Go Collector messages
	instana.SetLogger(logger)

	// ...
}

Platforms

The Go collector supports serverless mode, when instead of a host agent, it sends metrics and traces to the serverless acceptor endpoint. To switch collector into a serverless mode, set the INSTANA_ENDPOINT_URL environment variable to the serverless acceptor URL of your Instana installation and provide your agent key via INSTANA_AGENT_KEY. Refer to the Serverless Monitoring section to learn about other configuration options available in serverless mode.

AWS Fargate

Instana Go collector automatically detects if a service is running on AWS Fargate when running in a serverless mode.

Google Cloud Run

Instana Go collector automatically detects if a service is running on Google Cloud Run when running in a serverless mode.

AWS Lambda

Instana Go Collector supports tracing AWS Lambda function written in Go starting from v1.23.0. Handlers need to be instrumented using the github.com/instana/go-sensor/instrumentation/instalambda package in order to collect and send trace data. Please refer to AWS Lambda Go documentation for details.

Azure Function

Instana Go Collector supports the tracing of Azure functions that are written in Go. Handlers need to be instrumented by using the github.com/instana/go-sensor/instrumentation/instaazurefunction package to collect and send trace data. For more information, see Azure Functions Tracing for Go.

Azure Container Apps

The Instana Go Collector supports tracing of Go applications that are deployed in Azure Container Apps. To enable tracing, instrument your application with the Instana Go Tracer SDK, deploy it to Azure Container Apps, and ensure that the required environment variables are set. For more information, see Monitoring Azure Container Apps.

Kubernetes & OpenShift

If your Go application and the Instana agent run in a Kubernetes cluster, check the documentation on Kubernetes network access for information about the required configuration in this setup.

Configuration

The Go collector accepts configuration in two formats: within the application code via an instana.Options configuration object or via environment variables. The in-app configuration takes precedence over environment variables except for the following settings:

  • INSTANA_SERVICE_NAME allows to override the service name set in the code
  • INSTANA_PROCESS_NAME allows to override the name for the infrastructure entity that represents the Go process.
  • INSTANA_DEBUG enables debug logs even if the app code configuration defines a higher logging level
  • INSTANA_AUTO_PROFILE enables continuous profiling with AutoProfile™
  • INSTANA_LOG_LEVEL allows specifying the log level. Possible values are debug, error, warn and info. The INSTANA_DEBUG enviroment variable takes precedence if set
  • INSTANA_KAFKA_HEADER_FORMAT enables users to specify the format of Kafka headers propagated by Instana. Possible values are binary (legacy), string (new format) and both
  • INSTANA_ALLOW_ROOT_EXIT_SPAN determines whether the tracer starts a trace with an exit span or not. If you set the value to 1, the tracer records exit spans for the outgoing calls in instances with no parent entry span. If you set 0 or any other value, the tracer does not start a trace with an exit span.

For more detailed information, refer to the configuration page.

Instana AutoProfile™

Profiles are essential for locating performance hot spots and bottlenecks at the code level. They are instrumental in reducing resource consumption and improving performance.

AutoProfile™ generates and reports process profiles to Instana. Unlike development-time and on-demand profilers, where a user must manually initiate profiling, AutoProfile™ automatically schedules and continuously performs profiling appropriate for critical production environments.

To enable AutoProfile™ add EnableAutoProfile: true option in instana.InitSensor(opt). For detailed instructions, see github.com/instana/go-sensor. If you need to enable profiling for an app instrumented with Instana without changing the instana.InitSensor() config, set INSTANA_AUTO_PROFILE=true env variable. Note that this value takes precedence and overrides any attempt to disable profiling from inside the application code.

For more information, see our Instana AutoProfile™ docs.

Troubleshooting

Outdated Go runtime

Monitoring issue type: outdated_go_runtime

To resolve this issue, update the Go runtime version to the latest one.

See Also