x-b3-sampled header selalu disetel ke 0 saat mengakses layanan melalui pengontrol masuk
Saya telah menginstal Kubernetes 1.17.5 dan Istio 1.6.8 dengan profil demo.
Dan inilah pengaturan pengujian saya [nginx-ingress-controller] -> [proxy <-> ServiceA] -> [proxy <-> ServiceB]
- Proksi untuk serviceA dan serviceB disuntikkan secara otomatis oleh Istio (istio-injection = diaktifkan)
- Pengontrol ingress Nginx tidak mengaktifkan pelacakan dan tidak memiliki proxy utusan sebagai bantuan
- ServiceA meneruskan header pelacakan ke ServiceB
- Saya mencoba melacak panggilan dari ServiceA ke ServiceB dan tidak peduli tentang Ingress-> ServiceA span saat ini
Ketika saya mengirim permintaan ke ingress controller, saya dapat melihat bahwa ServiceA menerima semua header pelacakan yang diperlukan dari proxy
x-b3-traceid: d9bab9b4cdc8d0a7772e27bb7d15332f
x-request-id: 60e82827a270070cfbda38c6f30f478a
x-envoy-internal: true
x-b3-spanid: 772e27bb7d15332f
x-b3-sampled: 0
x-forwarded-proto: http
Problem is x-b3-sampled is always set to 0 and no spans/traces are getting pushed to Jaeger
Few things I've tried
- I've added Gateway and VirtualService to ServiceA to expose it through Istio ingressgateway. When I send traffic through ingressgateway everything works as expected. I can see traces [ingress-gateway]->[ServiceA]->[ServiceB] in the JaegerUI
- I've also tried to install Istio with custom config and play with tracing related parameters with no luck.
Here is the config I've tried to use
apiVersion: install.istio.io/v1alpha1
kind: IstioOperator
spec:
meshConfig:
enableTracing: true
defaultConfig:
tracing:
sampling: 100
addonComponents:
tracing:
enabled: true
grafana:
enabled: false
istiocoredns:
enabled: false
kiali:
enabled: false
prometheus:
enabled: false
values:
tracing:
enabled: true
pilot:
traceSampling: 100
Jawaban
After few days of digging I've figured it out. Problem is in the format of the x-request-id
header that nginx ingress controller uses.
Envoy proxy expects it to be an UUID (e.g. x-request-id: 3e21578f-cd04-9246-aa50-67188d790051
) but ingrex controller passes it as a non-formatted random string (x-request-id: 60e82827a270070cfbda38c6f30f478a
). When I pass properly formatted x-request-id header in the request to ingress controller its getting passed down to envoy proxy and request is getting sampled as expected. I also tried to remove x-request-id header from the request from ingress controller to ServiceA with a simple EnvoyFilter. And it also works as expected. Envoy proxy generates a new x-request-id and request is getting traced.