{"id":15968689,"url":"https://github.com/dmathieu/owe","last_synced_at":"2025-09-12T15:48:12.209Z","repository":{"id":249120288,"uuid":"824060350","full_name":"dmathieu/owe","owner":"dmathieu","description":"OpenTelemetry Wide Events for Go","archived":false,"fork":false,"pushed_at":"2025-03-10T08:21:50.000Z","size":73,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-10T09:35:09.571Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dmathieu.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-07-04T09:30:56.000Z","updated_at":"2025-03-10T08:21:52.000Z","dependencies_parsed_at":"2024-09-16T08:28:37.723Z","dependency_job_id":"75c22169-264d-43a6-b859-62f4f39e329f","html_url":"https://github.com/dmathieu/owe","commit_stats":null,"previous_names":["dmathieu/owe"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dmathieu/owe","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmathieu%2Fowe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmathieu%2Fowe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmathieu%2Fowe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmathieu%2Fowe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dmathieu","download_url":"https://codeload.github.com/dmathieu/owe/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmathieu%2Fowe/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259934747,"owners_count":22934329,"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":[],"created_at":"2024-10-07T19:03:21.955Z","updated_at":"2025-06-15T06:33:28.892Z","avatar_url":"https://github.com/dmathieu.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OpenTelemetry Wide Events for Go\n\nOpenTelemetry makes it easy to retrieve the current span stored in context.\n\n```golang\nspan := trace.SpanFromContext(ctx)\n```\n\nWith the notion of [Wide\nEvents](https://isburmistrov.substack.com/p/all-you-need-is-wide-events-not-metrics)\noriginally introduces by Charity Majors, you will also want to retrieve that\nmain span all the time.\n\nAnd yet, if a child span has been created, you will retrieve that new span and\nnot the wide event you expected.\n\nThis package allows you to define a wide event for a context, which will not\nchange unless you manually do so. You can then retrieve the proper main span\nall the time, even if child spans were created.\n\n```golang\nspan := owe.SpanFromContext(ctx)\n```\n\n![diagram](img/diagram.png)\n\n## Usage\n\nIn order to have a span to retrieve, one needs to be added to the context.\n\nYou can do that manually with the `ContextWithSpan` method:\n\n```golang\nctx := owe.ContextWithSpan(ctx, span)\n```\n\nOr you can use one of the provided handlers that will automatically create a\nwide event span.\n\n### net/http\n\nThe `owehttp` package allows setting wide events for HTTP servers.\n\n```golang\nhandler := func(http.ResponseWriter, *http.Request) {\n\t// the HTTP handler sets my app's behavior\n\tevent := owe.SpanFromContext(r.Context())\n}\n\nendpoint := otelhttp.NewHandler(owe.NewHandler(handler), \"otelhttp\")\nserver := \u0026http.Server{\n\tHandler: endpoint,\n}\nlog.Fatal(server.ListenAndServe())\n```\n\n### gRPC\n\nThe `owegrpc` package allows setting wide events for gRPC servers.\n\n```golang\ns := grpc.NewServer(\n\t\tgrpc.StatsHandler(otelgrpc.NewServerHandler()),\n\t\tgrpc.StatsHandler(owegrpc.NewHandler()),\n)\n\n// Register your gRPC services\n\nif err := s.Serve(lis); err != nil {\n\tlog.Fatalf(\"failed to serve: %v\", err)\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmathieu%2Fowe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdmathieu%2Fowe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmathieu%2Fowe/lists"}