Simplify servlet advice (#2972)
* Simplify servlet advice * fix sampling * Trigger Build * use the same logic as previously, maybe this helps agains glassfish smoke-test failure
This commit is contained in:
parent
615d51ad2a
commit
406eabef20
|
@ -53,39 +53,29 @@ public class Servlet3Advice {
|
||||||
}
|
}
|
||||||
|
|
||||||
Context attachedContext = tracer().getServerContext(httpServletRequest);
|
Context attachedContext = tracer().getServerContext(httpServletRequest);
|
||||||
if (attachedContext != null) {
|
if (attachedContext != null && tracer().needsRescoping(attachedContext)) {
|
||||||
// We are inside nested servlet/filter/app-server span, don't create new span
|
|
||||||
if (tracer().needsRescoping(attachedContext)) {
|
|
||||||
attachedContext =
|
attachedContext =
|
||||||
tracer().updateContext(attachedContext, httpServletRequest, mappingResolver, servlet);
|
tracer().updateContext(attachedContext, httpServletRequest, mappingResolver, servlet);
|
||||||
scope = attachedContext.makeCurrent();
|
scope = attachedContext.makeCurrent();
|
||||||
return;
|
// We are inside nested servlet/filter/app-server span, don't create new span
|
||||||
}
|
|
||||||
|
|
||||||
// We already have attached context to request but this could have been done by app server
|
|
||||||
// instrumentation, if needed update span with info from current request.
|
|
||||||
Context currentContext = Java8BytecodeBridge.currentContext();
|
|
||||||
Context updatedContext =
|
|
||||||
tracer().updateContext(currentContext, httpServletRequest, mappingResolver, servlet);
|
|
||||||
if (updatedContext != currentContext) {
|
|
||||||
// runOnceUnderAppServer updated context, need to re-scope
|
|
||||||
scope = updatedContext.makeCurrent();
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Context currentContext = Java8BytecodeBridge.currentContext();
|
Context currentContext = Java8BytecodeBridge.currentContext();
|
||||||
if (currentContext != null
|
if (attachedContext != null
|
||||||
&& Java8BytecodeBridge.spanFromContext(currentContext).isRecording()) {
|
|| Java8BytecodeBridge.spanFromContext(currentContext).isRecording()) {
|
||||||
// We already have a span but it was not created by servlet instrumentation.
|
// Update context with info from current request to ensure that server span gets the best
|
||||||
// In case it was created by app server integration we need to update it with info from
|
// possible name.
|
||||||
// current request.
|
// In case server span was created by app server instrumentations calling updateContext
|
||||||
|
// returns a new context that contains servlet context path that is used in other
|
||||||
|
// instrumentations for naming server span.
|
||||||
Context updatedContext =
|
Context updatedContext =
|
||||||
tracer().updateContext(currentContext, httpServletRequest, mappingResolver, servlet);
|
tracer().updateContext(currentContext, httpServletRequest, mappingResolver, servlet);
|
||||||
if (currentContext != updatedContext) {
|
if (currentContext != updatedContext) {
|
||||||
// updateContext updated context, need to re-scope
|
// updateContext updated context, need to re-scope
|
||||||
scope = updatedContext.makeCurrent();
|
scope = updatedContext.makeCurrent();
|
||||||
}
|
}
|
||||||
|
// We are inside nested servlet/filter/app-server span, don't create new span
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,39 +54,29 @@ public class JakartaServletServiceAdvice {
|
||||||
}
|
}
|
||||||
|
|
||||||
Context attachedContext = tracer().getServerContext(httpServletRequest);
|
Context attachedContext = tracer().getServerContext(httpServletRequest);
|
||||||
if (attachedContext != null) {
|
if (attachedContext != null && tracer().needsRescoping(attachedContext)) {
|
||||||
// We are inside nested servlet/filter/app-server span, don't create new span
|
|
||||||
if (tracer().needsRescoping(attachedContext)) {
|
|
||||||
attachedContext =
|
attachedContext =
|
||||||
tracer().updateContext(attachedContext, httpServletRequest, mappingResolver, servlet);
|
tracer().updateContext(attachedContext, httpServletRequest, mappingResolver, servlet);
|
||||||
scope = attachedContext.makeCurrent();
|
scope = attachedContext.makeCurrent();
|
||||||
return;
|
// We are inside nested servlet/filter/app-server span, don't create new span
|
||||||
}
|
|
||||||
|
|
||||||
// We already have attached context to request but this could have been done by app server
|
|
||||||
// instrumentation, if needed update span with info from current request.
|
|
||||||
Context currentContext = Java8BytecodeBridge.currentContext();
|
|
||||||
Context updatedContext =
|
|
||||||
tracer().updateContext(currentContext, httpServletRequest, mappingResolver, servlet);
|
|
||||||
if (updatedContext != currentContext) {
|
|
||||||
// runOnceUnderAppServer updated context, need to re-scope
|
|
||||||
scope = updatedContext.makeCurrent();
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Context currentContext = Java8BytecodeBridge.currentContext();
|
Context currentContext = Java8BytecodeBridge.currentContext();
|
||||||
if (currentContext != null
|
if (attachedContext != null
|
||||||
&& Java8BytecodeBridge.spanFromContext(currentContext).isRecording()) {
|
|| Java8BytecodeBridge.spanFromContext(currentContext).isRecording()) {
|
||||||
// We already have a span but it was not created by servlet instrumentation.
|
// Update context with info from current request to ensure that server span gets the best
|
||||||
// In case it was created by app server integration we need to update it with info from
|
// possible name.
|
||||||
// current request.
|
// In case server span was created by app server instrumentations calling updateContext
|
||||||
|
// returns a new context that contains servlet context path that is used in other
|
||||||
|
// instrumentations for naming server span.
|
||||||
Context updatedContext =
|
Context updatedContext =
|
||||||
tracer().updateContext(currentContext, httpServletRequest, mappingResolver, servlet);
|
tracer().updateContext(currentContext, httpServletRequest, mappingResolver, servlet);
|
||||||
if (currentContext != updatedContext) {
|
if (currentContext != updatedContext) {
|
||||||
// updateContext updated context, need to re-scope
|
// updateContext updated context, need to re-scope
|
||||||
scope = updatedContext.makeCurrent();
|
scope = updatedContext.makeCurrent();
|
||||||
}
|
}
|
||||||
|
// We are inside nested servlet/filter/app-server span, don't create new span
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue