Distributed tracing not working when using Google Cloud Load Balancer

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

Introduction


In environments using Google Cloud Load Balancer, you may encounter issues where distributed tracing does not work as expected.
traceparent
This article explains the cause of this issue and provides specific workarounds.

Symptom: 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 Load Balancer bug


This issue is caused by a known bug in 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 headers at your CDN


An effective workaround for this issue is to use the CDN's functionality to rewrite the HTTP headers in environments where a CDN is placed in front of the Google Cloud Load Balancer.
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're having trouble implementing distributed tracing on a system that uses Google Cloud Load Balancer, consider implementing this workaround.
SRG is looking for people to work with us. If you're interested, please contact us here.