{"id":26863213,"url":"https://github.com/djcass44/go-tracer","last_synced_at":"2025-03-31T02:55:25.062Z","repository":{"id":57546873,"uuid":"301368613","full_name":"djcass44/go-tracer","owner":"djcass44","description":"Simple library for request tracing between GoLang services","archived":false,"fork":false,"pushed_at":"2023-02-25T07:53:24.000Z","size":27,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2023-07-27T16:00:12.072Z","etag":null,"topics":["golang","golang-library","hacktoberfest","http","tracing"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/djcass44.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":"2020-10-05T10:18:09.000Z","updated_at":"2021-04-07T21:47:59.000Z","dependencies_parsed_at":"2022-09-05T12:30:50.898Z","dependency_job_id":null,"html_url":"https://github.com/djcass44/go-tracer","commit_stats":null,"previous_names":[],"tags_count":4,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djcass44%2Fgo-tracer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djcass44%2Fgo-tracer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djcass44%2Fgo-tracer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djcass44%2Fgo-tracer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/djcass44","download_url":"https://codeload.github.com/djcass44/go-tracer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246408098,"owners_count":20772230,"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":["golang","golang-library","hacktoberfest","http","tracing"],"created_at":"2025-03-31T02:55:24.473Z","updated_at":"2025-03-31T02:55:25.055Z","avatar_url":"https://github.com/djcass44.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Go Tracer\n\nThis library provides a method for simplifying request tracing and correlation between GoLang services.\n\n#### What it does\n\n* Extracts the `X-Request-ID` value or creates a new ID from a UUIDv4\n* Adds an entry to the `http.Request` context\n* Injects the `X-Request-ID` header to outgoing HTTP requests\n\nThis allows you to 'follow' requests as they move between various services as they will all have the same ID.\n\n\n#### Getting started\n\nHave a look at [example.go](example.go) for a simple example.\n\n```shell script\ngo get github.com/djcass44/go-tracer\n```\n\nUsing handler functions\n```go\nhttp.HandleFunc(\"/something\", tracer.NewFunc(myFunc))\n```\n\nUsing handlers\n```go\ntype myHandler struct {}\n\nfunc (mh myHandler) ServeHTTP(w http.ResponseWriter, _ *http.Request) {\n\t_, _ = w.Write([]byte(\"Hello World!\"))\n}\n// later on\nhttp.Handle(\"/something\", tracer.NewHandler(myHandler{}))\n```\n\n**Accessing the RequestID**\n\nThe ID can be pulled from the context directly, or using a helper function\n\nHelper:\n```go\nrequestId := tracer.GetRequestId(request)\n```\n\nDirect:\n```go\nrequestId := request.Context().Value(tracer.ContextKeyID).(string)\n```\n\n**Enabling outgoing RequestID injection**\n\nThis needs to be configured for all instances of `http.Client`\n\n*Note: this will replace the `http.Transport` of the client*\n\n```go\n// enable outgoing-tracing for the default http client\ntracer.Apply(http.DefaultClient)\n\nvar myClient = \u0026http.Client{}\ntracer.Apply(myClient)\n```\n\n#### Contribution\n\nContributions are more than welcome! Feel free to open a PR, or an issue if you have questions.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdjcass44%2Fgo-tracer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdjcass44%2Fgo-tracer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdjcass44%2Fgo-tracer/lists"}