This sample app runs a server "service" that listens for requests from a client "app" running as a CronJob.
- OpenTelemetry Operator installed in your cluster
- Artifact Registry set up in your GCP project (see the main README.md)
- An
OpenTelemetryCollectorobject already created in the current namespace, such as the samplecollector-config.yamlfrom the main README - An
Instrumentationobject already created in the current namespace, such as the sampleinstrumentation.yamlfrom the main README
-
Build the sample app and service:
make buildThis command will also push the app's images to the Artifact Registry you set up in the Prerequisites. It also updates the local manifests to refer to your image registry.
-
Deploy the apps in your cluster:
kubectl apply -f k8s/.If you want to run the sample app in a specific namespace, pass
-n <your-namespace>. -
Run the following commands to patch the app CronJob and service Deployment for auto-instrumentation:
kubectl patch deployment.apps/javashowcase-service -p '{"spec":{"template":{"metadata":{"annotations":{"instrumentation.opentelemetry.io/inject-java": "true"}}}}}' kubectl patch cronjob.batch/javashowcase-app -p '{"spec":{"jobTemplate":{"spec":{"template":{"metadata":{"annotations":{"instrumentation.opentelemetry.io/inject-java": "true"}}}}}}}'These commands will use the
Instrumentationcreated as part of the Prerequisites.
To stream logs from the otel-collector, which will include spans from this sample application, run:
kubectl logs deployment/otel-collector -f
Alternatively, follow the cloud-trace recipe to view your spans in Google Cloud Trace.