|
| 1 | +// Module is included in the following assemblies: |
| 2 | +// |
| 3 | +// * serverless/serverless-tracing.adoc |
| 4 | + |
| 5 | +:_content-type: PROCEDURE |
| 6 | +[id="serverless-open-telemetry_{context}"] |
| 7 | += Using {DTProductName} to enable distributed tracing |
| 8 | + |
| 9 | +{DTProductName} is made up of several components that work together to collect, store, and display tracing data. You can use {DTProductName} with {ServerlessProductName} to monitor and troubleshoot serverless applications. |
| 10 | + |
| 11 | +.Prerequisites |
| 12 | + |
| 13 | +* You have access to an {product-title} account with cluster administrator access. |
| 14 | +* You have not yet installed the {ServerlessOperatorName} and Knative Serving. These must be installed after the {DTProductName} installation. |
| 15 | +* You have installed {DTProductName} by following the {product-title} "Installing distributed tracing" documentation. |
| 16 | +* You have installed the OpenShift (`oc`) CLI. |
| 17 | +* You have created a project or have access to a project with the appropriate roles and permissions to create applications and other workloads in {product-title}. |
| 18 | +
|
| 19 | +.Procedure |
| 20 | + |
| 21 | +. Create an `OpenTelemetryCollector` custom resource (CR): |
| 22 | ++ |
| 23 | +.Example OpenTelemetryCollector CR |
| 24 | +[source,yaml] |
| 25 | +---- |
| 26 | +apiVersion: opentelemetry.io/v1alpha1 |
| 27 | +kind: OpenTelemetryCollector |
| 28 | +metadata: |
| 29 | + name: cluster-collector |
| 30 | + namespace: <namespace> |
| 31 | +spec: |
| 32 | + mode: deployment |
| 33 | + config: | |
| 34 | + receivers: |
| 35 | + zipkin: |
| 36 | + processors: |
| 37 | + exporters: |
| 38 | + jaeger: |
| 39 | + endpoint: jaeger-all-in-one-inmemory-collector-headless.tracing-system.svc:14250 |
| 40 | + tls: |
| 41 | + ca_file: "/var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt" |
| 42 | + logging: |
| 43 | + service: |
| 44 | + pipelines: |
| 45 | + traces: |
| 46 | + receivers: [zipkin] |
| 47 | + processors: [] |
| 48 | + exporters: [jaeger, logging] |
| 49 | +---- |
| 50 | + |
| 51 | +. Verify that you have two pods running in the namespace where {DTProductName} is installed: |
| 52 | ++ |
| 53 | +[source,terminal] |
| 54 | +---- |
| 55 | +$ oc get pods -n <namespace> |
| 56 | +---- |
| 57 | ++ |
| 58 | +.Example output |
| 59 | +[source,terminal] |
| 60 | +---- |
| 61 | +NAME READY STATUS RESTARTS AGE |
| 62 | +cluster-collector-collector-85c766b5c-b5g99 1/1 Running 0 5m56s |
| 63 | +jaeger-all-in-one-inmemory-ccbc9df4b-ndkl5 2/2 Running 0 15m |
| 64 | +---- |
| 65 | + |
| 66 | +. Verify that the following headless services have been created: |
| 67 | ++ |
| 68 | +[source,terminal] |
| 69 | +---- |
| 70 | +$ oc get svc -n <namespace> | grep headless |
| 71 | +---- |
| 72 | ++ |
| 73 | +.Example output |
| 74 | +[source,terminal] |
| 75 | +---- |
| 76 | +cluster-collector-collector-headless ClusterIP None <none> 9411/TCP 7m28s |
| 77 | +jaeger-all-in-one-inmemory-collector-headless ClusterIP None <none> 9411/TCP,14250/TCP,14267/TCP,14268/TCP 16m |
| 78 | +---- |
| 79 | ++ |
| 80 | +These services are used to configure Jaeger and Knative Serving. The name of the Jaeger service may vary. |
| 81 | + |
| 82 | +. Install the {ServerlessOperatorName} by following the "Installing the {ServerlessOperatorName}" documentation. |
| 83 | + |
| 84 | +. Install Knative Serving by creating the following `KnativeServing` CR: |
| 85 | ++ |
| 86 | +.Example KnativeServing CR |
| 87 | +[source,yaml] |
| 88 | +---- |
| 89 | +apiVersion: operator.knative.dev/v1alpha1 |
| 90 | +kind: KnativeServing |
| 91 | +metadata: |
| 92 | + name: knative-serving |
| 93 | + namespace: knative-serving |
| 94 | +spec: |
| 95 | + config: |
| 96 | + tracing: |
| 97 | + backend: "zipkin" |
| 98 | + zipkin-endpoint: "http://cluster-collector-collector-headless.tracing-system.svc:9411/api/v2/spans" |
| 99 | + debug: "true" |
| 100 | + sample-rate: "0.1" <1> |
| 101 | +---- |
| 102 | +<1> The `sample-rate` defines sampling probability. Using `sample-rate: "0.1"` means that 1 in 10 traces are sampled. |
| 103 | + |
| 104 | +. Create a Knative service: |
| 105 | ++ |
| 106 | +.Example service |
| 107 | +[source,yaml] |
| 108 | +---- |
| 109 | +apiVersion: serving.knative.dev/v1 |
| 110 | +kind: Service |
| 111 | +metadata: |
| 112 | + name: helloworld-go |
| 113 | +spec: |
| 114 | + template: |
| 115 | + metadata: |
| 116 | + labels: |
| 117 | + app: helloworld-go |
| 118 | + annotations: |
| 119 | + autoscaling.knative.dev/minScale: "1" |
| 120 | + autoscaling.knative.dev/target: "1" |
| 121 | + spec: |
| 122 | + containers: |
| 123 | + - image: quay.io/openshift-knative/helloworld:v1.2 |
| 124 | + imagePullPolicy: Always |
| 125 | + resources: |
| 126 | + requests: |
| 127 | + cpu: "200m" |
| 128 | + env: |
| 129 | + - name: TARGET |
| 130 | + value: "Go Sample v1" |
| 131 | +---- |
| 132 | + |
| 133 | +. Make some requests to the service: |
| 134 | ++ |
| 135 | +.Example HTTPS request |
| 136 | +[source,terminal] |
| 137 | +---- |
| 138 | +$ curl https://helloworld-go.example.com |
| 139 | +---- |
| 140 | + |
| 141 | +. Get the URL for the Jaeger web console: |
| 142 | ++ |
| 143 | +.Example command |
| 144 | +[source,terminal] |
| 145 | +---- |
| 146 | +$ oc get route jaeger-all-in-one-inmemory -o jsonpath='{.spec.host}' -n <namespace> |
| 147 | +---- |
| 148 | ++ |
| 149 | +You can now examine traces by using the Jaeger console. |
0 commit comments