diff --git a/.github/workflows/operator-integration-test.yml b/.github/workflows/operator-integration-test.yml index 62b20f418..3db79ee35 100644 --- a/.github/workflows/operator-integration-test.yml +++ b/.github/workflows/operator-integration-test.yml @@ -71,7 +71,8 @@ jobs: - name: Test for default instrumentation resources for Java run: | kubectl apply -f integration-tests/java/sample-deployment-java.yaml - sleep 5 +# sleep is to make sure the app is fully active before restart wait doesn't work as accurately + sleep 5 kubectl get pods -A kubectl describe pods -n default go run integration-tests/manifests/cmd/validate_instrumentation_vars.go default integration-tests/java/default_instrumentation_java_env_variables.json @@ -81,7 +82,7 @@ jobs: kubectl apply -f integration-tests/manifests/sample-instrumentation.yaml sleep 5 kubectl rollout restart deployment nginx - sleep 5 + kubectl wait --for=condition=Available deployment/nginx -n default kubectl get pods -A kubectl describe pods -n default cd integration-tests/manifests/cmd @@ -93,25 +94,45 @@ jobs: kubectl apply -f integration-tests/python/sample-deployment-python.yaml sleep 5 kubectl rollout restart deployment nginx - sleep 5 + kubectl wait --for=condition=Available deployment/nginx -n default kubectl get pods -A kubectl describe pods -n default go run integration-tests/manifests/cmd/validate_instrumentation_vars.go default integration-tests/python/default_instrumentation_python_env_variables.json - - name: Test for defined instrumentation resources for python run: | kubectl apply -f integration-tests/manifests/sample-instrumentation.yaml sleep 5 kubectl rollout restart deployment nginx - sleep 5 - kubectl get pods -A + kubectl wait --for=condition=Available deployment/nginx -n default kubectl describe pods -n default cd integration-tests/manifests/cmd go run validate_instrumentation_vars.go default ns_instrumentation_env_variables.json kubectl delete instrumentation sample-instrumentation + - name: Test for default instrumentation resources for python and java + run: | + kubectl apply -f integration-tests/python-java/sample-deployment-python-java.yaml + sleep 5 + kubectl rollout restart deployment nginx + kubectl wait --for=condition=Available deployment/nginx -n default + sleep 5 + kubectl get pods -A + kubectl describe pods -n default + kubectl describe pods -n amazon-cloudwatch + go run integration-tests/manifests/cmd/validate_instrumentation_vars.go default integration-tests/python-java/default_instrumentation_python-java_env_variables.json + - name: Test for defined instrumentation resources for python and java + run: | + kubectl apply -f integration-tests/manifests/sample-instrumentation.yaml + sleep 5 + kubectl rollout restart deployment nginx + kubectl wait --for=condition=Available deployment/nginx -n default + kubectl get pods -A + kubectl describe pods -n default + cd integration-tests/manifests/cmd + go run validate_instrumentation_vars.go default ns_instrumentation_env_variables.json + kubectl delete instrumentation sample-instrumentation DeploymentAnnotationsTest: name: DeploymentAnnotationsTest @@ -308,8 +329,5 @@ jobs: go test -v -run TestPythonOnlyNamespace ./integration-tests/manifests/annotations -timeout 30m sleep 5 go test -v -run TestAlreadyAutoAnnotatedResourceShouldNotRestart ./integration-tests/manifests/annotations -timeout 30m - kubectl get pods -A - kubectl describe pods -n default - diff --git a/config/manager/manager.yaml b/config/manager/manager.yaml index ae26d2df7..d4bef9fc2 100644 --- a/config/manager/manager.yaml +++ b/config/manager/manager.yaml @@ -28,6 +28,8 @@ spec: spec: containers: - image: controller + args: + - "--feature-gates=operator.autoinstrumentation.multi-instrumentation,operator.autoinstrumentation.multi-instrumentation.skip-container-validation" name: manager resources: requests: diff --git a/integration-tests/manifests/cmd/ns_instrumentation_env_variables.json b/integration-tests/manifests/cmd/ns_instrumentation_env_variables.json index d47ff1574..3c328cde5 100644 --- a/integration-tests/manifests/cmd/ns_instrumentation_env_variables.json +++ b/integration-tests/manifests/cmd/ns_instrumentation_env_variables.json @@ -2,5 +2,5 @@ "OTEL_TRACES_SAMPLER":"traceidratio", "OTEL_TRACES_SAMPLER_ARG": "0.5", "OTEL_EXPORTER_OTLP_ENDPOINT":"http://example.com/collector", - "OTEL_PROPAGATORS": "tracecontext,baggage,b3" + "OTEL_PROPAGATORS": "tracecontext,baggage,b3,xray" } \ No newline at end of file diff --git a/integration-tests/manifests/cmd/validate_instrumentation_vars.go b/integration-tests/manifests/cmd/validate_instrumentation_vars.go index 979e8c462..96cca63e2 100644 --- a/integration-tests/manifests/cmd/validate_instrumentation_vars.go +++ b/integration-tests/manifests/cmd/validate_instrumentation_vars.go @@ -52,7 +52,10 @@ func main() { } func verifyInstrumentationEnvVariables(clientset *kubernetes.Clientset, namespace, jsonPath string) bool { - podList, err := clientset.CoreV1().Pods(namespace).List(context.TODO(), metav1.ListOptions{LabelSelector: "app=nginx"}) + podList, err := clientset.CoreV1().Pods(namespace).List(context.TODO(), metav1.ListOptions{ + LabelSelector: "app=nginx", + FieldSelector: "status.phase!=Terminating", + }) if err != nil { fmt.Println("Error retrieving pods:", err) return false diff --git a/integration-tests/manifests/sample-instrumentation.yaml b/integration-tests/manifests/sample-instrumentation.yaml index 899bb137c..d7158042d 100644 --- a/integration-tests/manifests/sample-instrumentation.yaml +++ b/integration-tests/manifests/sample-instrumentation.yaml @@ -16,4 +16,5 @@ spec: propagators: - tracecontext - baggage - - b3 \ No newline at end of file + - b3 + - xray \ No newline at end of file diff --git a/integration-tests/python-java/default_instrumentation_python-java_env_variables.json b/integration-tests/python-java/default_instrumentation_python-java_env_variables.json new file mode 100644 index 000000000..cb2f787e9 --- /dev/null +++ b/integration-tests/python-java/default_instrumentation_python-java_env_variables.json @@ -0,0 +1,17 @@ + +{ + "PYTHONPATH": "/otel-auto-instrumentation-python/opentelemetry/instrumentation/auto_instrumentation:/otel-auto-instrumentation-python", + "OTEL_AWS_APP_SIGNALS_ENABLED": "true", + "OTEL_TRACES_SAMPLER_ARG": "endpoint=http://cloudwatch-agent.amazon-cloudwatch:2000", + "OTEL_TRACES_SAMPLER": "xray", + "OTEL_EXPORTER_OTLP_PROTOCOL": "http/protobuf", + "OTEL_EXPORTER_OTLP_TRACES_ENDPOINT": "http://cloudwatch-agent.amazon-cloudwatch:4316/v1/traces", + "OTEL_AWS_APP_SIGNALS_EXPORTER_ENDPOINT": "http://cloudwatch-agent.amazon-cloudwatch:4316/v1/metrics", + "OTEL_METRICS_EXPORTER": "none", + "OTEL_PYTHON_DISTRO": "aws_distro", + "OTEL_PYTHON_CONFIGURATOR": "aws_configurator", + "OTEL_SMP_ENABLED": "true", + "OTEL_AWS_SMP_EXPORTER_ENDPOINT": "http://cloudwatch-agent.amazon-cloudwatch:4316/v1/metrics", + "JAVA_TOOL_OPTIONS": "-javaagent:/otel-auto-instrumentation-java/javaagent.jar" + +} \ No newline at end of file diff --git a/integration-tests/python-java/sample-deployment-python-java.yaml b/integration-tests/python-java/sample-deployment-python-java.yaml new file mode 100644 index 000000000..91d9c7a8c --- /dev/null +++ b/integration-tests/python-java/sample-deployment-python-java.yaml @@ -0,0 +1,21 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: nginx +spec: + selector: + matchLabels: + app: nginx + template: + metadata: + labels: + app: nginx + annotations: + instrumentation.opentelemetry.io/inject-python: "true" + instrumentation.opentelemetry.io/inject-java: "true" + spec: + containers: + - name: nginx + image: nginx:1.14.2 + restartPolicy: Always +status: {} \ No newline at end of file