Bump github.com/openzipkin/zipkin-go from 0.4.1 to 0.4.2 (#2807)

* Bump github.com/openzipkin/zipkin-go from 0.4.1 to 0.4.2

Bumps [github.com/openzipkin/zipkin-go](https://github.com/openzipkin/zipkin-go) from 0.4.1 to 0.4.2.
- [Release notes](https://github.com/openzipkin/zipkin-go/releases)
- [Commits](https://github.com/openzipkin/zipkin-go/compare/v0.4.1...v0.4.2)

---
updated-dependencies:
- dependency-name: github.com/openzipkin/zipkin-go
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* Run ./hack/update-codegen.sh

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
dependabot[bot] 2023-08-29 13:47:37 +00:00 committed by GitHub
parent dab3c4359b
commit fcccb4e1a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 119 additions and 111 deletions

4
go.mod
View File

@ -23,7 +23,7 @@ require (
github.com/gorilla/websocket v1.5.0 github.com/gorilla/websocket v1.5.0
github.com/hashicorp/golang-lru v1.0.2 github.com/hashicorp/golang-lru v1.0.2
github.com/kelseyhightower/envconfig v1.4.0 github.com/kelseyhightower/envconfig v1.4.0
github.com/openzipkin/zipkin-go v0.4.1 github.com/openzipkin/zipkin-go v0.4.2
github.com/prometheus/client_golang v1.16.0 github.com/prometheus/client_golang v1.16.0
github.com/prometheus/common v0.44.0 github.com/prometheus/common v0.44.0
github.com/spf13/pflag v1.0.5 github.com/spf13/pflag v1.0.5
@ -63,7 +63,7 @@ require (
github.com/evanphx/json-patch v4.12.0+incompatible // indirect github.com/evanphx/json-patch v4.12.0+incompatible // indirect
github.com/go-kit/log v0.2.1 // indirect github.com/go-kit/log v0.2.1 // indirect
github.com/go-logfmt/logfmt v0.5.1 // indirect github.com/go-logfmt/logfmt v0.5.1 // indirect
github.com/go-logr/logr v1.2.3 // indirect github.com/go-logr/logr v1.2.4 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.20.0 // indirect github.com/go-openapi/jsonreference v0.20.0 // indirect
github.com/go-openapi/swag v0.19.15 // indirect github.com/go-openapi/swag v0.19.15 // indirect

16
go.sum
View File

@ -126,8 +126,8 @@ github.com/go-logfmt/logfmt v0.5.1 h1:otpy5pqBCBZ1ng9RQ0dPu4PN7ba75Y/aA+UpowDyNV
github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs=
github.com/go-logr/logr v0.2.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU= github.com/go-logr/logr v0.2.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU=
github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0= github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ=
github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg=
github.com/go-openapi/jsonpointer v0.19.5 h1:gZr+CIYByUqjcgeLXnQu2gHYQC9o73G2XUeOFYEICuY= github.com/go-openapi/jsonpointer v0.19.5 h1:gZr+CIYByUqjcgeLXnQu2gHYQC9o73G2XUeOFYEICuY=
github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg=
@ -137,6 +137,7 @@ github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh
github.com/go-openapi/swag v0.19.15 h1:D2NRCBzS9/pEY3gP9Nl8aDqGUcPFrwG2p+CNFrLyrCM= github.com/go-openapi/swag v0.19.15 h1:D2NRCBzS9/pEY3gP9Nl8aDqGUcPFrwG2p+CNFrLyrCM=
github.com/go-openapi/swag v0.19.15/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= github.com/go-openapi/swag v0.19.15/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI=
github.com/gobuffalo/flect v1.0.2 h1:eqjPGSo2WmjgY2XlpGwo2NXgL3RucAKo4k4qQMNA5sA= github.com/gobuffalo/flect v1.0.2 h1:eqjPGSo2WmjgY2XlpGwo2NXgL3RucAKo4k4qQMNA5sA=
github.com/gobuffalo/flect v1.0.2/go.mod h1:A5msMlrHtLqh9umBSnvabjsMrCcCpAyzglnDvkbYKHs= github.com/gobuffalo/flect v1.0.2/go.mod h1:A5msMlrHtLqh9umBSnvabjsMrCcCpAyzglnDvkbYKHs=
github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s=
@ -216,6 +217,7 @@ github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hf
github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 h1:yAJXTCF9TqKcTiHJAE8dj7HMvPfh66eeA2JYW7eFpSE=
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/google/s2a-go v0.1.5 h1:8IYp3w9nysqv3JH+NJgXJzGbDHzLOTj43BmSkp+O7qg= github.com/google/s2a-go v0.1.5 h1:8IYp3w9nysqv3JH+NJgXJzGbDHzLOTj43BmSkp+O7qg=
github.com/google/s2a-go v0.1.5/go.mod h1:Ej+mSEMGRnqRzjc7VtF+jdBwYG5fuJfiZ8ELkjEwM0A= github.com/google/s2a-go v0.1.5/go.mod h1:Ej+mSEMGRnqRzjc7VtF+jdBwYG5fuJfiZ8ELkjEwM0A=
@ -297,14 +299,14 @@ github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f h1:KUppIJq7/+
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.7.0 h1:WSHQ+IS43OoUrWtD1/bbclrwK8TTH5hzp+umCiuxHgs=
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= github.com/onsi/ginkgo/v2 v2.11.0 h1:WgqUCUt/lT6yXoQ8Wef0fsNn5cAuMK7+KT9UFRz2tcU=
github.com/onsi/ginkgo/v2 v2.4.0 h1:+Ig9nvqgS5OBSACXNk15PLdp0U9XPYROt9CFzVdFGIs=
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/onsi/gomega v1.23.0 h1:/oxKu9c2HVap+F3PfKort2Hw5DEU+HGlW8n+tguWsys= github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI=
github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4=
github.com/openzipkin/zipkin-go v0.4.1 h1:kNd/ST2yLLWhaWrkgchya40TJabe8Hioj9udfPcEO5A= github.com/openzipkin/zipkin-go v0.4.2 h1:zjqfqHjUpPmB3c1GlCvvgsM1G4LkvqQbBDueDOCg/jA=
github.com/openzipkin/zipkin-go v0.4.1/go.mod h1:qY0VqDSN1pOBN94dBc6w2GJlWLiovAyg7Qt6/I9HecM= github.com/openzipkin/zipkin-go v0.4.2/go.mod h1:ZeVkFjuuBiSy13y8vpSDCjMi9GoI3hPpCJSBx/EYFhY=
github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=

View File

@ -6,7 +6,6 @@ linters:
disable-all: true disable-all: true
enable: enable:
- asciicheck - asciicheck
- deadcode
- errcheck - errcheck
- forcetypeassert - forcetypeassert
- gocritic - gocritic
@ -18,10 +17,8 @@ linters:
- misspell - misspell
- revive - revive
- staticcheck - staticcheck
- structcheck
- typecheck - typecheck
- unused - unused
- varcheck
issues: issues:
exclude-use-default: false exclude-use-default: false

View File

@ -20,35 +20,5 @@ package logr
// used whenever the caller is not interested in the logs. Logger instances // used whenever the caller is not interested in the logs. Logger instances
// produced by this function always compare as equal. // produced by this function always compare as equal.
func Discard() Logger { func Discard() Logger {
return Logger{ return New(nil)
level: 0,
sink: discardLogSink{},
}
}
// discardLogSink is a LogSink that discards all messages.
type discardLogSink struct{}
// Verify that it actually implements the interface
var _ LogSink = discardLogSink{}
func (l discardLogSink) Init(RuntimeInfo) {
}
func (l discardLogSink) Enabled(int) bool {
return false
}
func (l discardLogSink) Info(int, string, ...interface{}) {
}
func (l discardLogSink) Error(error, string, ...interface{}) {
}
func (l discardLogSink) WithValues(...interface{}) LogSink {
return l
}
func (l discardLogSink) WithName(string) LogSink {
return l
} }

View File

@ -21,7 +21,7 @@ limitations under the License.
// to back that API. Packages in the Go ecosystem can depend on this package, // to back that API. Packages in the Go ecosystem can depend on this package,
// while callers can implement logging with whatever backend is appropriate. // while callers can implement logging with whatever backend is appropriate.
// //
// Usage // # Usage
// //
// Logging is done using a Logger instance. Logger is a concrete type with // Logging is done using a Logger instance. Logger is a concrete type with
// methods, which defers the actual logging to a LogSink interface. The main // methods, which defers the actual logging to a LogSink interface. The main
@ -30,15 +30,19 @@ limitations under the License.
// "structured logging". // "structured logging".
// //
// With Go's standard log package, we might write: // With Go's standard log package, we might write:
//
// log.Printf("setting target value %s", targetValue) // log.Printf("setting target value %s", targetValue)
// //
// With logr's structured logging, we'd write: // With logr's structured logging, we'd write:
//
// logger.Info("setting target", "value", targetValue) // logger.Info("setting target", "value", targetValue)
// //
// Errors are much the same. Instead of: // Errors are much the same. Instead of:
//
// log.Printf("failed to open the pod bay door for user %s: %v", user, err) // log.Printf("failed to open the pod bay door for user %s: %v", user, err)
// //
// We'd write: // We'd write:
//
// logger.Error(err, "failed to open the pod bay door", "user", user) // logger.Error(err, "failed to open the pod bay door", "user", user)
// //
// Info() and Error() are very similar, but they are separate methods so that // Info() and Error() are very similar, but they are separate methods so that
@ -47,7 +51,7 @@ limitations under the License.
// always logged, regardless of the current verbosity. If there is no error // always logged, regardless of the current verbosity. If there is no error
// instance available, passing nil is valid. // instance available, passing nil is valid.
// //
// Verbosity // # Verbosity
// //
// Often we want to log information only when the application in "verbose // Often we want to log information only when the application in "verbose
// mode". To write log lines that are more verbose, Logger has a V() method. // mode". To write log lines that are more verbose, Logger has a V() method.
@ -58,14 +62,16 @@ limitations under the License.
// Error messages do not have a verbosity level and are always logged. // Error messages do not have a verbosity level and are always logged.
// //
// Where we might have written: // Where we might have written:
//
// if flVerbose >= 2 { // if flVerbose >= 2 {
// log.Printf("an unusual thing happened") // log.Printf("an unusual thing happened")
// } // }
// //
// We can write: // We can write:
//
// logger.V(2).Info("an unusual thing happened") // logger.V(2).Info("an unusual thing happened")
// //
// Logger Names // # Logger Names
// //
// Logger instances can have name strings so that all messages logged through // Logger instances can have name strings so that all messages logged through
// that instance have additional context. For example, you might want to add // that instance have additional context. For example, you might want to add
@ -82,17 +88,19 @@ limitations under the License.
// joining operation (e.g. whitespace, commas, periods, slashes, brackets, // joining operation (e.g. whitespace, commas, periods, slashes, brackets,
// quotes, etc). // quotes, etc).
// //
// Saved Values // # Saved Values
// //
// Logger instances can store any number of key/value pairs, which will be // Logger instances can store any number of key/value pairs, which will be
// logged alongside all messages logged through that instance. For example, // logged alongside all messages logged through that instance. For example,
// you might want to create a Logger instance per managed object: // you might want to create a Logger instance per managed object:
// //
// With the standard log package, we might write: // With the standard log package, we might write:
//
// log.Printf("decided to set field foo to value %q for object %s/%s", // log.Printf("decided to set field foo to value %q for object %s/%s",
// targetValue, object.Namespace, object.Name) // targetValue, object.Namespace, object.Name)
// //
// With logr we'd write: // With logr we'd write:
//
// // Elsewhere: set up the logger to log the object name. // // Elsewhere: set up the logger to log the object name.
// obj.logger = mainLogger.WithValues( // obj.logger = mainLogger.WithValues(
// "name", obj.name, "namespace", obj.namespace) // "name", obj.name, "namespace", obj.namespace)
@ -100,7 +108,7 @@ limitations under the License.
// // later on... // // later on...
// obj.logger.Info("setting foo", "value", targetValue) // obj.logger.Info("setting foo", "value", targetValue)
// //
// Best Practices // # Best Practices
// //
// Logger has very few hard rules, with the goal that LogSink implementations // Logger has very few hard rules, with the goal that LogSink implementations
// might have a lot of freedom to differentiate. There are, however, some // might have a lot of freedom to differentiate. There are, however, some
@ -124,15 +132,15 @@ limitations under the License.
// around. For cases where passing a logger is optional, a pointer to Logger // around. For cases where passing a logger is optional, a pointer to Logger
// should be used. // should be used.
// //
// Key Naming Conventions // # Key Naming Conventions
// //
// Keys are not strictly required to conform to any specification or regex, but // Keys are not strictly required to conform to any specification or regex, but
// it is recommended that they: // it is recommended that they:
// * be human-readable and meaningful (not auto-generated or simple ordinals) // - be human-readable and meaningful (not auto-generated or simple ordinals)
// * be constant (not dependent on input data) // - be constant (not dependent on input data)
// * contain only printable characters // - contain only printable characters
// * not contain whitespace or punctuation // - not contain whitespace or punctuation
// * use lower case for simple keys and lowerCamelCase for more complex ones // - use lower case for simple keys and lowerCamelCase for more complex ones
// //
// These guidelines help ensure that log data is processed properly regardless // These guidelines help ensure that log data is processed properly regardless
// of the log implementation. For example, log implementations will try to // of the log implementation. For example, log implementations will try to
@ -141,24 +149,25 @@ limitations under the License.
// While users are generally free to use key names of their choice, it's // While users are generally free to use key names of their choice, it's
// generally best to avoid using the following keys, as they're frequently used // generally best to avoid using the following keys, as they're frequently used
// by implementations: // by implementations:
// * "caller": the calling information (file/line) of a particular log line // - "caller": the calling information (file/line) of a particular log line
// * "error": the underlying error value in the `Error` method // - "error": the underlying error value in the `Error` method
// * "level": the log level // - "level": the log level
// * "logger": the name of the associated logger // - "logger": the name of the associated logger
// * "msg": the log message // - "msg": the log message
// * "stacktrace": the stack trace associated with a particular log line or // - "stacktrace": the stack trace associated with a particular log line or
// error (often from the `Error` message) // error (often from the `Error` message)
// * "ts": the timestamp for a log line // - "ts": the timestamp for a log line
// //
// Implementations are encouraged to make use of these keys to represent the // Implementations are encouraged to make use of these keys to represent the
// above concepts, when necessary (for example, in a pure-JSON output form, it // above concepts, when necessary (for example, in a pure-JSON output form, it
// would be necessary to represent at least message and timestamp as ordinary // would be necessary to represent at least message and timestamp as ordinary
// named values). // named values).
// //
// Break Glass // # Break Glass
// //
// Implementations may choose to give callers access to the underlying // Implementations may choose to give callers access to the underlying
// logging implementation. The recommended pattern for this is: // logging implementation. The recommended pattern for this is:
//
// // Underlier exposes access to the underlying logging implementation. // // Underlier exposes access to the underlying logging implementation.
// // Since callers only have a logr.Logger, they have to know which // // Since callers only have a logr.Logger, they have to know which
// // implementation is in use, so this interface is less of an abstraction // // implementation is in use, so this interface is less of an abstraction
@ -168,8 +177,9 @@ limitations under the License.
// } // }
// //
// Logger grants access to the sink to enable type assertions like this: // Logger grants access to the sink to enable type assertions like this:
//
// func DoSomethingWithImpl(log logr.Logger) { // func DoSomethingWithImpl(log logr.Logger) {
// if underlier, ok := log.GetSink()(impl.Underlier) { // if underlier, ok := log.GetSink().(impl.Underlier); ok {
// implLogger := underlier.GetUnderlying() // implLogger := underlier.GetUnderlying()
// ... // ...
// } // }
@ -177,11 +187,12 @@ limitations under the License.
// //
// Custom `With*` functions can be implemented by copying the complete // Custom `With*` functions can be implemented by copying the complete
// Logger struct and replacing the sink in the copy: // Logger struct and replacing the sink in the copy:
//
// // WithFooBar changes the foobar parameter in the log sink and returns a // // WithFooBar changes the foobar parameter in the log sink and returns a
// // new logger with that modified sink. It does nothing for loggers where // // new logger with that modified sink. It does nothing for loggers where
// // the sink doesn't support that parameter. // // the sink doesn't support that parameter.
// func WithFoobar(log logr.Logger, foobar int) logr.Logger { // func WithFoobar(log logr.Logger, foobar int) logr.Logger {
// if foobarLogSink, ok := log.GetSink()(FoobarSink); ok { // if foobarLogSink, ok := log.GetSink().(FoobarSink); ok {
// log = log.WithSink(foobarLogSink.WithFooBar(foobar)) // log = log.WithSink(foobarLogSink.WithFooBar(foobar))
// } // }
// return log // return log
@ -201,11 +212,14 @@ import (
) )
// New returns a new Logger instance. This is primarily used by libraries // New returns a new Logger instance. This is primarily used by libraries
// implementing LogSink, rather than end users. // implementing LogSink, rather than end users. Passing a nil sink will create
// a Logger which discards all log lines.
func New(sink LogSink) Logger { func New(sink LogSink) Logger {
logger := Logger{} logger := Logger{}
logger.setSink(sink) logger.setSink(sink)
if sink != nil {
sink.Init(runtimeInfo) sink.Init(runtimeInfo)
}
return logger return logger
} }
@ -244,7 +258,7 @@ type Logger struct {
// Enabled tests whether this Logger is enabled. For example, commandline // Enabled tests whether this Logger is enabled. For example, commandline
// flags might be used to set the logging verbosity and disable some info logs. // flags might be used to set the logging verbosity and disable some info logs.
func (l Logger) Enabled() bool { func (l Logger) Enabled() bool {
return l.sink.Enabled(l.level) return l.sink != nil && l.sink.Enabled(l.level)
} }
// Info logs a non-error message with the given key/value pairs as context. // Info logs a non-error message with the given key/value pairs as context.
@ -254,6 +268,9 @@ func (l Logger) Enabled() bool {
// information. The key/value pairs must alternate string keys and arbitrary // information. The key/value pairs must alternate string keys and arbitrary
// values. // values.
func (l Logger) Info(msg string, keysAndValues ...interface{}) { func (l Logger) Info(msg string, keysAndValues ...interface{}) {
if l.sink == nil {
return
}
if l.Enabled() { if l.Enabled() {
if withHelper, ok := l.sink.(CallStackHelperLogSink); ok { if withHelper, ok := l.sink.(CallStackHelperLogSink); ok {
withHelper.GetCallStackHelper()() withHelper.GetCallStackHelper()()
@ -273,6 +290,9 @@ func (l Logger) Info(msg string, keysAndValues ...interface{}) {
// triggered this log line, if present. The err parameter is optional // triggered this log line, if present. The err parameter is optional
// and nil may be passed instead of an error instance. // and nil may be passed instead of an error instance.
func (l Logger) Error(err error, msg string, keysAndValues ...interface{}) { func (l Logger) Error(err error, msg string, keysAndValues ...interface{}) {
if l.sink == nil {
return
}
if withHelper, ok := l.sink.(CallStackHelperLogSink); ok { if withHelper, ok := l.sink.(CallStackHelperLogSink); ok {
withHelper.GetCallStackHelper()() withHelper.GetCallStackHelper()()
} }
@ -284,6 +304,9 @@ func (l Logger) Error(err error, msg string, keysAndValues ...interface{}) {
// level means a log message is less important. Negative V-levels are treated // level means a log message is less important. Negative V-levels are treated
// as 0. // as 0.
func (l Logger) V(level int) Logger { func (l Logger) V(level int) Logger {
if l.sink == nil {
return l
}
if level < 0 { if level < 0 {
level = 0 level = 0
} }
@ -294,6 +317,9 @@ func (l Logger) V(level int) Logger {
// WithValues returns a new Logger instance with additional key/value pairs. // WithValues returns a new Logger instance with additional key/value pairs.
// See Info for documentation on how key/value pairs work. // See Info for documentation on how key/value pairs work.
func (l Logger) WithValues(keysAndValues ...interface{}) Logger { func (l Logger) WithValues(keysAndValues ...interface{}) Logger {
if l.sink == nil {
return l
}
l.setSink(l.sink.WithValues(keysAndValues...)) l.setSink(l.sink.WithValues(keysAndValues...))
return l return l
} }
@ -304,6 +330,9 @@ func (l Logger) WithValues(keysAndValues ...interface{}) Logger {
// contain only letters, digits, and hyphens (see the package documentation for // contain only letters, digits, and hyphens (see the package documentation for
// more information). // more information).
func (l Logger) WithName(name string) Logger { func (l Logger) WithName(name string) Logger {
if l.sink == nil {
return l
}
l.setSink(l.sink.WithName(name)) l.setSink(l.sink.WithName(name))
return l return l
} }
@ -324,6 +353,9 @@ func (l Logger) WithName(name string) Logger {
// WithCallDepth(1) because it works with implementions that support the // WithCallDepth(1) because it works with implementions that support the
// CallDepthLogSink and/or CallStackHelperLogSink interfaces. // CallDepthLogSink and/or CallStackHelperLogSink interfaces.
func (l Logger) WithCallDepth(depth int) Logger { func (l Logger) WithCallDepth(depth int) Logger {
if l.sink == nil {
return l
}
if withCallDepth, ok := l.sink.(CallDepthLogSink); ok { if withCallDepth, ok := l.sink.(CallDepthLogSink); ok {
l.setSink(withCallDepth.WithCallDepth(depth)) l.setSink(withCallDepth.WithCallDepth(depth))
} }
@ -345,6 +377,9 @@ func (l Logger) WithCallDepth(depth int) Logger {
// implementation does not support either of these, the original Logger will be // implementation does not support either of these, the original Logger will be
// returned. // returned.
func (l Logger) WithCallStackHelper() (func(), Logger) { func (l Logger) WithCallStackHelper() (func(), Logger) {
if l.sink == nil {
return func() {}, l
}
var helper func() var helper func()
if withCallDepth, ok := l.sink.(CallDepthLogSink); ok { if withCallDepth, ok := l.sink.(CallDepthLogSink); ok {
l.setSink(withCallDepth.WithCallDepth(1)) l.setSink(withCallDepth.WithCallDepth(1))
@ -357,6 +392,11 @@ func (l Logger) WithCallStackHelper() (func(), Logger) {
return helper, l return helper, l
} }
// IsZero returns true if this logger is an uninitialized zero value
func (l Logger) IsZero() bool {
return l.sink == nil
}
// contextKey is how we find Loggers in a context.Context. // contextKey is how we find Loggers in a context.Context.
type contextKey struct{} type contextKey struct{}
@ -442,7 +482,7 @@ type LogSink interface {
WithName(name string) LogSink WithName(name string) LogSink
} }
// CallDepthLogSink represents a Logger that knows how to climb the call stack // CallDepthLogSink represents a LogSink that knows how to climb the call stack
// to identify the original call site and can offset the depth by a specified // to identify the original call site and can offset the depth by a specified
// number of frames. This is useful for users who have helper functions // number of frames. This is useful for users who have helper functions
// between the "real" call site and the actual calls to Logger methods. // between the "real" call site and the actual calls to Logger methods.
@ -467,7 +507,7 @@ type CallDepthLogSink interface {
WithCallDepth(depth int) LogSink WithCallDepth(depth int) LogSink
} }
// CallStackHelperLogSink represents a Logger that knows how to climb // CallStackHelperLogSink represents a LogSink that knows how to climb
// the call stack to identify the original call site and can skip // the call stack to identify the original call site and can skip
// intermediate helper functions if they mark themselves as // intermediate helper functions if they mark themselves as
// helper. Go's testing package uses that approach. // helper. Go's testing package uses that approach.

View File

@ -16,9 +16,8 @@ linters:
- lll - lll
- misspell - misspell
- nakedret - nakedret
- structcheck
- unparam - unparam
- varcheck - unused
linters-settings: linters-settings:
dupl: dupl:

View File

@ -109,7 +109,7 @@ backend asynchronously.
#### Kafka Reporter #### Kafka Reporter
High performance Reporter transporting Spans to the Zipkin server using a Kafka High performance Reporter transporting Spans to the Zipkin server using a Kafka
Producer digesting JSON V2 Spans. The reporter uses the Producer digesting JSON V2 Spans. The reporter uses the
[Sarama async producer](https://godoc.org/github.com/Shopify/sarama#AsyncProducer) [Sarama async producer](https://pkg.go.dev/github.com/IBM/sarama#AsyncProducer)
underneath. underneath.
## usage and examples ## usage and examples

4
vendor/modules.txt vendored
View File

@ -72,7 +72,7 @@ github.com/go-kit/log/level
# github.com/go-logfmt/logfmt v0.5.1 # github.com/go-logfmt/logfmt v0.5.1
## explicit; go 1.17 ## explicit; go 1.17
github.com/go-logfmt/logfmt github.com/go-logfmt/logfmt
# github.com/go-logr/logr v1.2.3 # github.com/go-logr/logr v1.2.4
## explicit; go 1.16 ## explicit; go 1.16
github.com/go-logr/logr github.com/go-logr/logr
# github.com/go-openapi/jsonpointer v0.19.5 # github.com/go-openapi/jsonpointer v0.19.5
@ -225,7 +225,7 @@ github.com/modern-go/reflect2
# github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 # github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822
## explicit ## explicit
github.com/munnerz/goautoneg github.com/munnerz/goautoneg
# github.com/openzipkin/zipkin-go v0.4.1 # github.com/openzipkin/zipkin-go v0.4.2
## explicit; go 1.18 ## explicit; go 1.18
github.com/openzipkin/zipkin-go github.com/openzipkin/zipkin-go
github.com/openzipkin/zipkin-go/idgenerator github.com/openzipkin/zipkin-go/idgenerator