diff options
24 files changed, 262 insertions, 32 deletions
diff --git a/cmd/podman/containers/cp.go b/cmd/podman/containers/cp.go index f0f9a158d..ac7037621 100644 --- a/cmd/podman/containers/cp.go +++ b/cmd/podman/containers/cp.go @@ -7,6 +7,7 @@ import ( "github.com/containers/libpod/pkg/rootless" "github.com/sirupsen/logrus" "github.com/spf13/cobra" + "github.com/spf13/pflag" ) var ( @@ -22,20 +23,41 @@ var ( RunE: cp, Example: "podman cp [CONTAINER:]SRC_PATH [CONTAINER:]DEST_PATH", } + + containerCpCommand = &cobra.Command{ + Use: cpCommand.Use, + Short: cpCommand.Short, + Long: cpCommand.Long, + Args: cpCommand.Args, + RunE: cpCommand.RunE, + Example: "podman container cp [CONTAINER:]SRC_PATH [CONTAINER:]DEST_PATH", + } ) var ( cpOpts entities.ContainerCpOptions ) +func cpFlags(flags *pflag.FlagSet) { + flags.BoolVar(&cpOpts.Extract, "extract", false, "Extract the tar file into the destination directory.") + flags.BoolVar(&cpOpts.Pause, "pause", copyPause(), "Pause the container while copying") +} + func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ Mode: []entities.EngineMode{entities.ABIMode}, Command: cpCommand, }) flags := cpCommand.Flags() - flags.BoolVar(&cpOpts.Extract, "extract", false, "Extract the tar file into the destination directory.") - flags.BoolVar(&cpOpts.Pause, "pause", copyPause(), "Pause the container while copying") + cpFlags(flags) + + registry.Commands = append(registry.Commands, registry.CliCommand{ + Mode: []entities.EngineMode{entities.ABIMode}, + Command: containerCpCommand, + Parent: containerCmd, + }) + containerCpFlags := containerCpCommand.Flags() + cpFlags(containerCpFlags) } func cp(cmd *cobra.Command, args []string) error { diff --git a/cmd/podman/containers/init.go b/cmd/podman/containers/init.go index bb02f22fd..417f170c3 100644 --- a/cmd/podman/containers/init.go +++ b/cmd/podman/containers/init.go @@ -8,6 +8,7 @@ import ( "github.com/containers/libpod/cmd/podman/utils" "github.com/containers/libpod/pkg/domain/entities" "github.com/spf13/cobra" + "github.com/spf13/pflag" ) var ( @@ -25,21 +26,47 @@ var ( podman init 3c45ef19d893 podman init test1`, } + + containerInitCommand = &cobra.Command{ + Use: initCommand.Use, + Short: initCommand.Short, + Long: initCommand.Long, + RunE: initCommand.RunE, + Args: initCommand.Args, + Example: `podman container init --latest + podman container init 3c45ef19d893 + podman container init test1`, + } ) var ( initOptions entities.ContainerInitOptions ) +func initFlags(flags *pflag.FlagSet) { + flags.BoolVarP(&initOptions.All, "all", "a", false, "Initialize all containers") + flags.BoolVarP(&initOptions.Latest, "latest", "l", false, "Act on the latest container podman is aware of") + if registry.IsRemote() { + _ = flags.MarkHidden("latest") + } +} + func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode}, Command: initCommand, }) flags := initCommand.Flags() - flags.BoolVarP(&initOptions.All, "all", "a", false, "Initialize all containers") - flags.BoolVarP(&initOptions.Latest, "latest", "l", false, "Act on the latest container podman is aware of") - _ = flags.MarkHidden("latest") + initFlags(flags) + + registry.Commands = append(registry.Commands, registry.CliCommand{ + Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode}, + Parent: containerCmd, + Command: containerInitCommand, + }) + + containerInitFlags := containerInitCommand.Flags() + initFlags(containerInitFlags) } func initContainer(cmd *cobra.Command, args []string) error { diff --git a/cmd/podman/containers/mount.go b/cmd/podman/containers/mount.go index 0bdac72cb..af4d52caa 100644 --- a/cmd/podman/containers/mount.go +++ b/cmd/podman/containers/mount.go @@ -30,9 +30,6 @@ var ( Args: func(cmd *cobra.Command, args []string) error { return parse.CheckAllLatestAndCIDFile(cmd, args, true, false) }, - Annotations: map[string]string{ - registry.ParentNSRequired: "", - }, } containerMountCommmand = &cobra.Command{ diff --git a/cmd/podman/system/unshare.go b/cmd/podman/system/unshare.go new file mode 100644 index 000000000..7db5d36d2 --- /dev/null +++ b/cmd/podman/system/unshare.go @@ -0,0 +1,50 @@ +package system + +import ( + "os" + + "github.com/containers/libpod/cmd/podman/registry" + "github.com/containers/libpod/pkg/domain/entities" + "github.com/containers/libpod/pkg/rootless" + "github.com/pkg/errors" + "github.com/spf13/cobra" +) + +var ( + unshareDescription = "Runs a command in a modified user namespace." + unshareCommand = &cobra.Command{ + Use: "unshare [flags] [COMMAND [ARG]]", + Short: "Run a command in a modified user namespace", + Long: unshareDescription, + RunE: unshare, + Example: `podman unshare id + podman unshare cat /proc/self/uid_map, + podman unshare podman-script.sh`, + } +) + +func init() { + registry.Commands = append(registry.Commands, registry.CliCommand{ + Mode: []entities.EngineMode{entities.ABIMode}, + Command: unshareCommand, + }) + flags := unshareCommand.Flags() + flags.SetInterspersed(false) +} + +func unshare(cmd *cobra.Command, args []string) error { + if isRootless := rootless.IsRootless(); !isRootless { + return errors.Errorf("please use unshare with rootless") + } + // exec the specified command, if there is one + if len(args) < 1 { + // try to exec the shell, if one's set + shell, shellSet := os.LookupEnv("SHELL") + if !shellSet { + return errors.Errorf("no command specified and no $SHELL specified") + } + args = []string{shell} + } + + return registry.ContainerEngine().Unshare(registry.Context(), args) +} @@ -52,7 +52,7 @@ require ( github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.5.1 github.com/syndtr/gocapability v0.0.0-20180916011248-d98352740cb2 - github.com/uber/jaeger-client-go v2.22.1+incompatible + github.com/uber/jaeger-client-go v2.23.1+incompatible github.com/uber/jaeger-lib v2.2.0+incompatible // indirect github.com/varlink/go v0.0.0-20190502142041-0f1d566d194b github.com/vishvananda/netlink v1.1.0 @@ -454,8 +454,8 @@ github.com/tchap/go-patricia v2.3.0+incompatible/go.mod h1:bmLyhP68RS6kStMGxByiQ github.com/theckman/go-flock v0.7.1/go.mod h1:kjuth3y9VJ2aNlkNEO99G/8lp9fMIKaGyBmh84IBheM= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/u-root/u-root v6.0.0+incompatible/go.mod h1:RYkpo8pTHrNjW08opNd/U6p/RJE7K0D8fXO0d47+3YY= -github.com/uber/jaeger-client-go v2.22.1+incompatible h1:NHcubEkVbahf9t3p75TOCR83gdUHXjRJvjoBh1yACsM= -github.com/uber/jaeger-client-go v2.22.1+incompatible/go.mod h1:WVhlPFC8FDjOFMMWRy2pZqQJSXxYSwNYOkTr/Z6d3Kk= +github.com/uber/jaeger-client-go v2.23.1+incompatible h1:uArBYHQR0HqLFFAypI7RsWTzPSj/bDpmZZuQjMLSg1A= +github.com/uber/jaeger-client-go v2.23.1+incompatible/go.mod h1:WVhlPFC8FDjOFMMWRy2pZqQJSXxYSwNYOkTr/Z6d3Kk= github.com/uber/jaeger-lib v2.2.0+incompatible h1:MxZXOiR2JuoANZ3J6DE/U0kSFv/eJ/GfSYVCjK7dyaw= github.com/uber/jaeger-lib v2.2.0+incompatible/go.mod h1:ComeNDZlWwrWnDv8aPp0Ba6+uUTzImX/AauajbLI56U= github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= diff --git a/pkg/domain/entities/engine_container.go b/pkg/domain/entities/engine_container.go index 7c93e6802..bb13794bd 100644 --- a/pkg/domain/entities/engine_container.go +++ b/pkg/domain/entities/engine_container.go @@ -71,6 +71,7 @@ type ContainerEngine interface { SetupRootless(ctx context.Context, cmd *cobra.Command) error Shutdown(ctx context.Context) SystemDf(ctx context.Context, options SystemDfOptions) (*SystemDfReport, error) + Unshare(ctx context.Context, args []string) error VarlinkService(ctx context.Context, opts ServiceOptions) error VolumeCreate(ctx context.Context, opts VolumeCreateOptions) (*IdOrNameResponse, error) VolumeInspect(ctx context.Context, namesOrIds []string, opts VolumeInspectOptions) ([]*VolumeInspectReport, error) diff --git a/pkg/domain/infra/abi/system.go b/pkg/domain/infra/abi/system.go index 24c62465f..fc92da1b2 100644 --- a/pkg/domain/infra/abi/system.go +++ b/pkg/domain/infra/abi/system.go @@ -5,6 +5,7 @@ import ( "fmt" "io/ioutil" "os" + "os/exec" "path/filepath" "strconv" "syscall" @@ -391,3 +392,18 @@ func (s SystemEngine) Shutdown(ctx context.Context) { logrus.Error(err) } } + +func unshareEnv(graphroot, runroot string) []string { + return append(os.Environ(), "_CONTAINERS_USERNS_CONFIGURED=done", + fmt.Sprintf("CONTAINERS_GRAPHROOT=%s", graphroot), + fmt.Sprintf("CONTAINERS_RUNROOT=%s", runroot)) +} + +func (ic *ContainerEngine) Unshare(ctx context.Context, args []string) error { + cmd := exec.Command(args[0], args[1:]...) + cmd.Env = unshareEnv(ic.Libpod.StorageConfig().GraphRoot, ic.Libpod.StorageConfig().RunRoot) + cmd.Stdin = os.Stdin + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + return cmd.Run() +} diff --git a/pkg/domain/infra/tunnel/system.go b/pkg/domain/infra/tunnel/system.go index 448fbed1f..d00795741 100644 --- a/pkg/domain/infra/tunnel/system.go +++ b/pkg/domain/infra/tunnel/system.go @@ -30,3 +30,7 @@ func (ic *ContainerEngine) SystemPrune(ctx context.Context, options entities.Sys func (ic *ContainerEngine) SystemDf(ctx context.Context, options entities.SystemDfOptions) (*entities.SystemDfReport, error) { panic(errors.New("system df is not supported on remote clients")) } + +func (ic *ContainerEngine) Unshare(ctx context.Context, args []string) error { + return errors.New("unshare is not supported on remote clients") +} diff --git a/vendor/github.com/uber/jaeger-client-go/CHANGELOG.md b/vendor/github.com/uber/jaeger-client-go/CHANGELOG.md index 818568b28..944feb2c8 100644 --- a/vendor/github.com/uber/jaeger-client-go/CHANGELOG.md +++ b/vendor/github.com/uber/jaeger-client-go/CHANGELOG.md @@ -1,6 +1,18 @@ Changes by Version ================== +2.23.1 (2020-04-28) +------------------- +- Fix regression by handling nil logger correctly ([#507](https://github.com/jaegertracing/jaeger-client-go/pull/507)) -- Prithvi Raj + + +2.23.0 (2020-04-22) +------------------- + +- Add the ability to log all span interactions at a new debug log level([#502](https://github.com/jaegertracing/jaeger-client-go/pull/502), [#503](https://github.com/jaegertracing/jaeger-client-go/pull/503), [#504](https://github.com/jaegertracing/jaeger-client-go/pull/504)) -- Prithvi Raj +- Chore (docs): fix typos ([#496](https://github.com/jaegertracing/jaeger-client-go/pull/496), [#498](https://github.com/jaegertracing/jaeger-client-go/pull/498)) -- Febrian Setianto and Ivan Babrou +- Unset highest bit of traceID in probabilistic sampler ([#490](https://github.com/jaegertracing/jaeger-client-go/pull/490)) -- Sokolov Yura + 2.22.1 (2020-01-16) ------------------- diff --git a/vendor/github.com/uber/jaeger-client-go/Gopkg.lock b/vendor/github.com/uber/jaeger-client-go/Gopkg.lock index 5a42ebf16..2a5215a50 100644 --- a/vendor/github.com/uber/jaeger-client-go/Gopkg.lock +++ b/vendor/github.com/uber/jaeger-client-go/Gopkg.lock @@ -46,6 +46,14 @@ version = "v1.1.1" [[projects]] + digest = "1:7ae311278f7ccaa724de8f2cdec0a507ba3ee6dea8c77237e8157bcf64b0f28b" + name = "github.com/golang/mock" + packages = ["gomock"] + pruneopts = "UT" + revision = "3a35fb6e3e18b9dbfee291262260dee7372d2a92" + version = "v1.4.3" + +[[projects]] digest = "1:573ca21d3669500ff845bdebee890eb7fc7f0f50c59f2132f2a0c6b03d85086a" name = "github.com/golang/protobuf" packages = ["proto"] @@ -182,7 +190,7 @@ revision = "2cfd321de3ee5d5f8a5fda2521d1703478334d98" [[projects]] - digest = "1:6be13632ab4bd5842a097abb3aabac045a8601e19a10da4239e7d8bd83d4b83c" + digest = "1:98a70115729234dc73ee7bb83973cb39cb8fedf278d17df77264382bad0183ec" name = "go.uber.org/zap" packages = [ ".", @@ -191,6 +199,7 @@ "internal/color", "internal/exit", "zapcore", + "zaptest/observer", ] pruneopts = "UT" revision = "a6015e13fab9b744d96085308ce4e8f11bad1996" @@ -297,6 +306,7 @@ analyzer-version = 1 input-imports = [ "github.com/crossdock/crossdock-go", + "github.com/golang/mock/gomock", "github.com/opentracing/opentracing-go", "github.com/opentracing/opentracing-go/ext", "github.com/opentracing/opentracing-go/harness", @@ -312,6 +322,7 @@ "go.uber.org/atomic", "go.uber.org/zap", "go.uber.org/zap/zapcore", + "go.uber.org/zap/zaptest/observer", ] solver-name = "gps-cdcl" solver-version = 1 diff --git a/vendor/github.com/uber/jaeger-client-go/README.md b/vendor/github.com/uber/jaeger-client-go/README.md index 0e4d9fc0b..7c348e73a 100644 --- a/vendor/github.com/uber/jaeger-client-go/README.md +++ b/vendor/github.com/uber/jaeger-client-go/README.md @@ -87,7 +87,7 @@ defer closer.Close() This is especially useful for command-line tools that enable tracing, as well as for the long-running apps that support graceful shutdown. For example, if your deployment system sends SIGTERM instead of killing the process and you trap that signal to do a graceful -exit, then having `defer closer.Closer()` ensures that all buffered spans are flushed. +exit, then having `defer closer.Close()` ensures that all buffered spans are flushed. ### Metrics & Monitoring @@ -279,20 +279,25 @@ However it is not the default propagation format, see [here](zipkin/README.md#Ne ## SelfRef -Jaeger Tracer supports an additional [reference](https://github.com/opentracing/specification/blob/1.1/specification.md#references-between-spans) -type call `Self`. This allows a caller to provide an already established `SpanContext`. -This allows loading and continuing spans/traces from offline (ie log-based) storage. The `Self` reference -bypasses trace and span id generation. +Jaeger Tracer supports an additional [span reference][] type call `Self`, which was proposed +to the OpenTracing Specification (https://github.com/opentracing/specification/issues/81) +but not yet accepted. This allows the caller to provide an already created `SpanContext` +when starting a new span. The `Self` reference bypasses trace and span id generation, +as well as sampling decisions (i.e. the sampling bit in the `SpanContext.flags` must be +set appropriately by the caller). +The `Self` reference supports the following use cases: + * the ability to provide externally generated trace and span IDs + * appending data to the same span from different processes, such as loading and continuing spans/traces from offline (ie log-based) storage -Usage requires passing in a `SpanContext` and the jaeger `Self` reference type: +Usage requires passing in a `SpanContext` and the `jaeger.Self` reference type: ``` span := tracer.StartSpan( "continued_span", - SelfRef(yourSpanContext), + jaeger.SelfRef(yourSpanContext), ) ... -defer span.finish() +defer span.Finish() ``` ## License @@ -310,3 +315,4 @@ defer span.finish() [ot-url]: http://opentracing.io [baggage]: https://github.com/opentracing/specification/blob/master/specification.md#set-a-baggage-item [timeunits]: https://golang.org/pkg/time/#ParseDuration +[span reference]: https://github.com/opentracing/specification/blob/1.1/specification.md#references-between-spans diff --git a/vendor/github.com/uber/jaeger-client-go/constants.go b/vendor/github.com/uber/jaeger-client-go/constants.go index 1702c7de4..1f8578fbd 100644 --- a/vendor/github.com/uber/jaeger-client-go/constants.go +++ b/vendor/github.com/uber/jaeger-client-go/constants.go @@ -22,7 +22,7 @@ import ( const ( // JaegerClientVersion is the version of the client library reported as Span tag. - JaegerClientVersion = "Go-2.22.1" + JaegerClientVersion = "Go-2.23.1" // JaegerClientVersionTagKey is the name of the tag used to report client version. JaegerClientVersionTagKey = "jaeger.version" diff --git a/vendor/github.com/uber/jaeger-client-go/glide.lock b/vendor/github.com/uber/jaeger-client-go/glide.lock index c16d6d43f..f4c05b2db 100644 --- a/vendor/github.com/uber/jaeger-client-go/glide.lock +++ b/vendor/github.com/uber/jaeger-client-go/glide.lock @@ -93,4 +93,6 @@ imports: - windows - name: gopkg.in/yaml.v2 version: 51d6538a90f86fe93ac480b35f37b2be17fef232 +- name: github.com/golang/mock + version: 3a35fb6e3e18b9dbfee291262260dee7372d2a92 testImports: [] diff --git a/vendor/github.com/uber/jaeger-client-go/glide.yaml b/vendor/github.com/uber/jaeger-client-go/glide.yaml index 3c7b5c379..eb58c67ff 100644 --- a/vendor/github.com/uber/jaeger-client-go/glide.yaml +++ b/vendor/github.com/uber/jaeger-client-go/glide.yaml @@ -25,3 +25,4 @@ testImport: - assert - require - suite +- package: github.com/golang/mock diff --git a/vendor/github.com/uber/jaeger-client-go/log/logger.go b/vendor/github.com/uber/jaeger-client-go/log/logger.go index 894bb3dbf..ced6e0ce9 100644 --- a/vendor/github.com/uber/jaeger-client-go/log/logger.go +++ b/vendor/github.com/uber/jaeger-client-go/log/logger.go @@ -47,13 +47,19 @@ func (l *stdLogger) Infof(msg string, args ...interface{}) { log.Printf(msg, args...) } +// Debugf logs a message at debug priority +func (l *stdLogger) Debugf(msg string, args ...interface{}) { + log.Printf(fmt.Sprintf("DEBUG: %s", msg), args...) +} + // NullLogger is implementation of the Logger interface that is no-op var NullLogger = &nullLogger{} type nullLogger struct{} -func (l *nullLogger) Error(msg string) {} -func (l *nullLogger) Infof(msg string, args ...interface{}) {} +func (l *nullLogger) Error(msg string) {} +func (l *nullLogger) Infof(msg string, args ...interface{}) {} +func (l *nullLogger) Debugf(msg string, args ...interface{}) {} // BytesBufferLogger implements Logger backed by a bytes.Buffer. type BytesBufferLogger struct { @@ -75,6 +81,13 @@ func (l *BytesBufferLogger) Infof(msg string, args ...interface{}) { l.mux.Unlock() } +// Debugf implements Logger. +func (l *BytesBufferLogger) Debugf(msg string, args ...interface{}) { + l.mux.Lock() + l.buf.WriteString("DEBUG: " + fmt.Sprintf(msg, args...) + "\n") + l.mux.Unlock() +} + // String returns string representation of the underlying buffer. func (l *BytesBufferLogger) String() string { l.mux.Lock() @@ -88,3 +101,41 @@ func (l *BytesBufferLogger) Flush() { defer l.mux.Unlock() l.buf.Reset() } + +// DebugLogger is an interface which adds a debug logging level +type DebugLogger interface { + Logger + + // Debugf logs a message at debug priority + Debugf(msg string, args ...interface{}) +} + +// DebugLogAdapter is a log adapter that converts a Logger into a DebugLogger +// If the provided Logger doesn't satisfy the interface, a logger with debug +// disabled is returned +func DebugLogAdapter(logger Logger) DebugLogger { + if logger == nil { + return nil + } + if debugLogger, ok := logger.(DebugLogger); ok { + return debugLogger + } + logger.Infof("debug logging disabled") + return debugDisabledLogAdapter{logger: logger} +} + +type debugDisabledLogAdapter struct { + logger Logger +} + +func (d debugDisabledLogAdapter) Error(msg string) { + d.logger.Error(msg) +} + +func (d debugDisabledLogAdapter) Infof(msg string, args ...interface{}) { + d.logger.Infof(msg, args...) +} + +// Debugf is a nop +func (d debugDisabledLogAdapter) Debugf(msg string, args ...interface{}) { +} diff --git a/vendor/github.com/uber/jaeger-client-go/reporter.go b/vendor/github.com/uber/jaeger-client-go/reporter.go index 830b5a4bb..a71a92c3e 100644 --- a/vendor/github.com/uber/jaeger-client-go/reporter.go +++ b/vendor/github.com/uber/jaeger-client-go/reporter.go @@ -257,6 +257,7 @@ func (r *remoteReporter) Report(span *Span) { // Close implements Close() method of Reporter by waiting for the queue to be drained. func (r *remoteReporter) Close() { + r.logger.Debugf("closing reporter") if swapped := atomic.CompareAndSwapInt64(&r.closed, 0, 1); !swapped { r.logger.Error("Repeated attempt to close the reporter is ignored") return @@ -307,6 +308,7 @@ func (r *remoteReporter) processQueue() { r.metrics.ReporterSuccess.Inc(int64(flushed)) // to reduce the number of gauge stats, we only emit queue length on flush r.metrics.ReporterQueueLength.Update(atomic.LoadInt64(&r.queueLength)) + r.logger.Debugf("flushed %d spans", flushed) } span.Release() case reporterQueueItemClose: diff --git a/vendor/github.com/uber/jaeger-client-go/reporter_options.go b/vendor/github.com/uber/jaeger-client-go/reporter_options.go index 65012d701..2fc030547 100644 --- a/vendor/github.com/uber/jaeger-client-go/reporter_options.go +++ b/vendor/github.com/uber/jaeger-client-go/reporter_options.go @@ -16,6 +16,8 @@ package jaeger import ( "time" + + "github.com/uber/jaeger-client-go/log" ) // ReporterOption is a function that sets some option on the reporter. @@ -31,7 +33,7 @@ type reporterOptions struct { // bufferFlushInterval is how often the buffer is force-flushed, even if it's not full bufferFlushInterval time.Duration // logger is used to log errors of span submissions - logger Logger + logger log.DebugLogger // metrics is used to record runtime stats metrics *Metrics } @@ -64,6 +66,6 @@ func (reporterOptions) BufferFlushInterval(bufferFlushInterval time.Duration) Re // errors of span submissions. func (reporterOptions) Logger(logger Logger) ReporterOption { return func(r *reporterOptions) { - r.logger = logger + r.logger = log.DebugLogAdapter(logger) } } diff --git a/vendor/github.com/uber/jaeger-client-go/sampler.go b/vendor/github.com/uber/jaeger-client-go/sampler.go index f47004b1f..d0be8ad50 100644 --- a/vendor/github.com/uber/jaeger-client-go/sampler.go +++ b/vendor/github.com/uber/jaeger-client-go/sampler.go @@ -17,6 +17,7 @@ package jaeger import ( "fmt" "math" + "strings" "sync" "github.com/uber/jaeger-client-go/thrift-gen/sampling" @@ -141,7 +142,7 @@ func (s *ProbabilisticSampler) SamplingRate() float64 { // IsSampled implements IsSampled() of Sampler. func (s *ProbabilisticSampler) IsSampled(id TraceID, operation string) (bool, []Tag) { - return s.samplingBoundary >= id.Low, s.tags + return s.samplingBoundary >= id.Low&maxRandomNumber, s.tags } // Close implements Close() of Sampler. @@ -319,6 +320,10 @@ func (s *GuaranteedThroughputProbabilisticSampler) update(lowerBound, samplingRa } } +func (s GuaranteedThroughputProbabilisticSampler) String() string { + return fmt.Sprintf("GuaranteedThroughputProbabilisticSampler(lowerBound=%f, samplingRate=%f)", s.lowerBound, s.samplingRate) +} + // ----------------------- // PerOperationSampler is a delegating sampler that applies GuaranteedThroughputProbabilisticSampler @@ -456,6 +461,23 @@ func (s *PerOperationSampler) Close() { s.defaultSampler.Close() } +func (s *PerOperationSampler) String() string { + var sb strings.Builder + + fmt.Fprintf(&sb, "PerOperationSampler(defaultSampler=%v, ", s.defaultSampler) + fmt.Fprintf(&sb, "lowerBound=%f, ", s.lowerBound) + fmt.Fprintf(&sb, "maxOperations=%d, ", s.maxOperations) + fmt.Fprintf(&sb, "operationNameLateBinding=%t, ", s.operationNameLateBinding) + fmt.Fprintf(&sb, "numOperations=%d,\n", len(s.samplers)) + fmt.Fprintf(&sb, "samplers=[") + for operationName, sampler := range s.samplers { + fmt.Fprintf(&sb, "\n(operationName=%s, sampler=%v)", operationName, sampler) + } + fmt.Fprintf(&sb, "])") + + return sb.String() +} + // Equal is not used. // TODO (breaking change) remove this in the future func (s *PerOperationSampler) Equal(other Sampler) bool { diff --git a/vendor/github.com/uber/jaeger-client-go/sampler_remote.go b/vendor/github.com/uber/jaeger-client-go/sampler_remote.go index 4448b8f64..112e3e1cb 100644 --- a/vendor/github.com/uber/jaeger-client-go/sampler_remote.go +++ b/vendor/github.com/uber/jaeger-client-go/sampler_remote.go @@ -24,6 +24,7 @@ import ( "sync/atomic" "time" + "github.com/uber/jaeger-client-go/log" "github.com/uber/jaeger-client-go/thrift-gen/sampling" ) @@ -199,6 +200,7 @@ func (s *RemotelyControlledSampler) updateSamplerViaUpdaters(strategy interface{ return err } if sampler != nil { + s.logger.Debugf("sampler updated: %+v", sampler) s.sampler = sampler return nil } @@ -290,7 +292,7 @@ func (u *AdaptiveSamplerUpdater) Update(sampler SamplerV2, strategy interface{}) type httpSamplingStrategyFetcher struct { serverURL string - logger Logger + logger log.DebugLogger } func (f *httpSamplingStrategyFetcher) Fetch(serviceName string) ([]byte, error) { diff --git a/vendor/github.com/uber/jaeger-client-go/sampler_remote_options.go b/vendor/github.com/uber/jaeger-client-go/sampler_remote_options.go index 3b5c6aa9c..e4a6108b7 100644 --- a/vendor/github.com/uber/jaeger-client-go/sampler_remote_options.go +++ b/vendor/github.com/uber/jaeger-client-go/sampler_remote_options.go @@ -35,7 +35,7 @@ type SamplerOptionsFactory struct{} type samplerOptions struct { metrics *Metrics sampler SamplerV2 - logger Logger + logger log.DebugLogger samplingServerURL string samplingRefreshInterval time.Duration samplingFetcher SamplingStrategyFetcher @@ -79,7 +79,7 @@ func (SamplerOptionsFactory) InitialSampler(sampler Sampler) SamplerOption { // Logger creates a SamplerOption that sets the logger used by the sampler. func (SamplerOptionsFactory) Logger(logger Logger) SamplerOption { return func(o *samplerOptions) { - o.logger = logger + o.logger = log.DebugLogAdapter(logger) } } diff --git a/vendor/github.com/uber/jaeger-client-go/tracer.go b/vendor/github.com/uber/jaeger-client-go/tracer.go index da43ec6db..8a3fc97ab 100644 --- a/vendor/github.com/uber/jaeger-client-go/tracer.go +++ b/vendor/github.com/uber/jaeger-client-go/tracer.go @@ -41,7 +41,7 @@ type Tracer struct { sampler SamplerV2 reporter Reporter metrics Metrics - logger log.Logger + logger log.DebugLogger timeNow func() time.Time randomNumber func() uint64 @@ -366,6 +366,7 @@ func (t *Tracer) Extract( // Close releases all resources used by the Tracer and flushes any remaining buffered spans. func (t *Tracer) Close() error { + t.logger.Debugf("closing tracer") t.reporter.Close() t.sampler.Close() if mgr, ok := t.baggageRestrictionManager.(io.Closer); ok { diff --git a/vendor/github.com/uber/jaeger-client-go/tracer_options.go b/vendor/github.com/uber/jaeger-client-go/tracer_options.go index f016484b9..f0734b772 100644 --- a/vendor/github.com/uber/jaeger-client-go/tracer_options.go +++ b/vendor/github.com/uber/jaeger-client-go/tracer_options.go @@ -21,6 +21,7 @@ import ( "github.com/uber/jaeger-client-go/internal/baggage" "github.com/uber/jaeger-client-go/internal/throttler" + "github.com/uber/jaeger-client-go/log" ) // TracerOption is a function that sets some option on the tracer @@ -42,7 +43,7 @@ func (tracerOptions) Metrics(m *Metrics) TracerOption { // Logger creates a TracerOption that gives the tracer a Logger. func (tracerOptions) Logger(logger Logger) TracerOption { return func(tracer *Tracer) { - tracer.logger = logger + tracer.logger = log.DebugLogAdapter(logger) } } diff --git a/vendor/modules.txt b/vendor/modules.txt index b638d1ad0..fac8238c6 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -486,7 +486,7 @@ github.com/stretchr/testify/require github.com/syndtr/gocapability/capability # github.com/tchap/go-patricia v2.3.0+incompatible github.com/tchap/go-patricia/patricia -# github.com/uber/jaeger-client-go v2.22.1+incompatible +# github.com/uber/jaeger-client-go v2.23.1+incompatible github.com/uber/jaeger-client-go github.com/uber/jaeger-client-go/config github.com/uber/jaeger-client-go/internal/baggage |