# Class AspNetCoreGoogleDiagnosticsExtensions (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.AspNetCoreGoogleDiagnosticsExtensions)
- [4.3.1](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.AspNetCore/4.3.1/Google.Cloud.Diagnostics.AspNetCore.AspNetCoreGoogleDiagnosticsExtensions)

    public static class AspNetCoreGoogleDiagnosticsExtensions

Extensions to configure Google.Cloud.Diagnostics for ASP.NET Core applications.

## Inheritance

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

## 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

### AddGoogleDiagnosticsForAspNetCore(IServiceCollection)

    public static IServiceCollection AddGoogleDiagnosticsForAspNetCore(this IServiceCollection services)

Configures Google Diagnostics to be used in ASP.NET Core applications with
default values.

| **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` |   |

**Remarks** Note that the Google Cloud Project ID to use is required and it can only be
obtained from the environment if running on GCP. This means that this overload
can only be used when running on GCP. If you are not running on GCP or need to specify
the Google Cloud Project ID, you can use any of
[AddGoogleDiagnosticsForAspNetCore(IServiceCollection, AspNetCoreTraceOptions, LoggingServiceOptions, ErrorReportingServiceOptions)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.AspNetCore/latest/Google.Cloud.Diagnostics.AspNetCore.AspNetCoreGoogleDiagnosticsExtensions#Google_Cloud_Diagnostics_AspNetCore_AspNetCoreGoogleDiagnosticsExtensions_AddGoogleDiagnosticsForAspNetCore_Microsoft_Extensions_DependencyInjection_IServiceCollection_Google_Cloud_Diagnostics_AspNetCore_AspNetCoreTraceOptions_Google_Cloud_Diagnostics_Common_LoggingServiceOptions_Google_Cloud_Diagnostics_Common_ErrorReportingServiceOptions_)
or
[AddGoogleDiagnosticsForAspNetCore(IServiceCollection, String, String, String, TraceOptions, LoggingOptions, ErrorReportingOptions)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.AspNetCore/latest/Google.Cloud.Diagnostics.AspNetCore.AspNetCoreGoogleDiagnosticsExtensions#Google_Cloud_Diagnostics_AspNetCore_AspNetCoreGoogleDiagnosticsExtensions_AddGoogleDiagnosticsForAspNetCore_Microsoft_Extensions_DependencyInjection_IServiceCollection_System_String_System_String_System_String_Google_Cloud_Diagnostics_Common_TraceOptions_Google_Cloud_Diagnostics_Common_LoggingOptions_Google_Cloud_Diagnostics_Common_ErrorReportingOptions_).

### AddGoogleDiagnosticsForAspNetCore(IServiceCollection, AspNetCoreTraceOptions, LoggingServiceOptions, ErrorReportingServiceOptions)

    public static IServiceCollection AddGoogleDiagnosticsForAspNetCore(this IServiceCollection services, AspNetCoreTraceOptions traceOptions = null, LoggingServiceOptions loggingOptions = null, ErrorReportingServiceOptions errorReportingOptions = null)

Configures Google Diagnostics to be used in ASP.NET Core applications.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `services` | `https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection` |
| `traceOptions` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.AspNetCore/latest/Google.Cloud.Diagnostics.AspNetCore.AspNetCoreTraceOptions` |
| `loggingOptions` | `https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/latest/Google.Cloud.Diagnostics.Common.LoggingServiceOptions.html` |
| `errorReportingOptions` | `https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/latest/Google.Cloud.Diagnostics.Common.ErrorReportingServiceOptions.html` |

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

**Remarks** Options may be null in which case defaults will be used. Note that the
Google Cloud Project ID to use is required. If not set via options, it will be
obtained from the environment, but only if running on GCP.

### AddGoogleDiagnosticsForAspNetCore(IServiceCollection, String, String, String, TraceOptions, LoggingOptions, ErrorReportingOptions)

    public static IServiceCollection AddGoogleDiagnosticsForAspNetCore(this IServiceCollection services, string projectId = null, string serviceName = null, string serviceVersion = null, TraceOptions traceOptions = null, LoggingOptions loggingOptions = null, ErrorReportingOptions errorReportingOptions = null)

Configures Google Diagnostics to be used in ASP.NET Core applications.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `services` | `https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection` |
| `projectId` | `https://learn.microsoft.com/dotnet/api/system.string` |
| `serviceName` | `https://learn.microsoft.com/dotnet/api/system.string` |
| `serviceVersion` | `https://learn.microsoft.com/dotnet/api/system.string` |
| `traceOptions` | `https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/latest/Google.Cloud.Diagnostics.Common.TraceOptions.html` |
| `loggingOptions` | `https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/latest/Google.Cloud.Diagnostics.Common.LoggingOptions.html` |
| `errorReportingOptions` | `https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/latest/Google.Cloud.Diagnostics.Common.ErrorReportingOptions.html` |

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

**Remarks** Options may be null in which case defaults will be used. Note that the
Google Cloud Project ID to use is required. If not set via options, it will be
obtained from the environment, but only if running on GCP.