TraceContext not propgate to ErrorPage
i custom a 500 errorpage
private static class CustomerErrorPageRegistrar implements ErrorPageRegistrar {
// Register your error pages and url paths.
@Override
public void registerErrorPages(ErrorPageRegistry registry) {
ErrorPage error401Page = new ErrorPage(HttpStatus.UNAUTHORIZED, "/error401");
ErrorPage error404Page = new ErrorPage(HttpStatus.NOT_FOUND, "/error404");
ErrorPage error412Page = new ErrorPage(SignatureVerifyException.class, "/error403");
ErrorPage error500Page = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/error");
registry.addErrorPages(error401Page, error404Page, error412Page, error500Page);
}
}
when i access tracer in ErrorPage controller
private String getTraceId() {
final Tracer tracer = this.tracer.getIfAvailable();
if (tracer != null) {
return tracer.currentSpan().context().traceIdString();
}
return null;
}
then current span context report null.
with: spring-cloud-sleuth-core:2.0.0.M9
we don't have a test like this in brave.. possibly we need to address it there in the brave-instrumentation-spring-webmvc project
On Wed, Apr 18, 2018 at 9:14 AM, yungoo [email protected] wrote:
i custom a 500 errorpage
` private static class CustomerErrorPageRegistrar implements ErrorPageRegistrar {
// Register your error pages and url paths. @Override public void registerErrorPages(ErrorPageRegistry registry) { ErrorPage error401Page = new ErrorPage(HttpStatus.UNAUTHORIZED, "/error401"); ErrorPage error404Page = new ErrorPage(HttpStatus.NOT_FOUND, "/error404"); ErrorPage error412Page = new ErrorPage(SignatureVerifyException.class, "/error403"); ErrorPage error500Page = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/error"); registry.addErrorPages(error401Page, error404Page, error412Page, error500Page); }}`
when i access tracer in ErrorPage controller
private String getTraceId() { final Tracer tracer = this.tracer.getIfAvailable(); if (tracer != null) { return tracer.currentSpan().context().traceIdString(); } return null; } tracer.currentSpan().context() is null
with: spring-cloud-sleuth-core:2.0.0.M9
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/spring-cloud/spring-cloud-sleuth/issues/948, or mute the thread https://github.com/notifications/unsubscribe-auth/AAD617-qeDy3-K49VhYvTbjXOFMSFrT9ks5tppNogaJpZM4TZRYk .
the unsuccessful request maybe redirect to error page, i think new scope should be created.
spring-cloud-sleuth-core:2.0.0.M8 works fine. Since TraceHandlerInterceptor will create a scope for it:
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response,
Object handler) throws Exception {
String spanName = spanName(handler);
boolean continueSpan = getRootSpanFromAttribute(request) != null;
Span span = continueSpan ? getRootSpanFromAttribute(request) :
httpTracing().tracing().tracer().nextSpan().name(spanName).start();
try (Tracer.SpanInScope ws = httpTracing().tracing().tracer().withSpanInScope(span)) {
if (log.isDebugEnabled()) {
log.debug("Handling span " + span);
}
addClassMethodTag(handler, span);
addClassNameTag(handler, span);
setSpanInAttribute(request, span);
if (!continueSpan) {
setNewSpanCreatedAttribute(request, span);
}
}
return true;
}
but M9 no module will do this work.
Thanks for your great works. Best regards!
This bug should probably be marked with milestone 2.0.0.RC2 since it was fixed by https://github.com/spring-cloud/spring-cloud-sleuth/pull/962