Remove a few `ServerSpanNaming` usages (#4900)
* Remove a few ServerSpanNaming usages * revert vaadin changes
This commit is contained in:
parent
2531b6e569
commit
9e3bd5c18d
|
@ -17,6 +17,7 @@ public class GrailsServerSpanNaming {
|
|||
info.getActionName() != null
|
||||
? info.getActionName()
|
||||
: info.getControllerClass().getDefaultAction();
|
||||
// this is not the actual route/mapping, but it's the best thing that we have access to
|
||||
return ServletContextPath.prepend(context, "/" + info.getControllerName() + "/" + action);
|
||||
};
|
||||
|
||||
|
|
|
@ -5,12 +5,10 @@
|
|||
|
||||
package io.opentelemetry.javaagent.instrumentation.axis2;
|
||||
|
||||
import static io.opentelemetry.instrumentation.api.servlet.ServerSpanNaming.Source.CONTROLLER;
|
||||
import static io.opentelemetry.javaagent.instrumentation.axis2.Axis2Singletons.instrumenter;
|
||||
|
||||
import io.opentelemetry.context.Context;
|
||||
import io.opentelemetry.context.Scope;
|
||||
import io.opentelemetry.instrumentation.api.servlet.ServerSpanNaming;
|
||||
import org.apache.axis2.jaxws.core.MessageContext;
|
||||
|
||||
public final class Axis2Helper {
|
||||
|
@ -24,8 +22,7 @@ public final class Axis2Helper {
|
|||
Context parentContext = Context.current();
|
||||
|
||||
Axis2Request request = new Axis2Request(message);
|
||||
ServerSpanNaming.updateServerSpanName(
|
||||
parentContext, CONTROLLER, Axis2ServerSpanNaming.SERVER_SPAN_NAME, request);
|
||||
Axis2ServerSpanNaming.updateServerSpan(parentContext, request);
|
||||
|
||||
if (!instrumenter().shouldStart(parentContext, request)) {
|
||||
return;
|
||||
|
|
|
@ -5,28 +5,34 @@
|
|||
|
||||
package io.opentelemetry.javaagent.instrumentation.axis2;
|
||||
|
||||
import io.opentelemetry.instrumentation.api.servlet.ServerSpanNameSupplier;
|
||||
import io.opentelemetry.api.trace.Span;
|
||||
import io.opentelemetry.context.Context;
|
||||
import io.opentelemetry.instrumentation.api.tracer.ServerSpan;
|
||||
import io.opentelemetry.javaagent.bootstrap.servlet.ServletContextPath;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import org.apache.axis2.jaxws.core.MessageContext;
|
||||
|
||||
public class Axis2ServerSpanNaming {
|
||||
public final class Axis2ServerSpanNaming {
|
||||
|
||||
public static final ServerSpanNameSupplier<Axis2Request> SERVER_SPAN_NAME =
|
||||
(context, axis2Request) -> {
|
||||
String spanName = axis2Request.spanName();
|
||||
MessageContext message = axis2Request.message();
|
||||
HttpServletRequest request =
|
||||
(HttpServletRequest) message.getMEPContext().get("transport.http.servletRequest");
|
||||
if (request != null) {
|
||||
String servletPath = request.getServletPath();
|
||||
if (!servletPath.isEmpty()) {
|
||||
spanName = servletPath + "/" + spanName;
|
||||
}
|
||||
}
|
||||
public static void updateServerSpan(Context context, Axis2Request axis2Request) {
|
||||
Span serverSpan = ServerSpan.fromContextOrNull(context);
|
||||
if (serverSpan == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
return ServletContextPath.prepend(context, spanName);
|
||||
};
|
||||
String spanName = axis2Request.spanName();
|
||||
MessageContext message = axis2Request.message();
|
||||
HttpServletRequest request =
|
||||
(HttpServletRequest) message.getMEPContext().get("transport.http.servletRequest");
|
||||
if (request != null) {
|
||||
String servletPath = request.getServletPath();
|
||||
if (!servletPath.isEmpty()) {
|
||||
spanName = servletPath + "/" + spanName;
|
||||
}
|
||||
}
|
||||
|
||||
serverSpan.updateName(ServletContextPath.prepend(context, spanName));
|
||||
}
|
||||
|
||||
private Axis2ServerSpanNaming() {}
|
||||
}
|
||||
|
|
|
@ -5,12 +5,10 @@
|
|||
|
||||
package io.opentelemetry.javaagent.instrumentation.cxf;
|
||||
|
||||
import static io.opentelemetry.instrumentation.api.servlet.ServerSpanNaming.Source.CONTROLLER;
|
||||
import static io.opentelemetry.javaagent.instrumentation.cxf.CxfSingletons.instrumenter;
|
||||
|
||||
import io.opentelemetry.context.Context;
|
||||
import io.opentelemetry.context.Scope;
|
||||
import io.opentelemetry.instrumentation.api.servlet.ServerSpanNaming;
|
||||
import org.apache.cxf.interceptor.Fault;
|
||||
import org.apache.cxf.message.Exchange;
|
||||
import org.apache.cxf.message.Message;
|
||||
|
@ -31,8 +29,7 @@ public final class CxfHelper {
|
|||
return;
|
||||
}
|
||||
|
||||
ServerSpanNaming.updateServerSpanName(
|
||||
parentContext, CONTROLLER, CxfServerSpanNaming.SERVER_SPAN_NAME, request);
|
||||
CxfServerSpanNaming.updateServerSpanName(parentContext, request);
|
||||
|
||||
if (!instrumenter().shouldStart(parentContext, request)) {
|
||||
return;
|
||||
|
|
|
@ -5,29 +5,35 @@
|
|||
|
||||
package io.opentelemetry.javaagent.instrumentation.cxf;
|
||||
|
||||
import io.opentelemetry.instrumentation.api.servlet.ServerSpanNameSupplier;
|
||||
import io.opentelemetry.api.trace.Span;
|
||||
import io.opentelemetry.context.Context;
|
||||
import io.opentelemetry.instrumentation.api.tracer.ServerSpan;
|
||||
import io.opentelemetry.javaagent.bootstrap.servlet.ServletContextPath;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
public class CxfServerSpanNaming {
|
||||
public final class CxfServerSpanNaming {
|
||||
|
||||
public static final ServerSpanNameSupplier<CxfRequest> SERVER_SPAN_NAME =
|
||||
(context, cxfRequest) -> {
|
||||
String spanName = cxfRequest.spanName();
|
||||
if (spanName == null) {
|
||||
return null;
|
||||
}
|
||||
public static void updateServerSpanName(Context context, CxfRequest cxfRequest) {
|
||||
String spanName = cxfRequest.spanName();
|
||||
if (spanName == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
HttpServletRequest request = (HttpServletRequest) cxfRequest.message().get("HTTP.REQUEST");
|
||||
if (request != null) {
|
||||
String servletPath = request.getServletPath();
|
||||
if (!servletPath.isEmpty()) {
|
||||
spanName = servletPath + "/" + spanName;
|
||||
}
|
||||
}
|
||||
Span serverSpan = ServerSpan.fromContextOrNull(context);
|
||||
if (serverSpan == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
return ServletContextPath.prepend(context, spanName);
|
||||
};
|
||||
HttpServletRequest request = (HttpServletRequest) cxfRequest.message().get("HTTP.REQUEST");
|
||||
if (request != null) {
|
||||
String servletPath = request.getServletPath();
|
||||
if (!servletPath.isEmpty()) {
|
||||
spanName = servletPath + "/" + spanName;
|
||||
}
|
||||
}
|
||||
|
||||
serverSpan.updateName(ServletContextPath.prepend(context, spanName));
|
||||
}
|
||||
|
||||
private CxfServerSpanNaming() {}
|
||||
}
|
||||
|
|
|
@ -5,14 +5,12 @@
|
|||
|
||||
package io.opentelemetry.javaagent.instrumentation.metro;
|
||||
|
||||
import static io.opentelemetry.instrumentation.api.servlet.ServerSpanNaming.Source.CONTROLLER;
|
||||
import static io.opentelemetry.javaagent.instrumentation.metro.MetroSingletons.instrumenter;
|
||||
|
||||
import com.sun.xml.ws.api.message.Packet;
|
||||
import com.sun.xml.ws.api.server.WSEndpoint;
|
||||
import io.opentelemetry.context.Context;
|
||||
import io.opentelemetry.context.Scope;
|
||||
import io.opentelemetry.instrumentation.api.servlet.ServerSpanNaming;
|
||||
|
||||
public final class MetroHelper {
|
||||
private static final String REQUEST_KEY = MetroHelper.class.getName() + ".Request";
|
||||
|
@ -26,8 +24,7 @@ public final class MetroHelper {
|
|||
Context parentContext = Context.current();
|
||||
|
||||
MetroRequest request = new MetroRequest(endpoint, packet);
|
||||
ServerSpanNaming.updateServerSpanName(
|
||||
parentContext, CONTROLLER, MetroServerSpanNaming.SERVER_SPAN_NAME, request);
|
||||
MetroServerSpanNaming.updateServerSpanName(parentContext, request);
|
||||
|
||||
if (!instrumenter().shouldStart(parentContext, request)) {
|
||||
return;
|
||||
|
|
|
@ -6,40 +6,45 @@
|
|||
package io.opentelemetry.javaagent.instrumentation.metro;
|
||||
|
||||
import com.sun.xml.ws.api.message.Packet;
|
||||
import io.opentelemetry.instrumentation.api.servlet.ServerSpanNameSupplier;
|
||||
import io.opentelemetry.api.trace.Span;
|
||||
import io.opentelemetry.context.Context;
|
||||
import io.opentelemetry.instrumentation.api.tracer.ServerSpan;
|
||||
import io.opentelemetry.javaagent.bootstrap.servlet.ServletContextPath;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.xml.ws.handler.MessageContext;
|
||||
|
||||
public class MetroServerSpanNaming {
|
||||
public final class MetroServerSpanNaming {
|
||||
|
||||
public static final ServerSpanNameSupplier<MetroRequest> SERVER_SPAN_NAME =
|
||||
(context, metroRequest) -> {
|
||||
String spanName = metroRequest.spanName();
|
||||
if (spanName == null) {
|
||||
return null;
|
||||
public static void updateServerSpanName(Context context, MetroRequest metroRequest) {
|
||||
String spanName = metroRequest.spanName();
|
||||
if (spanName == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Span serverSpan = ServerSpan.fromContextOrNull(context);
|
||||
if (serverSpan == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Packet packet = metroRequest.packet();
|
||||
HttpServletRequest request = (HttpServletRequest) packet.get(MessageContext.SERVLET_REQUEST);
|
||||
if (request != null) {
|
||||
String servletPath = request.getServletPath();
|
||||
if (!servletPath.isEmpty()) {
|
||||
String pathInfo = request.getPathInfo();
|
||||
if (pathInfo != null) {
|
||||
spanName = servletPath + "/" + spanName;
|
||||
} else {
|
||||
// when pathInfo is null then there is a servlet that is mapped to this exact service
|
||||
// servletPath already contains the service name
|
||||
String operationName = packet.getWSDLOperation().getLocalPart();
|
||||
spanName = servletPath + "/" + operationName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Packet packet = metroRequest.packet();
|
||||
HttpServletRequest request =
|
||||
(HttpServletRequest) packet.get(MessageContext.SERVLET_REQUEST);
|
||||
if (request != null) {
|
||||
String servletPath = request.getServletPath();
|
||||
if (!servletPath.isEmpty()) {
|
||||
String pathInfo = request.getPathInfo();
|
||||
if (pathInfo != null) {
|
||||
spanName = servletPath + "/" + spanName;
|
||||
} else {
|
||||
// when pathInfo is null then there is a servlet that is mapped to this exact service
|
||||
// servletPath already contains the service name
|
||||
String operationName = packet.getWSDLOperation().getLocalPart();
|
||||
spanName = servletPath + "/" + operationName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ServletContextPath.prepend(context, spanName);
|
||||
};
|
||||
serverSpan.updateName(ServletContextPath.prepend(context, spanName));
|
||||
}
|
||||
|
||||
private MetroServerSpanNaming() {}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
package io.opentelemetry.javaagent.instrumentation.jaxws.v2_0;
|
||||
|
||||
import static io.opentelemetry.instrumentation.api.servlet.ServerSpanNaming.Source.CONTROLLER;
|
||||
import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed;
|
||||
import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.implementsInterface;
|
||||
import static io.opentelemetry.javaagent.instrumentation.api.Java8BytecodeBridge.currentContext;
|
||||
|
@ -18,12 +17,10 @@ import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
|
|||
|
||||
import io.opentelemetry.context.Context;
|
||||
import io.opentelemetry.context.Scope;
|
||||
import io.opentelemetry.instrumentation.api.servlet.ServerSpanNaming;
|
||||
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
|
||||
import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer;
|
||||
import io.opentelemetry.javaagent.instrumentation.api.CallDepth;
|
||||
import io.opentelemetry.javaagent.instrumentation.jaxws.common.JaxWsRequest;
|
||||
import io.opentelemetry.javaagent.instrumentation.jaxws.common.JaxWsServerSpanNaming;
|
||||
import javax.xml.ws.Provider;
|
||||
import net.bytebuddy.asm.Advice;
|
||||
import net.bytebuddy.description.type.TypeDescription;
|
||||
|
@ -66,8 +63,6 @@ public class WebServiceProviderInstrumentation implements TypeInstrumentation {
|
|||
|
||||
Context parentContext = currentContext();
|
||||
request = new JaxWsRequest(target.getClass(), methodName);
|
||||
ServerSpanNaming.updateServerSpanName(
|
||||
parentContext, CONTROLLER, JaxWsServerSpanNaming.SERVER_SPAN_NAME, request);
|
||||
if (!instrumenter().shouldStart(parentContext, request)) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
/*
|
||||
* Copyright The OpenTelemetry Authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package io.opentelemetry.javaagent.instrumentation.jaxws.common;
|
||||
|
||||
import io.opentelemetry.instrumentation.api.servlet.ServerSpanNameSupplier;
|
||||
|
||||
public class JaxWsServerSpanNaming {
|
||||
|
||||
public static final ServerSpanNameSupplier<JaxWsRequest> SERVER_SPAN_NAME =
|
||||
(context, request) -> request.spanName();
|
||||
|
||||
private JaxWsServerSpanNaming() {}
|
||||
}
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
package io.opentelemetry.javaagent.instrumentation.jaxws.jws.v1_1;
|
||||
|
||||
import static io.opentelemetry.instrumentation.api.servlet.ServerSpanNaming.Source.CONTROLLER;
|
||||
import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed;
|
||||
import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasSuperMethod;
|
||||
import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.implementsInterface;
|
||||
|
@ -20,12 +19,10 @@ import static net.bytebuddy.matcher.ElementMatchers.named;
|
|||
|
||||
import io.opentelemetry.context.Context;
|
||||
import io.opentelemetry.context.Scope;
|
||||
import io.opentelemetry.instrumentation.api.servlet.ServerSpanNaming;
|
||||
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
|
||||
import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer;
|
||||
import io.opentelemetry.javaagent.instrumentation.api.CallDepth;
|
||||
import io.opentelemetry.javaagent.instrumentation.jaxws.common.JaxWsRequest;
|
||||
import io.opentelemetry.javaagent.instrumentation.jaxws.common.JaxWsServerSpanNaming;
|
||||
import javax.jws.WebService;
|
||||
import net.bytebuddy.asm.Advice;
|
||||
import net.bytebuddy.description.type.TypeDescription;
|
||||
|
@ -77,8 +74,6 @@ public class JwsAnnotationsInstrumentation implements TypeInstrumentation {
|
|||
|
||||
Context parentContext = currentContext();
|
||||
request = new JaxWsRequest(target.getClass(), methodName);
|
||||
ServerSpanNaming.updateServerSpanName(
|
||||
parentContext, CONTROLLER, JaxWsServerSpanNaming.SERVER_SPAN_NAME, request);
|
||||
if (!instrumenter().shouldStart(parentContext, request)) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ public class RequestHandlerExecutorInstrumentation implements TypeInstrumentatio
|
|||
ServerSpanNaming.updateServerSpanName(
|
||||
context,
|
||||
CONTROLLER,
|
||||
WicketServerSpanNameing.SERVER_SPAN_NAME,
|
||||
WicketServerSpanNaming.SERVER_SPAN_NAME,
|
||||
(IPageClassRequestHandler) handler);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import io.opentelemetry.javaagent.bootstrap.servlet.ServletContextPath;
|
|||
import org.apache.wicket.core.request.handler.IPageClassRequestHandler;
|
||||
import org.apache.wicket.request.cycle.RequestCycle;
|
||||
|
||||
public class WicketServerSpanNameing {
|
||||
public final class WicketServerSpanNaming {
|
||||
|
||||
public static final ServerSpanNameSupplier<IPageClassRequestHandler> SERVER_SPAN_NAME =
|
||||
(context, handler) -> {
|
||||
|
@ -22,5 +22,5 @@ public class WicketServerSpanNameing {
|
|||
return ServletContextPath.prepend(context, filterPath + "/" + pageName);
|
||||
};
|
||||
|
||||
private WicketServerSpanNameing() {}
|
||||
private WicketServerSpanNaming() {}
|
||||
}
|
Loading…
Reference in New Issue