Este contenido no está disponible en el idioma seleccionado.
Chapter 4. Tracing
4.1. Tracing requests
Distributed tracing records the path of a request through the various services that make up an application. It is used to tie information about different units of work together, to understand a whole chain of events in a distributed transaction. The units of work might be executed in different processes or hosts.
4.1.1. Distributed tracing overview
As a service owner, you can use distributed tracing to instrument your services to gather insights into your service architecture. You can use distributed tracing for monitoring, network profiling, and troubleshooting the interaction between components in modern, cloud-native, microservices-based applications.
With distributed tracing you can perform the following functions:
- Monitor distributed transactions
- Optimize performance and latency
- Perform root cause analysis
Red Hat OpenShift distributed tracing consists of two main components:
- Red Hat OpenShift distributed tracing platform - This component is based on the open source Jaeger project.
- Red Hat OpenShift distributed tracing data collection - This component is based on the open source OpenTelemetry project.
Both of these components are based on the vendor-neutral OpenTracing APIs and instrumentation.
4.2. Using Red Hat OpenShift distributed tracing
You can use Red Hat OpenShift distributed tracing with OpenShift Serverless to monitor and troubleshoot serverless applications.
4.2.1. Using Red Hat OpenShift distributed tracing to enable distributed tracing
Red Hat OpenShift distributed tracing is made up of several components that work together to collect, store, and display tracing data.
Prerequisites
- You have access to an OpenShift Container Platform account with cluster administrator access.
- You have installed Red Hat OpenShift distributed tracing by following the OpenShift Container Platform "Installing distributed tracing" documentation.
- 
							You have installed the OpenShift CLI (oc).
- You have created a project or have access to a project with the appropriate roles and permissions to create applications and other workloads in OpenShift Container Platform.
Procedure
- Create an - OpenTelemetryCollectorcustom resource (CR):- Example OpenTelemetryCollector CR - Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Verify that you have two pods running in the namespace where Red Hat OpenShift distributed tracing is installed: - oc get pods -n <namespace> - $ oc get pods -n <namespace>- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - Example output - NAME READY STATUS RESTARTS AGE cluster-collector-collector-85c766b5c-b5g99 1/1 Running 0 5m56s jaeger-all-in-one-inmemory-ccbc9df4b-ndkl5 2/2 Running 0 15m - NAME READY STATUS RESTARTS AGE cluster-collector-collector-85c766b5c-b5g99 1/1 Running 0 5m56s jaeger-all-in-one-inmemory-ccbc9df4b-ndkl5 2/2 Running 0 15m- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Verify that the following headless services have been created: - oc get svc -n <namespace> | grep headless - $ oc get svc -n <namespace> | grep headless- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - Example output - cluster-collector-collector-headless ClusterIP None <none> 9411/TCP 7m28s jaeger-all-in-one-inmemory-collector-headless ClusterIP None <none> 9411/TCP,14250/TCP,14267/TCP,14268/TCP 16m - cluster-collector-collector-headless ClusterIP None <none> 9411/TCP 7m28s jaeger-all-in-one-inmemory-collector-headless ClusterIP None <none> 9411/TCP,14250/TCP,14267/TCP,14268/TCP 16m- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - These services are used to configure Jaeger, Knative Serving, and Knative Eventing. The name of the Jaeger service may vary. 
- Install the OpenShift Serverless Operator by following the "Installing the OpenShift Serverless Operator" documentation.
- Install Knative Serving by creating the following - KnativeServingCR:- Example KnativeServing CR - Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - 1
- Thesample-ratedefines sampling probability. Usingsample-rate: "0.1"means that 1 in 10 traces are sampled.
 
- Install Knative Eventing by creating the following - KnativeEventingCR:- Example KnativeEventing CR - Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - 1
- Thesample-ratedefines sampling probability. Usingsample-rate: "0.1"means that 1 in 10 traces are sampled.
 
- Create a Knative service: - Example service - Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Make some requests to the service: - Example HTTPS request - curl https://helloworld-go.example.com - $ curl https://helloworld-go.example.com- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Get the URL for the Jaeger web console: - Example command - oc get route jaeger-all-in-one-inmemory -o jsonpath='{.spec.host}' -n <namespace>- $ oc get route jaeger-all-in-one-inmemory -o jsonpath='{.spec.host}' -n <namespace>- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - You can now examine traces by using the Jaeger console. 
4.3. Using Jaeger distributed tracing
If you do not want to install all of the components of Red Hat OpenShift distributed tracing, you can still use distributed tracing on OpenShift Container Platform with OpenShift Serverless.
4.3.1. Configuring Jaeger to enable distributed tracing
To enable distributed tracing using Jaeger, you must install and configure Jaeger as a standalone integration.
Prerequisites
- You have cluster administrator permissions on OpenShift Container Platform, or you have cluster or dedicated administrator permissions on Red Hat OpenShift Service on AWS or OpenShift Dedicated.
- You have installed the OpenShift Serverless Operator, Knative Serving, and Knative Eventing.
- You have installed the Red Hat OpenShift distributed tracing platform Operator.
- 
							You have installed the OpenShift CLI (oc).
- You have created a project or have access to a project with the appropriate roles and permissions to create applications and other workloads.
Procedure
- Create and apply a - Jaegercustom resource (CR) that contains the following:- Jaeger CR - apiVersion: jaegertracing.io/v1 kind: Jaeger metadata: name: jaeger namespace: default - apiVersion: jaegertracing.io/v1 kind: Jaeger metadata: name: jaeger namespace: default- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Enable tracing for Knative Serving, by editing the - KnativeServingCR and adding a YAML configuration for tracing:- Tracing YAML example for Serving - Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - 1
- Thesample-ratedefines sampling probability. Usingsample-rate: "0.1"means that 1 in 10 traces are sampled.
- 2
- backendmust be set to- zipkin.
- 3
- Thezipkin-endpointmust point to yourjaeger-collectorservice endpoint. To get this endpoint, substitute the namespace where the Jaeger CR is applied.
- 4
- Debugging should be set tofalse. Enabling debug mode by settingdebug: "true"allows all spans to be sent to the server, bypassing sampling.
 
- Enable tracing for Knative Eventing by editing the - KnativeEventingCR:- Tracing YAML example for Eventing - Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - 1
- Thesample-ratedefines sampling probability. Usingsample-rate: "0.1"means that 1 in 10 traces are sampled.
- 2
- Setbackendtozipkin.
- 3
- Point thezipkin-endpointto yourjaeger-collectorservice endpoint. To get this endpoint, substitute the namespace where the Jaeger CR is applied.
- 4
- Debugging should be set tofalse. Enabling debug mode by settingdebug: "true"allows all spans to be sent to the server, bypassing sampling.
 
Verification
						You can access the Jaeger web console to see tracing data, by using the jaeger route.
					
- Get the - jaegerroute’s hostname by entering the following command:- oc get route jaeger -n default - $ oc get route jaeger -n default- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - Example output - NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD jaeger jaeger-default.apps.example.com jaeger-query <all> reencrypt None - NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD jaeger jaeger-default.apps.example.com jaeger-query <all> reencrypt None- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Open the endpoint address in your browser to view the console.