The Elastic APM Go Agent enables you to trace the execution of operations in your Go applications, sending performance metrics and errors to the Elastic APM server. It has built-in support for popular frameworks and toolkits, like Gorilla and Gin, as well as support for instrumenting Go’s built-in net/http, database/sql drivers. The Agent also offers an API Documentation for custom instrumentation.
How does the Agent work?edit
The Agent includes instrumentation modules for Supported Technologies, each providing middleware or wrappers for recording interesting events, such as incoming HTTP requests, outgoing HTTP requests, and database queries.
To collect data about incoming HTTP requests, you can install router middleware for one of the supported Web Frameworks. Incoming requests will be recorded as transactions, along with any related panics or errors.
To collect data for outgoing HTTP requests,
you can instrument an
http.Transport using module/apmhttp.
To collect data about database queries, you can use module/apmsql,
which provides instrumentation for well known database drivers.
In order to connect transactions with related spans and errors, and propagate traces between services (distributed tracing),
the agent relies on Go’s built-in context package:
transactions and spans are stored in context objects.
For example, for incoming HTTP requests, in-flight trace data will be recorded in the
context object accessible through
You can read more about this in Context propagation.
In addition to capturing events like those mentioned above, the agent also collects system and application metrics at regular intervals. This collection happens in a background goroutine that is automatically started when the agent is initialized.
APM Agents work in conjunction with the APM Server, Elasticsearch, and Kibana. The APM Overview provides details on how these components work together, and provides a matrix outlining Agent and Server compatibility.