Recently upgraded to Springboot 3, using Spring Cloud Starter Gateway to act as a passthrough to backend APIs. When a request is processed by the Spring Cloud Starter Gateway, this gateway logs with traceId: 123, but when the request is calling the backend API a different traceId is used. Is this a defect with Spring Cloud Starter Gateway?
In Springboot 2.7, the same traceId was used when calling the backend API. In Springboot 3 seems like a different trace/span is generated.
Example below, Spring Cloud Starter Gateway logs using traceId: 63e1e181101f1c65b724a0dc87fd130f, but a different trace 63e1e18135962333c2276418e27154d4 is generated.
{
"timestamp":"2023-02-07T05:28:33.526Z",
"level":"DEBUG",
"thread":"reactor-http-nio-3",
"mdc":{
"traceId":"**63e1e181101f1c65b724a0dc87fd130f**",
"spanId":"b724a0dc87fd130f",
"Store-Message-Id":"b83deeb0-d752-4a8d-8ef9-51e62f85079d"
},
"logger":"org.springframework.cloud.gateway.filter.headers.observation.ObservedRequestHttpHeadersFilter",
"message":"Client observation {name=http.client.requests(null), error=null, context=name='http.client.requests', contextualName='null', error='null', lowCardinalityKeyValues=[http.method='POST', http.status_code='UNKNOWN', spring.cloud.gateway.route.id='assignuser', spring.cloud.gateway.route.uri='http://localhost:8092'], highCardinalityKeyValues=[http.uri='http://localhost:8089/WS/ShipmentListService'], map=[class io.micrometer.core.instrument.LongTaskTimer$Sample='SampleImpl{duration(seconds)=2.53E-4, duration(nanos)=253000.0, startTimeNanos=38506956965000}', class io.micrometer.tracing.handler.TracingObservationHandler$TracingContext='TracingContext{span=NoopSpan(63e1e18135962333c2276418e27154d4/fc6858e5cd2fb745), scope=null}', class io.micrometer.core.instrument.Timer$Sample='io.micrometer.core.instrument.Timer$Sample@6c9c71a'], parentObservation={name=http.server.requests(null), error=null, context=name='http.server.requests', contextualName='null', error='null', lowCardinalityKeyValues=[exception='none', method='POST', outcome='SUCCESS', status='200', uri='UNKNOWN'], highCardinalityKeyValues=[http.url='/assignuser/WS/ShipmentListService'], map=[class io.micrometer.core.instrument.LongTaskTimer$Sample='SampleImpl{duration(seconds)=0.038375, duration(nanos)=3.8375E7, startTimeNanos=38506918962541}', class io.micrometer.tracing.handler.TracingObservationHandler$TracingContext='TracingContext{span=NoopSpan(**63e1e18135962333c2276418e27154d4**/c2276418e27154d4), scope=null}', class io.micrometer.core.instrument.Timer$Sample='io.micrometer.core.instrument.Timer$Sample@1b7b018b'], parentObservation=null}} created for the request. New headers are [Content-Type:\"text/xml\", User-Agent:\"PostmanRuntime/7.28.0\", Accept:\"*/*\", Postman-Token:\"45ec1e82-bedd-4cb1-b63d-9fde5e7f13c6\", Host:\"localhost:8089\", Accept-Encoding:\"gzip, deflate, br\", Content-Length:\"1443\", Forwarded:\"proto=http;host=\"localhost:8089\";for=\"[0:0:0:0:0:0:0:1]:58382\"\", X-Forwarded-For:\"0:0:0:0:0:0:0:1\", X-Forwarded-Proto:\"http\", X-Forwarded-Prefix:\"/assignuser\", X-Forwarded-Port:\"8089\", X-Forwarded-Host:\"localhost:8089\", b3:\"63e1e18135962333c2276418e27154d4-fc6858e5cd2fb745-0\"]",
"context":"default"
}
Comment From: wilkinsona
Is this a defect with Spring Cloud Starter Gateway?
It's impossible for us to tell for sure what you've described thus far, but I think that's a good place to start. Please open a Spring Cloud Gateway issue and provide the team with a minimal reproducible example of the problem.