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
Syntax
public interface IManagedTracer
Methods
AnnotateSpan(Dictionary<String, String>)
Annotates the current span with the given labels.
Declaration
void AnnotateSpan(Dictionary<string, string> labels)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.Dictionary<System.String, System.String> | labels |
GetCurrentSpanId()
Gets the current span id or null if none exists.
Declaration
ulong? GetCurrentSpanId()
Returns
| Type | Description |
|---|---|
| System.Nullable<System.UInt64> |
GetCurrentTraceId()
Gets the current trace id or null if none exists.
Declaration
string GetCurrentTraceId()
Returns
| Type | Description |
|---|---|
| System.String |
RunInSpan(Action, String, StartSpanOptions)
Runs the function in a span and will add a stacktrace from a thrown exception (the exception will be re-thrown) to the span.
Declaration
void RunInSpan(Action action, string name, StartSpanOptions options = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Action | action | The action to run in a span. |
| System.String | name | The name of the span. Must not be null. |
| StartSpanOptions | options | The span options to override default values. |
RunInSpan<T>(Func<T>, String, StartSpanOptions)
Runs the function in a span and will add a stacktrace from a thrown exception (the exception will be re-thrown) to the span.
Declaration
T RunInSpan<T>(Func<T> func, string name, StartSpanOptions options = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Func<T> | func | The function to run in a span. |
| System.String | name | The name of the span. Must not be null. |
| StartSpanOptions | options | The span options to override default values. |
Returns
| Type | Description |
|---|---|
| T | The result from the call to |
Type Parameters
| Name | Description |
|---|---|
| T |
RunInSpanAsync<T>(Func<Task<T>>, String, StartSpanOptions)
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.
Declaration
Task<T> RunInSpanAsync<T>(Func<Task<T>> func, string name, StartSpanOptions options = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Func<System.Threading.Tasks.Task<T>> | func | The function to run in a span. |
| System.String | name | The name of the span. Must not be null. |
| StartSpanOptions | options | The span options to override default values. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<T> | The result from the call to |
Type Parameters
| Name | Description |
|---|---|
| T |
SetStackTrace(StackTrace)
Adds the given StackTrace to the current span.
Declaration
void SetStackTrace(StackTrace stackTrace)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Diagnostics.StackTrace | stackTrace |
StartSpan(String, StartSpanOptions)
Starts a new span using the most recent (if any) unfinished span as the parent.
Declaration
ISpan StartSpan(string name, StartSpanOptions options = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The name of the span. Must not be null. |
| StartSpanOptions | options | The span options to override default values. |
Returns
| Type | Description |
|---|---|
| ISpan | An ISpan that will end the current span when disposed. |