From 7c061b053811af703cd3cc66d26d9d3bafed25c0 Mon Sep 17 00:00:00 2001 From: Kuat Yessenov Date: Fri, 28 Jun 2019 14:41:29 -0700 Subject: [PATCH] override sampling decision Signed-off-by: Kuat Yessenov --- opencensus/trace/internal/span.cc | 2 ++ opencensus/trace/span.h | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/opencensus/trace/internal/span.cc b/opencensus/trace/internal/span.cc index b36d66e7..aa777999 100644 --- a/opencensus/trace/internal/span.cc +++ b/opencensus/trace/internal/span.cc @@ -224,6 +224,8 @@ const SpanContext& Span::context() const { return context_; } bool Span::IsSampled() const { return context_.trace_options().IsSampled(); } +void Span::StopRecording() { span_impl_ = nullptr; } + bool Span::IsRecording() const { return span_impl_ != nullptr; } void swap(Span& a, Span& b) { diff --git a/opencensus/trace/span.h b/opencensus/trace/span.h index 0607bab8..f554e93c 100644 --- a/opencensus/trace/span.h +++ b/opencensus/trace/span.h @@ -168,6 +168,11 @@ class Span final { // Sampled spans always record events. bool IsSampled() const; + // Stops recording the span and overrides the sampling decision to false. + // This should be used by the client to force disable sampling in support of + // delayed sampling decisions (e.g. health check URI blacklist). + void StopRecording(); + // Returns true if the Span is recording events (will appear in Span stores). // Sampled spans always record events, but not all Spans that are recording // are sampled.