Skip to content

Commit

Permalink
Nit change to flag descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
jjti committed Dec 28, 2023
1 parent d1f1772 commit 2edc6fb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ Usage of spanlint:
-enable-all
enable all checks, overriding individual check flags
-enable-record-error-check
enable the check for calling span.RecordError(err) when returning an error
enable the check for a span.RecordError(err) call when returning an error
-enable-set-status-check
enable the check for calling span.SetStatus(codes.Error, msg) when returning an error
enable the check for a span.SetStatus(codes.Error, msg) call when returning an error
-ignore-record-error-check-signatures string
comma-separated list of function signature regex that should disable the span.RecordError(err) checks on errors
-ignore-set-status-check-signatures string
Expand All @@ -37,7 +37,7 @@ Only the `span.End()` check is enabled by default. The others can be enabled wit

### Ignore check signatures

The `span.SetStatus()` and `span.RecordError()` checks warn when there is a path to return statement, with an error, without a call (to `SetStatus`, or `RecordError`, respectively). But it is convenient to set span's status and record errors from utility methods [1](https://andydote.co.uk/2023/09/19/tracing-is-better/#step-2-wrap-the-errors). To support that, the `ignore-*-check-signatures` settings can be used to ignore paths to return statements if that signature is present.
The `span.SetStatus()` and `span.RecordError()` checks warn when there is a path to return statement, with an error, without a call (to `SetStatus`, or `RecordError`, respectively). But it's convenient to set span's status and record errors from utility methods [[1](https://andydote.co.uk/2023/09/19/tracing-is-better/#step-2-wrap-the-errors)]. To support that, the `ignore-*-check-signatures` settings can be used to ignore paths to return statements if that signature is present.

For example, by default, the code below would have the warning shown:

Expand Down Expand Up @@ -104,6 +104,10 @@ OpenTelemetry docs: [Creating spans](https://opentelemetry.io/docs/instrumentati
Uptrace tutorial: [OpenTelemetry Go Tracing API](https://uptrace.dev/opentelemetry/go-tracing.html#quickstart)
## Checks
This linter supports three checks, each documented below. Only the check for `span.End()` is enabled by default.
### `span.End()` Check
Not calling `End` can cause memory leaks and prevents spans from being closed.
Expand Down
4 changes: 2 additions & 2 deletions cmd/spanlint/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ func main() {
config := spanlint.NewDefaultConfig()
flag.BoolVar(&config.DisableEndCheck, "disable-end-check", config.DisableEndCheck, "disable the check for calling span.End() after span creation")
flag.BoolVar(&config.EnableAll, "enable-all", config.EnableAll, "enable all checks, overriding individual check flags")
flag.BoolVar(&config.EnableSetStatusCheck, "enable-set-status-check", config.EnableSetStatusCheck, "enable the check for calling span.SetStatus(codes.Error, msg) when returning an error")
flag.BoolVar(&config.EnableSetStatusCheck, "enable-set-status-check", config.EnableSetStatusCheck, "enable the check for a span.SetStatus(codes.Error, msg) call when returning an error")
ignoreSetStatusCheckSignatures := flag.String(ignoreSetStatusCheckSignatures, "", "comma-separated list of function signature regex that should disable the span.SetStatus(codes.Error, msg) checks on errors")
flag.BoolVar(&config.EnableRecordErrorCheck, "enable-record-error-check", config.EnableRecordErrorCheck, "enable the check for calling span.RecordError(err) when returning an error")
flag.BoolVar(&config.EnableRecordErrorCheck, "enable-record-error-check", config.EnableRecordErrorCheck, "enable the check for a span.RecordError(err) call when returning an error")
ignoreRecordErrorCheckSignatures := flag.String(ignoreRecordErrorCheckSignatures, "", "comma-separated list of function signature regex that should disable the span.RecordError(err) checks on errors")
flag.Parse()

Expand Down

0 comments on commit 2edc6fb

Please sign in to comment.