A type-safe Prometheus metrics builder library for Go that provides a declarative API with compile-time label validation.
gotoprom is a Go library that wraps the official Prometheus client to provide a type-safe, declarative API for defining and using metrics. It ensures label correctness at compile time, preventing common errors like misordered label values and enabling better IDE support for refactoring.
Go developers building applications with Prometheus metrics who prioritize type safety, maintainability, and IDE integration over raw performance.
Developers choose gotoprom for its compile-time validation of labels, which eliminates runtime map errors and misordered label values, and for its declarative API that enhances code navigation and refactoring with IDE support.
Type-safe Prometheus metrics builder library for golang [managed by soy-programador]
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Labels are defined as Go structs with tags, ensuring misordered or missing values are caught at compile time, preventing runtime errors like those in vanilla Prometheus.
Metrics are defined using structs and tags, making code self-documenting and easier to navigate, as shown in the README's comparison replacing map-based labels.
Leverages Go's type system to enable full IDE features like 'find usages' and refactoring, improving developer productivity for metric-heavy codebases.
Supports adding custom metric types beyond built-in ones, such as TimeHistogram for observing durations, through extensible builders using reflection.
Benchmarks show gotoprom is 3x slower with 33% more memory usage and 3x more allocations than vanilla Prometheus, which may impact high-throughput applications.
Requires defining structs and tags for labels, adding boilerplate code compared to the more concise vanilla Prometheus API, as seen in the motivation example.
Static struct definitions make handling runtime-generated or dynamic labels cumbersome, forcing workarounds or reliance on vanilla Prometheus for such cases.