NonRecordingSpan class
A non-recording APISpan that carries a SpanContext without recording anything.
This is the span the OpenTelemetry specification requires in two places (trace/api.md):
- "Wrapping a SpanContext in a Span": "The API MUST provide an
operation for wrapping a
SpanContextwith an object implementing theSpaninterface....SHOULD be namedNonRecordingSpan."getContext(the spanContext getter) returns the wrapped context, isRecording returnsfalse, and all other operations are no-ops. - "Behavior of the API in the absence of an installed SDK": the API
returns a non-recording span carrying the
SpanContextfrom the parentContextunchanged, or an empty one (all-zero IDs, emptyTraceState, unsampledTraceFlags) when the context has no span.
Unlike other spans, a NonRecordingSpan may carry an invalid (all-zero) SpanContext.
Constructors
- NonRecordingSpan(SpanContext spanContext)
-
Wraps
spanContextin a non-recording span.factory
Properties
- attributes ← Attributes
-
Sets the attributes, replacing all existing attributes since
implementations SHOULD NOT provide access to a Span's attributes
besides its SpanContext.
Adding attributes at span creation is preferred to calling
set attribute later, as samplers can only consider information already
present during span creation.
Ignored if isEnded
no getterinherited
- endTime → DateTime?
-
The end time of this APISpan.
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- instrumentationScope → InstrumentationScope
-
Returns the instrumentation scope for this span
no setterinherited
- isEnded → bool
-
Returns whether this span has been ended
no setterinherited
- isRecording → bool
-
Always
false: this span never records, per the spec.no setteroverride - isValid → bool
-
Returns whether this span context is valid
A span context is valid when it has a non-zero traceId and a non-zero spanId.
no setterinherited
- kind → SpanKind
-
Returns the SpanKind of this Span.
no setterinherited
- name → String
-
The name of this APISpan.
no setterinherited
- parentSpan → APISpan?
-
Returns the parent span, if any.
Root spans have no parent.
no setterinherited
- parentSpanContext → SpanContext?
-
Returns the parent span context, if any.
Root spans have no parent span context.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- spanContext → SpanContext
-
Returns the SpanContext associated with this Span, if any.
Root spans have no SpanContext.
no setterinherited
- spanId → SpanId
-
Returns the id of this Span, if any.
Root spans have no SpanId.
no setterinherited
- startTime → DateTime
-
The start time of this APISpan.
no setterinherited
Methods
-
addAttributes(
Attributes attributes) → void -
Adds multiple attributes to the span at once by merging with existing attributes.
This is more efficient than calling individual attribute setters when you need to add
multiple attributes.
inherited
-
addEvent(
SpanEvent spanEvent) → void -
Adds an event to the Span. Ignored if isEnded
Note that the OpenTelemetry project documents certain
"standard event names and keys" which have prescribed semantic meanings.
See https://github.com/open-telemetry/semantic-conventions/blob/main/docs/README.md
inherited
-
addEventNow(
String name, [Attributes? attributes]) → void -
Adds an event to the Span. Ignored if isEnded
inherited
-
addEvents(
Map< String, Attributes?> spanEvents) → void -
Adds an events to the Span from a map of names and attributes. Ignored if isEnded
inherited
-
addLink(
SpanContext spanContext, [Attributes? attributes]) → void -
Adds a link to this Span.
inherited
-
addSpanLink(
SpanLink spanLink) → void -
Adds a link to this Span.
inherited
-
end(
{DateTime? endTime, SpanStatusCode? spanStatus}) → void -
Marks the end of the Span execution.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
recordException(
Object exception, {StackTrace? stackTrace, Attributes? attributes, bool? escaped}) → void -
Record an exception for the span. Does NOT set the status.
inherited
-
setBoolAttribute(
String name, bool value) → void -
Sets an attribute, replacing any existing attribute with the same name/key
Adding attributes at span creation is preferred to calling
set attribute later, as samplers can only consider information already
present during span creation.
Ignored if isEnded
inherited
-
setBoolListAttribute(
String name, List< bool> value) → void -
Sets an attribute, replacing any existing attribute with the same name/key
Adding attributes at span creation is preferred to calling
set attribute later, as samplers can only consider information already
present during span creation.
Ignored if isEnded
inherited
-
setDateTimeAsStringAttribute(
String name, DateTime value) → void -
Sets String attribute from a DateTime, replacing any existing attribute
with the same name/key
Adding attributes at span creation is preferred to calling
set attribute later, as samplers can only consider information already
present during span creation.
Ignored if isEnded
inherited
-
setDoubleAttribute(
String name, double value) → void -
Sets an attribute, replacing any existing attribute with the same name/key
Adding attributes at span creation is preferred to calling
set attribute later, as samplers can only consider information already
present during span creation.
Ignored if isEnded
inherited
-
setDoubleListAttribute(
String name, List< double> value) → void -
Sets an attribute, replacing any existing attribute with the same name/key
Adding attributes at span creation is preferred to calling
set attribute later, as samplers can only consider information already
present during span creation.
Ignored if isEnded
inherited
-
setIntAttribute(
String name, int value) → void -
Sets an attribute, replacing any existing attribute with the same name/key
Adding attributes at span creation is preferred to calling
set attribute later, as samplers can only consider information already
present during span creation.
Ignored if isEnded
inherited
-
setIntListAttribute(
String name, List< int> value) → void -
Sets an attribute, replacing any existing attribute with the same name/key
Adding attributes at span creation is preferred to calling
set attribute later, as samplers can only consider information already
present during span creation.
Ignored if isEnded
inherited
-
setStatus(
SpanStatusCode statusCode, [String? description]) → void -
Sets the status of the Span. Ignored if isEnded
Setting
StatuswithStatusCode=Okwill override any prior or future attempts to set spanStatuswithStatusCode=ErrororStatusCode=UnsetdescriptionAn optional description of the status. An emptyDescriptionis equivalent with a not present one. Attempts to set value Unset is ignored.descriptionWhenstatusCodeis error, description should include the error's toString() if an exception is caught available.inherited -
setStringAttribute<
T> (String name, String value) → void -
Sets an attribute, replacing any existing attribute with the same name/key
Adding attributes at span creation is preferred to calling
set attribute later, as samplers can only consider information already
present during span creation.
Ignored if isEnded
inherited
-
setStringListAttribute<
T> (String name, List< String> value) → void -
Sets an attribute, replacing any existing attribute with the same name/key
Adding attributes at span creation is preferred to calling
set attribute later, as samplers can only consider information already
present during span creation.
Ignored if isEnded
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
updateName(
String name) → void -
Updates the Span name.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited