{"id":14987690,"url":"https://github.com/bose/go-gin-opentracing","last_synced_at":"2025-06-10T22:04:47.191Z","repository":{"id":33922908,"uuid":"138066404","full_name":"Bose/go-gin-opentracing","owner":"Bose","description":"Gin Web Framework Open Tracing middleware","archived":false,"fork":false,"pushed_at":"2021-05-25T14:53:37.000Z","size":42,"stargazers_count":37,"open_issues_count":1,"forks_count":9,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-12T00:16:49.926Z","etag":null,"topics":["gin","gin-gonic","gin-middleware","go","middleware","opentracing","trace"],"latest_commit_sha":null,"homepage":null,"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/Bose.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-06-20T17:43:37.000Z","updated_at":"2025-03-20T03:46:46.000Z","dependencies_parsed_at":"2022-08-07T23:30:45.393Z","dependency_job_id":null,"html_url":"https://github.com/Bose/go-gin-opentracing","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bose%2Fgo-gin-opentracing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bose%2Fgo-gin-opentracing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bose%2Fgo-gin-opentracing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bose%2Fgo-gin-opentracing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Bose","download_url":"https://codeload.github.com/Bose/go-gin-opentracing/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bose%2Fgo-gin-opentracing/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259159655,"owners_count":22814492,"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":["gin","gin-gonic","gin-middleware","go","middleware","opentracing","trace"],"created_at":"2024-09-24T14:15:11.167Z","updated_at":"2025-06-10T22:04:47.155Z","avatar_url":"https://github.com/Bose.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-gin-opentracing\n[![](https://godoc.org/github.com/Bose/go-gin-opentracing?status.svg)](https://godoc.org/github.com/Bose/go-gin-opentracing) \n[![Go Report Card](https://goreportcard.com/badge/github.com/Bose/go-gin-opentracing)](https://goreportcard.com/report/github.com/Bose/go-gin-opentracing)\n[![Release](https://img.shields.io/github/release/Bose/go-gin-opentracing.svg?style=flat-square)](https://github.com/Bose/go-gin-opentracing/releases) \n\nOpenTracing middleware from the [Gin http framework](https://github.com/gin-gonic/gin).\n\nBased on [opentracing-go](https://github.com/opentracing/opentracing-go), this middleware adds an OpenTracing span for every http request, using the inbound requestID (if one exists) and adds the request span to the gin.Context as the key: `tracing-context`.\n\n\n## Required Reading\nIn order to understand the Go platform API, one must first be familiar with the [OpenTracing project](https://opentracing.io/) and [terminology](https://opentracing.io/specification/) more specifically.\n\n\n\n## Installation\n\n`$ go get github.com/Bose/go-gin-opentracing`\n\n## Usage as middleware\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n\n\tginopentracing \"github.com/Bose/go-gin-opentracing\"\n\t\"github.com/gin-gonic/gin\"\n\t\"github.com/opentracing/opentracing-go\"\n)\n\nfunc main() {\n\tr := gin.Default()\n\thostName, err := os.Hostname()\n\tif err != nil {\n\t\thostName = \"unknown\"\n\t}\n\t// initialize the global singleton for tracing...\n\ttracer, reporter, closer, err := ginopentracing.InitTracing(fmt.Sprintf(\"go-gin-opentracing-example::%s\", hostName), \"localhost:5775\", ginopentracing.WithEnableInfoLog(true))\n\tif err != nil {\n\t\tpanic(\"unable to init tracing\")\n\t}\n\tdefer closer.Close()\n\tdefer reporter.Close()\n\topentracing.SetGlobalTracer(tracer)\n\n\t// create the middleware\n\tp := ginopentracing.OpenTracer([]byte(\"api-request-\"))\n\n\t// tell gin to use the middleware\n\tr.Use(p)\n\n\tr.GET(\"/\", func(c *gin.Context) {\n\t\tc.JSON(200, \"Hello world!\")\n\t})\n\n\tr.Run(\":29090\")\n}\n\n```\n\nSee the [example.go file](https://github.com/Bose/go-gin-opentracing/blob/master/example/example.go)\n\n## Usage within gin.Handler\n\nWithin the gin Handler you can access this request span and use it to create additional spans, and/or add span tags. \n```go\nfunc HelloWorld(c *gin.Context) {\n\tif cspan, ok := c.Get(\"tracing-context\"); ok {\n\t\tspan = tracing.StartSpanWithParent(cspan.(opentracing.Span).Context(), \"helloword\", c.Request.Method, c.Request.URL.Path)\t\n\t} else {\n\t\tspan = tracing.StartSpanWithHeader(\u0026c.Request.Header, \"helloworld\", c.Request.Method, c.Request.URL.Path)\n\t}\n\tdefer span.Finish()\n\tc.String(200, \"Hello.\")\n}\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbose%2Fgo-gin-opentracing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbose%2Fgo-gin-opentracing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbose%2Fgo-gin-opentracing/lists"}