Google Cloud Trace v2 API - Class TraceServiceClient (3.2.0)

public abstract class TraceServiceClient

Reference documentation and code samples for the Google Cloud Trace v2 API class TraceServiceClient.

TraceService client wrapper, for convenient use.

Inheritance

Object > TraceServiceClient

Derived Types

Namespace

Google.Cloud.Trace.V2

Assembly

Google.Cloud.Trace.V2.dll

Remarks

This file describes an API for collecting and viewing traces and spans within a trace. A Trace is a collection of spans corresponding to a single operation or set of operations for an application. A span is an individual timed event which forms a node of the trace tree. A single trace may contain span(s) from multiple services.

Properties

DefaultEndpoint

public static string DefaultEndpoint { get; }

The default endpoint for the TraceService service, which is a host of "cloudtrace.googleapis.com" and a port of 443.

Property Value
TypeDescription
String

DefaultScopes

public static IReadOnlyList<string> DefaultScopes { get; }

The default TraceService scopes.

Property Value
TypeDescription
IReadOnlyList<String>
Remarks

GrpcClient

public virtual TraceService.TraceServiceClient GrpcClient { get; }

The underlying gRPC TraceService client

Property Value
TypeDescription
TraceService.TraceServiceClient

ServiceMetadata

public static ServiceMetadata ServiceMetadata { get; }

The service metadata associated with this client type.

Property Value
TypeDescription
ServiceMetadata

Methods

BatchWriteSpans(ProjectName, IEnumerable<Span>, CallSettings)

public virtual void BatchWriteSpans(ProjectName name, IEnumerable<Span> spans, CallSettings callSettings = null)

Sends new spans to new or existing traces. You cannot update existing spans.

Parameters
NameDescription
nameProjectName

Required. The name of the project where the spans belong. The format is projects/[PROJECT_ID].

spansIEnumerable<Span>

Required. A list of new spans. The span names must not match existing spans, or the results are undefined.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Example
// Create client
TraceServiceClient traceServiceClient = TraceServiceClient.Create();
// Initialize request argument(s)
ProjectName name = ProjectName.FromProject("[PROJECT]");
IEnumerable<Span> spans = new Span[] { new Span(), };
// Make the request
traceServiceClient.BatchWriteSpans(name, spans);

BatchWriteSpans(BatchWriteSpansRequest, CallSettings)

public virtual void BatchWriteSpans(BatchWriteSpansRequest request, CallSettings callSettings = null)

Sends new spans to new or existing traces. You cannot update existing spans.

Parameters
NameDescription
requestBatchWriteSpansRequest

The request object containing all of the parameters for the API call.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Example
// Create client
TraceServiceClient traceServiceClient = TraceServiceClient.Create();
// Initialize request argument(s)
BatchWriteSpansRequest request = new BatchWriteSpansRequest
{
    ProjectName = ProjectName.FromProject("[PROJECT]"),
    Spans = { new Span(), },
};
// Make the request
traceServiceClient.BatchWriteSpans(request);

BatchWriteSpans(String, IEnumerable<Span>, CallSettings)

public virtual void BatchWriteSpans(string name, IEnumerable<Span> spans, CallSettings callSettings = null)

Sends new spans to new or existing traces. You cannot update existing spans.

Parameters
NameDescription
nameString

Required. The name of the project where the spans belong. The format is projects/[PROJECT_ID].

spansIEnumerable<Span>

Required. A list of new spans. The span names must not match existing spans, or the results are undefined.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Example
// Create client
TraceServiceClient traceServiceClient = TraceServiceClient.Create();
// Initialize request argument(s)
string name = "projects/[PROJECT]";
IEnumerable<Span> spans = new Span[] { new Span(), };
// Make the request
traceServiceClient.BatchWriteSpans(name, spans);

BatchWriteSpansAsync(ProjectName, IEnumerable<Span>, CallSettings)

public virtual Task BatchWriteSpansAsync(ProjectName name, IEnumerable<Span> spans, CallSettings callSettings = null)

Sends new spans to new or existing traces. You cannot update existing spans.

Parameters
NameDescription
nameProjectName

Required. The name of the project where the spans belong. The format is projects/[PROJECT_ID].

spansIEnumerable<Span>

Required. A list of new spans. The span names must not match existing spans, or the results are undefined.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
Task

A Task containing the RPC response.

Example
// Create client
TraceServiceClient traceServiceClient = await TraceServiceClient.CreateAsync();
// Initialize request argument(s)
ProjectName name = ProjectName.FromProject("[PROJECT]");
IEnumerable<Span> spans = new Span[] { new Span(), };
// Make the request
await traceServiceClient.BatchWriteSpansAsync(name, spans);

BatchWriteSpansAsync(ProjectName, IEnumerable<Span>, CancellationToken)

public virtual Task BatchWriteSpansAsync(ProjectName name, IEnumerable<Span> spans, CancellationToken cancellationToken)

Sends new spans to new or existing traces. You cannot update existing spans.

Parameters
NameDescription
nameProjectName

Required. The name of the project where the spans belong. The format is projects/[PROJECT_ID].

spansIEnumerable<Span>

Required. A list of new spans. The span names must not match existing spans, or the results are undefined.

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
Task

A Task containing the RPC response.

Example
// Create client
TraceServiceClient traceServiceClient = await TraceServiceClient.CreateAsync();
// Initialize request argument(s)
ProjectName name = ProjectName.FromProject("[PROJECT]");
IEnumerable<Span> spans = new Span[] { new Span(), };
// Make the request
await traceServiceClient.BatchWriteSpansAsync(name, spans);

BatchWriteSpansAsync(BatchWriteSpansRequest, CallSettings)

public virtual Task BatchWriteSpansAsync(BatchWriteSpansRequest request, CallSettings callSettings = null)

Sends new spans to new or existing traces. You cannot update existing spans.

Parameters
NameDescription
requestBatchWriteSpansRequest

The request object containing all of the parameters for the API call.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
Task

A Task containing the RPC response.

Example
// Create client
TraceServiceClient traceServiceClient = await TraceServiceClient.CreateAsync();
// Initialize request argument(s)
BatchWriteSpansRequest request = new BatchWriteSpansRequest
{
    ProjectName = ProjectName.FromProject("[PROJECT]"),
    Spans = { new Span(), },
};
// Make the request
await traceServiceClient.BatchWriteSpansAsync(request);

BatchWriteSpansAsync(BatchWriteSpansRequest, CancellationToken)

public virtual Task BatchWriteSpansAsync(BatchWriteSpansRequest request, CancellationToken cancellationToken)

Sends new spans to new or existing traces. You cannot update existing spans.

Parameters
NameDescription
requestBatchWriteSpansRequest

The request object containing all of the parameters for the API call.

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
Task

A Task containing the RPC response.

Example
// Create client
TraceServiceClient traceServiceClient = await TraceServiceClient.CreateAsync();
// Initialize request argument(s)
BatchWriteSpansRequest request = new BatchWriteSpansRequest
{
    ProjectName = ProjectName.FromProject("[PROJECT]"),
    Spans = { new Span(), },
};
// Make the request
await traceServiceClient.BatchWriteSpansAsync(request);

BatchWriteSpansAsync(String, IEnumerable<Span>, CallSettings)

public virtual Task BatchWriteSpansAsync(string name, IEnumerable<Span> spans, CallSettings callSettings = null)

Sends new spans to new or existing traces. You cannot update existing spans.

Parameters
NameDescription
nameString

Required. The name of the project where the spans belong. The format is projects/[PROJECT_ID].

spansIEnumerable<Span>

Required. A list of new spans. The span names must not match existing spans, or the results are undefined.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
Task

A Task containing the RPC response.

Example
// Create client
TraceServiceClient traceServiceClient = await TraceServiceClient.CreateAsync();
// Initialize request argument(s)
string name = "projects/[PROJECT]";
IEnumerable<Span> spans = new Span[] { new Span(), };
// Make the request
await traceServiceClient.BatchWriteSpansAsync(name, spans);

BatchWriteSpansAsync(String, IEnumerable<Span>, CancellationToken)

public virtual Task BatchWriteSpansAsync(string name, IEnumerable<Span> spans, CancellationToken cancellationToken)

Sends new spans to new or existing traces. You cannot update existing spans.

Parameters
NameDescription
nameString

Required. The name of the project where the spans belong. The format is projects/[PROJECT_ID].

spansIEnumerable<Span>

Required. A list of new spans. The span names must not match existing spans, or the results are undefined.

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
Task

A Task containing the RPC response.

Example
// Create client
TraceServiceClient traceServiceClient = await TraceServiceClient.CreateAsync();
// Initialize request argument(s)
string name = "projects/[PROJECT]";
IEnumerable<Span> spans = new Span[] { new Span(), };
// Make the request
await traceServiceClient.BatchWriteSpansAsync(name, spans);

Create()

public static TraceServiceClient Create()

Synchronously creates a TraceServiceClient using the default credentials, endpoint and settings. To specify custom credentials or other settings, use TraceServiceClientBuilder.

Returns
TypeDescription
TraceServiceClient

The created TraceServiceClient.

CreateAsync(CancellationToken)

public static Task<TraceServiceClient> CreateAsync(CancellationToken cancellationToken = default(CancellationToken))

Asynchronously creates a TraceServiceClient using the default credentials, endpoint and settings. To specify custom credentials or other settings, use TraceServiceClientBuilder.

Parameter
NameDescription
cancellationTokenCancellationToken

The CancellationToken to use while creating the client.

Returns
TypeDescription
Task<TraceServiceClient>

The task representing the created TraceServiceClient.

CreateSpan(Span, CallSettings)

public virtual Span CreateSpan(Span request, CallSettings callSettings = null)

Creates a new span.

Parameters
NameDescription
requestSpan

The request object containing all of the parameters for the API call.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
Span

The RPC response.

Example
// Create client
TraceServiceClient traceServiceClient = TraceServiceClient.Create();
// Initialize request argument(s)
Span request = new Span
{
    SpanName = SpanName.FromProjectTraceSpan("[PROJECT]", "[TRACE]", "[SPAN]"),
    SpanId = "",
    ParentSpanId = "",
    DisplayName = new TruncatableString(),
    StartTime = new Timestamp(),
    EndTime = new Timestamp(),
    Attributes = new Span.Types.Attributes(),
    StackTrace = new StackTrace(),
    TimeEvents = new Span.Types.TimeEvents(),
    Links = new Span.Types.Links(),
    Status = new Status(),
    SameProcessAsParentSpan = false,
    ChildSpanCount = 0,
    SpanKind = Span.Types.SpanKind.Unspecified,
};
// Make the request
Span response = traceServiceClient.CreateSpan(request);

CreateSpanAsync(Span, CallSettings)

public virtual Task<Span> CreateSpanAsync(Span request, CallSettings callSettings = null)

Creates a new span.

Parameters
NameDescription
requestSpan

The request object containing all of the parameters for the API call.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
Task<Span>

A Task containing the RPC response.

Example
// Create client
TraceServiceClient traceServiceClient = await TraceServiceClient.CreateAsync();
// Initialize request argument(s)
Span request = new Span
{
    SpanName = SpanName.FromProjectTraceSpan("[PROJECT]", "[TRACE]", "[SPAN]"),
    SpanId = "",
    ParentSpanId = "",
    DisplayName = new TruncatableString(),
    StartTime = new Timestamp(),
    EndTime = new Timestamp(),
    Attributes = new Span.Types.Attributes(),
    StackTrace = new StackTrace(),
    TimeEvents = new Span.Types.TimeEvents(),
    Links = new Span.Types.Links(),
    Status = new Status(),
    SameProcessAsParentSpan = false,
    ChildSpanCount = 0,
    SpanKind = Span.Types.SpanKind.Unspecified,
};
// Make the request
Span response = await traceServiceClient.CreateSpanAsync(request);

CreateSpanAsync(Span, CancellationToken)

public virtual Task<Span> CreateSpanAsync(Span request, CancellationToken cancellationToken)

Creates a new span.

Parameters
NameDescription
requestSpan

The request object containing all of the parameters for the API call.

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
Task<Span>

A Task containing the RPC response.

Example
// Create client
TraceServiceClient traceServiceClient = await TraceServiceClient.CreateAsync();
// Initialize request argument(s)
Span request = new Span
{
    SpanName = SpanName.FromProjectTraceSpan("[PROJECT]", "[TRACE]", "[SPAN]"),
    SpanId = "",
    ParentSpanId = "",
    DisplayName = new TruncatableString(),
    StartTime = new Timestamp(),
    EndTime = new Timestamp(),
    Attributes = new Span.Types.Attributes(),
    StackTrace = new StackTrace(),
    TimeEvents = new Span.Types.TimeEvents(),
    Links = new Span.Types.Links(),
    Status = new Status(),
    SameProcessAsParentSpan = false,
    ChildSpanCount = 0,
    SpanKind = Span.Types.SpanKind.Unspecified,
};
// Make the request
Span response = await traceServiceClient.CreateSpanAsync(request);

ShutdownDefaultChannelsAsync()

public static Task ShutdownDefaultChannelsAsync()

Shuts down any channels automatically created by Create() and CreateAsync(CancellationToken). Channels which weren't automatically created are not affected.

Returns
TypeDescription
Task

A task representing the asynchronous shutdown operation.

Remarks

After calling this method, further calls to Create() and CreateAsync(CancellationToken) will create new channels, which could in turn be shut down by another call to this method.