Skip to content

Commit

Permalink
Reorganize shared servlet code (intro to open-telemetry#4317) (open-t…
Browse files Browse the repository at this point in the history
…elemetry#4785)

* Reorganize shared servlet code (intro to open-telemetry#4317)

* Fix dropwizard tests

* fix compile error
  • Loading branch information
Mateusz Rzeszutek authored and RashmiRam committed May 23, 2022
1 parent 7415de8 commit c0161e7
Show file tree
Hide file tree
Showing 49 changed files with 387 additions and 121 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ class DropwizardTest extends HttpServerTest<DropwizardTestSupport> implements Ag
endpoint != NOT_FOUND
}

@Override
boolean hasResponseSpan(ServerEndpoint endpoint) {
endpoint == NOT_FOUND
}

@Override
boolean testPathParam() {
true
Expand Down Expand Up @@ -112,6 +117,11 @@ class DropwizardTest extends HttpServerTest<DropwizardTestSupport> implements Ag
}
}

@Override
void responseSpan(TraceAssert trace, int index, Object parent, String method, ServerEndpoint endpoint) {
sendErrorSpan(trace, index, parent)
}

static class TestApp extends Application<Configuration> {
@Override
void initialize(Bootstrap<Configuration> bootstrap) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@ plugins {
}

dependencies {
api(project(":instrumentation:servlet:servlet-common:library"))
implementation(project(":instrumentation:servlet:servlet-common:javaagent"))
api(project(":instrumentation:servlet:servlet-common:javaagent"))
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import io.opentelemetry.context.Context;
import io.opentelemetry.context.Scope;
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
import io.opentelemetry.instrumentation.servlet.ServletAccessor;
import io.opentelemetry.javaagent.instrumentation.servlet.ServletAccessor;
import io.opentelemetry.javaagent.instrumentation.servlet.ServletHelper;
import io.opentelemetry.javaagent.instrumentation.servlet.ServletRequestContext;
import io.opentelemetry.javaagent.instrumentation.servlet.ServletResponseContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import io.opentelemetry.context.Scope;
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
import io.opentelemetry.instrumentation.api.servlet.AppServerBridge;
import io.opentelemetry.instrumentation.servlet.ServletAccessor;
import io.opentelemetry.javaagent.instrumentation.servlet.ServletAccessor;
import io.opentelemetry.javaagent.instrumentation.servlet.ServletHelper;
import io.opentelemetry.javaagent.instrumentation.servlet.ServletRequestContext;
import io.opentelemetry.javaagent.instrumentation.servlet.ServletResponseContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ muzzle {
dependencies {
compileOnly("javax.servlet:servlet-api:2.2")
implementation(project(":instrumentation:servlet:servlet-common:javaagent"))
implementation(project(":instrumentation:servlet:servlet-javax-common:library"))
implementation(project(":instrumentation:servlet:servlet-javax-common:javaagent"))

testInstrumentation(project(":instrumentation:servlet:servlet-javax-common:javaagent"))
testInstrumentation(project(":instrumentation:servlet:servlet-3.0:javaagent"))

testLibrary("org.eclipse.jetty:jetty-server:7.0.0.v20091005")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

package io.opentelemetry.javaagent.instrumentation.servlet.v2_2;

import io.opentelemetry.instrumentation.servlet.ServletAsyncListener;
import io.opentelemetry.instrumentation.servlet.javax.JavaxServletAccessor;
import io.opentelemetry.javaagent.instrumentation.servlet.ServletAsyncListener;
import io.opentelemetry.javaagent.instrumentation.servlet.javax.JavaxServletAccessor;
import java.util.Collections;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

package io.opentelemetry.javaagent.instrumentation.servlet.v2_2;

import io.opentelemetry.instrumentation.servlet.ServletAccessor;
import io.opentelemetry.javaagent.instrumentation.servlet.ServletAccessor;
import io.opentelemetry.javaagent.instrumentation.servlet.ServletHttpAttributesExtractor;
import io.opentelemetry.javaagent.instrumentation.servlet.ServletRequestContext;
import io.opentelemetry.javaagent.instrumentation.servlet.ServletResponseContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule;
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
import io.opentelemetry.javaagent.instrumentation.servlet.common.service.ServletAndFilterInstrumentation;
import io.opentelemetry.javaagent.instrumentation.servlet.javax.response.JavaxResponseInstrumentationFactory;
import java.util.Arrays;
import java.util.List;
import net.bytebuddy.matcher.ElementMatcher;
Expand All @@ -34,6 +35,7 @@ public List<TypeInstrumentation> typeInstrumentations() {
new HttpServletResponseInstrumentation(),
new ServletAndFilterInstrumentation(
"javax.servlet",
Servlet2InstrumentationModule.class.getPackage().getName() + ".Servlet2Advice"));
Servlet2InstrumentationModule.class.getPackage().getName() + ".Servlet2Advice"),
JavaxResponseInstrumentationFactory.create());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
package io.opentelemetry.javaagent.instrumentation.servlet.v2_2;

import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor;
import io.opentelemetry.instrumentation.servlet.ServletAccessor;
import io.opentelemetry.javaagent.instrumentation.servlet.ServletAccessor;
import io.opentelemetry.javaagent.instrumentation.servlet.ServletRequestContext;

public class Servlet2SpanNameExtractor<REQUEST, RESPONSE>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ muzzle {
dependencies {
compileOnly("javax.servlet:javax.servlet-api:3.0.1")
api(project(":instrumentation:servlet:servlet-common:javaagent"))
api(project(":instrumentation:servlet:servlet-javax-common:library"))
api(project(":instrumentation:servlet:servlet-javax-common:javaagent"))

testInstrumentation(project(":instrumentation:jetty:jetty-8.0:javaagent"))
testInstrumentation(project(":instrumentation:servlet:servlet-javax-common:javaagent"))

testLibrary("org.eclipse.jetty:jetty-server:8.0.0.v20110901")
testLibrary("org.eclipse.jetty:jetty-servlet:8.0.0.v20110901")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

package io.opentelemetry.javaagent.instrumentation.servlet.v3_0;

import io.opentelemetry.instrumentation.servlet.ServletAsyncListener;
import io.opentelemetry.instrumentation.servlet.javax.JavaxServletAccessor;
import io.opentelemetry.javaagent.instrumentation.servlet.ServletAsyncListener;
import io.opentelemetry.javaagent.instrumentation.servlet.javax.JavaxServletAccessor;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

package io.opentelemetry.javaagent.instrumentation.servlet.v3_0;

import io.opentelemetry.instrumentation.servlet.naming.ServletFilterMappingResolverFactory;
import io.opentelemetry.javaagent.instrumentation.servlet.ServletFilterMappingResolverFactory;
import java.util.Collection;
import javax.servlet.FilterConfig;
import javax.servlet.FilterRegistration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import io.opentelemetry.javaagent.instrumentation.servlet.common.async.AsyncContextStartInstrumentation;
import io.opentelemetry.javaagent.instrumentation.servlet.common.async.AsyncStartInstrumentation;
import io.opentelemetry.javaagent.instrumentation.servlet.common.service.ServletAndFilterInstrumentation;
import io.opentelemetry.javaagent.instrumentation.servlet.javax.response.JavaxResponseInstrumentationFactory;
import java.util.List;
import net.bytebuddy.matcher.ElementMatcher;

Expand Down Expand Up @@ -42,7 +43,8 @@ BASE_PACKAGE, adviceClassName(".Servlet3AsyncContextStartAdvice")),
BASE_PACKAGE,
adviceClassName(".Servlet3Advice"),
adviceClassName(".Servlet3InitAdvice"),
adviceClassName(".Servlet3FilterInitAdvice")));
adviceClassName(".Servlet3FilterInitAdvice")),
JavaxResponseInstrumentationFactory.create());
}

private static String adviceClassName(String suffix) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

package io.opentelemetry.javaagent.instrumentation.servlet.v3_0;

import io.opentelemetry.instrumentation.servlet.naming.ServletMappingResolverFactory;
import io.opentelemetry.javaagent.instrumentation.servlet.ServletMappingResolverFactory;
import javax.annotation.Nullable;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
Expand Down
Loading

0 comments on commit c0161e7

Please sign in to comment.