This sample demonstrates how to use the OpenTelemetry GCP Auth Extension to configure the OpenTelemetry SDK in a manually instrumented application and export telemetry to Google Cloud using OTLP exporters for both traces and metrics.
First, ensure you have Google Cloud credentials available on your machine:
gcloud auth application-default loginExecuting this command will save your application credentials to the default path:
- Linux, macOS:
$HOME/.config/gcloud/application_default_credentials.json - Windows:
%APPDATA%\gcloud\application_default_credentials.json
Next, set the GOOGLE_CLOUD_PROJECT environment variable to your GCP project ID:
export GOOGLE_CLOUD_PROJECT="your-gcp-project-id"This environment variable is used by the GCP Auth Extension to identify the project.
To run the sample from the repository root, use the following Gradle command:
./gradlew :examples-autoconf-auth-extension:runRunning this sample will generate traces and metrics and export them to Google Cloud via OTLP.
The sample uses OpenTelemetry SDK Autoconfigure. The following system properties are configured in build.gradle and can be overridden or set as environment variables:
otel.exporter.otlp.endpoint: Set tohttps://telemetry.googleapis.comfor Google Cloud OTLP receiver.otel.traces.exporter: Set tootlpto use OTLP exporter for traces.otel.metrics.exporter: Set tootlpto use OTLP exporter for metrics.otel.exporter.otlp.protocol: Set tohttp/protobufas required by Google Cloud OTLP receiver.