Skip to content

Commit

Permalink
Move AppServerBridge and MappingResolver to `servlet-common:boots…
Browse files Browse the repository at this point in the history
…trap` (#4817)

* Move AppServerBridge and MappingResolver to servlet-common:bootstrap

* Introduce additional gradle configuration for bootstrap libs
  • Loading branch information
Mateusz Rzeszutek authored Dec 7, 2021
1 parent 735c1b0 commit 075434c
Show file tree
Hide file tree
Showing 48 changed files with 88 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,18 @@ plugins {

extra["mavenGroupId"] = "io.opentelemetry.javaagent.instrumentation"

base.archivesName.set(projectDir.parentFile.name)
base.archivesName.set(projectDir.parentFile.name)

configurations {
val bootstrap by creating {
isCanBeResolved = false
isCanBeConsumed = false
}

named("compileOnly") {
extendsFrom(bootstrap)
}
named("muzzleBootstrap") {
extendsFrom(bootstrap)
}
}
2 changes: 1 addition & 1 deletion instrumentation/jaxrs/jaxrs-1.0/javaagent/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ muzzle {
}

dependencies {
compileOnly(project(":instrumentation:jaxrs:jaxrs-common:bootstrap"))
bootstrap(project(":instrumentation:jaxrs:jaxrs-common:bootstrap"))

compileOnly("javax.ws.rs:jsr311-api:1.1.1")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ muzzle {
}

dependencies {
compileOnly(project(":instrumentation:jaxrs:jaxrs-common:bootstrap"))
bootstrap(project(":instrumentation:jaxrs:jaxrs-common:bootstrap"))

compileOnly("javax.ws.rs:javax.ws.rs-api:2.0")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ muzzle {
}

dependencies {
compileOnly(project(":instrumentation:jaxrs:jaxrs-common:bootstrap"))
bootstrap(project(":instrumentation:jaxrs:jaxrs-common:bootstrap"))

compileOnly("javax.ws.rs:javax.ws.rs-api:2.0")
compileOnly("javax.servlet:javax.servlet-api:3.1.0")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ muzzle {
}

dependencies {
compileOnly(project(":instrumentation:jaxrs:jaxrs-common:bootstrap"))
bootstrap(project(":instrumentation:jaxrs:jaxrs-common:bootstrap"))

compileOnly("javax.ws.rs:javax.ws.rs-api:2.0")
compileOnly("javax.servlet:javax.servlet-api:3.1.0")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ muzzle {
}

dependencies {
compileOnly(project(":instrumentation:jaxrs:jaxrs-common:bootstrap"))
bootstrap(project(":instrumentation:jaxrs:jaxrs-common:bootstrap"))

compileOnly("javax.ws.rs:javax.ws.rs-api:2.0")
library("org.jboss.resteasy:resteasy-jaxrs:3.0.0.Final")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
}

dependencies {
compileOnly(project(":instrumentation:jaxrs:jaxrs-common:bootstrap"))
bootstrap(project(":instrumentation:jaxrs:jaxrs-common:bootstrap"))

compileOnly("javax.ws.rs:javax.ws.rs-api:2.0")
compileOnly("org.jboss.resteasy:resteasy-jaxrs:3.1.0.Final")
Expand Down
6 changes: 4 additions & 2 deletions instrumentation/jetty/jetty-11.0/javaagent/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ muzzle {
}

dependencies {
library("org.eclipse.jetty:jetty-server:11.0.0")
implementation(project(":instrumentation:servlet:servlet-5.0:javaagent"))
implementation(project(":instrumentation:jetty:jetty-common:javaagent"))
implementation(project(":instrumentation:servlet:servlet-5.0:javaagent"))
bootstrap(project(":instrumentation:servlet:servlet-common:bootstrap"))

library("org.eclipse.jetty:jetty-server:11.0.0")

testInstrumentation(project(":instrumentation:jetty:jetty-8.0:javaagent"))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import static io.opentelemetry.instrumentation.api.servlet.ServerSpanNaming.Source.CONTAINER;

import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
import io.opentelemetry.instrumentation.api.servlet.AppServerBridge;
import io.opentelemetry.instrumentation.api.servlet.ServerSpanNaming;
import io.opentelemetry.javaagent.bootstrap.servlet.AppServerBridge;
import io.opentelemetry.javaagent.instrumentation.jetty.common.JettyHelper;
import io.opentelemetry.javaagent.instrumentation.servlet.ServletInstrumenterBuilder;
import io.opentelemetry.javaagent.instrumentation.servlet.ServletRequestContext;
Expand Down
6 changes: 4 additions & 2 deletions instrumentation/jetty/jetty-8.0/javaagent/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ muzzle {
}

dependencies {
library("org.eclipse.jetty:jetty-server:8.0.0.v20110901")
implementation(project(":instrumentation:servlet:servlet-3.0:javaagent"))
implementation(project(":instrumentation:jetty:jetty-common:javaagent"))
implementation(project(":instrumentation:servlet:servlet-3.0:javaagent"))
bootstrap(project(":instrumentation:servlet:servlet-common:bootstrap"))

library("org.eclipse.jetty:jetty-server:8.0.0.v20110901")

testInstrumentation(project(":instrumentation:servlet:servlet-javax-common:javaagent"))
testInstrumentation(project(":instrumentation:jetty:jetty-11.0:javaagent"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import static io.opentelemetry.instrumentation.api.servlet.ServerSpanNaming.Source.CONTAINER;

import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
import io.opentelemetry.instrumentation.api.servlet.AppServerBridge;
import io.opentelemetry.instrumentation.api.servlet.ServerSpanNaming;
import io.opentelemetry.javaagent.bootstrap.servlet.AppServerBridge;
import io.opentelemetry.javaagent.instrumentation.jetty.common.JettyHelper;
import io.opentelemetry.javaagent.instrumentation.servlet.ServletInstrumenterBuilder;
import io.opentelemetry.javaagent.instrumentation.servlet.ServletRequestContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ muzzle {
group.set("org.apache.kafka")
module.set("kafka-clients")
versions.set("[0.11.0.0,)")
extraDependency(project(":instrumentation:kafka-clients:kafka-clients-0.11:bootstrap"))
assertInverse.set(true)
}
}
Expand All @@ -16,7 +15,7 @@ dependencies {
compileOnly("com.google.auto.value:auto-value-annotations")
annotationProcessor("com.google.auto.value:auto-value")

compileOnly(project(":instrumentation:kafka-clients:kafka-clients-0.11:bootstrap"))
bootstrap(project(":instrumentation:kafka-clients:kafka-clients-0.11:bootstrap"))
implementation(project(":instrumentation:kafka-clients:kafka-clients-common:library"))

library("org.apache.kafka:kafka-clients:0.11.0.0")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ muzzle {
}

dependencies {
compileOnly(project(":instrumentation:kafka-clients:kafka-clients-0.11:bootstrap"))
bootstrap(project(":instrumentation:kafka-clients:kafka-clients-0.11:bootstrap"))
implementation(project(":instrumentation:kafka-clients:kafka-clients-common:library"))

library("org.apache.kafka:kafka-streams:0.11.0.0")
Expand Down
2 changes: 2 additions & 0 deletions instrumentation/liberty/liberty/javaagent/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ plugins {
// liberty module has access to servlet api while liberty-dispatcher does not

dependencies {
bootstrap(project(":instrumentation:servlet:servlet-common:bootstrap"))

compileOnly("javax.servlet:javax.servlet-api:3.0.1")

implementation(project(":instrumentation:servlet:servlet-common:javaagent"))
Expand Down
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.api.servlet.AppServerBridge;
import io.opentelemetry.javaagent.bootstrap.servlet.AppServerBridge;
import io.opentelemetry.javaagent.instrumentation.servlet.ServletAccessor;
import io.opentelemetry.javaagent.instrumentation.servlet.ServletHelper;
import io.opentelemetry.javaagent.instrumentation.servlet.ServletRequestContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import static io.opentelemetry.instrumentation.api.servlet.ServerSpanNaming.Source.CONTAINER;

import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
import io.opentelemetry.instrumentation.api.servlet.AppServerBridge;
import io.opentelemetry.instrumentation.api.servlet.ServerSpanNaming;
import io.opentelemetry.javaagent.bootstrap.servlet.AppServerBridge;
import io.opentelemetry.javaagent.instrumentation.servlet.ServletInstrumenterBuilder;
import io.opentelemetry.javaagent.instrumentation.servlet.ServletRequestContext;
import io.opentelemetry.javaagent.instrumentation.servlet.ServletResponseContext;
Expand Down
2 changes: 1 addition & 1 deletion instrumentation/rmi/javaagent/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dependencies {
compileOnly("com.google.auto.value:auto-value-annotations")
annotationProcessor("com.google.auto.value:auto-value")

compileOnly(project(":instrumentation:rmi:bootstrap"))
bootstrap(project(":instrumentation:rmi:bootstrap"))
}

// We cannot use "--release" javac option here because that will forbid importing "sun.rmi" package.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ muzzle {
}

dependencies {
compileOnly("javax.servlet:servlet-api:2.2")
implementation(project(":instrumentation:servlet:servlet-common:javaagent"))
implementation(project(":instrumentation:servlet:servlet-javax-common:javaagent"))
bootstrap(project(":instrumentation:servlet:servlet-common:bootstrap"))

compileOnly("javax.servlet:servlet-api:2.2")

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import io.opentelemetry.context.Context;
import io.opentelemetry.context.Scope;
import io.opentelemetry.instrumentation.api.field.VirtualField;
import io.opentelemetry.instrumentation.api.servlet.AppServerBridge;
import io.opentelemetry.javaagent.bootstrap.servlet.AppServerBridge;
import io.opentelemetry.javaagent.instrumentation.api.CallDepth;
import io.opentelemetry.javaagent.instrumentation.api.Java8BytecodeBridge;
import io.opentelemetry.javaagent.instrumentation.servlet.ServletRequestContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ 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:javaagent"))
bootstrap(project(":instrumentation:servlet:servlet-common:bootstrap"))

compileOnly("javax.servlet:javax.servlet-api:3.0.1")

testInstrumentation(project(":instrumentation:jetty:jetty-8.0:javaagent"))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

import io.opentelemetry.context.Context;
import io.opentelemetry.context.Scope;
import io.opentelemetry.instrumentation.api.servlet.AppServerBridge;
import io.opentelemetry.instrumentation.api.servlet.MappingResolver;
import io.opentelemetry.instrumentation.api.tracer.ServerSpan;
import io.opentelemetry.javaagent.bootstrap.servlet.AppServerBridge;
import io.opentelemetry.javaagent.bootstrap.servlet.MappingResolver;
import io.opentelemetry.javaagent.instrumentation.api.CallDepth;
import io.opentelemetry.javaagent.instrumentation.api.Java8BytecodeBridge;
import io.opentelemetry.javaagent.instrumentation.servlet.ServletRequestContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
package io.opentelemetry.javaagent.instrumentation.servlet.v3_0;

import io.opentelemetry.instrumentation.api.field.VirtualField;
import io.opentelemetry.instrumentation.api.servlet.MappingResolver;
import io.opentelemetry.javaagent.bootstrap.servlet.MappingResolver;
import javax.servlet.Filter;
import javax.servlet.FilterConfig;
import net.bytebuddy.asm.Advice;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
package io.opentelemetry.javaagent.instrumentation.servlet.v3_0;

import io.opentelemetry.instrumentation.api.field.VirtualField;
import io.opentelemetry.instrumentation.api.servlet.MappingResolver;
import io.opentelemetry.javaagent.bootstrap.servlet.MappingResolver;
import javax.servlet.Servlet;
import javax.servlet.ServletConfig;
import net.bytebuddy.asm.Advice;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

import io.opentelemetry.instrumentation.api.field.VirtualField;
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
import io.opentelemetry.instrumentation.api.servlet.MappingResolver;
import io.opentelemetry.instrumentation.api.servlet.ServerSpanNaming;
import io.opentelemetry.javaagent.bootstrap.servlet.MappingResolver;
import io.opentelemetry.javaagent.instrumentation.servlet.ServletHelper;
import io.opentelemetry.javaagent.instrumentation.servlet.ServletInstrumenterBuilder;
import io.opentelemetry.javaagent.instrumentation.servlet.ServletRequestContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ muzzle {

dependencies {
api(project(":instrumentation:servlet:servlet-common:javaagent"))
bootstrap(project(":instrumentation:servlet:servlet-common:bootstrap"))

compileOnly("jakarta.servlet:jakarta.servlet-api:5.0.0")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

import io.opentelemetry.instrumentation.api.field.VirtualField;
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
import io.opentelemetry.instrumentation.api.servlet.MappingResolver;
import io.opentelemetry.instrumentation.api.servlet.ServerSpanNaming;
import io.opentelemetry.javaagent.bootstrap.servlet.MappingResolver;
import io.opentelemetry.javaagent.instrumentation.servlet.ServletHelper;
import io.opentelemetry.javaagent.instrumentation.servlet.ServletInstrumenterBuilder;
import io.opentelemetry.javaagent.instrumentation.servlet.ServletRequestContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
package io.opentelemetry.javaagent.instrumentation.servlet.v5_0.service;

import io.opentelemetry.instrumentation.api.field.VirtualField;
import io.opentelemetry.instrumentation.api.servlet.MappingResolver;
import io.opentelemetry.javaagent.bootstrap.servlet.MappingResolver;
import jakarta.servlet.Filter;
import jakarta.servlet.FilterConfig;
import net.bytebuddy.asm.Advice;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
package io.opentelemetry.javaagent.instrumentation.servlet.v5_0.service;

import io.opentelemetry.instrumentation.api.field.VirtualField;
import io.opentelemetry.instrumentation.api.servlet.MappingResolver;
import io.opentelemetry.javaagent.bootstrap.servlet.MappingResolver;
import jakarta.servlet.Servlet;
import jakarta.servlet.ServletConfig;
import net.bytebuddy.asm.Advice;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

import io.opentelemetry.context.Context;
import io.opentelemetry.context.Scope;
import io.opentelemetry.instrumentation.api.servlet.AppServerBridge;
import io.opentelemetry.instrumentation.api.servlet.MappingResolver;
import io.opentelemetry.instrumentation.api.tracer.ServerSpan;
import io.opentelemetry.javaagent.bootstrap.servlet.AppServerBridge;
import io.opentelemetry.javaagent.bootstrap.servlet.MappingResolver;
import io.opentelemetry.javaagent.instrumentation.api.CallDepth;
import io.opentelemetry.javaagent.instrumentation.api.Java8BytecodeBridge;
import io.opentelemetry.javaagent.instrumentation.servlet.ServletRequestContext;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
plugins {
id("otel.javaagent-bootstrap")
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.instrumentation.api.servlet;
package io.opentelemetry.javaagent.bootstrap.servlet;

import io.opentelemetry.context.Context;
import io.opentelemetry.context.ContextKey;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.instrumentation.api.servlet;
package io.opentelemetry.javaagent.bootstrap.servlet;

import java.util.ArrayList;
import java.util.Collection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ plugins {

// This module is only used as a dependency for other javaagent modules and does not contain any
// non-abstract implementations of InstrumentationModule

dependencies {
compileOnly(project(":instrumentation:servlet:servlet-common:bootstrap"))
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
import io.opentelemetry.api.trace.SpanContext;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
import io.opentelemetry.instrumentation.api.servlet.AppServerBridge;
import io.opentelemetry.instrumentation.api.servlet.MappingResolver;
import io.opentelemetry.instrumentation.api.servlet.ServerSpanNaming;
import io.opentelemetry.instrumentation.api.servlet.ServletContextPath;
import io.opentelemetry.instrumentation.api.tracer.ServerSpan;
import io.opentelemetry.javaagent.bootstrap.servlet.AppServerBridge;
import io.opentelemetry.javaagent.bootstrap.servlet.MappingResolver;
import java.util.function.Function;

public abstract class BaseServletHelper<REQUEST, RESPONSE> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpServerAttributesExtractor;
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpServerMetrics;
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor;
import io.opentelemetry.instrumentation.api.servlet.MappingResolver;
import io.opentelemetry.javaagent.bootstrap.servlet.MappingResolver;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

package io.opentelemetry.javaagent.instrumentation.servlet;

import io.opentelemetry.instrumentation.api.servlet.MappingResolver;
import io.opentelemetry.javaagent.bootstrap.servlet.MappingResolver;
import java.util.Collection;
import javax.annotation.Nullable;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
package io.opentelemetry.javaagent.instrumentation.servlet;

import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor;
import io.opentelemetry.instrumentation.api.servlet.MappingResolver;
import io.opentelemetry.javaagent.bootstrap.servlet.MappingResolver;
import java.util.function.Function;
import javax.annotation.Nullable;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
package io.opentelemetry.javaagent.instrumentation.servlet;

import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.servlet.MappingResolver;
import io.opentelemetry.instrumentation.api.servlet.ServerSpanNameTwoArgSupplier;
import io.opentelemetry.instrumentation.api.servlet.ServletContextPath;
import io.opentelemetry.javaagent.bootstrap.servlet.MappingResolver;
import javax.annotation.Nullable;

/** Helper class for constructing span name for given servlet/filter mapping and request. */
Expand Down
Loading

0 comments on commit 075434c

Please sign in to comment.