public sealed class TraceHeaderContext : ITraceContextContext from the Google Cloud Trace Header.
Implements
ITraceContextNamespace
Google.Cloud.Diagnostics.CommonAssembly
Google.Cloud.Diagnostics.Common.dll
Remarks
A trace can be forced by passing information along in the trace header ("X-Cloud-Trace-Context"). The trace id, parent span id and whether or not to trace can be set. See: https://cloud.google.com/trace/docs/faq#how_do_i_force_a_request_to_be_traced
Fields
TraceHeader
public const string TraceHeader = "X-Cloud-Trace-Context"The trace header.
| Field Value | |
|---|---|
| Type | Description | 
String | 
        |
Properties
ShouldTrace
public bool? ShouldTrace { get; }Whether this request should be traced or not. May be null, which means that there's not enough information to know whether this request should be traced or not.
| Property Value | |
|---|---|
| Type | Description | 
Nullable<Boolean> | 
        |
SpanId
public ulong? SpanId { get; }The span id or null if none is available.
| Property Value | |
|---|---|
| Type | Description | 
Nullable<UInt64> | 
        |
This corresponds to the span_id field of the TraceSpan message in the API. See https://cloud.google.com/trace/docs/reference/v2/rpc/google.devtools.cloudtrace.v1#tracespan for more information.
TraceId
public string TraceId { get; }The trace id or null if none is available.
| Property Value | |
|---|---|
| Type | Description | 
String | 
        |
This corresponds to the trace_id field of the Trace message in the API. See https://cloud.google.com/trace/docs/reference/v2/rpc/google.devtools.cloudtrace.v1#trace for more information.
Methods
Create(String, Nullable<UInt64>, Nullable<Boolean>)
public static TraceHeaderContext Create(string traceId, ulong? spanId, bool? shouldTrace)Creates a TraceHeaderContext from a trace and span id.
| Parameters | |
|---|---|
| Name | Description | 
traceId | 
        String | 
      
spanId | 
        Nullable<UInt64> | 
      
shouldTrace | 
        Nullable<Boolean> | 
      
| Returns | |
|---|---|
| Type | Description | 
TraceHeaderContext | 
        |
FromHeader(String)
public static TraceHeaderContext FromHeader(string header)Creates a TraceHeaderContext from a header.
| Parameter | |
|---|---|
| Name | Description | 
header | 
        StringThe string value of the trace header. Can be null. See: https://cloud.google.com/trace/docs/faq  | 
      
| Returns | |
|---|---|
| Type | Description | 
TraceHeaderContext | 
        |
FromHeader(String, Func<Nullable<Boolean>>)
public static TraceHeaderContext FromHeader(string header, Func<bool?> traceFallbackPredicate)Creates a TraceHeaderContext from a header.
| Parameters | |
|---|---|
| Name | Description | 
header | 
        StringThe string value of the trace header. Can be null. See: https://cloud.google.com/trace/docs/faq  | 
      
traceFallbackPredicate | 
        Func<Nullable<Boolean>>Optional function to override and trace requests. Can be null.  | 
      
| Returns | |
|---|---|
| Type | Description | 
TraceHeaderContext | 
        |
ToString()
public override string ToString()Gets the TraceHeaderContext as a string. Formatted as "[trace-id]/[span-id];o=[should-trace]" where "should-trace" is 1 to trace and 0 otherwise.
| Returns | |
|---|---|
| Type | Description | 
String | 
        |