{"id":13830287,"url":"https://github.com/go-slog/otelslog","last_synced_at":"2025-07-09T11:32:40.881Z","repository":{"id":194778584,"uuid":"691572702","full_name":"go-slog/otelslog","owner":"go-slog","description":"Handler attaching OpenTelemetry trace and resource details to logs","archived":false,"fork":false,"pushed_at":"2024-10-20T19:45:57.000Z","size":117,"stargazers_count":12,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-22T09:32:16.550Z","etag":null,"topics":["hacktoberfest","slog"],"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/go-slog.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}},"created_at":"2023-09-14T13:01:18.000Z","updated_at":"2024-10-20T19:44:32.000Z","dependencies_parsed_at":null,"dependency_job_id":"ca270eb2-30b8-4071-8a05-2542a151eded","html_url":"https://github.com/go-slog/otelslog","commit_stats":null,"previous_names":["go-slog/otelslog"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-slog%2Fotelslog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-slog%2Fotelslog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-slog%2Fotelslog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-slog%2Fotelslog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/go-slog","download_url":"https://codeload.github.com/go-slog/otelslog/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225539368,"owners_count":17485313,"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":["hacktoberfest","slog"],"created_at":"2024-08-04T10:00:58.279Z","updated_at":"2025-07-09T11:32:40.857Z","avatar_url":"https://github.com/go-slog.png","language":"Go","funding_links":[],"categories":["Enrichment"],"sub_categories":[],"readme":"# OpenTelemetry handler\n\n[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/go-slog/otelslog/ci.yaml?style=flat-square)](https://github.com/go-slog/otelslog/actions/workflows/ci.yaml)\n[![go.dev reference](https://img.shields.io/badge/go.dev-reference-007d9c?logo=go\u0026logoColor=white\u0026style=flat-square)](https://pkg.go.dev/mod/github.com/go-slog/otelslog)\n![Go Version](https://img.shields.io/badge/go%20version-%3E=1.22-61CFDD.svg?style=flat-square)\n[![built with nix](https://builtwithnix.org/badge.svg)](https://builtwithnix.org)\n\n**[log/slog](https://pkg.go.dev/log/slog) handler attaching OpenTelemetry trace details to logs.**\n\n\u003e [!TIP]\n\u003e You might want to consider using the [slog-\u003eOTEL bridge](https://github.com/open-telemetry/opentelemetry-go-contrib/tree/main/bridges/otelslog) instead.\n\n## Installation\n\n```shell\ngo get github.com/go-slog/otelslog\n```\n\n## Usage\n\nWrap an existing handler:\n\n```go\nimport(\n    \"log/slog\"\n\n    \"github.com/go-slog/otelslog\"\n)\n\nvar handler slog.Handler\n\n// Set up your handler\n// handler = ...\n\n// Wrap Handler\nhandler = otelslog.NewHandler(handler)\n\nlogger := slog.New(handler)\n\n// Call logger with a context\n\nlogger.InfoContext(ctx, \"hello world\")\n\n// Output: level=INFO msg=\"hello world\" trace_id=74726163655f69645f74657374313233 span_id=7370616e5f696431\n```\n\nUse it as a middleware in [slogmulti.Pipe](https://pkg.go.dev/github.com/samber/slog-multi#Pipe):\n\n```go\nimport (\n    \"github.com/go-slog/otelslog\"\n    \"github.com/samber/slog-multi\"\n)\n\nhandler = slogmulti.Pipe(otelslog.Middleware()).Handler(handler)\n\n// Set p logger\n// ...\n```\n\n## Development\n\nRun tests:\n\n```shell\ngo test -race -v ./...\n```\n\nRun linter:\n\n```shell\ngolangci-lint run\n```\n\n## License\n\nThe project is licensed under the [MIT License](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgo-slog%2Fotelslog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgo-slog%2Fotelslog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgo-slog%2Fotelslog/lists"}