{"id":26544832,"url":"https://github.com/talon-one/go-httpmetrics","last_synced_at":"2025-03-22T04:13:57.103Z","repository":{"id":57606186,"uuid":"139970851","full_name":"talon-one/go-httpmetrics","owner":"talon-one","description":"Capture metrics for http.Requests and http.Responses","archived":false,"fork":false,"pushed_at":"2018-07-06T15:43:36.000Z","size":2744,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":23,"default_branch":"master","last_synced_at":"2025-01-27T05:31:38.634Z","etag":null,"topics":["go","golang","http","metrics"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/talon-one.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":"2018-07-06T10:31:42.000Z","updated_at":"2019-01-22T23:34:24.000Z","dependencies_parsed_at":"2022-08-26T17:12:48.955Z","dependency_job_id":null,"html_url":"https://github.com/talon-one/go-httpmetrics","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/talon-one%2Fgo-httpmetrics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/talon-one%2Fgo-httpmetrics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/talon-one%2Fgo-httpmetrics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/talon-one%2Fgo-httpmetrics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/talon-one","download_url":"https://codeload.github.com/talon-one/go-httpmetrics/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244902918,"owners_count":20529115,"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":["go","golang","http","metrics"],"created_at":"2025-03-22T04:13:56.494Z","updated_at":"2025-03-22T04:13:57.094Z","avatar_url":"https://github.com/talon-one.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# httpmetrics [![GoDoc](https://godoc.org/github.com/talon-one/go-httpmetrics?status.svg)](https://godoc.org/github.com/talon-one/go-httpmetrics) [![go-report](https://goreportcard.com/badge/github.com/talon-one/go-httpmetrics)](https://goreportcard.com/report/github.com/talon-one/go-httpmetrics)\n\nCapture metrics for http.Requests and http.Responses\n\n```bash\ngo get github.com/talon-one/go-httpmetrics\n```\n\n# Usage\n```go\nfunc main() {\n\thttp.HandleFunc(\"/\", func(w http.ResponseWriter, r *http.Request) {\n\t\tw.Header().Set(\"Content-Type\", \"text/plain\")\n\t\tw.WriteHeader(http.StatusOK)\n\t\tio.WriteString(w, \"Hello World\")\n\t})\n\n\tcollectMetrics := httpmetrics.New(httpmetrics.CollectOptions{\n\t\tCollectRequestBody:  128,\n\t\tCollectResponseBody: 128,\n\t})\n\n\tcollectMetrics.Collect(func(m httpmetrics.Metrics) {\n\t\tfmt.Printf(`Duration: %s\nRequest.URL: %s\nRequest.Header: %v\nRequest.Body: %s\nResponse.Code: %d\nResponse.Header: %v\nResponse.Body: %s\n============================\n`, m.Duration.String(),\n\t\t\tm.Request.URL.String(),\n\t\t\tm.Request.Header,\n\t\t\tstring(m.Request.Body),\n\t\t\tm.Response.Code,\n\t\t\tm.Response.Header,\n\t\t\tstring(m.Response.Body))\n\t})\n\n\thttp.ListenAndServe(\":8000\", collectMetrics)\n}\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftalon-one%2Fgo-httpmetrics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftalon-one%2Fgo-httpmetrics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftalon-one%2Fgo-httpmetrics/lists"}