-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
feat: add spancheck
linter
#4290
Conversation
Hey, thank you for opening your first Pull Request ! |
In order for a pull request adding a linter to be reviewed, the linter and the PR must follow some requirements.
Pull Request Description
Linter
The Linter Tests Inside Golangci-lint
|
eec3ae9
to
c2e6c30
Compare
Related to |
Hey, @Antonboom. I totally agree they're related. Both check usage of OpenTelemetry traces (which are difficult to use and get right). They have quite different goals and checks, though. I tried to describe the differences below. The summary of below is:
Different goalsThe goals of the linters are different enough to where I don't know if we could/should combine them. My 2c is that not every function that takes a My personal experience has been that a small number of spans, each liberally annotated with |
The names of the options (
|
Point taken @ldez re: there being no list, and the settings being a bit verbose. I just changed settings to leave only a type SpancheckSettings struct {
Checks []string `mapstructure:"checks"`
IgnoreCheckSignatures []string `mapstructure:"ignore-check-signatures"`
} If unset, |
@ldez I see the |
You are using the package Also, your CI configuration should use a fixed minor version of Go to ensure the Go min version supported by your linter, the current CI configuration doesn't allow that: |
I recommend using |
Makes sense and thanks for that tip, I was unaware of that alias. Just made the switch in ci and confirmed it passed for spancheck v0.4.2 which doesn't have the |
It's always frustrating not to be able to use the latest language features, but this is the price of the compatibility with the previous Go version. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Co-authored-by: Fernandez Ludovic <[email protected]>
Background
This adds a
spancheck
linter: https://github.com/jjti/go-spancheckThe linter checks usage of OpenTelemetry spans, which are easy to get wrong. Self-instrumented traces requires a lot of easy-to-forget boilerplate:
Checks for spans include:
span.End()
is called (by default, not having this can cause memory leaks, and spans never being closed/useful)span.SetStatus(codes.Error, msg)
is called on errorspan.RecordError(err)
is called on errorTesting
Like
protogetter
I have an external dependency (otel) so madespanchecker
s tests their own module intest/testdata/spancheck/spancheck.go
Fixes #3722