You can enable Trace for ASP.NET Core applications
by using the
libraries for .NET.
- For applications that target ASP.NET Core 3 or later, use the
Google.Cloud.Diagnostics.AspNetCore3library. For examples that show how to configure and use this library, see
- For applications that target earlier versions of ASP.NET Core, use the
Google.Cloud.Diagnostics.AspNetCorelibrary. For examples that show how to configure and use this library see
Configure your platform
You can use Cloud Trace on Google Cloud and other platforms.
Running on Google Cloud
When your application is running on Google Cloud, you don't need to provide authentication credentials in the form of a service account to the client library. However, you do need to ensure that your Google Cloud platform has the Cloud Trace API access scope enabled.
For a list of supported Google Cloud environments, see Environment support.
For the following configurations, the default access-scope settings enable the Cloud Trace API:
- App Engine flexible environment
Google Kubernetes Engine (GKE)
If you use custom access scopes, then you must ensure that Cloud Trace API access scope is enabled:
For information about how to configure the access scopes for your environment by using the Google Cloud console, see Configuring your Google Cloud project.
gcloudusers, specify access scopes using the
--scopesflag and include the
trace.appendCloud Trace API access scope. For example, to create a GKE cluster with only the Cloud Trace API enabled, do the following:
gcloud container clusters create example-cluster-name --scopes=https://www.googleapis.com/auth/trace.append
Running locally and elsewhere
If your application is running outside of Google Cloud, then you must provide authentication credentials in the form of a service account to the client library. The service account must contain the Cloud Trace agent role. For instructions, see Creating a service account.
Google Cloud client libraries use Application Default Credentials (ADC) to find your application's credentials.
You can provide these credentials in one of three ways:
gcloud auth application-default login
Place the service account in a default path for your operating system. The following lists the default paths for Windows and Linux:
GOOGLE_APPLICATION_CREDENTIALSenvironment variable to the path to your service account:
Viewing the traces
After deployment, you can view the traces in the Google Cloud console Trace Viewer.
For information on troubleshooting issues with Cloud Trace, go to the Troubleshooting page.
- For ASP.NET Core 3+ applications
- For earlier ASP.NET Core applications
- GitHub: googleapis/google-cloud-dotnet
- GitHub issue tracker
- Stack Overflow