{"id":37135033,"url":"https://github.com/pnelson/metrics","last_synced_at":"2026-01-14T15:45:16.589Z","repository":{"id":57709954,"uuid":"500096834","full_name":"pnelson/metrics","owner":"pnelson","description":"Package metrics aggregates metrics over regular intervals.","archived":false,"fork":false,"pushed_at":"2022-06-05T12:51:57.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-13T05:13:03.281Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pnelson.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}},"created_at":"2022-06-05T12:51:42.000Z","updated_at":"2022-06-05T12:52:00.000Z","dependencies_parsed_at":"2022-09-26T21:21:26.028Z","dependency_job_id":null,"html_url":"https://github.com/pnelson/metrics","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pnelson/metrics","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pnelson%2Fmetrics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pnelson%2Fmetrics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pnelson%2Fmetrics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pnelson%2Fmetrics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pnelson","download_url":"https://codeload.github.com/pnelson/metrics/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pnelson%2Fmetrics/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28424695,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T15:24:48.085Z","status":"ssl_error","status_checked_at":"2026-01-14T15:23:41.940Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2026-01-14T15:45:15.818Z","updated_at":"2026-01-14T15:45:16.580Z","avatar_url":"https://github.com/pnelson.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# metrics\n\nPackage metrics aggregates metrics over regular intervals.\n\n## Usage\n\nInitialize a new metrics instance with 10 second aggregated intervals over a 1\nhour window. Optionally emit runtime stats.\n\n```go\nm := metrics.New(time.Hour, 10*time.Second)\ngo m.MemStats(time.Second)\n```\n\nUse `Add` for monotonically increasing `Counter` values such as errors or\nexecution counts.\n\n```go\nm.Add([]string{\"errors\"}, 1)\n```\n\nUse `Set` for measured `Gauge` values such as memory usage or active requests.\n\n```go\nvar n uint64\nm.Set([]string{\"active\"}, float64(atomic.AddUint64(\u0026n, 1)))\ndefer func() { m.Set([]string{\"active\"}, float64(atomic.AddUint64(\u0026n, ^uint64(0)))) }()\n```\n\nUse `Mod` to simplify a `Gauge` that increments or decrements like the above.\nThe gauge will increment or decrement from zero if there is no previous value\nwithin the entire stored window.\n\n```go\nm.Mod([]string{\"active\"}, 1)\ndefer m.Mod([]string{\"active\"}, -1)\n```\n\nUse `Put` for sample values distributed over the `Histogram` bucket values such\nas latency. The `Histogram` also stores a count of the samples.\n\n```go\nm.Put([]string{\"latency\"}, 1)\n```\n\nUse `Timer` as a shorthand for `Put` to sample the duration elapsed in\nmilliseconds from a starting `time.Time` value.\n\n```go\nfunc (m *M) Method() {\n  defer m.Timer([]string{\"method\", \"latency\"}, time.Now())\n  // ...\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpnelson%2Fmetrics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpnelson%2Fmetrics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpnelson%2Fmetrics/lists"}