From 144dca0cae5042be559a055cb0f284fa31a39207 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Tue, 4 Jul 2023 00:23:50 +0300 Subject: [PATCH] tracer: add Flush method Signed-off-by: Vasiliy Tolstov --- metadata/context.go | 4 ---- tracer/noop.go | 6 ++++++ tracer/tracer.go | 2 ++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/metadata/context.go b/metadata/context.go index fadfea5b..1406b30d 100644 --- a/metadata/context.go +++ b/metadata/context.go @@ -39,8 +39,6 @@ func FromOutgoingContext(ctx context.Context) (Metadata, bool) { // FromContext returns metadata from the given context // returned metadata shoud not be modified or race condition happens -// -// Deprecated: use FromIncomingContext or FromOutgoingContext func FromContext(ctx context.Context) (Metadata, bool) { if ctx == nil { return nil, false @@ -53,8 +51,6 @@ func FromContext(ctx context.Context) (Metadata, bool) { } // NewContext creates a new context with the given metadata -// -// Deprecated: use NewIncomingContext or NewOutgoingContext func NewContext(ctx context.Context, md Metadata) context.Context { if ctx == nil { ctx = context.Background() diff --git a/tracer/noop.go b/tracer/noop.go index 64fe2248..69a89a82 100644 --- a/tracer/noop.go +++ b/tracer/noop.go @@ -4,6 +4,8 @@ import ( "context" ) +var _ Tracer = (*noopTracer)(nil) + type noopTracer struct { opts Options } @@ -21,6 +23,10 @@ func (t *noopTracer) Start(ctx context.Context, name string, opts ...SpanOption) return NewSpanContext(ctx, span), span } +func (t *noopTracer) Flush(ctx context.Context) error { + return nil +} + func (t *noopTracer) Init(opts ...Option) error { for _, o := range opts { o(&t.opts) diff --git a/tracer/tracer.go b/tracer/tracer.go index daecd53e..3d8af485 100644 --- a/tracer/tracer.go +++ b/tracer/tracer.go @@ -16,6 +16,8 @@ type Tracer interface { Init(...Option) error // Start a trace Start(ctx context.Context, name string, opts ...SpanOption) (context.Context, Span) + // Flush flushes spans + Flush(ctx context.Context) error } type Span interface {