You can view and analyze trace data collected from multiple Google Cloud projects in a single view by configuring a trace scope and the observability scope. A trace scope lists the resources to search for trace data, while the observability scope specifies which trace scope to use by default.
To view trace spans that are stored in multiple projects—for example, when an application in one project calls a service hosted in another project—do the following:
For each project where trace data is stored, ask your administrator to grant you the role Cloud Trace User (
roles/cloudtrace.user) on the project. This role lets you view the trace data stored by the project.Identify the project where you plan to view your trace data and ask your administrator to grant you the following roles on that project:
- Cloud Trace User (
roles/cloudtrace.user) - Observability Scopes Editor (
roles/observability.scopesEditor)
- Cloud Trace User (
In the project where you plan to view your trace data, create a trace scope and configure it to list the default trace view for each project that stores trace data.
A project's default trace view provides access to all trace data stored by the project and has the path
_Trace/Spans/_AllSpans, where the fields_Trace,Spans, and_AllSpansrefer to an observability bucket, dataset, and view. For information about trace scopes, see Create and manage trace scopes.In the same project, set your new trace scope as the default trace scope.
When you set a default trace scope, you also update the observability scope, which the Trace Explorer page uses to identify which resources to search for trace data. Because the observability scope also identifies the default log scope, the observability scope lets the system correlate log and trace data.
If you don't perform this step, then the Trace Explorer page automatically searches only your selected project for trace data. Also, the system might not be able to correlate your log and trace data. For more information, see Configure observability scopes for multi-project queries.
After the Trace Explorer page is open, to change which resources the page searches for trace data, use the Scope element in the toolbar. For more information, see Configure which views the Trace Explorer searches.