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

add build tag to disable tracing #754

Merged
merged 4 commits into from
Mar 4, 2025

Conversation

rashmi-tondare
Copy link
Contributor

This PR addresses issue #704

Changes

Add a build tag retrynotrace to disable tracing to help with dead code elimination

Verification

Wrote a small main function and built it with & without the build tag to get the expected output.

  • Without the build tag:
✗ go build -ldflags=-dumpdep ./interceptors/retry/main |& whydeadcode
text/template.(*state).evalField reachable from:
         text/template.(*state).evalFieldChain
         text/template.(*state).evalCommand
         text/template.(*state).evalPipeline
         text/template.(*state).walk
         text/template.(*Template).execute
         html/template.(*Template).Execute
         golang.org/x/net/trace.RenderEvents
         golang.org/x/net/trace.Events
         golang.org/x/net/trace.Events·f
         golang.org/x/net/trace.init.0
         golang.org/x/net/trace..inittask
         go:main.inittasks
         _
  • With the build tag (no output):
    ✗ go build -tags=retrynotrace -ldflags=-dumpdep ./interceptors/retry/main |& whydeadcode

* add new build tag `-build=retrynotrace` to support dead code elimination
Copy link
Collaborator

@johanbrandhorst johanbrandhorst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add a README.md to the interceptors/retry directory that explains how to use this build tag and when it might be useful? Otherwise this looks great!

Co-authored-by: Johan Brandhorst-Satzkorn <[email protected]>
@rashmi-tondare
Copy link
Contributor Author

Thanks for your inputs @johanbrandhorst. Will add a readme and update this PR shortly as suggested.

@rashmi-tondare
Copy link
Contributor Author

@johanbrandhorst i've added a readme as suggested. Please do take a look when you have some time

Copy link
Collaborator

@johanbrandhorst johanbrandhorst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@johanbrandhorst johanbrandhorst merged commit 509959f into grpc-ecosystem:main Mar 4, 2025
5 checks passed
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