open-telemetry / opentelemetry-cpp-contrib

https://opentelemetry.io/
Apache License 2.0
121 stars 128 forks source link

Support for legacy Cloud Trace propagation header #447

Open bambuchaAdm opened 1 month ago

bambuchaAdm commented 1 month ago

Describe your environment

We are using this module as part of ingress-nginx under Global application load balancer on Google Cloud Platform. What was heavy used feature by us was connection of logged request by LB had connected tracing information. As GCLB supports right now only legacy trace propagation mechanism and there is no immediate view on updates to WC3 standards we would like to add support for understanding X-Cloud-Trace-Context for nginx tracing at least on input.

As otel module for nginx does not understood that trace exist on request it create new one and propagated using WC3 headers. Our application are implemented with guidlines to prefere WC3 over legacy traces and this "disconnects" traces from LB from other system trace.

Versios: Ingress-Nginx helm chart version: 4.10.0 Ingress-Nginx: v1.10.0 Nginx: 1.25.3 k8s: v1.29.1-gke.1589020 opentelemetry-contrib-cpp: aaa51e2297bcb34297f3c7aa44fa790497d2f7f3

Steps to reproduce Deploy nginx under Classic Global Load balancer. Traces would differ between request and upstream of it. As consequence logs would also does not appear under same trace.

What is the expected behavior? Have ability to switch input to understood legacy Cloud Trace Format

What is the actual behavior? Legacy Cloud Trace propagation header is ignored

Additional context I put report about Import/Export implementation to main library to not duplicate code as probably there are still services that are understood/produce only legacy traces https://github.com/open-telemetry/opentelemetry-cpp/issues/2683

marcalff commented 1 month ago

Thanks for the report, labeling as a feature request.

Guidelines for submitting a PR to implement this feature below.


To support X-Cloud-Trace-Context propagation headers, it is necessary to implement a custom propagator for this header format.

This propagator should be:

A custom propagator implementation consists of a subclass of class opentelemetry::context::propagation::TextMapCarrier from the opentelemetry-cpp API

To use this custom propagator in an application, use opentelemetry::context::propagation::GlobalTextMapPropagator::SetGlobalPropagator() to set the global propagator singleton.