This repo hosts samples for working with the OpenTelemetry Operator on GCP.
- A running GKE cluster
- Helm (for GKE Autopilot)
cert-manager
installed in your cluster
For GKE Autopilot, install cert-manager
with the following Helm commands:
helm repo add jetstack https://charts.jetstack.io
helm repo update
helm install \
--create-namespace \
--namespace cert-manager \
--set installCRDs=true \
--set global.leaderElection.namespace=cert-manager \
--set extraArgs={--issuer-ambient-credentials=true} \
cert-manager jetstack/cert-manager
Install the latest release of the Operator with:
kubectl apply -f https://github.com/open-telemetry/opentelemetry-operator/releases/latest/download/opentelemetry-operator.yaml
Set up an instance of the OpenTelemetry Collector by creating an OpenTelemetryCollector
object.
The one in this repo sets up a basic OTLP receiver and logging exporter:
kubectl apply -f collector-config.yaml
The Operator offers auto-instrumentation of application pods by adding an annotation to the Pod spec.
First, create an Instrumentation
Custom Resource
that contains the settings for the instrumentation. We have provided a sample resource
in instrumentation.yaml
:
kubectl apply -f instrumentation.yaml
With a Collector and auto-instrumentation set up, you can experiment with it using one of the sample applications, or skip right to the recipes if you already have an application running.
The sample-apps/
folder contains basic apps to demonstrate collecting traces with
the operator in various languages.
Each sample app can be built as a container and deployed in a GKE cluster with a few
commands. First, run make setup
to create an Artifact Registry if you don't already
have one:
export REGISTRY_LOCATION=us-central1
export CONTAINER_REGISTRY=otel-operator
make setup
The build and deploy commands for each app use the environment variables from above to run
the container image from your registry, along with GCLOUD_PROJECT
.
Make sure to set the GCLOUD_PROJECT
environment variable before running these:
export GCLOUD_PROJECT=my-gke-project
Then run one of the language-based sample apps below:
- NodeJS
- Java (coming soon)
- Python (coming soon)
- DotNET (coming soon)
- Go (coming soon)
Each of these sample apps works well with the recipes listed below.
The recipes
directory holds different sample use cases for working with the
operator and auto-instrumentation along with setup guides for each recipe. Currently there are:
- Trace sampling configuration
- Trace filtering (coming soon)
- Trace enhancements (coming soon)
- Cloud Trace integration
See CONTRIBUTING.md
for details.
Apache 2.0; see LICENSE
for details.