gitmyhub

client_golang

Go ★ 6.0k updated 1d ago

Prometheus instrumentation library for Go applications

This is the official Go library for adding Prometheus monitoring to your own applications. Prometheus is a widely used system for collecting and querying numeric measurements over time, things like how many requests your server handled, how long they took, or how much memory your app is using. This library gives Go developers the tools to record those numbers inside their code and expose them in the format Prometheus expects.

The library has two distinct parts. The first is an instrumentation package that you add to your Go application's source code. It provides counters, gauges, histograms, and summaries, which are the four standard metric types Prometheus understands. You register metrics, update them as your code runs, and the library handles formatting and serving them over HTTP so a Prometheus server can scrape them on a schedule.

The second part is an API client that lets a Go program talk to a Prometheus server directly. You can use it to write applications that query stored time-series data, run expressions against it, and retrieve results programmatically. This client is marked as experimental, meaning its interface may change without the version number signaling a breaking change.

The library targets the two most recent major Go releases. It follows semantic versioning for its stable parts, but some newer APIs are marked experimental and may change independently. A v2 redesign has been in progress; an early attempt lives in a separate branch, and a preview of the new API style is available inside the current 1.x release under a special namespace.

This is part of the official Prometheus project under the Cloud Native Computing Foundation. The README points to the Prometheus website for guides on how to instrument a typical Go application, and a set of example programs lives in the repository itself for quick reference.