@@ -87,20 +87,27 @@ class SpanImpl final {
8787
8888 void SetName (absl::string_view name) LOCKS_EXCLUDED(mu_);
8989
90+ void MarkAbandoned () LOCKS_EXCLUDED(mu_);
91+
9092 // Returns true on success (if this is the first time the Span has ended) and
9193 // also marks the end of the Span and sets its end_time_.
9294 bool End () LOCKS_EXCLUDED(mu_);
9395
94- // Returns true if the span has ended.
96+ // Returns true if the Span has ended.
9597 bool HasEnded () const LOCKS_EXCLUDED(mu_);
9698
99+ // Returns true if the Span is sampled for export. Returns false if the Span
100+ // was abandoned.
101+ bool IsSampled () const LOCKS_EXCLUDED(mu_);
102+
97103 absl::string_view name () const { return name_; }
98104
99105 // Returns the name of the span as a constref string.
100106 const std::string& name_constref () const { return name_; }
101107
102108 // Returns the SpanContext associated with this Span.
103- SpanContext context () const { return context_; }
109+ // The trace_options do reflect MarkAbandoned().
110+ SpanContext context () const LOCKS_EXCLUDED(mu_);
104111
105112 SpanId parent_span_id () const { return parent_span_id_; }
106113
@@ -126,7 +133,7 @@ class SpanImpl final {
126133 // a root span.
127134 const SpanId parent_span_id_;
128135 // TraceId, SpanId, and TraceOptions for the current span.
129- const SpanContext context_;
136+ SpanContext context_ GUARDED_BY (mu_) ;
130137 // Queue of recorded annotations.
131138 TraceEvents<EventWithTime<exporter::Annotation>> annotations_ GUARDED_BY (mu_);
132139 // Queue of recorded network events.
@@ -138,6 +145,8 @@ class SpanImpl final {
138145 AttributeList attributes_ GUARDED_BY (mu_);
139146 // Marks if the span has ended.
140147 bool has_ended_ GUARDED_BY (mu_);
148+ // Marks if the span was abandoned.
149+ bool is_abandoned_ GUARDED_BY (mu_);
141150 // True if the parent Span is in a different process.
142151 const bool remote_parent_;
143152};
0 commit comments