Distributed tracing not possible when using Google Cloud Load Balancer

This is Hasegawa (@rarirureluis) from the Service Reliability Group (SRG) of the Media Headquarters.
#SRG(Service Reliability Group) mainly provides cross-sectional support for the infrastructure of our media services, improving existing services, launching new ones, contributing to OSS, etc.
This article explains an issue where distributed tracing does not work as expected in an environment using Google Cloud Load Balancer.
 

Introduction


In environments that use Google Cloud Load Balancer, you may encounter issues with distributed tracing not working as expected.
traceparent
This article explains the cause of this issue and provides specific workarounds.

Symptoms of the issue: The flag in the traceparent header changes


traceparent
This header is defined by the W3C Trace Context standard and contains information such as the trace ID, span ID, and sampling flag.
traceparent
-00
This causes problems as requests that you want to trace are not sampled and cannot be tracked by the distributed tracing system.

Cause: Known bug in Load Balancer


This issue is caused by a known bug in the Google Cloud Load Balancer.
This issue has been filed in Google's issue tracker and is currently being worked on to resolve.
X-Cloud-Trace-Context
o=0
-00
o=1
-01

Workaround: Rewrite the headers at the CDN


As an effective workaround for this issue, if you have a CDN in front of the Google Cloud Load Balancer, you can use the CDN's functionality to rewrite the HTTP header.
Specifically, add the following rules to your CDN settings:
  1. traceparent
  1. o=1
X-Cloud-Trace-Context
  • traceparent
  • X-Cloud-Trace-Context
  • 1
X-Cloud-Trace-Context;o=1
 

Conclusion


traceparent
X-Cloud-Trace-Context
If you are having trouble implementing distributed tracing on a system that uses Google Cloud Load Balancer, consider using this workaround.
SRG is looking for people to work with us. If you are interested, please contact us here.