Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade OTEL to 1.3.1 #341

Closed
wants to merge 69 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
a8c9628
:arrow_up: upgrade to 1.3.1
ryandens Jul 7, 2021
9926079
:recycle: update ComponentInstaller to AgentListener
ryandens Jul 7, 2021
ccc721d
:recycle: refactor IgnoreMatcherProvider to IgnoredTypesConfigurer
ryandens Jul 7, 2021
d735b65
:recycle: refactor java-streams instrumentation
ryandens Jul 7, 2021
6286b0f
:recycle: refactor ApacheClientInstrumentationModule to use new Instr…
ryandens Jul 7, 2021
ddf99c3
:recycle: refactor apache-httpasyncclient-4.1 to use new instrumentat…
ryandens Jul 13, 2021
6a42e6d
:recycle: update grpc to use new instrumentation API
ryandens Jul 13, 2021
08d9232
:recycle: update jaxrs-client-2.0 to use new instrumentation extensio…
ryandens Jul 13, 2021
b1eb1ff
:recycle: update servlet-3.0 to use new instrumentation extension API
ryandens Jul 13, 2021
353f743
:recycle: update servlet test instrumentation
ryandens Jul 14, 2021
bca128a
:sparkles: add library to unshade the netty-4.0-all JAR
ryandens Jul 19, 2021
7666d5f
:recycle: refactor netty-4.0 to use the unshaded jar library
ryandens Jul 19, 2021
205f867
:sparkles: create project to unshade netty-4.1 otel dependency
ryandens Jul 19, 2021
7261819
:recycle: refactor netty to use unsahded JAR
ryandens Jul 19, 2021
ae29dbe
:recycle: update usage of instrumentation api in okhttp module
ryandens Jul 22, 2021
3d4f04e
:recycle: move configuration of instrumentation subproject dependenci…
ryandens Jul 23, 2021
b1ca343
:recycle: refactor unshade logic into plugin
ryandens Jul 23, 2021
3fccdac
:bug: fix id of plugin for netty 4.1
ryandens Jul 23, 2021
61cb08c
:bug: fix netty-4.1
ryandens Jul 23, 2021
d79103a
:recycle: refactor undertow-1.4 build to rely on unshaded otel JAR
ryandens Jul 23, 2021
ef36e29
:recycle: refactor undertow instrumentation to use new instrumentatio…
ryandens Jul 23, 2021
f4ebf0d
:truck: move vertx-web to dedicated folder
ryandens Jul 23, 2021
7030f1e
:bug: include vertx-web instrumentation in instrumentation JAR
ryandens Jul 23, 2021
d6ca0ac
:recycle: make vertx depend on shaded jar
ryandens Jul 23, 2021
ca74d9d
:recycle: refactor vertx to use new instrumentation api
ryandens Jul 23, 2021
4a7488c
:fire: remove shadow plugin version
ryandens Jul 23, 2021
57f209d
:recycle: update grpc-shaded-netty-1.9 to use new instrumentation api
ryandens Jul 23, 2021
c458163
:arrow_up: upgrade byte buddy
ryandens Jul 23, 2021
cf93cf0
:white_check_mark: add grpc-netty dependency for runtime usage by the…
ryandens Jul 23, 2021
b53ebd8
:alembic: add extension-api to tooling dependencies
ryandens Jul 26, 2021
232bbc7
:alembic: refactor buildSrc to match otel more
ryandens Jul 26, 2021
75168f9
:recycle: update instrumentation projects to account for muzzle plugi…
ryandens Jul 26, 2021
28ce72f
:fire: delete manual meta-inf entry for MuzzlePlugin'
ryandens Jul 26, 2021
471b9bd
:fire: remove extension-api from dependent tasks for mzuzle
ryandens Jul 27, 2021
d00ee68
Revert ":fire: remove extension-api from dependent tasks for mzuzle"
ryandens Jul 27, 2021
a0f9297
Revert ":fire: delete manual meta-inf entry for MuzzlePlugin'"
ryandens Jul 27, 2021
db75901
Revert ":recycle: update instrumentation projects to account for muzz…
ryandens Jul 27, 2021
f474ef9
Revert ":alembic: refactor buildSrc to match otel more"
ryandens Jul 27, 2021
e130b21
:recycle: gradle lazy configuration
ryandens Jul 27, 2021
4db30c6
:heavy_plus_sign: add bootstrap to testing-common
ryandens Jul 28, 2021
1696d61
:alembic: initialize AgentClassLoader as app class loader
ryandens Jul 28, 2021
aa6cda8
:recycle: relocate shaded slf4j
ryandens Jul 29, 2021
9fe46f5
:bug: unsshade otel httpasync module for testing
ryandens Jul 29, 2021
80eba74
:bug: unshade apache-httpclient for testing purposes
ryandens Jul 30, 2021
e140e92
:bug: unshade grpc for testing purposes'
ryandens Jul 30, 2021
ce5fdf9
:recycle: refactor java-streams test instrumentation to match new ins…
ryandens Jul 30, 2021
b50154c
:bug: unshade jaxrs-client for testing purposes'
ryandens Jul 30, 2021
2b7c74d
:bug: use unshaded netty for micronaut
ryandens Jul 30, 2021
b22598f
:bug: unshade spark instrumentation deps for testing purposes'
ryandens Jul 30, 2021
d7e005a
:bug: unshade struts instrumentation deps for testing purposes
ryandens Jul 30, 2021
6043274
relocate netty lib usage
ryandens Jul 30, 2021
bc2ceb6
:bug: unshade okhttp instrumentation deps for testing purposes
ryandens Jul 30, 2021
11caff7
:recycle: use unshaded servlet 3.0 instrumentation for testing purposes
ryandens Jul 30, 2021
8b370cb
:bug: relocate shaded standalone instrumentation library
ryandens Jul 30, 2021
b342488
:heavy_plus_sign: add missing tracing library as dependency to servle…
ryandens Aug 2, 2021
e313943
:recycle: refactor servle-rw test instrumentation to use the new inst…
ryandens Aug 2, 2021
abcc11f
:fire: remove unused otel dependencies
ryandens Aug 2, 2021
654086b
:bug: fix bug where muzzle found violations by restricting what is in…
ryandens Aug 2, 2021
5f08199
:bug: fix missing async response bodies/headers as a result of a the …
ryandens Aug 3, 2021
e1039fa
:recycle: make sure request buffer gets reset
ryandens Aug 3, 2021
932c014
:bug: fix bug where bad key was used in call depth map
ryandens Aug 3, 2021
a73795d
:recycle: add back in inheritance
ryandens Aug 4, 2021
b685d60
:bug: get client context from superclass volatile field
ryandens Aug 4, 2021
b278da7
:bug: fix bug where two traces are sent
ryandens Aug 4, 2021
1ab19bf
:bug: fix flaky test
ryandens Aug 4, 2021
3586a4b
recycle: levearge unshaded jaxrs library in insturmentation module
ryandens Aug 4, 2021
21d85e8
:recycle: remove unneded changes to netty module
ryandens Aug 4, 2021
9589e3a
Revert "recycle: levearge unshaded jaxrs library in insturmentation m…
ryandens Aug 5, 2021
ec65069
:arrow_up: upgrade OTEL api
ryandens Aug 5, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ subprojects {
description = "Hypertrace OpenTelemetry Javaagent"

extra.set("versions", mapOf(
"opentelemetry" to "1.2.0",
"opentelemetry_java_agent" to "1.2.0-alpha",
"opentelemetry_java_agent_all" to "1.2.0",
"byte_buddy" to "1.10.18",
"opentelemetry" to "1.3.0",
"opentelemetry_java_agent" to "1.3.1-alpha",
"opentelemetry_java_agent_all" to "1.3.1",
"byte_buddy" to "1.11.2",
"slf4j" to "1.7.30"
))

Expand Down
8 changes: 7 additions & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,25 @@ gradlePlugin {
id = "io.opentelemetry.instrumentation.auto-instrumentation"
implementationClass = "io.opentelemetry.instrumentation.gradle.AutoInstrumentationPlugin"
}
create("open-telemetry-un-shade-plugin") {
id = "io.opentelemetry.instrumentation.un-shade"
implementationClass = "io.opentelemetry.instrumentation.gradle.OpenTelemetryUnShadePlugin"
}
}
}

repositories {
mavenLocal()
jcenter()
gradlePluginPortal()
mavenCentral()
}

dependencies {
implementation(gradleApi())
implementation(localGroovy())

implementation("com.github.jengelman.gradle.plugins:shadow:6.0.0")
implementation("org.eclipse.aether", "aether-connector-basic", "1.1.0")
implementation("org.eclipse.aether", "aether-transport-http", "1.1.0")
implementation("org.apache.maven", "maven-aether-provider", "3.3.9")
Expand All @@ -35,7 +41,7 @@ dependencies {
implementation("org.ow2.asm", "asm", "7.0-beta")
implementation("org.ow2.asm", "asm-tree", "7.0-beta")
implementation("org.apache.httpcomponents:httpclient:4.5.10")
implementation("net.bytebuddy:byte-buddy-gradle-plugin:1.10.18")
implementation("net.bytebuddy:byte-buddy-gradle-plugin:1.11.2")

testImplementation("org.spockframework", "spock-core", "1.3-groovy-2.5")
testImplementation("org.codehaus.groovy", "groovy-all", "2.5.8")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,18 @@

import java.io.File;
import java.util.Arrays;
import java.util.Map;
import java.util.Objects;
import org.gradle.api.Action;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.artifacts.Dependency;
import org.gradle.api.artifacts.dsl.DependencyHandler;
import org.gradle.api.attributes.AttributeContainer;
import org.gradle.api.attributes.LibraryElements;
import org.gradle.api.plugins.JavaLibraryPlugin;
import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.tasks.Internal;
import org.gradle.api.tasks.testing.Test;
import org.gradle.process.CommandLineArgumentProvider;
Expand All @@ -27,6 +34,7 @@ public class AutoInstrumentationPlugin implements Plugin<Project> {
public void apply(Project project) {
project.getPlugins().apply(JavaLibraryPlugin.class);
createLibraryConfiguration(project);
addDependencies(project);
project
.getTasks()
.withType(
Expand All @@ -43,6 +51,40 @@ public void apply(Project project) {
});
}

private void addDependencies(Project project) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems the upstream does not have AutoInstrumentationPlugin.java in 1.3x anymore.

Shall we align more with the upstream and remove this file as well?

DependencyHandler dependencies = project.getDependencies();
@SuppressWarnings("unchecked") final Map<String, String> versions = Objects.requireNonNull(
(Map<String, String>) project.getExtensions().getExtraProperties().get("versions"));

dependencies.add("implementation", "org.slf4j:slf4j-api:1.7.30");
dependencies.add("compileOnly", "com.google.auto.service:auto-service-annotations:1.0");
dependencies.add("annotationProcessor", "com.google.auto.service:auto-service:1.0");
dependencies.add("implementation", "net.bytebuddy:byte-buddy:" + versions.get("byte_buddy"));
dependencies.add("implementation",
"io.opentelemetry:opentelemetry-api:" + versions.get("opentelemetry"));
dependencies.add("implementation",
"io.opentelemetry.javaagent:opentelemetry-javaagent-tooling:" + versions
.get("opentelemetry_java_agent"));
dependencies.add("implementation",
"io.opentelemetry.javaagent:opentelemetry-javaagent-extension-api:" + versions
.get("opentelemetry_java_agent"));
dependencies.add("implementation",
"io.opentelemetry.javaagent:opentelemetry-javaagent-api:" + versions
.get("opentelemetry_java_agent"));
dependencies.add("implementation",
"io.opentelemetry.instrumentation:opentelemetry-instrumentation-api:" + versions
.get("opentelemetry_java_agent"));

dependencies.add("implementation", dependencies.project(Map.of("path", ":javaagent-core")));
dependencies.add("implementation", dependencies.project(Map.of("path", ":filter-api")));

project.getConfigurations().named(JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME).configure(
files -> files.attributes(attributeContainer -> attributeContainer.attribute(
LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE,
project.getObjects().named(LibraryElements.class, LibraryElements.JAR))));

}

/**
* Creates a custom dependency configuration called {@code library} inspired by the <a
* href="https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/0b0516bd1a0599c8f536cc6b2151782000681f39/gradle/instrumentation-common.gradle#L8">opentelemetry-java-instrumentation</a>.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package io.opentelemetry.instrumentation.gradle;

import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.plugins.JavaLibraryPlugin;

/**
* Plugin to encapsulate our rather odd practice of depending on a shaded instrumentation JAR
* published by OpenTelemetry, un-shading the OTEL public API by relocating the packages to their
* original location so we can use the utilities exposed in the not-shaded OTEL
* instrumentation library classes.
*/
public final class OpenTelemetryUnShadePlugin implements Plugin<Project> {

@Override
public void apply(final Project project) {
project.getPlugins().apply(JavaLibraryPlugin.class);
project.getPlugins().apply("com.github.johnrengelman.shadow");
project.getTasks().named("shadowJar", ShadowJar.class).configure(shadowJar -> {
shadowJar.relocate("io.opentelemetry.javaagent.shaded.io.opentelemetry.api",
"io.opentelemetry.api");
shadowJar.relocate("io.opentelemetry.javaagent.shaded.io.opentelemetry.context",
"io.opentelemetry.context");
shadowJar.relocate("io.opentelemetry.javaagent.shaded.io.opentelemetry.semconv",
"io.opentelemetry.semconv");
shadowJar.relocate("io.opentelemetry.javaagent.shaded.instrumentation.api",
"io.opentelemetry.instrumentation.api");
shadowJar.relocate("io.opentelemetry.javaagent.slf4j", "org.slf4j");
});

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@
import java.io.File;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import net.bytebuddy.build.gradle.ByteBuddySimpleTask;
import net.bytebuddy.build.gradle.Transformation;
import org.gradle.api.Action;
import org.gradle.api.Project;
import org.gradle.api.Task;
import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.TaskProvider;
import org.gradle.api.tasks.compile.AbstractCompile;

/**
Expand All @@ -35,6 +39,7 @@
* of the compile task.
*/
public class ByteBuddyPluginConfigurator {

private static final List<String> LANGUAGES = Arrays.asList("java", "scala", "kotlin");

private final Project project;
Expand All @@ -61,43 +66,67 @@ public ByteBuddyPluginConfigurator(

public void configure() {
String taskName = getTaskName();
Task byteBuddyTask = project.getTasks().create(taskName);

for (String language : LANGUAGES) {
AbstractCompile compile = getCompileTask(language);

if (compile != null) {
Task languageTask = createLanguageTask(compile, taskName + language);
// We also process resources for SPI classes.
languageTask.dependsOn(sourceSet.getProcessResourcesTaskName());
byteBuddyTask.dependsOn(languageTask);
}
}

project.getTasks().getByName(sourceSet.getClassesTaskName()).dependsOn(byteBuddyTask);
List<TaskProvider<?>> languageTasks =
LANGUAGES.stream()
.map(
language -> {
if (project.fileTree("src/" + sourceSet.getName() + "/" + language).isEmpty()) {
return null;
}
String compileTaskName = sourceSet.getCompileTaskName(language);
if (!project.getTasks().getNames().contains(compileTaskName)) {
return null;
}
TaskProvider<?> compileTask = project.getTasks().named(compileTaskName);

// We also process resources for SPI classes.
return createLanguageTask(
compileTask, taskName + language, sourceSet.getProcessResourcesTaskName());
})
.filter(Objects::nonNull)
.collect(Collectors.toList());

TaskProvider<?> byteBuddyTask =
project.getTasks().register(taskName, task -> task.dependsOn(languageTasks));

project
.getTasks()
.named(sourceSet.getClassesTaskName())
.configure(task -> task.dependsOn(byteBuddyTask));
}

private Task createLanguageTask(AbstractCompile compileTask, String name) {
ByteBuddySimpleTask task = project.getTasks().create(name, ByteBuddySimpleTask.class);
task.setGroup("Byte Buddy");
task.getOutputs().cacheIf(unused -> true);

File classesDirectory = compileTask.getDestinationDir();
File rawClassesDirectory =
new File(classesDirectory.getParent(), classesDirectory.getName() + "raw")
.getAbsoluteFile();

task.dependsOn(compileTask);
compileTask.setDestinationDir(rawClassesDirectory);

task.setSource(rawClassesDirectory);
task.setTarget(classesDirectory);
task.setClassPath(compileTask.getClasspath());

task.dependsOn(compileTask);

task.getTransformations().add(createTransformation(inputClasspath, pluginClassName));
return task;
private TaskProvider<?> createLanguageTask(
TaskProvider<?> compileTaskProvider, String name, String processResourcesTaskName) {
return project
.getTasks()
.register(
name,
ByteBuddySimpleTask.class,
task -> {
task.setGroup("Byte Buddy");
task.getOutputs().cacheIf(unused -> true);

Task maybeCompileTask = compileTaskProvider.get();
if (maybeCompileTask instanceof AbstractCompile) {
AbstractCompile compileTask = (AbstractCompile) maybeCompileTask;
File classesDirectory = compileTask.getDestinationDirectory().getAsFile().get();
File rawClassesDirectory =
new File(classesDirectory.getParent(), classesDirectory.getName() + "raw")
.getAbsoluteFile();

task.dependsOn(compileTask);
compileTask.getDestinationDirectory().set(rawClassesDirectory);

task.setSource(rawClassesDirectory);
task.setTarget(classesDirectory);
task.setClassPath(compileTask.getClasspath());

task.dependsOn(compileTask, processResourcesTaskName);
}

task.getTransformations().add(createTransformation(inputClasspath, pluginClassName));
});
}

private AbstractCompile getCompileTask(String language) {
Expand Down
3 changes: 1 addition & 2 deletions instrumentation/apache-httpasyncclient-4.1/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ dependencies {
api(project(":instrumentation:java-streams"))
api(project(":instrumentation:apache-httpclient-4.0"))

api("io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-apache-httpasyncclient-4.1:${versions["opentelemetry_java_agent"]}")

implementation(project(":instrumentation:otel-apache-httpasyncclient-unshaded", "shadow"))
library("org.apache.httpcomponents:httpasyncclient:4.1")
testImplementation(testFixtures(project(":testing-common")))
}
Expand Down
Loading