Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send User-Agent header with commit hash #56

Merged
merged 1 commit into from
Jul 2, 2024
Merged

Send User-Agent header with commit hash #56

merged 1 commit into from
Jul 2, 2024

Conversation

vegarsti
Copy link
Member

@vegarsti vegarsti commented Jul 1, 2024

This PR adds a User-Agent header on the format node-indexer/<hash>. We try follow the convention described on Wikipedia.

This will be very useful when debugging!

We inject the Git hash using option 1 from Adam's excellent resource https://developers.redhat.com/articles/2022/11/14/3-ways-embed-commit-hash-go-programs#1__using__ldflags. Option 3 doesn't work because even when building with -buildvcs, a go build <file> doesn't embed the VCS info, as tracked in this open issue: golang/go#51279 (comment)

Have verified this locally using Docker build.

Copy link
Member Author

vegarsti commented Jul 1, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @vegarsti and the rest of your teammates on Graphite Graphite

@adammilnesmith
Copy link
Contributor

Option 3 just missing -buildvcs i think

@adammilnesmith
Copy link
Contributor

If you do end up getting runtime/debug ReadBuildInfo() to work then I think we'd probably be interested in the following when debugging on behalf of customers (in priority order if we don't want to squeeze them all in):

  • vcs.revision
  • GoVersion
  • GOARCH
  • GOOS
  • vcs.modified
  • vcs.time

@vegarsti
Copy link
Member Author

vegarsti commented Jul 1, 2024

Turns out buildvcs doesn't do it for us either 😕 Not when building by listing Go files directly, like we do with go build ... cmd/main.go golang/go#51279 (comment)

@vegarsti vegarsti merged commit c6465b5 into main Jul 2, 2024
1 check passed
@vegarsti vegarsti deleted the user-agent branch July 2, 2024 10:10
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.

2 participants