{"id":13743351,"url":"https://github.com/lyft/gostats","last_synced_at":"2025-04-06T01:08:44.872Z","repository":{"id":16544056,"uuid":"77485113","full_name":"lyft/gostats","owner":"lyft","description":"Go client for Stats","archived":false,"fork":false,"pushed_at":"2024-05-16T18:52:29.000Z","size":389,"stargazers_count":55,"open_issues_count":7,"forks_count":23,"subscribers_count":562,"default_branch":"master","last_synced_at":"2024-05-22T14:33:47.340Z","etag":null,"topics":["lyft"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lyft.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-12-27T22:01:18.000Z","updated_at":"2024-06-18T14:05:53.850Z","dependencies_parsed_at":"2024-05-16T19:51:03.397Z","dependency_job_id":null,"html_url":"https://github.com/lyft/gostats","commit_stats":null,"previous_names":[],"tags_count":54,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lyft%2Fgostats","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lyft%2Fgostats/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lyft%2Fgostats/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lyft%2Fgostats/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lyft","download_url":"https://codeload.github.com/lyft/gostats/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247419860,"owners_count":20936012,"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":["lyft"],"created_at":"2024-08-03T05:00:45.105Z","updated_at":"2025-04-06T01:08:44.854Z","avatar_url":"https://github.com/lyft.png","language":"Go","funding_links":[],"categories":["Golang"],"sub_categories":["Statistics"],"readme":"# Gostats [![GoDoc](https://godoc.org/github.com/lyft/gostats?status.svg)](https://godoc.org/github.com/lyft/gostats) [![Build Status](https://github.com/lyft/gostats/actions/workflows/actions.yml/badge.svg?branch=master)](https://github.com/lyft/gostats/actions/workflows/actions.yml)\n\n`gostats` is a Go metrics library with support for Counters, Gauges, and Timers.\n\n## Installation\n\n```sh\ngo get github.com/lyft/gostats\n```\n\n## Building \u0026 Testing\n\n```sh\ngo test ./...\n```\n\n## Usage\n\nIn order to start using `gostats`, import it into your project with:\n\n```go\nimport \"github.com/lyft/gostats\"\n```\n\n\n## Mocking\n\nA thread-safe mock sink is provided by the [gostats/mock](https://github.com/lyft/gostats/blob/mock-sink/mock/sink.go) package.  The mock sink also provides methods that are useful for testing (as demonstrated below).\n```go\npackage mock_test\n\nimport (\n\t\"testing\"\n\n\t\"github.com/lyft/gostats\"\n\t\"github.com/lyft/gostats/mock\"\n)\n\ntype Config struct {\n\tStats stats.Store\n}\n\nfunc TestMockExample(t *testing.T) {\n\tsink := mock.NewSink()\n\tconf := Config{\n\t\tStats: stats.NewStore(sink, false),\n\t}\n\tconf.Stats.NewCounter(\"name\").Inc()\n\tconf.Stats.Flush()\n\tsink.AssertCounterEquals(t, \"name\", 1)\n}\n```\n\nIf you do not need to assert on the contents of the sink the below example can be used to quickly create a thread-safe `stats.Scope`:\n```go\npackage config\n\nimport (\n\t\"github.com/lyft/gostats\"\n\t\"github.com/lyft/gostats/mock\"\n)\n\ntype Config struct {\n\tStats stats.Store\n}\n\nfunc NewConfig() *Config {\n\treturn \u0026Config{\n\t\tStats: stats.NewDefaultStore(),\n\t}\n}\n\nfunc NewMockConfig() *Config {\n\tsink := mock.NewSink()\n\treturn \u0026Config{\n\t\tStats: stats.NewStore(sink, false),\n\t}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flyft%2Fgostats","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flyft%2Fgostats","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flyft%2Fgostats/lists"}