{"id":13413513,"url":"https://github.com/pascaldekloe/metrics","last_synced_at":"2025-03-21T23:31:49.098Z","repository":{"id":57488185,"uuid":"168129077","full_name":"pascaldekloe/metrics","owner":"pascaldekloe","description":"atomic measures + Prometheus exposition library","archived":false,"fork":false,"pushed_at":"2023-03-22T15:58:38.000Z","size":200,"stargazers_count":27,"open_issues_count":3,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-18T05:51:20.775Z","etag":null,"topics":["metrics","metrics-exporter","prometheus","prometheus-exporter"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pascaldekloe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2019-01-29T09:39:18.000Z","updated_at":"2025-01-18T13:39:23.000Z","dependencies_parsed_at":"2023-09-25T01:51:47.249Z","dependency_job_id":"bdd46680-f1f5-427e-9da9-73af378cdec8","html_url":"https://github.com/pascaldekloe/metrics","commit_stats":{"total_commits":123,"total_committers":1,"mean_commits":123.0,"dds":0.0,"last_synced_commit":"b8fd78f9c1f5ca4c130919f7aa927c331aec6a02"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pascaldekloe%2Fmetrics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pascaldekloe%2Fmetrics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pascaldekloe%2Fmetrics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pascaldekloe%2Fmetrics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pascaldekloe","download_url":"https://codeload.github.com/pascaldekloe/metrics/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244885137,"owners_count":20526282,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["metrics","metrics-exporter","prometheus","prometheus-exporter"],"created_at":"2024-07-30T20:01:42.073Z","updated_at":"2025-03-21T23:31:48.818Z","avatar_url":"https://github.com/pascaldekloe.png","language":"Go","funding_links":[],"categories":["Microsoft Office","杂项","Miscellaneous","其他杂项","Uncategorized"],"sub_categories":["Uncategorized","未分类的","Strings","暂未分类","暂未分类这些库被放在这里是因为其他类别似乎都不适合。"],"readme":"[![API](https://pkg.go.dev/badge/github.com/pascaldekloe/metrics.svg)](https://pkg.go.dev/github.com/pascaldekloe/metrics)\n[![Build](https://github.com/pascaldekloe/metrics/actions/workflows/go.yml/badge.svg)](https://github.com/pascaldekloe/metrics/actions/workflows/go.yml)\n\n## About\n\nMetrics are measures of quantitative assessment commonly used for comparing, and\ntracking performance or production. This library offers atomic counters, gauges\nand historgrams for the Go programming language. Users have the option to expose\nsnapshots in the Prometheus text-format.\n\nThis is free and unencumbered software released into the\n[public domain](https://creativecommons.org/publicdomain/zero/1.0).\n\n\n## Use\n\nStatic regisration on package level comes recommened. The declarations also help\nto document the funcionality that is covered in the code.\n\n```go\n// Package Metrics\nvar (\n\tConnectCount = metrics.MustCounter(\"db_connects_total\", \"Number of established initiations.\")\n\tCacheBytes   = metrics.MustInteger(\"db_cache_bytes\", \"Size of collective responses.\")\n\tDiskUsage    = metrics.Must1LabelRealSample(\"db_disk_usage_ratio\", \"device\")\n)\n```\n\nUpdate methods operate error free by design, e.g., `CacheBytes.Add(-72)` or\n`DiskUsage(dev.Name).Set(1 - dev.Free, time.Now())`.\n\nServe HTTP with just `http.HandleFunc(\"/metrics\", metrics.ServeHTTP)`.\n\n```\n\u003c HTTP/1.1 200 OK\n\u003c Content-Type: text/plain;version=0.0.4\n\u003c Date: Sun, 07 Mar 2021 15:22:47 GMT\n\u003c Content-Length: 351\n\u003c \n# Prometheus Samples\n\n# TYPE db_connects_total counter\n# HELP db_connects_total Number of established initiations.\ndb_connects_total 4 1615130567389\n\n# TYPE db_cache_bytes gauge\n# HELP db_cache_bytes Size of collective responses.\ndb_cache_bytes 7600 1615130567389\n\n# TYPE db_disk_usage_ratio gauge\ndb_disk_usage_ratio{device=\"sda\"} 0.19 1615130563595\n```\n\nPackage `github.com/pascaldekloe/metrics/gostat` provides a standard collection\nof Go metrics which is similar to the setup as provided by the\n[original Prometheus library](https://github.com/prometheus/client_golang).\n\nSamples may be fetched in a lazy manner, like how the\n[lazy example](https://pkg.go.dev/github.com/pascaldekloe/metrics#example-Sample-Lazy)\ndoes.\n\n\n## Performance\n\nThe following results were measured on an Apple M1 with Go 1.20.\n\n```\nname                          time/op\nLabel/sequential/4-8            14.4ns ± 0%\nLabel/sequential/4x4-8          17.1ns ± 0%\nLabel/sequential/4x4x4-8        29.6ns ± 0%\nLabel/parallel/4-8              85.3ns ± 2%\nLabel/parallel/4x4-8            89.2ns ± 1%\nLabel/parallel/4x4x4-8           103ns ± 0%\nGet/histogram5/sequential-8     45.0ns ± 0%\nGet/histogram5/2routines-8      85.1ns ± 0%\nSet/real/sequential-8           5.64ns ± 0%\nSet/real/2routines-8            16.5ns ± 2%\nSet/sample/sequential-8         13.6ns ± 1%\nSet/sample/2routines-8          38.7ns ± 7%\nAdd/counter/sequential-8        6.88ns ± 0%\nAdd/counter/2routines-8         16.1ns ± 2%\nAdd/integer/sequential-8        6.88ns ± 0%\nAdd/integer/2routines-8         16.1ns ± 1%\nAdd/histogram5/sequential-8     16.1ns ± 1%\nAdd/histogram5/2routines-8      69.5ns ± 1%\nServeHTTP/32/counter-8           687ns ± 0%\nServeHTTP/32/real-8             1.87µs ± 0%\nServeHTTP/32/integer-8           694ns ± 0%\nServeHTTP/32/histogram5-8       6.05µs ± 0%\nServeHTTP/32/label5-8           1.97µs ± 0%\nServeHTTP/32/label2x3x5-8       1.98µs ± 0%\nServeHTTP/32/sample-8           2.06µs ± 0%\nServeHTTP/1024/counter-8        18.5µs ± 0%\nServeHTTP/1024/real-8           50.9µs ± 0%\nServeHTTP/1024/integer-8        18.8µs ± 0%\nServeHTTP/1024/histogram5-8      192µs ± 0%\nServeHTTP/1024/label5-8         54.4µs ± 0%\nServeHTTP/1024/label2x3x5-8     54.4µs ± 0%\nServeHTTP/1024/sample-8         57.6µs ± 0%\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpascaldekloe%2Fmetrics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpascaldekloe%2Fmetrics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpascaldekloe%2Fmetrics/lists"}