Go is being considered a good fit to implement microservices, and as we engage with the IT marketplace, we see it quite commonly used for new projects. From the perspective of pure size, the resulting programs are small in terms of binary and footprint, making them good citizens “inside” containers. The language itself is not complex and is easy to learn for anybody in the IT organization. The runtime is thin, while offering sufficient mechanisms for garbage collection, parallel programming etc., allowing the focus to be on functionality. And it’s popular among operations people, bringing engineering aspects to otherwise unmanageable classic collection of shell scripts. Code is compiled, making programs more robust against execution unpredictability.
Many organizations run Go programs in production, and thus it is becoming important to monitor the runtime behaviour of these programs. And since these programs (microservices) play some partial role in a larger context, it is also important to map the execution flow across the microservices written in Go. Instana offers both, the complete view and relationship of Go programs in the larger context of the application as well as execution tracing details of the individual program.
The Instana Go sensor is open source on GitHub: https://github.com/instana/golang-sensor. It contains examples of how to integrate Instana’s Go monitoring and tracing into your application.
Go Runtime Monitoring
Given the dependency is resolved for your Go build:
For simple runtime behaviour - metrics - the single requirement is to instantiate the Instana Golang sensor somewhere in main():
Assuming that the Instana agent is running on the same host (or container host), the Golang sensor will automatically connect to it and start sending 1 second granularity metrics. The connection works automatically and transparently when the Go program and agent are co-located on the host or running “inside” a container:
The Go application is automatically discovered and the event is recorded in Instana:
That process is then automatically mapped into the Instana dependency model, our Dynamic Graph:
Most important metrics, such as GC behaviour, memory allocation etc. are captured and transmitted per second.
Go Tracing, Service Discovery and Health Monitoring
Instana implements the concept of distributed tracing for Go microservices into the overall flow so that you can easily visualize the message patterns and behavior of your larger application.
In order to enable tracing of Go programs, Instana follows the OpenTracing Go API (https://github.com/opentracing/opentracing-go), allowing developers to benefit from its integration in frameworks and to control the tracing themselves.
Enabling tracing in your Go program is as simple as turning on the metrics sensor:
And in the main():
This automatically activates the metrics sensor described above, and in addition activates the OpenTracing Instana backend. From here, you simply follow the OpenTracing API to control tracing. Or, if your framework already utilizes the OpenTracing API, leave it up to the framework and benefit from the tracing hooks already in place.
like any other logical service reporting to and discovered by Instana.
Instana Go monitoring and tracing is already being used by several customers in production. It will continue to grow, especially with the integration of OpenTracing into Go frameworks.
With the Instana Go sensor, Instana is now supporting 6 major languages (Java, Node.js, PHP, Ruby and Scala) with more to come. Our goal, as always, is full visibility into your application’s health and the execution flow of your microservices environment, on the way to full management of its quality of service.