Skip to content

T-20356 Make slog-betterstack the official Better Stack Go client - #1

Merged
PetrHeinz merged 8 commits into
mainfrom
claude/t-20356-official-client
Oct 6, 2026
Merged

PetrHeinz merged 8 commits into
mainfrom
claude/t-20356-official-client

Conversation

@PetrHeinz

@PetrHeinz PetrHeinz commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

Makes github.com/BetterStackHQ/slog-betterstack the official Better Stack client for Go's log/slog. The code is samber/slog-betterstack as of its main branch (v1.4.4 plus dependency bumps) with its full git history, taken as-is: this PR changes the module path, the project files and the repository setup so that the library looks and releases like our other clients. The behaviour fixes (batching, flush on close, retries, surfacing delivery errors) come in a follow-up PR.

  • Module path github.com/BetterStackHQ/slog-betterstack, package name slogbetterstack and the API unchanged, so upgrading is an import path change. logger.name in every record and the User-Agent now say BetterStackHQ/slog-betterstack. logger.version comes from version.go, which the Release workflow bumps. It says 1.4.4, and that is the version this lands as, the same code at its new path: tag the merge commit v1.4.4 by hand, push the tag and dispatch retry from main, which creates the GitHub release and primes the Go module proxy. The fixes PR then releases as 1.5.0.
  • README in the house layout: license, latest version and CI badges (the version badge links to pkg.go.dev, Go's package index), the docs link and credits to Samuel Berthe, nothing else. Usage documentation lives at betterstack.com/docs/logs/go. The sponsor banners and the catalogue of his other handlers are gone. LICENSE keeps his MIT copyright line and adds Better Stack's.
  • main.yml builds, vets and runs the tests with the race detector on Go 1.21 through 1.25 and stable, on every push and PR, weekly and on demand, plus gofmt, go mod tidy and golangci-lint checks. release.yml is the Ruby and Python clients' workflow ported to a Go module: patch, minor, major and retry runs plus dry runs, the version bump in version.go, the version commit and annotated tag pushed by the workflow, a GitHub release with generated notes, and a go list -m through proxy.golang.org so the version is cached and indexed immediately. A major release also moves the module path to /vN in go.mod, the example import and the README's pkg.go.dev links in the same version commit, as Go's semantic import versioning requires. Every push touching the file is a dry run, so this PR's checks include one. samber's test, lint and automerge workflows and FUNDING.yml are removed; Dependabot stays monthly.
  • handler_test.go pins what applications rely on: the record keys (dt, level, message, logger.name, logger.version, extra), the error and runtime shapes, the request headers, the defaults and every option. The tests look only at what reaches the server, so the follow-up can change the transport underneath them. goleak's TestMain finally has tests to guard. Statement coverage is 100%.
  • example/ became example-project/ like in the other clients and reads the token and ingesting host from the environment.
  • handler.go is gofmt-ed. No other code change.

Verified locally: go test -race green on Go 1.25, golangci-lint clean, actionlint clean. The example sent three records to a test source on the clanker team and they arrived with the new logger.name. The Release bump step was rehearsed on a clone: 1.4.4 → 1.5.0 for minor, 2.0.0 with the module moved to /v2 and a passing build for major, retry refuses without a tag, a tagged HEAD refuses patch, and retry on a tagged HEAD checks the tag out and reads the module path from it.

Repository setting this relies on: main is unprotected today and the Release workflow's version push needs it to stay that way, or the GitHub Actions app must be allowed to bypass the pull request requirement as in the Ruby repos.

🤖 Generated with Claude Code

PetrHeinz and others added 5 commits October 6, 2026 14:51
Better Stack takes over samber/slog-betterstack as its official Go client.
The package name slogbetterstack and the API stay as they are, so upgrading
is a change of the import path.

- logger.name in every record and the User-Agent now say
  BetterStackHQ/slog-betterstack.
- version.go carries the latest released version instead of a placeholder
  the release pipeline used to rewrite; the Release workflow bumps it. It
  says 1.4.4, samber's last release, until the first release from here.
- example/ becomes example-project/ like in the other clients and reads the
  source token and ingesting host from the environment.
- handler.go is gofmt-ed.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Applications and Better Stack rely on the shape of the records this handler
sends: the dt, level, message, logger.name, logger.version and extra keys,
errors expanded under extra as kind/error/stack, the call site under
extra.runtime, and the request headers. The tests pin all of that and what
every Option field and package setting does, looking only at what reaches
the server so the transport can change underneath them.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
main.yml builds, vets and runs the tests with the race detector on every Go
from 1.21 to stable, on pushes, pull requests, weekly and on demand, and
checks gofmt, go mod tidy and golangci-lint.

release.yml is the Ruby and Python clients' Release workflow ported to a Go
module: patch, minor and retry runs plus dry runs, the version bump in
version.go, the version commit and annotated tag pushed by the workflow, a
GitHub release with generated notes, and a go list -m through
proxy.golang.org so the new version is cached and indexed right away. Every
push that touches the file is a dry run.

samber's test, lint and Dependabot automerge workflows and FUNDING.yml go;
Dependabot itself stays on its monthly schedule. The Makefile keeps the
targets the workflows use.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The README follows the other Better Stack clients: install, usage, the
record shape, the upgrade path from samber/slog-betterstack and credits to
Samuel Berthe. The sponsor banners and the catalogue of unrelated handlers
are gone. LICENSE keeps Samuel's MIT copyright line and adds Better Stack's.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Usage documentation lives at betterstack.com/docs/logs/go like for the
other clients, so the README keeps the house layout plus the credits to
Samuel Berthe.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@PetrHeinz
PetrHeinz marked this pull request as ready for review October 6, 2026 13:07
PetrHeinz and others added 3 commits October 6, 2026 15:12
Go's semantic import versioning puts the major version into the module
path from v2 on, so a major release rewrites go.mod, the imports of this
repository and the README's pkg.go.dev links to "<path>/vN" in the same
version commit, and the publish job fetches that path through the proxy.
Rehearsed on a clone: major gives 2.0.0 with a building /v2 module, minor
and patch leave the path alone, retry reads the path from the tag.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Statement coverage goes from 92% to 100%.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The version badge reads the latest GitHub release and links to pkg.go.dev,
the Go equivalent of the package registry pages the other clients link to.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@PetrHeinz
PetrHeinz merged commit c15176c into main Oct 6, 2026
12 checks passed
@PetrHeinz
PetrHeinz deleted the claude/t-20356-official-client branch October 6, 2026 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant