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.
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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["\u003cp\u003eThis documentation details the \u003ccode\u003eAspNetCoreGoogleDiagnosticsExtensions\u003c/code\u003e class, which provides extensions for integrating Google Cloud Diagnostics into ASP.NET Core applications.\u003c/p\u003e\n"],["\u003cp\u003eThe class offers three overloaded \u003ccode\u003eAddGoogleDiagnosticsForAspNetCore\u003c/code\u003e methods, which configure Google Diagnostics services for ASP.NET Core applications.\u003c/p\u003e\n"],["\u003cp\u003eOne of the \u003ccode\u003eAddGoogleDiagnosticsForAspNetCore\u003c/code\u003e methods configures Google Diagnostics with default values, and can be used when running on GCP as it obtains the Project ID from the environment.\u003c/p\u003e\n"],["\u003cp\u003eThe other two \u003ccode\u003eAddGoogleDiagnosticsForAspNetCore\u003c/code\u003e methods allow for more comprehensive customization through parameters such as \u003ccode\u003etraceOptions\u003c/code\u003e, \u003ccode\u003eloggingOptions\u003c/code\u003e, \u003ccode\u003eerrorReportingOptions\u003c/code\u003e, \u003ccode\u003eprojectId\u003c/code\u003e, \u003ccode\u003eserviceName\u003c/code\u003e, and \u003ccode\u003eserviceVersion\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eAddGoogleDiagnosticsForAspNetCore\u003c/code\u003e methods return an \u003ccode\u003eIServiceCollection\u003c/code\u003e, allowing them to be integrated into the ASP.NET Core dependency injection pipeline.\u003c/p\u003e\n"]]],[],null,["# Class AspNetCoreGoogleDiagnosticsExtensions (4.4.0)\n\nVersion latestkeyboard_arrow_down\n\n- [4.4.0 (latest)](/dotnet/docs/reference/Google.Cloud.Diagnostics.AspNetCore/latest/Google.Cloud.Diagnostics.AspNetCore.AspNetCoreGoogleDiagnosticsExtensions)\n- [4.3.1](/dotnet/docs/reference/Google.Cloud.Diagnostics.AspNetCore/4.3.1/Google.Cloud.Diagnostics.AspNetCore.AspNetCoreGoogleDiagnosticsExtensions) \n\n public static class AspNetCoreGoogleDiagnosticsExtensions\n\nExtensions to configure Google.Cloud.Diagnostics for ASP.NET Core applications. \n\nInheritance\n-----------\n\n[Object](https://learn.microsoft.com/dotnet/api/system.object) \\\u003e AspNetCoreGoogleDiagnosticsExtensions \n\nInherited Members\n-----------------\n\n[Object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode#system-object-gethashcode) \n[Object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype#system-object-gettype) \n[Object.MemberwiseClone()](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone#system-object-memberwiseclone) \n[Object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring#system-object-tostring)\n\nNamespace\n---------\n\n[Google.Cloud.Diagnostics.AspNetCore](/dotnet/docs/reference/Google.Cloud.Diagnostics.AspNetCore/latest/Google.Cloud.Diagnostics.AspNetCore)\n\nAssembly\n--------\n\nGoogle.Cloud.Diagnostics.AspNetCore.dll\n\nMethods\n-------\n\n### AddGoogleDiagnosticsForAspNetCore(IServiceCollection)\n\n public static IServiceCollection AddGoogleDiagnosticsForAspNetCore(this IServiceCollection services)\n\nConfigures Google Diagnostics to be used in ASP.NET Core applications with\ndefault values.\n\n**Remarks** \nNote that the Google Cloud Project ID to use is required and it can only be\nobtained from the environment if running on GCP. This means that this overload\ncan only be used when running on GCP. If you are not running on GCP or need to specify\nthe Google Cloud Project ID, you can use any of\n[AddGoogleDiagnosticsForAspNetCore(IServiceCollection, AspNetCoreTraceOptions, LoggingServiceOptions, ErrorReportingServiceOptions)](/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_)\nor\n[AddGoogleDiagnosticsForAspNetCore(IServiceCollection, String, String, String, TraceOptions, LoggingOptions, ErrorReportingOptions)](/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_).\n\n### AddGoogleDiagnosticsForAspNetCore(IServiceCollection, AspNetCoreTraceOptions, LoggingServiceOptions, ErrorReportingServiceOptions)\n\n public static IServiceCollection AddGoogleDiagnosticsForAspNetCore(this IServiceCollection services, AspNetCoreTraceOptions traceOptions = null, LoggingServiceOptions loggingOptions = null, ErrorReportingServiceOptions errorReportingOptions = null)\n\nConfigures Google Diagnostics to be used in ASP.NET Core applications.\n\n**Remarks** \nOptions may be null in which case defaults will be used. Note that the\nGoogle Cloud Project ID to use is required. If not set via options, it will be\nobtained from the environment, but only if running on GCP.\n\n### AddGoogleDiagnosticsForAspNetCore(IServiceCollection, String, String, String, TraceOptions, LoggingOptions, ErrorReportingOptions)\n\n 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)\n\nConfigures Google Diagnostics to be used in ASP.NET Core applications.\n\n**Remarks** \nOptions may be null in which case defaults will be used. Note that the\nGoogle Cloud Project ID to use is required. If not set via options, it will be\nobtained from the environment, but only if running on GCP."]]