Cloud Trace and Cloud Service Mesh

Note: This guide only supports Cloud Service Mesh with Istio APIs and doesnot support Google Cloud APIs. For more information see,Cloud Service Mesh overview.

Cloud Trace is a distributed tracing system that collectslatency data from the applications and displays it in near real-time. It allowsyou to follow a sample request through your distributed system, observe thenetwork calls and profile your system end to end.

Cloud Trace is available with Cloud Service Mesh installations on thefollowing platforms:

  • GKE on Google Cloud
  • GKE Enterprise clusters on-premises if you installed withCloud Service Mesh certificate authority

Note that Cloud Trace is disabled by default. Once enabled,Cloud Service Mesh pages in the Google Cloud console provide a link to thetraces in the Cloud Trace page . For detailed pricing information, refer totheCloud Trace pricing page.

Enable Cloud Trace

This section shows you how to enable Cloud Trace.

Managed (TD)

Note: Cloud Service Mesh with a managed Cloud Service Mesh control plane onlysupports cluster-wide telemetry API configuration with a single Istiotelemetry API custom resource (CR) in the root namespace. Don't deploymultiple Istio telemetry API CRs in a cluster. If you deploy multiple Istiotelemetry API CRs in a cluster, only the first one takes effect. If youalready have an existing Istio telemetry API CR, include them within your newIstio telemetry API CR to preserve your previous customization settings inyour existing Istio telemetry CR.

This section shows you how to enable Cloud Trace on Cloud Service Meshwith a managed Cloud Service Mesh control plane.

  1. Run the following command to enable Cloud Trace:

    cat <<EOF | kubectl apply -n istio-system -f -apiVersion: telemetry.istio.io/v1alpha1kind: Telemetrymetadata:   name: enable-cloud-trace   namespace: istio-systemspec:   tracing:   - providers:     - name: stackdriverEOF

Managed (Istiod)

This section shows you how to enable Cloud Trace on Cloud Service Meshwith managed Istiod control plane.

Warning: You can overwrite your own changes. If you already have an existingconfigmap, you must include all previous customization settings within themesh: section to preserve your changes.
  1. Run the following command:

    cat <<EOF | kubectl apply -f -apiVersion: v1data:   mesh: |-      defaultConfig:        tracing:          stackdriver: {}kind: ConfigMapmetadata:   name: istio-release-channel   namespace: istio-systemEOF

    whererelease-channel is yourrelease channel(asm-managed,asm-managed-stable, orasm-managed-rapid).

  2. Run the following command to view the configmap:

    kubectl get configmap istio-release-channel -n istio-system -o yaml
  3. To verify that Cloud Trace is enabled, ensure sure thefollowing lines appears in themesh: section.

    ...apiVersion: v1data:   mesh: |   ....   defaultConfig:      tracing:         stackdriver:{}...
  4. Restart the proxies.

    Note that tracer configuration is part of the proxy bootstrapconfiguration, so each pod needs to restart and get re-injected to pick upthe tracer update. For example, you can use the following command to restartpods that belong to a deployment:

    kubectl rollout restart deployment -nNAMESPACEDEPLOYMENT_NAME

In-cluster

This section shows you how to enable Cloud Trace on Cloud Service Meshwith in-cluster control plane.

To enable Cloud Trace, redeploy the customer-managed control plane usingthe following overlay file. For more information about overlay files, seeAbout the overlay files.

Caution: Usingasmcli install overwrites the existing control planeconfiguration. When you enable optional features to an existing installation,make sure to specify all files that you want to keep in the originalconfiguration, as well as the overlay files for the features that you want toenable. We recommended that you store the overlay files that you use forinstallation in source control so that you can apply the same configurationsto your control plane with upgrades or when enabling additional optionalfeatures.

Default

Run the following command to enable Cloud Trace:

 ./asmcli install \OTHER_FLAGS \    --option cloud-trace

This command applies the following overlay file to enable tracing withdefault options. Note that the default sampling rate is 1%. If you want tooverride the default, you must instead use--custom-overlay.

apiVersion:install.istio.io/v1alpha1kind:IstioOperatorspec:meshConfig:enableTracing:truevalues:global:proxy:tracer:stackdriver

For a list of options see theanthos-service-mesh package.

Custom

You can override the default by specifying atracing.sampling value. The value must be in the range of 0.0 to 100.0 with a precision of 0.01. For example, to trace 5 requests out of every 10,000, use 0.05.

The following example shows a sampling rate of 100% (which you would only do for demo or troubleshooting purposes).

apiVersion:install.istio.io/v1alpha1kind:IstioOperatorspec:meshConfig:enableTracing:truedefaultConfig:tracing:sampling:100values:global:proxy:tracer:stackdriver

Run the following command to enable Cloud Trace:

 ./asmcli install \OTHER_FLAGS \    --custom_overlayPATH_TO_FILE

Note that the tracer configuration is part of proxy bootstrap configuration,so pods need to restart and get re-injected to pick up the tracer update. Usethe following command to restart pods that belong to a deployment:

kubectl rollout restart deployment -nNAMESPACEDEPLOYMENT_NAME

Trace context propagation

Although the sidecar proxies can automatically send trace spans, they need somehints to tie together the entire trace. Applications need to propagate theappropriate HTTP headers so that when the proxies send span information, thespans can be correlated correctly into a single trace.

To do this, an application needs to collect and propagate the appropriateheaders from the incoming request to any outgoing requests. TheCloud Service Mesh Stackdriver tracing configuration will accept any of thefollowing header formats, and will propagateall of the following formats:

  • B3 (x-b3-traceid,x-b3-spanid,x-b3parentspanid,x-b3-sampled,x-b3-flags)
  • W3C TraceContext (traceparent)
  • Google Cloud Trace (x-cloud-trace-context)
  • gRPC TraceBin (grpc-trace-bin)

This means that your applications can use any of those formats to propagatetracing context and the traces will be generated and set to Stackdriverappropriately.

Example

Here is an example HTTP-Get request with atraceparent header in the originalrequest. Notice the additional trace context headers added by the proxy.

$kubectlexec-itsleep-557747455f-n6flv--curl"httpbin:8000/anything?freeform="-H"accept: application/json"-H"Traceparent: 00-7543d15e09e5d61801d4f74cde1269b8-604ef051d35c5b3f-01"-vv*Trying10.12.3.52:8000...*Connectedtohttpbin(10.12.3.52)port8000(#0)>GET/anything?freeform=HTTP/1.1>Host:httpbin:8000>User-Agent:curl/7.80.0-DEV>accept:application/json>Traceparent:00-7543d15e09e5d61801d4f74cde1269b8-604ef051d35c5b3f-01>*Markbundleasnotsupportingmultiuse<HTTP/1.1200OK<server:envoy<date:Wed,10Nov202120:36:04GMT<content-type:application/json<content-length:1032<access-control-allow-origin:*<access-control-allow-credentials:true<x-envoy-upstream-service-time:5<{"args":{"freeform":""},"data":"","files":{},"form":{},"headers":{"Accept":"application/json","Grpc-Trace-Bin":"AAB1Q9FeCeXWGAHU90zeEmm4AaDHmGRtdM7wAgE","Host":"httpbin:8000","Traceparent":"00-7543d15e09e5d61801d4f74cde1269b8-a0c798646d74cef0-01","User-Agent":"curl/7.80.0-DEV","X-B3-Sampled":"1","X-B3-Spanid":"a0c798646d74cef0","X-B3-Traceid":"7543d15e09e5d61801d4f74cde1269b8","X-Cloud-Trace-Context":"7543d15e09e5d61801d4f74cde1269b8/11585396123534413552;o=1","X-Envoy-Attempt-Count":"1","X-Forwarded-Client-Cert":"<REDACTED>"},"json":null,"method":"GET","origin":"127.0.0.6","url":"http://httpbin:8000/anything?freeform="}

Notice that in the returned set of request headers, the full set of tracecontext headers is present.

For more examples propagating the headers, seeTrace context propagation.

Create a trace from client with custom ID

To create a trace from a client with a custom ID, use thecurl command tocreate a request with an external client and force it to show a trace. For example:

curl $URL --header "x-client-trace-id: 105445aa7843bc8bf206b12000100000"

For more information aboutx-client-trace-id, refer to theEnvoy documentation.

Note: If you are testing the Cloud Service Mesh sidecar containers sendingCloud Trace data using the Googlemicroservices-demo,make sure that you disable the built-in Cloud Trace functionality. Themicroservices-demo is able to send Cloud Trace data without Istio. Notdisabling this functionality will result in duplicated traces because both theapplication container and the sidecar container will send traces. There areseveralDISABLE_TRACINGvariables to configure in the microservices-demo release file.

Access traces

View trace samples for a service

To view a sampling of traces for a service in your app, follow these steps:

  1. Go to theCloud Service Mesh page in the Google Cloud console.

    Go to the Cloud Service Mesh page

  2. UnderServices, select the name of the Service you want to inspect.

    The following screenshot shows an example of afrontend Service.

    Cloud Service Mesh trace graph

  3. UnderRequest traces, click any trace to see more information.

    The following screenshot shows an example of the trace request subpanel.

    Cloud Service Mesh trace sub-panel

View all traces

To view all traces for a Service, follow these steps:

  1. Go to theCloud Service Mesh page in the Google Cloud console.

    Go to the Cloud Service Mesh page

  2. UnderServices, select the name of the Service you want to inspect.

  3. Go to theMetrics page.

  4. Specify a time span from theTime Span dropdown menu orset a custom span with the timeline.

  5. ClickView traces.

The traces for a service in Cloud Service Mesh contain following information:

  • Request latencies across different services in the mesh.
  • HTTP request properties, including ID, URL, size, latency, and protocol.
  • Service name, namespace and mesh id as part of the labelsistio.canonical_service,istio.namespace, andistio.mesh_id,respectively.

What's next

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-02-19 UTC.