# Google Cloud Trace v2 API - Class TraceServiceClient (3.7.0)

<button class="button button-with-icon cloud-select-dropdown__button " aria-haspopup="true">Version latest</button>

- [3.7.0 (latest)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Trace.V2/latest/Google.Cloud.Trace.V2.TraceServiceClient)
- [3.6.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Trace.V2/3.6.0/Google.Cloud.Trace.V2.TraceServiceClient)
- [3.5.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Trace.V2/3.5.0/Google.Cloud.Trace.V2.TraceServiceClient)
- [3.4.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Trace.V2/3.4.0/Google.Cloud.Trace.V2.TraceServiceClient)
- [3.3.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Trace.V2/3.3.0/Google.Cloud.Trace.V2.TraceServiceClient)
- [3.2.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Trace.V2/3.2.0/Google.Cloud.Trace.V2.TraceServiceClient)
- [3.1.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Trace.V2/3.1.0/Google.Cloud.Trace.V2.TraceServiceClient)
- [3.0.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Trace.V2/3.0.0/Google.Cloud.Trace.V2.TraceServiceClient)
- [2.3.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Trace.V2/2.3.0/Google.Cloud.Trace.V2.TraceServiceClient)
- [2.2.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Trace.V2/2.2.0/Google.Cloud.Trace.V2.TraceServiceClient)

    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](https://learn.microsoft.com/dotnet/api/system.object) \> TraceServiceClient

## Inherited Members

[object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) [object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) [object.MemberwiseClone()](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone) [object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)

## Derived Types

[TraceServiceClientImpl](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Trace.V2/latest/Google.Cloud.Trace.V2.TraceServiceClientImpl)

## Namespace

[Google.Cloud.Trace.V2](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Trace.V2/latest/Google.Cloud.Trace.V2)

## Assembly

Google.Cloud.Trace.V2.dll

## Remarks

Service for collecting and viewing traces and spans within a trace.

A trace is a collection of spans corresponding to a single
operation or a set of operations in an application.

A span is an individual timed event which forms a node of the trace tree.
A single trace can contain spans 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** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.string` |   |

### DefaultScopes

    public static IReadOnlyList<string> DefaultScopes { get; }

The default TraceService scopes.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.collections.generic.ireadonlylist-1https://learn.microsoft.com/dotnet/api/system.string` |   |

**Remarks** The default TraceService scopes are:

- <https://www.googleapis.com/auth/cloud-platform>
- <https://www.googleapis.com/auth/trace.append>

<br />

### GrpcClient

    public virtual TraceService.TraceServiceClient GrpcClient { get; }

The underlying gRPC TraceService client

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Trace.V2/latest/Google.Cloud.Trace.V2.TraceServicehttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Trace.V2/latest/Google.Cloud.Trace.V2.TraceService.TraceServiceClient` |   |

### ServiceMetadata

    public static ServiceMetadata ServiceMetadata { get; }

The service metadata associated with this client type.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.ServiceMetadata.html` |   |

## Methods

### BatchWriteSpans(ProjectName, IEnumerable\<Span\>, CallSettings)

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

Batch writes new spans to new or existing traces. You cannot update
existing spans.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.ResourceNames.ProjectName.html` Required. The name of the project where the spans belong. The format is `projects/[PROJECT_ID]`. |
| `spans` | `https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Trace.V2/latest/Google.Cloud.Trace.V2.Span` Required. A list of new spans. The span names must not match existing spans, otherwise the results are undefined. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` 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)

Batch writes new spans to new or existing traces. You cannot update
existing spans.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Trace.V2/latest/Google.Cloud.Trace.V2.BatchWriteSpansRequest` The request object containing all of the parameters for the API call. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` 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)

Batch writes new spans to new or existing traces. You cannot update
existing spans.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://learn.microsoft.com/dotnet/api/system.string` Required. The name of the project where the spans belong. The format is `projects/[PROJECT_ID]`. |
| `spans` | `https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Trace.V2/latest/Google.Cloud.Trace.V2.Span` Required. A list of new spans. The span names must not match existing spans, otherwise the results are undefined. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` 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)

Batch writes new spans to new or existing traces. You cannot update
existing spans.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.ResourceNames.ProjectName.html` Required. The name of the project where the spans belong. The format is `projects/[PROJECT_ID]`. |
| `spans` | `https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Trace.V2/latest/Google.Cloud.Trace.V2.Span` Required. A list of new spans. The span names must not match existing spans, otherwise the results are undefined. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.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)

Batch writes new spans to new or existing traces. You cannot update
existing spans.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.ResourceNames.ProjectName.html` Required. The name of the project where the spans belong. The format is `projects/[PROJECT_ID]`. |
| `spans` | `https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Trace.V2/latest/Google.Cloud.Trace.V2.Span` Required. A list of new spans. The span names must not match existing spans, otherwise the results are undefined. |
| `cancellationToken` | `https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken` A [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken) to use for this RPC. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.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)

Batch writes new spans to new or existing traces. You cannot update
existing spans.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Trace.V2/latest/Google.Cloud.Trace.V2.BatchWriteSpansRequest` The request object containing all of the parameters for the API call. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.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)

Batch writes new spans to new or existing traces. You cannot update
existing spans.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Trace.V2/latest/Google.Cloud.Trace.V2.BatchWriteSpansRequest` The request object containing all of the parameters for the API call. |
| `cancellationToken` | `https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken` A [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken) to use for this RPC. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.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)

Batch writes new spans to new or existing traces. You cannot update
existing spans.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://learn.microsoft.com/dotnet/api/system.string` Required. The name of the project where the spans belong. The format is `projects/[PROJECT_ID]`. |
| `spans` | `https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Trace.V2/latest/Google.Cloud.Trace.V2.Span` Required. A list of new spans. The span names must not match existing spans, otherwise the results are undefined. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.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)

Batch writes new spans to new or existing traces. You cannot update
existing spans.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://learn.microsoft.com/dotnet/api/system.string` Required. The name of the project where the spans belong. The format is `projects/[PROJECT_ID]`. |
| `spans` | `https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Trace.V2/latest/Google.Cloud.Trace.V2.Span` Required. A list of new spans. The span names must not match existing spans, otherwise the results are undefined. |
| `cancellationToken` | `https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken` A [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken) to use for this RPC. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.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](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Trace.V2/latest/Google.Cloud.Trace.V2.TraceServiceClient) using the default credentials, endpoint and
settings. To specify custom credentials or other settings, use [TraceServiceClientBuilder](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Trace.V2/latest/Google.Cloud.Trace.V2.TraceServiceClientBuilder).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Trace.V2/latest/Google.Cloud.Trace.V2.TraceServiceClient` | The created [TraceServiceClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Trace.V2/latest/Google.Cloud.Trace.V2.TraceServiceClient). |

### CreateAsync(CancellationToken)

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

Asynchronously creates a [TraceServiceClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Trace.V2/latest/Google.Cloud.Trace.V2.TraceServiceClient) using the default credentials, endpoint and
settings. To specify custom credentials or other settings, use [TraceServiceClientBuilder](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Trace.V2/latest/Google.Cloud.Trace.V2.TraceServiceClientBuilder).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `cancellationToken` | `https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken` The [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken) to use while creating the client. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Trace.V2/latest/Google.Cloud.Trace.V2.TraceServiceClient` | The task representing the created [TraceServiceClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Trace.V2/latest/Google.Cloud.Trace.V2.TraceServiceClient). |

### CreateSpan(Span, CallSettings)

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

Creates a new span.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Trace.V2/latest/Google.Cloud.Trace.V2.Span` The request object containing all of the parameters for the API call. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Trace.V2/latest/Google.Cloud.Trace.V2.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** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Trace.V2/latest/Google.Cloud.Trace.V2.Span` The request object containing all of the parameters for the API call. |
| `callSettings` | `https://cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings.html` If not null, applies overrides to this RPC call. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Trace.V2/latest/Google.Cloud.Trace.V2.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** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Trace.V2/latest/Google.Cloud.Trace.V2.Span` The request object containing all of the parameters for the API call. |
| `cancellationToken` | `https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken` A [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken) to use for this RPC. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Trace.V2/latest/Google.Cloud.Trace.V2.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()](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Trace.V2/latest/Google.Cloud.Trace.V2.TraceServiceClient#Google_Cloud_Trace_V2_TraceServiceClient_Create) and
[CreateAsync(CancellationToken)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Trace.V2/latest/Google.Cloud.Trace.V2.TraceServiceClient#Google_Cloud_Trace_V2_TraceServiceClient_CreateAsync_System_Threading_CancellationToken_). Channels which weren't automatically created are not
affected.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task` | A task representing the asynchronous shutdown operation. |

**Remarks** After calling this method, further calls to [Create()](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Trace.V2/latest/Google.Cloud.Trace.V2.TraceServiceClient#Google_Cloud_Trace_V2_TraceServiceClient_Create) and
[CreateAsync(CancellationToken)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Trace.V2/latest/Google.Cloud.Trace.V2.TraceServiceClient#Google_Cloud_Trace_V2_TraceServiceClient_CreateAsync_System_Threading_CancellationToken_) will create new channels, which could in turn be shut down
by another call to this method.