{"id":51228054,"url":"https://github.com/paradeum-team/gin-prometheus-ext","last_synced_at":"2026-06-28T13:02:21.524Z","repository":{"id":57558145,"uuid":"321919692","full_name":"paradeum-team/gin-prometheus-ext","owner":"paradeum-team","description":null,"archived":false,"fork":false,"pushed_at":"2022-06-14T10:53:10.000Z","size":11,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-02-15T06:24:12.499Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/paradeum-team.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-12-16T08:37:41.000Z","updated_at":"2020-12-18T09:54:54.000Z","dependencies_parsed_at":"2022-08-28T09:30:44.376Z","dependency_job_id":null,"html_url":"https://github.com/paradeum-team/gin-prometheus-ext","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/paradeum-team/gin-prometheus-ext","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paradeum-team%2Fgin-prometheus-ext","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paradeum-team%2Fgin-prometheus-ext/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paradeum-team%2Fgin-prometheus-ext/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paradeum-team%2Fgin-prometheus-ext/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/paradeum-team","download_url":"https://codeload.github.com/paradeum-team/gin-prometheus-ext/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paradeum-team%2Fgin-prometheus-ext/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34889047,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-28T02:00:05.809Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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-06-28T13:02:20.535Z","updated_at":"2026-06-28T13:02:21.512Z","avatar_url":"https://github.com/paradeum-team.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gin-prometheus-ext\n\n在[go-gin-prometheus](https://github.com/zsais/go-gin-prometheus) 的基础上，增加了几个metrics ，兼容api的分位数和耗时统计\n\n\n\n# go-gin-prometheus\n[![](https://godoc.org/github.com/zsais/go-gin-prometheus?status.svg)](https://godoc.org/github.com/zsais/go-gin-prometheus) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nGin Web Framework Prometheus metrics exporter\n\n## Installation\n\n`$ go get github.com/paradeum-team/gin-prometheus-ext`\n\n## Usage\n\n```go\npackage main\n\nimport (\n\t\"github.com/gin-gonic/gin\"\n\t\"github.com/paradeum-team/gin-prometheus-ext\"\n\t\"strings\"\n)\n\nfunc main() {\n\tr := gin.New()\n\n\tp := ginprometheusext.NewPrometheus(\"gin\")\n\tp.Use(r)\n\n\tr.GET(\"/\", func(c *gin.Context) {\n\t\tc.JSON(200, \"Hello world!\")\n\t})\n\n\tr.Run(\":8090\")\n}\n```\n\n\n## Preserving a low cardinality for the request counter\n\nThe request counter (`requests_total`) has a `url` label which,\nalthough desirable, can become problematic in cases where your\napplication uses templated routes expecting a great number of\nvariations, as Prometheus explicitly recommends against metrics having\nhigh cardinality dimensions:\n\nhttps://prometheus.io/docs/practices/naming/#labels\n\nIf you have for instance a `/customer/:name` templated route and you\ndon't want to generate a time series for every possible customer name,\nyou could supply this mapping function to the middleware:\n\n```go\npackage main\n\nimport (\n\t\"github.com/gin-gonic/gin\"\n\t\"github.com/paradeum-team/gin-prometheus-ext\"\n\t\"strings\"\n)\n\nfunc main() {\n\tr := gin.New()\n\n\tp := ginprometheusext.NewPrometheus(\"gin\")\n\n\tp.ReqCntURLLabelMappingFn = func(c *gin.Context) string {\n\t\turl := c.Request.URL.Path\n\t\tfor _, p := range c.Params {\n\t\t\tif p.Key == \"name\" {\n\t\t\t\turl = strings.Replace(url, p.Value, \":name\", 1)\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\treturn url\n\t}\n\n\tp.Use(r)\n\n\tr.GET(\"/\", func(c *gin.Context) {\n\t\tc.JSON(200, \"Hello world!\")\n\t})\n\n\tr.Run(\":8090\")\n}\n```\n\nwhich would map `/customer/alice` and `/customer/bob` to their\ntemplate `/customer/:name`, and thus preserve a low cardinality for\nour metrics.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparadeum-team%2Fgin-prometheus-ext","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fparadeum-team%2Fgin-prometheus-ext","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparadeum-team%2Fgin-prometheus-ext/lists"}