Skip to content

Upgrate OTEL to 1.1.0 #308

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

Merged
merged 6 commits into from
Apr 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ smoke-test:
muzzle:
# daemon was causing failure "java.lang.IllegalStateException: Could not locate class file for"
# for injecting helper classes from the same packages as instrumentations
./gradlew muzzle --no-daemon
./gradlew assemble muzzle --no-daemon

.PHONY: docker
docker: assemble
Expand Down
6 changes: 3 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ subprojects {
description = "Hypertrace OpenTelemetry Javaagent"

extra.set("versions", mapOf(
"opentelemetry" to "1.0.1",
"opentelemetry_java_agent" to "1.0.1-alpha",
"opentelemetry_java_agent_all" to "1.0.1",
"opentelemetry" to "1.1.0",
"opentelemetry_java_agent" to "1.1.0-alpha",
"opentelemetry_java_agent_all" to "1.1.0",
"byte_buddy" to "1.10.18",
"slf4j" to "1.7.30"
))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@

import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.trace.Span;
import io.opentelemetry.javaagent.instrumentation.api.WeakMap;
import io.opentelemetry.instrumentation.api.caching.Cache;
import org.apache.http.HttpEntity;

public class ApacheHttpClientObjectRegistry {

public static final WeakMap<HttpEntity, SpanAndAttributeKey> entityToSpan =
WeakMap.Provider.newWeakMap();
public static final Cache<HttpEntity, SpanAndAttributeKey> entityToSpan =
Cache.newBuilder().setWeakKeys().build();

public static class SpanAndAttributeKey {
public final Span span;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
public class HttpEntityInstrumentation implements TypeInstrumentation {

@Override
public ElementMatcher<? super TypeDescription> typeMatcher() {
public ElementMatcher<TypeDescription> typeMatcher() {
return implementsInterface(named("org.apache.http.HttpEntity"));
}

Expand Down Expand Up @@ -138,13 +138,15 @@ public static void enter(
public static void exit(
@Advice.This HttpEntity thizz, @Advice.Argument(0) OutputStream outputStream) {
SpanAndAttributeKey spanAndAttributeKey =
ApacheHttpClientObjectRegistry.entityToSpan.remove(thizz);
ApacheHttpClientObjectRegistry.entityToSpan.get(thizz);
ApacheHttpClientObjectRegistry.entityToSpan.remove(thizz);
if (spanAndAttributeKey == null) {
return;
}

BoundedByteArrayOutputStream bufferedOutStream =
GlobalObjectRegistry.outputStreamToBufferMap.remove(outputStream);
GlobalObjectRegistry.outputStreamToBufferMap.get(outputStream);
GlobalObjectRegistry.outputStreamToBufferMap.remove(outputStream);
try {
String requestBody = bufferedOutStream.toStringWithSuppliedCharset();
spanAndAttributeKey.span.setAttribute(spanAndAttributeKey.attributeKey, requestBody);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public static void exit(@Return Object response) {

static class HttpEntityInstrumentation implements TypeInstrumentation {
@Override
public ElementMatcher<? super TypeDescription> typeMatcher() {
public ElementMatcher<TypeDescription> typeMatcher() {
return implementsInterface(named("org.apache.http.HttpEntity"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public List<TypeInstrumentation> typeInstrumentations() {
static class InputStreamInstrumentation implements TypeInstrumentation {

@Override
public ElementMatcher<? super TypeDescription> typeMatcher() {
public ElementMatcher<TypeDescription> typeMatcher() {
return safeHasSuperType(namedOneOf("java.io.InputStream"));
}

Expand Down
2 changes: 1 addition & 1 deletion instrumentation/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ tasks {
relocate("org.checkerframework", "io.opentelemetry.javaagent.shaded.org.hypertrace.shaded.com.checkerframework")
relocate("org.yaml", "io.opentelemetry.javaagent.shaded.org.hypertrace.shaded.org.yaml")

relocate("com.blogspot.mydailyjava", "io.opentelemetry.javaagent.shaded.org.hypertrace.shaded.com.blogspot.mydailyjava")
relocate("com.blogspot.mydailyjava.weaklockfree", "io.opentelemetry.instrumentation.api.internal.shaded.weaklockfree")

exclude("**/module-info.class")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public List<TypeInstrumentation> typeInstrumentations() {
*/
class NettyUtilsInstrumentation implements TypeInstrumentation {
@Override
public ElementMatcher<? super TypeDescription> typeMatcher() {
public ElementMatcher<TypeDescription> typeMatcher() {
return failSafe(named("io.grpc.netty.Utils"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public List<TypeInstrumentation> typeInstrumentations() {
static class InputStreamInstrumentation implements TypeInstrumentation {

@Override
public ElementMatcher<? super TypeDescription> typeMatcher() {
public ElementMatcher<TypeDescription> typeMatcher() {
return extendsClass(named(InputStream.class.getName()))
.and(not(safeHasSuperType(named("javax.servlet.ServletInputStream"))));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public List<TypeInstrumentation> typeInstrumentations() {
static class OutputStreamInstrumentation implements TypeInstrumentation {

@Override
public ElementMatcher<? super TypeDescription> typeMatcher() {
public ElementMatcher<TypeDescription> typeMatcher() {
return extendsClass(named(OutputStream.class.getName()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,6 @@ public ElementMatcher.Junction<ClassLoader> classLoaderMatcher() {
.and(not(hasClassesNamed("javax.servlet.AsyncEvent", "javax.servlet.AsyncListener")));
}

@Override
public Map<String, String> contextStore() {
return singletonMap("javax.servlet.ServletResponse", Integer.class.getName());
}

@Override
public List<TypeInstrumentation> typeInstrumentations() {
return Collections.singletonList(new Servlet2BodyInstrumentation());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public ElementMatcher<ClassLoader> classLoaderOptimization() {
}

@Override
public ElementMatcher<? super TypeDescription> typeMatcher() {
public ElementMatcher<TypeDescription> typeMatcher() {
return safeHasSuperType(namedOneOf("javax.servlet.Filter", "javax.servlet.Servlet"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,7 @@
import io.opentelemetry.javaagent.tooling.InstrumentationModule;
import io.opentelemetry.javaagent.tooling.TypeInstrumentation;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.hypertrace.agent.core.instrumentation.SpanAndObjectPair;
import org.hypertrace.agent.core.instrumentation.buffer.BoundedByteArrayOutputStream;
import org.hypertrace.agent.core.instrumentation.buffer.BoundedCharArrayWriter;
import org.hypertrace.agent.core.instrumentation.buffer.ByteBufferSpanPair;
import org.hypertrace.agent.core.instrumentation.buffer.CharBufferSpanPair;

@AutoService(InstrumentationModule.class)
public class Servlet31NoWrappingInstrumentationModule extends InstrumentationModule {
Expand All @@ -54,19 +47,4 @@ public List<TypeInstrumentation> typeInstrumentations() {
new ServletResponseInstrumentation(),
new ServletOutputStreamInstrumentation());
}

@Override
protected Map<String, String> contextStore() {
Map<String, String> context = new HashMap<>();
// capture request body
context.put("javax.servlet.http.HttpServletRequest", SpanAndObjectPair.class.getName());
context.put("javax.servlet.ServletInputStream", ByteBufferSpanPair.class.getName());
context.put("java.io.BufferedReader", CharBufferSpanPair.class.getName());

// capture response body
context.put("javax.servlet.http.HttpServletResponse", SpanAndObjectPair.class.getName());
context.put("javax.servlet.ServletOutputStream", BoundedByteArrayOutputStream.class.getName());
context.put("java.io.PrintWriter", BoundedCharArrayWriter.class.getName());
return context;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
public class ServletInputStreamInstrumentation implements TypeInstrumentation {

@Override
public ElementMatcher<? super TypeDescription> typeMatcher() {
public ElementMatcher<TypeDescription> typeMatcher() {
return safeHasSuperType(named("javax.servlet.ServletInputStream"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
public class ServletRequestInstrumentation implements TypeInstrumentation {

@Override
public ElementMatcher<? super TypeDescription> typeMatcher() {
public ElementMatcher<TypeDescription> typeMatcher() {
return safeHasSuperType(named("javax.servlet.ServletRequest"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
public class ServletOutputStreamInstrumentation implements TypeInstrumentation {

@Override
public ElementMatcher<? super TypeDescription> typeMatcher() {
public ElementMatcher<TypeDescription> typeMatcher() {
return safeHasSuperType(named("javax.servlet.ServletOutputStream"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
public class ServletResponseInstrumentation implements TypeInstrumentation {

@Override
public ElementMatcher<? super TypeDescription> typeMatcher() {
public ElementMatcher<TypeDescription> typeMatcher() {
return safeHasSuperType(named("javax.servlet.ServletResponse"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public ServletInputStreamContextAccessInstrumentationModule() {
}

@Override
protected Map<String, String> contextStore() {
protected Map<String, String> getMuzzleContextStoreClasses() {
Map<String, String> context = new HashMap<>();
context.put("javax.servlet.ServletInputStream", ByteBufferSpanPair.class.getName());
return context;
Expand All @@ -58,7 +58,7 @@ public List<TypeInstrumentation> typeInstrumentations() {
class InputStreamTriggerInstrumentation implements TypeInstrumentation {

@Override
public ElementMatcher<? super TypeDescription> typeMatcher() {
public ElementMatcher<TypeDescription> typeMatcher() {
return named("org.ServletStreamContextAccess");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public ServletOutputStreamContextAccessInstrumentationModule() {
}

@Override
protected Map<String, String> contextStore() {
protected Map<String, String> getMuzzleContextStoreClasses() {
Map<String, String> context = new HashMap<>();
context.put("javax.servlet.ServletOutputStream", BoundedByteArrayOutputStream.class.getName());
return context;
Expand All @@ -57,7 +57,7 @@ public List<TypeInstrumentation> typeInstrumentations() {
class OutputStreamTriggerInstrumentation implements TypeInstrumentation {

@Override
public ElementMatcher<? super TypeDescription> typeMatcher() {
public ElementMatcher<TypeDescription> typeMatcher() {
return named("org.ServletStreamContextAccess");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public List<TypeInstrumentation> typeInstrumentations() {
private static class Servlet30BodyInstrumentation implements TypeInstrumentation {

@Override
public ElementMatcher<? super TypeDescription> typeMatcher() {
public ElementMatcher<TypeDescription> typeMatcher() {
return safeHasSuperType(namedOneOf("javax.servlet.Filter", "javax.servlet.http.HttpServlet"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public List<TypeInstrumentation> typeInstrumentations() {
private static final class Servlet31BodyInstrumentation implements TypeInstrumentation {

@Override
public ElementMatcher<? super TypeDescription> typeMatcher() {
public ElementMatcher<TypeDescription> typeMatcher() {
return safeHasSuperType(namedOneOf("javax.servlet.Filter", "javax.servlet.http.HttpServlet"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
public class BufferedReaderInstrumentation implements TypeInstrumentation {

@Override
public ElementMatcher<? super TypeDescription> typeMatcher() {
public ElementMatcher<TypeDescription> typeMatcher() {
return safeHasSuperType(named("java.io.BufferedReader")).or(named("java.io.BufferedReader"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
import io.opentelemetry.javaagent.tooling.TypeInstrumentation;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.hypertrace.agent.core.instrumentation.buffer.CharBufferSpanPair;

/**
* Instrumentation module for {@link java.io.BufferedReader}. It must be be defined in a separate
Expand All @@ -36,11 +34,6 @@ public BufferedReaderInstrumentationModule() {
super("bufferedreader", "servlet", "servlet-3", "ht", "servlet-no-wrapping");
}

@Override
protected Map<String, String> contextStore() {
return Collections.singletonMap("java.io.BufferedReader", CharBufferSpanPair.class.getName());
}

@Override
public List<TypeInstrumentation> typeInstrumentations() {
return Collections.singletonList(new BufferedReaderInstrumentation());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
public class PrintWriterInstrumentation implements TypeInstrumentation {

@Override
public ElementMatcher<? super TypeDescription> typeMatcher() {
public ElementMatcher<TypeDescription> typeMatcher() {
return safeHasSuperType(named("java.io.PrintWriter")).or(named("java.io.PrintWriter"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
import io.opentelemetry.javaagent.tooling.TypeInstrumentation;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.hypertrace.agent.core.instrumentation.buffer.BoundedCharArrayWriter;

@AutoService(InstrumentationModule.class)
public class PrintWriterInstrumentationModule extends InstrumentationModule {
Expand All @@ -31,11 +29,6 @@ public PrintWriterInstrumentationModule() {
super("printwriter", "servlet", "servlet-3", "ht", "servlet-no-wrapping");
}

@Override
protected Map<String, String> contextStore() {
return Collections.singletonMap("java.io.PrintWriter", BoundedCharArrayWriter.class.getName());
}

@Override
public List<TypeInstrumentation> typeInstrumentations() {
return Collections.singletonList(new PrintWriterInstrumentation());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public BufferedReaderContextAccessInstrumentationModule() {
}

@Override
protected Map<String, String> contextStore() {
protected Map<String, String> getMuzzleContextStoreClasses() {
return Collections.singletonMap("java.io.BufferedReader", CharBufferSpanPair.class.getName());
}

Expand All @@ -53,7 +53,7 @@ public List<TypeInstrumentation> typeInstrumentations() {
class BufferedReaderTriggerInstrumentation implements TypeInstrumentation {

@Override
public ElementMatcher<? super TypeDescription> typeMatcher() {
public ElementMatcher<TypeDescription> typeMatcher() {
return named("org.BufferedReaderPrintWriterContextAccess");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public PrintWriterContextAccessInstrumentationModule() {
}

@Override
protected Map<String, String> contextStore() {
protected Map<String, String> getMuzzleContextStoreClasses() {
return Collections.singletonMap("java.io.PrintWriter", BoundedCharArrayWriter.class.getName());
}

Expand All @@ -55,7 +55,7 @@ public List<TypeInstrumentation> typeInstrumentations() {
class PrintWriterTriggerInstrumentation implements TypeInstrumentation {

@Override
public ElementMatcher<? super TypeDescription> typeMatcher() {
public ElementMatcher<TypeDescription> typeMatcher() {
return named("org.BufferedReaderPrintWriterContextAccess");
}

Expand Down
9 changes: 0 additions & 9 deletions instrumentation/struts-2.3/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
plugins {
`java-library`
id("io.opentelemetry.instrumentation.auto-instrumentation")
muzzle
}

muzzle {
pass {
group = "org.apache.struts"
module = "struts2-core"
versions = "[2.3.1,)"
}
}

val versions: Map<String, String> by extra
Expand Down
9 changes: 0 additions & 9 deletions instrumentation/vertx-web-3.0/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,6 @@ plugins {
`java-library`
id("net.bytebuddy.byte-buddy")
id("io.opentelemetry.instrumentation.auto-instrumentation")
muzzle
}

muzzle {
pass {
group = "io.vertx"
module = "vertx-web"
versions = "[3.0.0,)"
}
}

afterEvaluate{
Expand Down
Loading