|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// * observability/otel/otel-troubleshooting.adoc |
| 4 | + |
| 5 | +:_mod-docs-content-type: PROCEDURE |
| 6 | +[id="otel-troubleshooting-instrumentation-injection-into-your-workload_{context}"] |
| 7 | += Troubleshooting instrumentation injection into your workload |
| 8 | + |
| 9 | +To troubleshoot instrumentation injection, you can perform the following activities: |
| 10 | + |
| 11 | +* Checking if the `Instrumentation` object was created |
| 12 | +* Checking if the init-container started |
| 13 | +* Checking if the resources were deployed in the correct order |
| 14 | +* Searching for errors in the Operator logs |
| 15 | +* Double-checking the pod annotations |
| 16 | +
|
| 17 | +.Procedure |
| 18 | + |
| 19 | +. Run the following command to verify that the `Instrumentation` object was successfully created: |
| 20 | ++ |
| 21 | +[source,terminal] |
| 22 | +---- |
| 23 | +$ oc get instrumentation -n <workload_project> # <1> |
| 24 | +---- |
| 25 | +<1> The namespace where the instrumentation was created. |
| 26 | + |
| 27 | +. Run the following command to verify that the `opentelemetry-auto-instrumentation` init-container successfully started, which is a prerequisite for instrumentation injection into workloads: |
| 28 | ++ |
| 29 | +[source,terminal] |
| 30 | +---- |
| 31 | +$ oc get events -n <workload_project> # <1> |
| 32 | +---- |
| 33 | +<1> The namespace where the instrumentation is injected for workloads. |
| 34 | ++ |
| 35 | +.Example output |
| 36 | +[source,terminal] |
| 37 | +---- |
| 38 | +... Created container opentelemetry-auto-instrumentation |
| 39 | +... Started container opentelemetry-auto-instrumentation |
| 40 | +---- |
| 41 | +
|
| 42 | +. Verify that the resources were deployed in the correct order for the auto-instrumentation to work correctly. The correct order is to deploy the `Instrumentation` custom resource (CR) before the application. For information about the `Instrumentation` CR, see the section "Configuring the instrumentation". |
| 43 | ++ |
| 44 | +[NOTE] |
| 45 | +==== |
| 46 | +When the pod starts, the {OTELOperator} checks the `Instrumentation` CR for annotations containing instructions for injecting auto-instrumentation. Generally, the Operator then adds an init-container to the application’s pod that injects the auto-instrumentation and environment variables into the application's container. If the `Instrumentation` CR is not available to the Operator when the application is deployed, the Operator is unable to inject the auto-instrumentation. |
| 47 | +==== |
| 48 | ++ |
| 49 | +Fixing the order of deployment requires the following steps: |
| 50 | +
|
| 51 | +.. Update the instrumentation settings. |
| 52 | +.. Delete the instrumentation object. |
| 53 | +.. Redeploy the application. |
| 54 | +
|
| 55 | +. Run the following command to inspect the Operator logs for instrumentation errors: |
| 56 | ++ |
| 57 | +[source,terminal] |
| 58 | +---- |
| 59 | +$ oc logs -l app.kubernetes.io/name=opentelemetry-operator --container manager -n openshift-opentelemetry-operator --follow |
| 60 | +---- |
| 61 | + |
| 62 | +. Troubleshoot pod annotations for the instrumentations for a specific programming language. See the required annotation fields and values in "Configuring the instrumentation". |
| 63 | + |
| 64 | +.. Verify that the application pods that you are instrumenting are labeled with correct annotations and the appropriate auto-instrumentation settings have been applied. |
| 65 | ++ |
| 66 | +.Example |
| 67 | +---- |
| 68 | +instrumentation.opentelemetry.io/inject-python="true" |
| 69 | +---- |
| 70 | ++ |
| 71 | +.Example command to get pod annotations for an instrumented Python application |
| 72 | +[source,terminal] |
| 73 | +---- |
| 74 | +$ oc get pods -n <workload_project> -o jsonpath='{range .items[?(@.metadata.annotations["instrumentation.opentelemetry.io/inject-python"]=="true")]}{.metadata.name}{"\n"}{end}' |
| 75 | +---- |
| 76 | + |
| 77 | +.. Verify that the annotation applied to the instrumentation object is correct for the programming language that you are instrumenting. |
| 78 | + |
| 79 | +.. If there are multiple instrumentations in the same namespace, specify the name of the `Instrumentation` object in their annotations. |
| 80 | ++ |
| 81 | +.Example |
| 82 | +---- |
| 83 | +instrumentation.opentelemetry.io/inject-nodejs: "<instrumentation_object>" |
| 84 | +---- |
| 85 | + |
| 86 | +.. If the `Instrumentation` object is in a different namespace, specify the namespace in the annotation. |
| 87 | ++ |
| 88 | +.Example |
| 89 | +---- |
| 90 | +instrumentation.opentelemetry.io/inject-nodejs: "<other_namespace>/<instrumentation_object>" |
| 91 | +---- |
| 92 | + |
| 93 | +.. Verify that the `OpenTelemetryCollector` custom resource specifies the auto-instrumentation annotations under `spec.template.metadata.annotations`. If the auto-instrumentation annotations are in `spec.metadata.annotations` instead, move them into `spec.template.metadata.annotations`. |
0 commit comments