Google.Cloud.Diagnostics.Common - Interface IManagedTracer (5.1.0)

public interface IManagedTracer

Reference documentation and code samples for the Google.Cloud.Diagnostics.Common interface IManagedTracer.

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

Namespace

GoogleCloudGoogle.Cloud.DiagnosticsCommon

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
labelsDictionarystringstring

GetCurrentSpanId()

ulong? GetCurrentSpanId()

Gets the current span id or null if none exists.

Returns
TypeDescription
ulong

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

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
funcFuncTask

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

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.