Home / Companies / Elastic / Blog / Post Details
Content Deep Dive

Inside the Elastic APM Go Agent

Blog post from Elastic

Post Details
Company
Date Published
Author
Andrew Wilkins
Word Count
1,344
Language
-
Hacker News Points
-
Summary

Elastic APM has introduced beta support for monitoring Go applications, focusing on measuring and reporting response times through a detailed agent that instruments application code. The agent uses an API to record transactions and spans, capturing the time taken for operations and their context, which are processed and sent to the Elastic APM Server for indexing in Elasticsearch. In designing the agent, minimizing overhead was crucial, leveraging Go's toolchain and libraries to reduce memory allocation and CPU usage. The agent processes data off the main code path using background goroutines and employs a buffered channel to handle data flow, discarding excess data when necessary. Failure designs ensure system reliability by incorporating a circular buffer to manage data when the APM Server is unavailable. Performance optimizations include object pooling and a custom zero-copy, zero-allocation JSON encoder to improve efficiency. Elastic's gobench tool is used to benchmark the agent's performance continuously, storing results in Elasticsearch for analysis and future improvements.