Interface ISpan
A trace span.
Inherited Members
System.IDisposable.Dispose()
Namespace: Google.Cloud.Diagnostics.Common
Assembly: Google.Cloud.Diagnostics.Common.dll
Syntax
public interface ISpan : IDisposable
Remarks
The functions here, aside from System.IDisposable.Dispose(), do not need to be used in most cases. They need to be used when updating the current span in a disjoint thread. For example:
public void DoSomething(IManagedTracer tracer)
{
var tcs = new TaskCompletionSource<bool>();
ISpan span = null;
Thread t = new Thread(() =>
{
span = tracer.StartSpan(nameof(DoSomething));
tcs.SetResult(true);
});
Thread t2 = new Thread(() =>
{
tcs.Task.Wait();
span.AnnotateSpan(new Dictionary<string, string> { { "new", "label"} });
span.Dispose();
});
t.Start();
t2.Start();
}
NOTE: While it is possible to end a span in another thread any new spans after this may be in a poor state.
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 |
Disposed()
True if the span has been disposed and ended.
Declaration
bool Disposed()
Returns
| Type | Description |
|---|---|
| System.Boolean |
SetStackTrace(StackTrace)
Adds the given StackTrace to the current span.
Declaration
void SetStackTrace(StackTrace stackTrace)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Diagnostics.StackTrace | stackTrace |
SpanId()
Gets span's id.
Declaration
ulong SpanId()
Returns
| Type | Description |
|---|---|
| System.UInt64 |