此内容没有您所选择的语言版本。
Chapter 3. Distributed tracing and Service Mesh
Integrate Red Hat OpenShift distributed tracing platform with Red Hat OpenShift Service Mesh by using Red Hat OpenShift distributed tracing platform (Tempo) for distributed tracing platform storage and Red Hat OpenShift distributed tracing data collection for standardized telemetry data collection and processing.
Two parts integrate Red Hat OpenShift distributed tracing platform with Red Hat OpenShift Service Mesh: Red Hat OpenShift distributed tracing platform (Tempo) and Red Hat OpenShift distributed tracing data collection.
- Red Hat OpenShift distributed tracing platform (Tempo)
Provides distributed tracing platform to monitor and troubleshoot transactions in complex distributed systems. Tempo derives its core functionality from the open source Grafana Tempo project.
For more about information about distributed tracing platform (Tempo), its features, installation, and configuration, see, "Red Hat OpenShift distributed tracing platform (Tempo)".
- Red Hat OpenShift distributed tracing data collection
Derives its core functionality from the open source "OpenTelemetry project", which aims to offer unified, standardized, and vendor-neutral telemetry data collection for cloud-native software. Red Hat OpenShift distributed tracing data collection product provides support for deploying and managing the OpenTelemetry Collector and simplifying the instrumentation of workloads.
The "OpenTelemetry Collector" can receive, process, and forward telemetry data in many formats, making it the ideal component for telemetry processing and interoperability between telemetry systems. The Collector provides a unified solution for collecting and processing metrics, traces, and logs.
For more information about distributed tracing data collection, its features, installation, and configuration, see: "Red Hat OpenShift distributed tracing data collection".
You can integrate Red Hat OpenShift Service Mesh with Red Hat OpenShift distributed tracing data collection to instrument, generate, collect, and export OpenTelemetry traces, metrics, and logs to analyze and understand the performance and behavior of the software.
Prerequisites
- You have installed the Tempo Operator. For more information, see "Installing the Tempo Operator".
- You have installed the Red Hat OpenShift distributed tracing data collection Operator. For more information, see "Installing the Red Hat build of OpenTelemetry".
-
You have installed a
TempoStackand configured it in atemponamespace. For more information, see "Installing aTempoStackinstance". -
You have created an
Istioinstance. -
You have created an
IstioCNIinstance.
Procedure
Navigate to the Red Hat OpenShift distributed tracing data collection Operator and install the
OpenTelemetryCollectorresource in theistio-systemnamespace, similar to the following example:kind: OpenTelemetryCollector apiVersion: opentelemetry.io/v1beta1 metadata: name: otel namespace: istio-system spec: observability: metrics: {} deploymentUpdateStrategy: {} config: exporters: otlp: endpoint: 'tempo-sample-distributor.tempo.svc.cluster.local:4317' tls: insecure: true receivers: otlp: protocols: grpc: endpoint: '0.0.0.0:4317' http: {} service: pipelines: traces: exporters: - otlp receivers: - otlpUpdate the Red Hat OpenShift Service Mesh Istio custom resource (CR) to enable tracing and define the distributed tracing data collection tracing providers in your
meshConfig, similar to the following example:apiVersion: sailoperator.io/v1 kind: Istio metadata: # ... name: default spec: namespace: istio-system # ... values: meshConfig: enableTracing: true extensionProviders: - name: otel opentelemetry: port: 4317 service: otel-collector.istio-system.svc.cluster.local-
spec.values.meshConfig.ExtensionProviders.opentelemetry.serviceis theOpenTelemetrycollector service in theistio-systemnamespace.
-
Create an Istio Telemetry resource to enable tracers defined in
spec.values.meshConfig.ExtensionProviders, similar to the following example:apiVersion: telemetry.istio.io/v1 kind: Telemetry metadata: name: otel-demo namespace: istio-system spec: tracing: - providers: - name: otel randomSamplingPercentage: 100After you verify that you can see traces, lower the
randomSamplingPercentagevalue or set it todefaultto reduce the number of requests.NoteYou can use a single Istio Telemetry resource for both the Prometheus metrics provider and a tracing provider by setting
spec.metrics.overrides.disabledtofalse. This enables the Prometheus metrics provider. This is an optional step and you can skip it if you configured metrics through the OpenShift Cluster Monitoring method described in the earlier step.Create the
bookinfonamespace by running the following command:$ oc create ns bookinfoDepending on the update strategy you are using, enable sidecar injection in the namespace by running the appropriate commands:
If you are using the
InPlaceupdate strategy, run the following command:$ oc label namespace curl istio-injection=enabledIf you are using the
RevisionBasedupdate strategy, run the following commands:Display the revision name by running the following command:
$ oc get istiorevisions.sailoperator.ioYou should see output similar to the following example:
NAME TYPE READY STATUS IN USE VERSION AGE default Local True Healthy True v1.24.3 3m33sLabel the namespace with the revision name to enable sidecar injection by running the following command:
$ oc label namespace curl istio.io/rev=default
Deploy the
bookinfoapplication in thebookinfonamespace by running the following command:$ oc apply -f https://raw.githubusercontent.com/openshift-service-mesh/istio/release-1.24/samples/bookinfo/platform/kube/bookinfo.yaml -n bookinfoGenerate traffic to the
productpagepod to generate traces:$ oc exec -it -n bookinfo deployments/productpage-v1 -c istio-proxy -- curl localhost:9080/productpageValidate the integration by running the following command to see traces in the UI:
$ oc get routes -n tempo tempo-sample-query-frontendNoteYou must create the OpenShift route for the Jaeger UI in the Tempo namespace. You can either manually create it for the
tempo-sample-query-frontendservice, or update theTempocustom resource with.spec.template.queryFrontend.jaegerQuery.ingress.type: route.
Generate Layer 7 (L7) tracing spans in OpenShift Service Mesh ambient mode by using waypoint or gateway proxies to capture application-level telemetry that the Layer 4 (L4) ztunnel component does not offer.
Prerequisites
- You have installed the Tempo Operator. For more information, see "Installing the Tempo Operator".
- You have installed the Red Hat OpenShift distributed tracing data collection Operator. For more information, see "Installing the Red Hat build of OpenTelemetry".
-
You have installed a
TempoStackand configured it in atemponamespace. For more information, see "Installing aTempoStackinstance". -
You have created an
Istioinstance.
Procedure
Navigate to the Red Hat OpenShift distributed tracing data collection Operator and install the
OpenTelemetryCollectorresource in theistio-systemnamespace, similar to the following example:kind: OpenTelemetryCollector apiVersion: opentelemetry.io/v1beta1 metadata: name: otel namespace: istio-system spec: mode: deployment observability: metrics: {} deploymentUpdateStrategy: {} config: exporters: otlp: endpoint: 'tempo-sample-distributor.tempo.svc.cluster.local:4317' tls: insecure: true receivers: otlp: protocols: grpc: endpoint: '0.0.0.0:4317' http: {} service: pipelines: traces: exporters: - otlp receivers: - otlp-
spec.config.exporters.otlp.endpointdefines the Tempo sample distributor service in a namespace such astempo.
-
Update the Red Hat OpenShift Service Mesh Istio custom resource (CR) to define a tracing provider in the
spec.values.meshConfigfield, similar to the following example:apiVersion: sailoperator.io/v1 kind: Istio metadata: # ... name: default spec: namespace: istio-system profile: ambient # ... values: meshConfig: enableTracing: true extensionProviders: - name: otel opentelemetry: port: 4317 service: otel-collector.istio-system.svc.cluster.local pilot: trustedZtunnelNamespace: ztunnel-
spec.values.meshConfig.extensionProviders.opentelemetry.servicedefines the OpenTelemetry collector service in theistio-systemnamespace.
-
Create an Istio Telemetry CR to enable the tracing provider defined in the
spec.values.meshConfig.ExtensionProvidersfield, similar to the following example:apiVersion: telemetry.istio.io/v1 kind: Telemetry metadata: name: otel-demo namespace: istio-system spec: tracing: - providers: - name: otel randomSamplingPercentage: 100NoteAfter you can see the traces, lower the
randomSamplingPercentagevalue or set it todefaultto reduce the number of requests. You can also use thespec.targetRefsfield to enable tracing at a gateway or a waypoint level.-
Optional: Use a single Istio Telemetry resource for both a Prometheus metrics provider and a tracing provider by setting
spec.metrics.overrides.disabledfield tofalse. This enables the Prometheus metrics provider. You do not need this step if you have configured metrics through the OpenShift Cluster Monitoring approach described in the earlier step.
3.1.3.1. Verifying traces in ambient mode 复制链接链接已复制到粘贴板!
You can verify that the traces for your application are in ambient mode. The following example uses the Bookinfo application.
Prerequisites
- You have deployed the Bookinfo application in ambient mode to use the following example. For more information, see "Deploying the Bookinfo application in Istio ambient mode".
-
You have deployed a waypoint proxy and enrolled the
bookinfonamespace to use the waypoint. For more information, see "Deploying a waypoint proxy".
Procedure
Send some traffic to the Bookinfo
productpageservice for generating traces by running the following command:$ curl "http://${GATEWAY_URL}/productpage" | grep "<title>"Verify that the Bookinfo application traces appear in a Tempo dashboard UI by running the following command:
$ oc get routes -n tempo tempo-sample-query-frontend-
Select the
bookinfo-gateway-istio.booinfoor thewaypoint.bookinfoservice from the dashboard UI. Click Find Traces.
NoteThe
TempoStackcustom resource (CR) creates the route for the Tempo dashboard UI when you set the .spec.template.queryFrontend.jaegerQuery.ingress.typefield toroute.