summaryrefslogtreecommitdiff
path: root/vendor/github.com/opentracing/opentracing-go/gocontext.go
diff options
context:
space:
mode:
authorValentin Rothberg <rothberg@redhat.com>2021-02-25 20:47:21 +0100
committerValentin Rothberg <rothberg@redhat.com>2021-03-08 09:22:42 +0100
commitd0d084dd8ce37141e0a2f0e9def78ffbb613ab94 (patch)
treebd626d1310b64b2f5410a2ca8a7f5a7232634d2b /vendor/github.com/opentracing/opentracing-go/gocontext.go
parent320df838810cbdb0f3dc0e2092f5ed04fc9b6e5d (diff)
downloadpodman-d0d084dd8ce37141e0a2f0e9def78ffbb613ab94.tar.gz
podman-d0d084dd8ce37141e0a2f0e9def78ffbb613ab94.tar.bz2
podman-d0d084dd8ce37141e0a2f0e9def78ffbb613ab94.zip
turn hidden --trace into a NOP
The --trace has helped in early stages analyze Podman code. However, it's contributing to dependency and binary bloat. The standard go tooling can also help in profiling, so let's turn `--trace` into a NOP. [NO TESTS NEEDED] Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'vendor/github.com/opentracing/opentracing-go/gocontext.go')
-rw-r--r--vendor/github.com/opentracing/opentracing-go/gocontext.go65
1 files changed, 0 insertions, 65 deletions
diff --git a/vendor/github.com/opentracing/opentracing-go/gocontext.go b/vendor/github.com/opentracing/opentracing-go/gocontext.go
deleted file mode 100644
index 1831bc9b2..000000000
--- a/vendor/github.com/opentracing/opentracing-go/gocontext.go
+++ /dev/null
@@ -1,65 +0,0 @@
-package opentracing
-
-import "context"
-
-type contextKey struct{}
-
-var activeSpanKey = contextKey{}
-
-// ContextWithSpan returns a new `context.Context` that holds a reference to
-// the span. If span is nil, a new context without an active span is returned.
-func ContextWithSpan(ctx context.Context, span Span) context.Context {
- if span != nil {
- if tracerWithHook, ok := span.Tracer().(TracerContextWithSpanExtension); ok {
- ctx = tracerWithHook.ContextWithSpanHook(ctx, span)
- }
- }
- return context.WithValue(ctx, activeSpanKey, span)
-}
-
-// SpanFromContext returns the `Span` previously associated with `ctx`, or
-// `nil` if no such `Span` could be found.
-//
-// NOTE: context.Context != SpanContext: the former is Go's intra-process
-// context propagation mechanism, and the latter houses OpenTracing's per-Span
-// identity and baggage information.
-func SpanFromContext(ctx context.Context) Span {
- val := ctx.Value(activeSpanKey)
- if sp, ok := val.(Span); ok {
- return sp
- }
- return nil
-}
-
-// StartSpanFromContext starts and returns a Span with `operationName`, using
-// any Span found within `ctx` as a ChildOfRef. If no such parent could be
-// found, StartSpanFromContext creates a root (parentless) Span.
-//
-// The second return value is a context.Context object built around the
-// returned Span.
-//
-// Example usage:
-//
-// SomeFunction(ctx context.Context, ...) {
-// sp, ctx := opentracing.StartSpanFromContext(ctx, "SomeFunction")
-// defer sp.Finish()
-// ...
-// }
-func StartSpanFromContext(ctx context.Context, operationName string, opts ...StartSpanOption) (Span, context.Context) {
- return StartSpanFromContextWithTracer(ctx, GlobalTracer(), operationName, opts...)
-}
-
-// StartSpanFromContextWithTracer starts and returns a span with `operationName`
-// using a span found within the context as a ChildOfRef. If that doesn't exist
-// it creates a root span. It also returns a context.Context object built
-// around the returned span.
-//
-// It's behavior is identical to StartSpanFromContext except that it takes an explicit
-// tracer as opposed to using the global tracer.
-func StartSpanFromContextWithTracer(ctx context.Context, tracer Tracer, operationName string, opts ...StartSpanOption) (Span, context.Context) {
- if parentSpan := SpanFromContext(ctx); parentSpan != nil {
- opts = append(opts, ChildOf(parentSpan.Context()))
- }
- span := tracer.StartSpan(operationName, opts...)
- return span, ContextWithSpan(ctx, span)
-}