{"id":22576615,"url":"https://github.com/ndolestudio/go-otelroundtripper","last_synced_at":"2025-04-22T11:27:34.732Z","repository":{"id":42427576,"uuid":"430120149","full_name":"NdoleStudio/go-otelroundtripper","owner":"NdoleStudio","description":"Go http.RoundTripper that emits open telemetry metrics. This helps you easily get metrics for all external APIs you interact with.","archived":false,"fork":false,"pushed_at":"2024-06-28T02:52:48.000Z","size":71,"stargazers_count":76,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-07-31T20:52:37.600Z","etag":null,"topics":["api-client","httpclient","opentelemetry-go","roundtripper"],"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/NdoleStudio.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.MD","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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-11-20T14:09:18.000Z","updated_at":"2024-06-28T02:52:51.000Z","dependencies_parsed_at":"2023-02-12T16:16:03.805Z","dependency_job_id":"1d771939-add6-4a7d-bec7-7e8f37e52d0a","html_url":"https://github.com/NdoleStudio/go-otelroundtripper","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":"NdoleStudio/go-http-client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NdoleStudio%2Fgo-otelroundtripper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NdoleStudio%2Fgo-otelroundtripper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NdoleStudio%2Fgo-otelroundtripper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NdoleStudio%2Fgo-otelroundtripper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NdoleStudio","download_url":"https://codeload.github.com/NdoleStudio/go-otelroundtripper/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250230894,"owners_count":21396382,"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":["api-client","httpclient","opentelemetry-go","roundtripper"],"created_at":"2024-12-08T04:07:22.114Z","updated_at":"2025-04-22T11:27:34.711Z","avatar_url":"https://github.com/NdoleStudio.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-otelroundtripper\n\n[![Build](https://github.com/NdoleStudio/go-otelroundtripper/actions/workflows/main.yml/badge.svg)](https://github.com/NdoleStudio/go-otelroundtripper/actions/workflows/main.yml)\n[![codecov](https://codecov.io/gh/NdoleStudio/go-otelroundtripper/branch/main/graph/badge.svg)](https://codecov.io/gh/NdoleStudio/go-otelroundtripper)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/NdoleStudio/go-otelroundtripper/badges/quality-score.png?b=main)](https://scrutinizer-ci.com/g/NdoleStudio/go-otelroundtripper/?branch=main)\n[![Go Report Card](https://goreportcard.com/badge/github.com/NdoleStudio/go-otelroundtripper)](https://goreportcard.com/report/github.com/NdoleStudio/go-otelroundtripper)\n[![GitHub contributors](https://img.shields.io/github/contributors/NdoleStudio/go-otelroundtripper)](https://github.com/NdoleStudio/go-otelroundtripper/graphs/contributors)\n[![GitHub license](https://img.shields.io/github/license/NdoleStudio/go-otelroundtripper?color=brightgreen)](https://github.com/NdoleStudio/go-otelroundtripper/blob/master/LICENSE)\n[![PkgGoDev](https://pkg.go.dev/badge/github.com/NdoleStudio/go-otelroundtripper)](https://pkg.go.dev/github.com/NdoleStudio/go-otelroundtripper)\n\n\nThis package provides an easy way to collect http related metrics\n(e.g Response times, Status Codes, number of in flight requests etc) for your HTTP API Clients.\nYou can do this by using this round tripper when instantiating the `http.Client{}`.\n\n## Why this package exists\n\nI currently have to integrate with multiple APIs and I needed a simple way to export metrics for those external\nAPI's. Sometimes external API's have their own SDK and the only input is `http.Client`. In this scenario, I can create\nan HTTP client with a round tripper automatically exports metrics according to the open telemetry specification.\n\n## Installation\n\n`go-otelroundtripper` is compatible with modern Go releases in module mode, with Go installed:\n\n```bash\ngo get github.com/NdoleStudio/go-otelroundtripper\n```\n\nAlternatively the same can be achieved if you use `import` in a package:\n\n```go\nimport \"github.com/NdoleStudio/go-otelroundtripper\"\n```\n\n## Usage\n\nThis is a sample code that instantiates an HTTP client which sends requests to `https://example.com`.\nYou can see a runnable [example here](./example_test.go)\n\n```go\nclient := http.Client{\n    Transport: New(\n        WithName(\"example.com\"),\n        WithMeter(global.MeterProvider()Meter(\"otel-round-tripper\")),\n        WithAttributes(\n            semconv.ServiceNameKey.String(\"otel-round-tripper\"),\n        ),\n    ),\n}\n\nresponse, err := client.Get(\"https://example.com\")\n```\n\n## Metrics Emitted\n\nThe following metrics will be emitted by this package. Note that `*` will be replaced by the prefix passed in `WithName()`.\n\n- `*.no_request` http calls with nil `http.Request`\n- `*.errors` http requests which had an error response i.e `err != nil`\n- `*.success` http requests which were successfull. Meaning there were no transport errors\n- `*.timeouts` http requests which timed out\n- `*.cancelled` http requests with cancelled context\n- `*.deadline_exceeded` http requests with context dateline exceeded\n- `*.total_duration` total time it takes to execute the http request in milliseconds\n- `*.in_flight` concurrent http requests\n- `*.attempts` http requests attempted\n- `*.failures` http requests with  http status code \u003e= 400\n- `*.redirects`  http requests with  300 \u003c= http status code \u003c 400\n\n## Testing\n\nYou can run the unit tests for this client from the root directory using the command below:\n\n```bash\ngo test -v\n```\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fndolestudio%2Fgo-otelroundtripper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fndolestudio%2Fgo-otelroundtripper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fndolestudio%2Fgo-otelroundtripper/lists"}