Table of Contents

Class Tracer

Namespace
OpenTelemetry.Trace
Assembly
OpenTelemetry.Api.dll

Tracer is the class responsible for creating TelemetrySpan.

public class Tracer
Inheritance
Tracer
Inherited Members

Remarks

Tracer is a wrapper around OpenTelemetry.Trace.Tracer.ActivitySource class.

Properties

CurrentSpan

Gets the current span from the context.

public static TelemetrySpan CurrentSpan { get; }

Property Value

TelemetrySpan

Methods

Starts a span and make it the current active span.

public TelemetrySpan StartActiveSpan(string name, SpanKind kind = SpanKind.Internal, in SpanContext parentContext = default, SpanAttributes initialAttributes = null, IEnumerable<Link> links = null, DateTimeOffset startTime = default)

Parameters

name string

Span name.

kind SpanKind

Kind.

parentContext SpanContext

Parent Context for new span.

initialAttributes SpanAttributes

Initial attributes for the span.

links IEnumerable<Link>

Link for the span.

startTime DateTimeOffset

Start time for the span.

Returns

TelemetrySpan

Span instance.

Starts a span and make it the current active span.

public TelemetrySpan StartActiveSpan(string name, SpanKind kind, in TelemetrySpan parentSpan, SpanAttributes initialAttributes = null, IEnumerable<Link> links = null, DateTimeOffset startTime = default)

Parameters

name string

Span name.

kind SpanKind

Kind.

parentSpan TelemetrySpan

Parent for new span.

initialAttributes SpanAttributes

Initial attributes for the span.

links IEnumerable<Link>

Link for the span.

startTime DateTimeOffset

Start time for the span.

Returns

TelemetrySpan

Span instance.

Starts root span.

public TelemetrySpan StartRootSpan(string name, SpanKind kind = SpanKind.Internal, SpanAttributes initialAttributes = null, IEnumerable<Link> links = null, DateTimeOffset startTime = default)

Parameters

name string

Span name.

kind SpanKind

Kind.

initialAttributes SpanAttributes

Initial attributes for the span.

links IEnumerable<Link>

Link for the span.

startTime DateTimeOffset

Start time for the span.

Returns

TelemetrySpan

Span instance.

Starts a span and does not make it as current span.

public TelemetrySpan StartSpan(string name, SpanKind kind = SpanKind.Internal, in SpanContext parentContext = default, SpanAttributes initialAttributes = null, IEnumerable<Link> links = null, DateTimeOffset startTime = default)

Parameters

name string

Span name.

kind SpanKind

Kind.

parentContext SpanContext

Parent Context for new span.

initialAttributes SpanAttributes

Initial attributes for the span.

links IEnumerable<Link>

Link for the span.

startTime DateTimeOffset

Start time for the span.

Returns

TelemetrySpan

Span instance.

Starts a span and does not make it as current span.

public TelemetrySpan StartSpan(string name, SpanKind kind, in TelemetrySpan parentSpan, SpanAttributes initialAttributes = null, IEnumerable<Link> links = null, DateTimeOffset startTime = default)

Parameters

name string

Span name.

kind SpanKind

Kind.

parentSpan TelemetrySpan

Parent for new span.

initialAttributes SpanAttributes

Initial attributes for the span.

links IEnumerable<Link>

Link for the span.

startTime DateTimeOffset

Start time for the span.

Returns

TelemetrySpan

Span instance.

WithSpan(TelemetrySpan)

Makes the given span as the current one.

public static TelemetrySpan WithSpan(TelemetrySpan span)

Parameters

span TelemetrySpan

The span to be made current.

Returns

TelemetrySpan

The current span.