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.