Skip to content

Instantly share code, notes, and snippets.

@Brunomachadob
Last active October 27, 2020 09:43
Show Gist options
  • Save Brunomachadob/d998a59c27ada3cacfafa95d2f3ecd9f to your computer and use it in GitHub Desktop.
Save Brunomachadob/d998a59c27ada3cacfafa95d2f3ecd9f to your computer and use it in GitHub Desktop.
Envoy tracing custom_tags modifying x-request-id

Envoy is changing the x-request-id version when we configure the connection manager with:

tracing: {}

I configured Envoy with the upstream cluster pointing to postman-echo.com which will return as response body, the request headers sent.

curl --location --request GET 'localhost:8080/headers' \
--header 'x-request-id: 968ea8f8-3806-45c9-8228-8d3dde5df3b4' \
--header 'x-another-id: 968ea8f8-3806-45c9-8228-8d3dde5df3b4'
{
    "headers":{
        "x-forwarded-proto":"http",
        "x-forwarded-port":"80",
        "host":"localhost",
        "x-amzn-trace-id":"Root=1-5f97d990-6daf0ed27c296cad5e916f6c",
        "content-length":"0",
        "user-agent":"curl/7.64.1",
        "accept":"*/*",
        "x-request-id":"968ea8f8-3806-95c9-8228-8d3dde5df3b4",
        "x-another-id":"968ea8f8-3806-45c9-8228-8d3dde5df3b4",
        "x-envoy-expected-rq-timeout-ms":"15000"
    }
}
-968ea8f8-3806-45c9-8228-8d3dde5df3b4
+968ea8f8-3806-95c9-8228-8d3dde5df3b4

My use case is the one below, as I need to copy the x-request-id as a tag:

tracing:
  custom_tags:
    - tag: x-request-id
        request_header:
        name: x-request-id

But as you can try it out here, only by adding an empty tracing: {} the problem happens.

Also, the problem only happens with the x-request-id, as you can see I used also a x-another-id and that one did not change.

version: '3'
services:
envoy:
image: envoyproxy/envoy:v1.16-latest
ports:
- "8080:8080"
volumes:
- ./envoy.yaml:/opt/envoy.yaml
entrypoint:
- sh
- -c
- /usr/local/bin/envoy -c /opt/envoy.yaml
static_resources:
listeners:
- name: main
address:
socket_address:
address: 0.0.0.0
port_value: 8080
filter_chains:
- filters:
- name: envoy.http_connection_manager
config:
stat_prefix: ingress_http
codec_type: auto
generate_request_id: true
preserve_external_request_id: true
tracing: {}
route_config:
name: local_route
virtual_hosts:
- name: local_service
domains:
- "*"
routes:
- match:
prefix: "/"
route:
cluster: echo_service
http_filters:
- name: envoy.router
config: {}
clusters:
- name: echo_service
connect_timeout: 0.25s
type: STRICT_DNS
lb_policy: ROUND_ROBIN
hosts:
- socket_address:
address: postman-echo.com
port_value: 80
admin:
access_log_path: "/dev/null"
address:
socket_address:
address: 0.0.0.0
port_value: 8001
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment