In Google Cloud Platform (GCP), Load Balancers play a crucial role in distributing incoming traffic across backend instances to ensure high availability and reliability of your services. However, when GCP Load Balancers handle the initial request from a client, a unique challenge arises regarding trace export.
GCP Load Balancers are responsible for creating the initial request span. This root span, which represents the entire lifecycle of a request, is created within the Load Balancer itself. Unfortunately, due to the architectural design of GCP Load Balancers, this root span cannot be directly exported to external observability platforms, except to Google BigQuery.
This tool is a Proof of Concept (PoC) as to how one could export the root span into native OpenTelemetry Protocol (OTLP) format.
- Clone the repository to your local machine:
git clone https://github.com/yourusername/gcp-cloud-trace-otel-converter.git
- Build the tool:
cd gcp-cloud-trace-otel-converter
go build
- Authenticate to Google Cloud
gcloud auth login --update-ad
- Export credentials
export GOOGLE_CREDENTIALS=$(cat /Users/${USER}/.config/gcloud/application_default_credentials.json)
export GOOGLE_APPLICATION_CREDENTIALS=/Users/${USER}/.config/gcloud/application_default_credentials.json
- Export your OTLP endpoint
export OTEL_EXPORTER_OTLP_ENDPOINT="localhost:4317"
- Run the tool
./gcp-cloud-trace-otel --project_id=foo-bar-dev-1a2b3c