# Class AspNetCoreTraceExtensions (4.4.0)

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

- [4.4.0 (latest)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.AspNetCore/latest/Google.Cloud.Diagnostics.AspNetCore.AspNetCoreTraceExtensions)
- [4.3.1](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.AspNetCore/4.3.1/Google.Cloud.Diagnostics.AspNetCore.AspNetCoreTraceExtensions)

    public static class AspNetCoreTraceExtensions

Extensions for configuring Google Cloud Trace in ASP.NET Core applications.

## Inheritance

[Object](https://learn.microsoft.com/dotnet/api/system.object) \> AspNetCoreTraceExtensions

## Inherited Members

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

## Namespace

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

## Assembly

Google.Cloud.Diagnostics.AspNetCore.dll

## Methods

### AddGoogleTraceForAspNetCore(IServiceCollection, AspNetCoreTraceOptions)

    public static IServiceCollection AddGoogleTraceForAspNetCore(this IServiceCollection services, AspNetCoreTraceOptions options = null)

Configures Google Cloud Tracing for ASP .NET Core applications./\>.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `services` | `https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection` |
| `options` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.AspNetCore/latest/Google.Cloud.Diagnostics.AspNetCore.AspNetCoreTraceOptions` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection` |   |

### TryAddGoogleTraceContextProvider(IServiceCollection)

    public static IServiceCollection TryAddGoogleTraceContextProvider(this IServiceCollection services)

Adds the services needed for obtaining the trace context from Google's own trace header,
but only if no other trace context provider is registered.
If you are using [AddGoogleTraceForAspNetCore(IServiceCollection, AspNetCoreTraceOptions)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.AspNetCore/latest/Google.Cloud.Diagnostics.AspNetCore.AspNetCoreTraceExtensions#Google_Cloud_Diagnostics_AspNetCore_AspNetCoreTraceExtensions_AddGoogleTraceForAspNetCore_Microsoft_Extensions_DependencyInjection_IServiceCollection_Google_Cloud_Diagnostics_AspNetCore_AspNetCoreTraceOptions_)
you don't need to call this method. Only use this method if you want to extract the trace context
information from Google's own header for your own code to use, or if you are not using the tracing
component of this library but are using the logging component and want the trace context information
to be associated with the log entries.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `services` | `https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection` |   |