This is a sample app consisting of a basic client and server written in Go. The server listens for requests which the client makes on a timed loop.
- OpenTelemetry Operator installed in your cluster
- Artifact Registry set up in your GCP project (see the main README.md)
- An
OpenTelemetryCollector
object already created in the current namespace, such as the samplecollector-config.yaml
from the main README - An
Instrumentation
object already created in the current namespace, such as the sampleinstrumentation.yaml
from the main README
-
Build the sample app:
make build
This command will also update the local manifests to refer to your image location.
-
Push the local image to the Artifact Registry you created in the setup steps (if you did not create one, or are using an already created registry, make sure to set the
REGISTRY_LOCATION
andCONTAINER_REGISTRY
variables):make push
-
Deploy the app 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
andserver
deployments for auto-instrumentation:kubectl patch deployment.apps/goshowcase-app -p '{"spec":{"template":{"metadata":{"annotations":{"instrumentation.opentelemetry.io/inject-go": "true", "instrumentation.opentelemetry.io/otel-go-auto-target-exe": "/app/main"}}}}}' kubectl patch deployment.apps/goshowcase-server -p '{"spec":{"template":{"metadata":{"annotations":{"instrumentation.opentelemetry.io/inject-go": "true", "instrumentation.opentelemetry.io/otel-go-auto-target-exe": "/server/main"}}}}}'
These commands will use the
Instrumentation
created 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.