Interface IManagedTracer

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
NameDescription
labelsDictionary<String, String>

GetCurrentSpanId()

ulong? GetCurrentSpanId()

Gets the current span id or null if none exists.

Returns
TypeDescription
Nullable<UInt64>

GetCurrentTraceId()

string GetCurrentTraceId()

Gets the current trace id or null if none exists.

Returns
TypeDescription
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
NameDescription
actionAction

The action to run in a span.

nameString

The name of the span. Must not be null.

optionsStartSpanOptions

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
NameDescription
funcFunc<T>

The function to run in a span.

nameString

The name of the span. Must not be null.

optionsStartSpanOptions

The span options to override default values.

Returns
TypeDescription
T

The result from the call to func

Type Parameter
NameDescription
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
NameDescription
funcFunc<Task<T>>

The function to run in a span.

nameString

The name of the span. Must not be null.

optionsStartSpanOptions

The span options to override default values.

Returns
TypeDescription
Task<T>

The result from the call to func

Type Parameter
NameDescription
T

SetStackTrace(StackTrace)

void SetStackTrace(StackTrace stackTrace)

Adds the given StackTrace to the current span.

Parameter
NameDescription
stackTraceStackTrace

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
NameDescription
nameString

The name of the span. Must not be null.

optionsStartSpanOptions

The span options to override default values.

Returns
TypeDescription
ISpan

An ISpan that will end the current span when disposed.