How to instrument Go code with custom expvar metrics
Blog post from Sysdig
The blog post discusses how to instrument Go code with custom metrics using the expvar library, a standard interface in Golang for exposing application metrics via HTTP. It explains how expvar can be used to track application performance and health by exporting custom variables and built-in metrics like memory allocation and garbage collection stats. The post details the process of setting up expvar, including registering an endpoint for JSON-formatted metrics and creating custom metrics using various expvar types such as String, Integer, Float64, Map, and Structs. Additionally, it provides a complete example of a Go application utilizing expvar to export custom metrics and discusses challenges and solutions for collecting these metrics in a containerized environment using Sysdig Monitor. Sysdig Monitor is highlighted for its ability to simplify expvar metric collection and enhance monitoring by automatically discovering application components and offering real-time insights without requiring significant code changes.