Interface IManagedTracer (5.0.0)

public interface IManagedTracer

Manages creating spans for a trace as well as adding meta data to them.

Namespace

Google.Cloud.Diagnostics.Common

Assembly

Google.Cloud.Diagnostics.Common.dll

Methods

AnnotateSpan(Dictionary<String, String>)

void AnnotateSpan(Dictionary<string, string> labels)

Annotates the current span with the given labels.

Parameter
Name Description
labels Dictionary<String, String>

GetCurrentSpanId()

ulong? GetCurrentSpanId()

Gets the current span id or null if none exists.

Returns
Type Description
Nullable<UInt64>

GetCurrentTraceId()

string GetCurrentTraceId()

Gets the current trace id or null if none exists.

Returns
Type Description
String

RunInSpan(Action, String, StartSpanOptions)

void RunInSpan(Action action, string name, StartSpanOptions options = null)

Runs the function in a span and will add a stacktrace from a thrown exception (the exception will be re-thrown) to the span.

Parameters
Name Description
action Action

The action to run in a span.

name String

The name of the span. Must not be null.

options StartSpanOptions

The span options to override default values.

RunInSpan<T>(Func<T>, String, StartSpanOptions)

T RunInSpan<T>(Func<T> func, string name, StartSpanOptions options = null)

Runs the function in a span and will add a stacktrace from a thrown exception (the exception will be re-thrown) to the span.

Parameters
Name Description
func Func<T>

The function to run in a span.

name String

The name of the span. Must not be null.

options StartSpanOptions

The span options to override default values.

Returns
Type Description
T

The result from the call to func

Type Parameter
Name Description
T

RunInSpanAsync<T>(Func<Task<T>>, String, StartSpanOptions)

Task<T> RunInSpanAsync<T>(Func<Task<T>> func, string name, StartSpanOptions options = null)

Runs the function asynchronously in a span and will add a stacktrace from a thrown exception (the exception will be re-thrown) to the span.

Parameters
Name Description
func Func<Task<T>>

The function to run in a span.

name String

The name of the span. Must not be null.

options StartSpanOptions

The span options to override default values.

Returns
Type Description
Task<T>

The result from the call to func

Type Parameter
Name Description
T

SetStackTrace(StackTrace)

void SetStackTrace(StackTrace stackTrace)

Adds the given StackTrace to the current span.

Parameter
Name Description
stackTrace StackTrace

StartSpan(String, StartSpanOptions)

ISpan StartSpan(string name, StartSpanOptions options = null)

Starts a new span using the most recent (if any) unfinished span as the parent.

Parameters
Name Description
name String

The name of the span. Must not be null.

options StartSpanOptions

The span options to override default values.

Returns
Type Description
ISpan

An ISpan that will end the current span when disposed.