Class TelemetrySpan
- Namespace
- OpenTelemetry.Trace
- Assembly
- OpenTelemetry.Api.dll
Span represents a single operation within a trace.
public class TelemetrySpan : IDisposable
- Inheritance
-
TelemetrySpan
- Implements
- Inherited Members
Remarks
TelemetrySpan is a wrapper around OpenTelemetry.Trace.TelemetrySpan.Activity class.
Properties
Context
Gets the span context.
public SpanContext Context { get; }
Property Value
IsRecording
Gets a value indicating whether this span will be recorded.
public bool IsRecording { get; }
Property Value
ParentSpanId
Gets the identity of the parent span id, if any.
public ActivitySpanId ParentSpanId { get; }
Property Value
- ActivitySpanId
Methods
AddEvent(string)
Adds a single Event to the TelemetrySpan.
public TelemetrySpan AddEvent(string name)
Parameters
name
stringName of the event.
Returns
- TelemetrySpan
The TelemetrySpan instance for chaining.
AddEvent(string, SpanAttributes)
Adds a single Event to the TelemetrySpan.
public TelemetrySpan AddEvent(string name, SpanAttributes attributes)
Parameters
name
stringName of the event.
attributes
SpanAttributesAttributes for the event.
Returns
- TelemetrySpan
The TelemetrySpan instance for chaining.
AddEvent(string, DateTimeOffset)
Adds a single Event to the TelemetrySpan.
public TelemetrySpan AddEvent(string name, DateTimeOffset timestamp)
Parameters
name
stringName of the event.
timestamp
DateTimeOffsetTimestamp of the event.
Returns
- TelemetrySpan
The TelemetrySpan instance for chaining.
AddEvent(string, DateTimeOffset, SpanAttributes)
Adds a single Event to the TelemetrySpan.
public TelemetrySpan AddEvent(string name, DateTimeOffset timestamp, SpanAttributes attributes)
Parameters
name
stringName of the event.
timestamp
DateTimeOffsetTimestamp of the event.
attributes
SpanAttributesAttributes for the event.
Returns
- TelemetrySpan
The TelemetrySpan instance for chaining.
Dispose()
public void Dispose()
Dispose(bool)
Releases the unmanaged resources used by this class and optionally releases the managed resources.
protected virtual void Dispose(bool disposing)
Parameters
disposing
booltrue to release both managed and unmanaged resources; false to release only unmanaged resources.
End()
End the span.
public void End()
End(DateTimeOffset)
End the span.
public void End(DateTimeOffset endTimestamp)
Parameters
endTimestamp
DateTimeOffsetEnd timestamp.
RecordException(Exception)
Record Exception.
public TelemetrySpan RecordException(Exception ex)
Parameters
ex
ExceptionException to be recorded.
Returns
- TelemetrySpan
The TelemetrySpan instance for chaining.
RecordException(string, string, string)
Record Exception.
public TelemetrySpan RecordException(string type, string message, string stacktrace)
Parameters
type
stringType of the exception to be recorded.
message
stringMessage of the exception to be recorded.
stacktrace
stringStacktrace of the exception to be recorded.
Returns
- TelemetrySpan
The TelemetrySpan instance for chaining.
SetAttribute(string, bool)
Sets a new attribute on the span.
public TelemetrySpan SetAttribute(string key, bool value)
Parameters
Returns
- TelemetrySpan
The TelemetrySpan instance for chaining.
SetAttribute(string, bool[])
Sets a new attribute on the span.
public TelemetrySpan SetAttribute(string key, bool[] values)
Parameters
Returns
- TelemetrySpan
The TelemetrySpan instance for chaining.
SetAttribute(string, double)
Sets a new attribute on the span.
public TelemetrySpan SetAttribute(string key, double value)
Parameters
Returns
- TelemetrySpan
The TelemetrySpan instance for chaining.
SetAttribute(string, double[])
Sets a new attribute on the span.
public TelemetrySpan SetAttribute(string key, double[] values)
Parameters
Returns
- TelemetrySpan
The TelemetrySpan instance for chaining.
SetAttribute(string, int)
Sets a new attribute on the span.
public TelemetrySpan SetAttribute(string key, int value)
Parameters
Returns
- TelemetrySpan
The TelemetrySpan instance for chaining.
SetAttribute(string, int[])
Sets a new attribute on the span.
public TelemetrySpan SetAttribute(string key, int[] values)
Parameters
Returns
- TelemetrySpan
The TelemetrySpan instance for chaining.
SetAttribute(string, string)
Sets a new attribute on the span.
public TelemetrySpan SetAttribute(string key, string value)
Parameters
Returns
- TelemetrySpan
The TelemetrySpan instance for chaining.
SetAttribute(string, string[])
Sets a new attribute on the span.
public TelemetrySpan SetAttribute(string key, string[] values)
Parameters
Returns
- TelemetrySpan
The TelemetrySpan instance for chaining.
SetStatus(Status)
Sets the status of the span execution.
public void SetStatus(Status value)
Parameters
value
StatusStatus to be set.
UpdateName(string)
Updates the TelemetrySpan name.
If used, this will override the name provided via StartSpan method overload. Upon this update, any sampling behavior based on TelemetrySpan name will depend on the implementation.
public TelemetrySpan UpdateName(string name)
Parameters
name
stringName of the span.
Returns
- TelemetrySpan
The TelemetrySpan instance for chaining.