Google Cloud Trace v1 API - Class TraceServiceClient (3.2.0)

public abstract class TraceServiceClient

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

TraceService client wrapper, for convenient use.

Inheritance

object > TraceServiceClient

Derived Types

Namespace

Google.Cloud.Trace.V1

Assembly

Google.Cloud.Trace.V1.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. Spans for a single trace may span 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
IReadOnlyListstring
Remarks

GrpcClient

public virtual TraceService.TraceServiceClient GrpcClient { get; }

The underlying gRPC TraceService client

Property Value
TypeDescription
TraceServiceTraceServiceClient

ServiceMetadata

public static ServiceMetadata ServiceMetadata { get; }

The service metadata associated with this client type.

Property Value
TypeDescription
ServiceMetadata

Methods

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)

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
TaskTraceServiceClient

The task representing the created TraceServiceClient.

GetTrace(GetTraceRequest, CallSettings)

public virtual Trace GetTrace(GetTraceRequest request, CallSettings callSettings = null)

Gets a single trace by its ID.

Parameters
NameDescription
requestGetTraceRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
Trace

The RPC response.

Example
// Create client
TraceServiceClient traceServiceClient = TraceServiceClient.Create();
// Initialize request argument(s)
GetTraceRequest request = new GetTraceRequest
{
    ProjectId = "",
    TraceId = "",
};
// Make the request
Trace response = traceServiceClient.GetTrace(request);

GetTrace(string, string, CallSettings)

public virtual Trace GetTrace(string projectId, string traceId, CallSettings callSettings = null)

Gets a single trace by its ID.

Parameters
NameDescription
projectIdstring

Required. ID of the Cloud project where the trace data is stored.

traceIdstring

Required. ID of the trace to return.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
Trace

The RPC response.

Example
// Create client
TraceServiceClient traceServiceClient = TraceServiceClient.Create();
// Initialize request argument(s)
string projectId = "";
string traceId = "";
// Make the request
Trace response = traceServiceClient.GetTrace(projectId, traceId);

GetTraceAsync(GetTraceRequest, CallSettings)

public virtual Task<Trace> GetTraceAsync(GetTraceRequest request, CallSettings callSettings = null)

Gets a single trace by its ID.

Parameters
NameDescription
requestGetTraceRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskTrace

A Task containing the RPC response.

Example
// Create client
TraceServiceClient traceServiceClient = await TraceServiceClient.CreateAsync();
// Initialize request argument(s)
GetTraceRequest request = new GetTraceRequest
{
    ProjectId = "",
    TraceId = "",
};
// Make the request
Trace response = await traceServiceClient.GetTraceAsync(request);

GetTraceAsync(GetTraceRequest, CancellationToken)

public virtual Task<Trace> GetTraceAsync(GetTraceRequest request, CancellationToken cancellationToken)

Gets a single trace by its ID.

Parameters
NameDescription
requestGetTraceRequest

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

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
TaskTrace

A Task containing the RPC response.

Example
// Create client
TraceServiceClient traceServiceClient = await TraceServiceClient.CreateAsync();
// Initialize request argument(s)
GetTraceRequest request = new GetTraceRequest
{
    ProjectId = "",
    TraceId = "",
};
// Make the request
Trace response = await traceServiceClient.GetTraceAsync(request);

GetTraceAsync(string, string, CallSettings)

public virtual Task<Trace> GetTraceAsync(string projectId, string traceId, CallSettings callSettings = null)

Gets a single trace by its ID.

Parameters
NameDescription
projectIdstring

Required. ID of the Cloud project where the trace data is stored.

traceIdstring

Required. ID of the trace to return.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskTrace

A Task containing the RPC response.

Example
// Create client
TraceServiceClient traceServiceClient = await TraceServiceClient.CreateAsync();
// Initialize request argument(s)
string projectId = "";
string traceId = "";
// Make the request
Trace response = await traceServiceClient.GetTraceAsync(projectId, traceId);

GetTraceAsync(string, string, CancellationToken)

public virtual Task<Trace> GetTraceAsync(string projectId, string traceId, CancellationToken cancellationToken)

Gets a single trace by its ID.

Parameters
NameDescription
projectIdstring

Required. ID of the Cloud project where the trace data is stored.

traceIdstring

Required. ID of the trace to return.

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
TaskTrace

A Task containing the RPC response.

Example
// Create client
TraceServiceClient traceServiceClient = await TraceServiceClient.CreateAsync();
// Initialize request argument(s)
string projectId = "";
string traceId = "";
// Make the request
Trace response = await traceServiceClient.GetTraceAsync(projectId, traceId);

ListTraces(ListTracesRequest, CallSettings)

public virtual PagedEnumerable<ListTracesResponse, Trace> ListTraces(ListTracesRequest request, CallSettings callSettings = null)

Returns of a list of traces that match the specified filter conditions.

Parameters
NameDescription
requestListTracesRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
PagedEnumerableListTracesResponseTrace

A pageable sequence of Trace resources.

Example
// Create client
TraceServiceClient traceServiceClient = TraceServiceClient.Create();
// Initialize request argument(s)
ListTracesRequest request = new ListTracesRequest
{
    ProjectId = "",
    View = ListTracesRequest.Types.ViewType.Unspecified,
    StartTime = new Timestamp(),
    EndTime = new Timestamp(),
    Filter = "",
    OrderBy = "",
};
// Make the request
PagedEnumerable<ListTracesResponse, Trace> response = traceServiceClient.ListTraces(request);

// Iterate over all response items, lazily performing RPCs as required
foreach (Trace item in response)
{
    // Do something with each item
    Console.WriteLine(item);
}

// Or iterate over pages (of server-defined size), performing one RPC per page
foreach (ListTracesResponse page in response.AsRawResponses())
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (Trace item in page)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
}

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<Trace> singlePage = response.ReadPage(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (Trace item in singlePage)
{
    // Do something with each item
    Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;

ListTraces(string, string, int?, CallSettings)

public virtual PagedEnumerable<ListTracesResponse, Trace> ListTraces(string projectId, string pageToken = null, int? pageSize = null, CallSettings callSettings = null)

Returns of a list of traces that match the specified filter conditions.

Parameters
NameDescription
projectIdstring

Required. ID of the Cloud project where the trace data is stored.

pageTokenstring

The token returned from the previous request. A value of null or an empty string retrieves the first page.

pageSizeint

The size of page to request. The response will not be larger than this, but may be smaller. A value of null or 0 uses a server-defined page size.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
PagedEnumerableListTracesResponseTrace

A pageable sequence of Trace resources.

Example
TraceServiceClient client = TraceServiceClient.Create();
PagedEnumerable<ListTracesResponse, Trace> traces = client.ListTraces(projectId);
foreach (Trace trace in traces.Take(10))
{
    Console.WriteLine($"{trace.TraceId}:");
    foreach (TraceSpan span in trace.Spans)
    {
        Console.WriteLine($"  {span.StartTime}-{span.EndTime}: {span.Kind}");
    }
}

ListTracesAsync(ListTracesRequest, CallSettings)

public virtual PagedAsyncEnumerable<ListTracesResponse, Trace> ListTracesAsync(ListTracesRequest request, CallSettings callSettings = null)

Returns of a list of traces that match the specified filter conditions.

Parameters
NameDescription
requestListTracesRequest

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

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
PagedAsyncEnumerableListTracesResponseTrace

A pageable asynchronous sequence of Trace resources.

Example
// Create client
TraceServiceClient traceServiceClient = await TraceServiceClient.CreateAsync();
// Initialize request argument(s)
ListTracesRequest request = new ListTracesRequest
{
    ProjectId = "",
    View = ListTracesRequest.Types.ViewType.Unspecified,
    StartTime = new Timestamp(),
    EndTime = new Timestamp(),
    Filter = "",
    OrderBy = "",
};
// Make the request
PagedAsyncEnumerable<ListTracesResponse, Trace> response = traceServiceClient.ListTracesAsync(request);

// Iterate over all response items, lazily performing RPCs as required
await response.ForEachAsync((Trace item) =>
{
    // Do something with each item
    Console.WriteLine(item);
});

// Or iterate over pages (of server-defined size), performing one RPC per page
await response.AsRawResponses().ForEachAsync((ListTracesResponse page) =>
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (Trace item in page)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
});

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<Trace> singlePage = await response.ReadPageAsync(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (Trace item in singlePage)
{
    // Do something with each item
    Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;

ListTracesAsync(string, string, int?, CallSettings)

public virtual PagedAsyncEnumerable<ListTracesResponse, Trace> ListTracesAsync(string projectId, string pageToken = null, int? pageSize = null, CallSettings callSettings = null)

Returns of a list of traces that match the specified filter conditions.

Parameters
NameDescription
projectIdstring

Required. ID of the Cloud project where the trace data is stored.

pageTokenstring

The token returned from the previous request. A value of null or an empty string retrieves the first page.

pageSizeint

The size of page to request. The response will not be larger than this, but may be smaller. A value of null or 0 uses a server-defined page size.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
PagedAsyncEnumerableListTracesResponseTrace

A pageable asynchronous sequence of Trace resources.

Example
// Create client
TraceServiceClient traceServiceClient = await TraceServiceClient.CreateAsync();
// Initialize request argument(s)
string projectId = "";
// Make the request
PagedAsyncEnumerable<ListTracesResponse, Trace> response = traceServiceClient.ListTracesAsync(projectId);

// Iterate over all response items, lazily performing RPCs as required
await response.ForEachAsync((Trace item) =>
{
    // Do something with each item
    Console.WriteLine(item);
});

// Or iterate over pages (of server-defined size), performing one RPC per page
await response.AsRawResponses().ForEachAsync((ListTracesResponse page) =>
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (Trace item in page)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
});

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<Trace> singlePage = await response.ReadPageAsync(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (Trace item in singlePage)
{
    // Do something with each item
    Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;

PatchTraces(PatchTracesRequest, CallSettings)

public virtual void PatchTraces(PatchTracesRequest request, CallSettings callSettings = null)

Sends new traces to Stackdriver Trace or updates existing traces. If the ID of a trace that you send matches that of an existing trace, any fields in the existing trace and its spans are overwritten by the provided values, and any new fields provided are merged with the existing trace data. If the ID does not match, a new trace is created.

Parameters
NameDescription
requestPatchTracesRequest

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)
PatchTracesRequest request = new PatchTracesRequest
{
    ProjectId = "",
    Traces = new Traces(),
};
// Make the request
traceServiceClient.PatchTraces(request);

PatchTraces(string, Traces, CallSettings)

public virtual void PatchTraces(string projectId, Traces traces, CallSettings callSettings = null)

Sends new traces to Stackdriver Trace or updates existing traces. If the ID of a trace that you send matches that of an existing trace, any fields in the existing trace and its spans are overwritten by the provided values, and any new fields provided are merged with the existing trace data. If the ID does not match, a new trace is created.

Parameters
NameDescription
projectIdstring

Required. ID of the Cloud project where the trace data is stored.

tracesTraces

Required. The body of the message.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Example
// Create client
TraceServiceClient traceServiceClient = TraceServiceClient.Create();
// Initialize request argument(s)
string projectId = "";
Traces traces = new Traces();
// Make the request
traceServiceClient.PatchTraces(projectId, traces);

PatchTracesAsync(PatchTracesRequest, CallSettings)

public virtual Task PatchTracesAsync(PatchTracesRequest request, CallSettings callSettings = null)

Sends new traces to Stackdriver Trace or updates existing traces. If the ID of a trace that you send matches that of an existing trace, any fields in the existing trace and its spans are overwritten by the provided values, and any new fields provided are merged with the existing trace data. If the ID does not match, a new trace is created.

Parameters
NameDescription
requestPatchTracesRequest

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)
PatchTracesRequest request = new PatchTracesRequest
{
    ProjectId = "",
    Traces = new Traces(),
};
// Make the request
await traceServiceClient.PatchTracesAsync(request);

PatchTracesAsync(PatchTracesRequest, CancellationToken)

public virtual Task PatchTracesAsync(PatchTracesRequest request, CancellationToken cancellationToken)

Sends new traces to Stackdriver Trace or updates existing traces. If the ID of a trace that you send matches that of an existing trace, any fields in the existing trace and its spans are overwritten by the provided values, and any new fields provided are merged with the existing trace data. If the ID does not match, a new trace is created.

Parameters
NameDescription
requestPatchTracesRequest

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)
PatchTracesRequest request = new PatchTracesRequest
{
    ProjectId = "",
    Traces = new Traces(),
};
// Make the request
await traceServiceClient.PatchTracesAsync(request);

PatchTracesAsync(string, Traces, CallSettings)

public virtual Task PatchTracesAsync(string projectId, Traces traces, CallSettings callSettings = null)

Sends new traces to Stackdriver Trace or updates existing traces. If the ID of a trace that you send matches that of an existing trace, any fields in the existing trace and its spans are overwritten by the provided values, and any new fields provided are merged with the existing trace data. If the ID does not match, a new trace is created.

Parameters
NameDescription
projectIdstring

Required. ID of the Cloud project where the trace data is stored.

tracesTraces

Required. The body of the message.

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 projectId = "";
Traces traces = new Traces();
// Make the request
await traceServiceClient.PatchTracesAsync(projectId, traces);

PatchTracesAsync(string, Traces, CancellationToken)

public virtual Task PatchTracesAsync(string projectId, Traces traces, CancellationToken cancellationToken)

Sends new traces to Stackdriver Trace or updates existing traces. If the ID of a trace that you send matches that of an existing trace, any fields in the existing trace and its spans are overwritten by the provided values, and any new fields provided are merged with the existing trace data. If the ID does not match, a new trace is created.

Parameters
NameDescription
projectIdstring

Required. ID of the Cloud project where the trace data is stored.

tracesTraces

Required. The body of the message.

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 projectId = "";
Traces traces = new Traces();
// Make the request
await traceServiceClient.PatchTracesAsync(projectId, traces);

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.