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 document provides reference documentation for the \u003ccode\u003eGoogleDiagnosticsExtensions\u003c/code\u003e class, which is used to configure Google Cloud Diagnostics for non-ASP.NET Core applications.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eGoogleDiagnosticsExtensions\u003c/code\u003e class includes three overloads of the \u003ccode\u003eAddGoogleDiagnostics\u003c/code\u003e method, each catering to different configuration needs and varying ways to provide options for trace, logging, and error reporting.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eAddGoogleDiagnostics\u003c/code\u003e method requires a Google Cloud Project ID, which can be provided directly or obtained from the environment when running on Google Cloud Platform (GCP).\u003c/p\u003e\n"],["\u003cp\u003eThe latest version available for the \u003ccode\u003eGoogleDiagnosticsExtensions\u003c/code\u003e class is version 5.2.0, with older versions listed back to version 4.3.1.\u003c/p\u003e\n"],["\u003cp\u003eThis class is within the \u003ccode\u003eGoogle.Cloud.Diagnostics.Common\u003c/code\u003e namespace and is found in the \u003ccode\u003eGoogle.Cloud.Diagnostics.Common.dll\u003c/code\u003e assembly.\u003c/p\u003e\n"]]],[],null,["# Google.Cloud.Diagnostics.Common - Class GoogleDiagnosticsExtensions (5.3.0)\n\nVersion latestkeyboard_arrow_down\n\n- [5.3.0 (latest)](/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/latest/Google.Cloud.Diagnostics.Common.GoogleDiagnosticsExtensions)\n- [5.2.0](/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/5.2.0/Google.Cloud.Diagnostics.Common.GoogleDiagnosticsExtensions)\n- [5.1.0](/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/5.1.0/Google.Cloud.Diagnostics.Common.GoogleDiagnosticsExtensions)\n- [5.0.0](/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/5.0.0/Google.Cloud.Diagnostics.Common.GoogleDiagnosticsExtensions)\n- [4.4.0](/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/4.4.0/Google.Cloud.Diagnostics.Common.GoogleDiagnosticsExtensions)\n- [4.3.1](/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/4.3.1/Google.Cloud.Diagnostics.Common.GoogleDiagnosticsExtensions) \n\n public static class GoogleDiagnosticsExtensions\n\nReference documentation and code samples for the Google.Cloud.Diagnostics.Common class GoogleDiagnosticsExtensions.\n\nExtensions to configure Google.Cloud.Diagnostics for non ASP.NET Core applications. \n\nInheritance\n-----------\n\n[object](https://learn.microsoft.com/dotnet/api/system.object) \\\u003e GoogleDiagnosticsExtensions \n\nInherited Members\n-----------------\n\n[object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) \n[object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) \n[object.MemberwiseClone()](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone) \n[object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)\n\nNamespace\n---------\n\n[Google.Cloud.Diagnostics.Common](/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/latest/Google.Cloud.Diagnostics.Common)\n\nAssembly\n--------\n\nGoogle.Cloud.Diagnostics.Common.dll\n\nMethods\n-------\n\n### AddGoogleDiagnostics(IServiceCollection)\n\n public static IServiceCollection AddGoogleDiagnostics(this IServiceCollection services)\n\nConfigures Google Diagnostics to be used in non ASP.NET Core applications.\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[AddGoogleDiagnostics(IServiceCollection, TraceServiceOptions, LoggingServiceOptions, ErrorReportingServiceOptions)](/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/latest/Google.Cloud.Diagnostics.Common.GoogleDiagnosticsExtensions#Google_Cloud_Diagnostics_Common_GoogleDiagnosticsExtensions_AddGoogleDiagnostics_Microsoft_Extensions_DependencyInjection_IServiceCollection_Google_Cloud_Diagnostics_Common_TraceServiceOptions_Google_Cloud_Diagnostics_Common_LoggingServiceOptions_Google_Cloud_Diagnostics_Common_ErrorReportingServiceOptions_)\nor\n[AddGoogleDiagnostics(IServiceCollection, string, string, string, TraceOptions, LoggingOptions, ErrorReportingOptions)](/dotnet/docs/reference/Google.Cloud.Diagnostics.Common/latest/Google.Cloud.Diagnostics.Common.GoogleDiagnosticsExtensions#Google_Cloud_Diagnostics_Common_GoogleDiagnosticsExtensions_AddGoogleDiagnostics_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### AddGoogleDiagnostics(IServiceCollection, TraceServiceOptions, LoggingServiceOptions, ErrorReportingServiceOptions)\n\n public static IServiceCollection AddGoogleDiagnostics(this IServiceCollection services, TraceServiceOptions traceOptions = null, LoggingServiceOptions loggingOptions = null, ErrorReportingServiceOptions errorReportingOptions = null)\n\nConfigures Google Diagnostics to be used in non 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### AddGoogleDiagnostics(IServiceCollection, string, string, string, TraceOptions, LoggingOptions, ErrorReportingOptions)\n\n public static IServiceCollection AddGoogleDiagnostics(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 non 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."]]