ProductPromotion
Logo

Go.Lang

made by https://0x3d.site

GitHub - pascaldekloe/metrics: atomic measures + Prometheus exposition library
atomic measures + Prometheus exposition library. Contribute to pascaldekloe/metrics development by creating an account on GitHub.
Visit Site

GitHub - pascaldekloe/metrics: atomic measures + Prometheus exposition library

GitHub - pascaldekloe/metrics: atomic measures + Prometheus exposition library

API Build

About

Metrics are measures of quantitative assessment commonly used for comparing, and tracking performance or production. This library offers atomic counters, gauges and historgrams for the Go programming language. Users have the option to expose snapshots in the Prometheus text-format.

This is free and unencumbered software released into the public domain.

Use

Static regisration on package level comes recommened. The declarations also help to document the funcionality that is covered in the code.

// Package Metrics
var (
	ConnectCount = metrics.MustCounter("db_connects_total", "Number of established initiations.")
	CacheBytes   = metrics.MustInteger("db_cache_bytes", "Size of collective responses.")
	DiskUsage    = metrics.Must1LabelRealSample("db_disk_usage_ratio", "device")
)

Update methods operate error free by design, e.g., CacheBytes.Add(-72) or DiskUsage(dev.Name).Set(1 - dev.Free, time.Now()).

Serve HTTP with just http.HandleFunc("/metrics", metrics.ServeHTTP).

< HTTP/1.1 200 OK
< Content-Type: text/plain;version=0.0.4
< Date: Sun, 07 Mar 2021 15:22:47 GMT
< Content-Length: 351
< 
# Prometheus Samples

# TYPE db_connects_total counter
# HELP db_connects_total Number of established initiations.
db_connects_total 4 1615130567389

# TYPE db_cache_bytes gauge
# HELP db_cache_bytes Size of collective responses.
db_cache_bytes 7600 1615130567389

# TYPE db_disk_usage_ratio gauge
db_disk_usage_ratio{device="sda"} 0.19 1615130563595

Package github.com/pascaldekloe/metrics/gostat provides a standard collection of Go metrics which is similar to the setup as provided by the original Prometheus library.

Samples may be fetched in a lazy manner, like how the lazy example does.

Performance

The following results were measured on an Apple M1 with Go 1.20.

name                          time/op
Label/sequential/4-8            14.4ns ± 0%
Label/sequential/4x4-8          17.1ns ± 0%
Label/sequential/4x4x4-8        29.6ns ± 0%
Label/parallel/4-8              85.3ns ± 2%
Label/parallel/4x4-8            89.2ns ± 1%
Label/parallel/4x4x4-8           103ns ± 0%
Get/histogram5/sequential-8     45.0ns ± 0%
Get/histogram5/2routines-8      85.1ns ± 0%
Set/real/sequential-8           5.64ns ± 0%
Set/real/2routines-8            16.5ns ± 2%
Set/sample/sequential-8         13.6ns ± 1%
Set/sample/2routines-8          38.7ns ± 7%
Add/counter/sequential-8        6.88ns ± 0%
Add/counter/2routines-8         16.1ns ± 2%
Add/integer/sequential-8        6.88ns ± 0%
Add/integer/2routines-8         16.1ns ± 1%
Add/histogram5/sequential-8     16.1ns ± 1%
Add/histogram5/2routines-8      69.5ns ± 1%
ServeHTTP/32/counter-8           687ns ± 0%
ServeHTTP/32/real-8             1.87µs ± 0%
ServeHTTP/32/integer-8           694ns ± 0%
ServeHTTP/32/histogram5-8       6.05µs ± 0%
ServeHTTP/32/label5-8           1.97µs ± 0%
ServeHTTP/32/label2x3x5-8       1.98µs ± 0%
ServeHTTP/32/sample-8           2.06µs ± 0%
ServeHTTP/1024/counter-8        18.5µs ± 0%
ServeHTTP/1024/real-8           50.9µs ± 0%
ServeHTTP/1024/integer-8        18.8µs ± 0%
ServeHTTP/1024/histogram5-8      192µs ± 0%
ServeHTTP/1024/label5-8         54.4µs ± 0%
ServeHTTP/1024/label2x3x5-8     54.4µs ± 0%
ServeHTTP/1024/sample-8         57.6µs ± 0%

Articles
to learn more about the golang concepts.

Resources
which are currently available to browse on.

mail [email protected] to add your project or resources here 🔥.

FAQ's
to know more about the topic.

mail [email protected] to add your project or resources here 🔥.

Queries
or most google FAQ's about GoLang.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory