OpenCensus Agent
After completing this task, you will understand how to have your application participate in tracing with the OpenCensus Agent, export those traces to the OpenTelemetry collector, and have the OpenTelemetry collector export those spans to Jaeger.
To learn how Istio handles tracing, visit this task’s overview6.
Before you begin
Setup Istio by following the instructions in the Installation guide7.
Deploy the sleep9 sample app to use as a test source for sending requests. If you have automatic sidecar injection enabled, run the following command to deploy the sample app:
Otherwise, manually inject the sidecar before deploying the
sleep
application with the following command:Set the
SOURCE_POD
environment variable to the name of your source pod:
Configure tracing
If you used an IstioOperator
CR to install Istio, add the following field to your configuration:
With this configuration Istio is installed with OpenCensus Agent as the default tracer. Trace data will be sent to an OpenTelemetry backend.
By default, Istio’s OpenCensus Agent tracing will attempt to read and write 4 types of trace headers:
- B3,
- gRPC’s binary trace header,
- W3C Trace Context11,
- and Cloud Trace Context.
If you supply multiple values, the proxy will attempt to read trace headers in the specified order, using the first one that successfully parsed and writing all headers. This permits interoperability between services that use different headers, e.g. one service that propagates B3 headers and one that propagates W3C Trace Context headers can participate in the same trace. In this example we only use W3C Trace Context.
In the default profile the sampling rate is 1%. Increase it to 100% using the Telemetry API12:
Deploy OpenTelemetry Collector
OpenTelemetry collector supports exporting traces to several backends by default13 in the core distribution. Other backends are available in the contrib distribution14 of OpenTelemetry collector.
Deploy and configure the collector to receive and export spans to the Jaeger instance:
Access the dashboard
Remotely Accessing Telemetry Addons15 details how to configure access to the Istio addons through a gateway.
For testing (and temporary access), you may also use port-forwarding. Use the following, assuming you’ve deployed Jaeger to the istio-system
namespace:
Generating traces using the Bookinfo sample
When the Bookinfo application is up and running, access
http://$GATEWAY_URL/productpage
one or more times to generate trace information.To see trace data, you must send requests to your service. The number of requests depends on Istio’s sampling rate and can be configured using the Telemetry API12. With the default sampling rate of 1%, you need to send at least 100 requests before the first trace is visible. To send a 100 requests to the
productpage
service, use the following command:From the left-hand pane of the dashboard, select
productpage.default
from the Service drop-down list and click Find Traces:Click on the most recent trace at the top to see the details corresponding to the latest request to
/productpage
:The trace is comprised of a set of spans, where each span corresponds to a Bookinfo service, invoked during the execution of a
/productpage
request, or internal Istio component, for example:istio-ingressgateway
.
As you also configured logging exporter in OpenTelemetry Collector, you can see traces in the logs as well:
Cleanup
Remove any
istioctl
processes that may still be running using control-C or:If you are not planning to explore any follow-on tasks, refer to the Bookinfo cleanup instructions to shutdown the application.
Remove the
Jaeger
addon:Remove the
OpenTelemetry Collector
:Remove, or set to
""
, themeshConfig.extensionProviders
andmeshConfig.defaultProviders
setting in your Istio install configuration.Remove the telemetry resource: