From 2edc6fb9fc5330c39be0e7c580106bbe29b25e4a Mon Sep 17 00:00:00 2001 From: Joshua Timmons Date: Wed, 27 Dec 2023 22:36:06 -0500 Subject: [PATCH] Nit change to flag descriptions --- README.md | 10 +++++++--- cmd/spanlint/main.go | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 6114124..eee19d7 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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: @@ -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. diff --git a/cmd/spanlint/main.go b/cmd/spanlint/main.go index 17a704b..b1bfd40 100644 --- a/cmd/spanlint/main.go +++ b/cmd/spanlint/main.go @@ -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()