Skip to content

Bump OTEL to 0.14.0 #237

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 1 commit into from
Jan 18, 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
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ subprojects {
description = "Hypertrace OpenTelemetry Javaagent"

extra.set("versions", mapOf(
"opentelemetry" to "0.13.1",
"opentelemetry_java_agent" to "0.13.0",
"opentelemetry" to "0.14.1",
"opentelemetry_java_agent" to "0.14.0",
"byte_buddy" to "1.10.18"
))

Expand Down

This file was deleted.

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

package io.opentelemetry.javaagent.instrumentation.hypertrace.apachehttpasyncclient;

import static io.opentelemetry.javaagent.tooling.ClassLoaderMatcher.hasClassesNamed;
import static io.opentelemetry.javaagent.tooling.bytebuddy.matcher.AgentElementMatchers.implementsInterface;
import static io.opentelemetry.javaagent.tooling.bytebuddy.matcher.ClassLoaderMatcher.hasClassesNamed;
import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
import static net.bytebuddy.matcher.ElementMatchers.named;
Expand All @@ -28,7 +28,6 @@
import io.opentelemetry.api.trace.Span;
import io.opentelemetry.context.Context;
import io.opentelemetry.javaagent.instrumentation.apachehttpasyncclient.ApacheHttpAsyncClientInstrumentation.DelegatingRequestProducer;
import io.opentelemetry.javaagent.instrumentation.apachehttpasyncclient.DelegatingRequestAccessor;
import io.opentelemetry.javaagent.instrumentation.hypertrace.apachehttpclient.v4_0.ApacheHttpClientUtils;
import io.opentelemetry.javaagent.tooling.InstrumentationModule;
import io.opentelemetry.javaagent.tooling.TypeInstrumentation;
Expand Down Expand Up @@ -104,7 +103,7 @@ public static void enter(
if (requestProducer instanceof DelegatingRequestProducer) {
DelegatingRequestProducer delegatingRequestProducer =
(DelegatingRequestProducer) requestProducer;
Context context = DelegatingRequestAccessor.get(delegatingRequestProducer);
Context context = delegatingRequestProducer.getContext();
requestProducer = new DelegatingCaptureBodyRequestProducer(context, requestProducer);
futureCallback = new BodyCaptureDelegatingCallback(context, httpContext, futureCallback);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
import org.hypertrace.agent.testing.AbstractInstrumenterTest;
import org.hypertrace.agent.testing.TestHttpServer;
import org.hypertrace.agent.testing.TestHttpServer.GetJsonHandler;
import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
Expand Down Expand Up @@ -183,35 +182,7 @@ public boolean isRepeatable() {

@Override
public InputStream getContent() {
return new TestInputStream(this.content);
}
}

// TODO remove once https://github.com/hypertrace/javaagent/issues/189 is fixed
static class TestInputStream extends ByteArrayInputStream {

public TestInputStream(byte[] buf) {
super(buf);
}

@Override
public synchronized int read() {
return super.read();
}

@Override
public int read(@NotNull byte[] b) throws IOException {
return super.read(b);
}

@Override
public synchronized int read(byte[] b, int off, int len) {
return super.read(b, off, len);
}

@Override
public synchronized int available() {
return super.available();
return new ByteArrayInputStream(this.content);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package io.opentelemetry.javaagent.instrumentation.hypertrace.apachehttpclient.v4_0.readall;

import static io.opentelemetry.javaagent.tooling.bytebuddy.matcher.AgentElementMatchers.safeHasSuperType;
import static io.opentelemetry.javaagent.tooling.matcher.NameMatchers.namedOneOf;
import static io.opentelemetry.javaagent.tooling.bytebuddy.matcher.NameMatchers.namedOneOf;
import static net.bytebuddy.matcher.ElementMatchers.is;
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

package io.opentelemetry.javaagent.instrumentation.hypertrace.grpc.v1_5.server;

import static io.opentelemetry.javaagent.tooling.ClassLoaderMatcher.hasClassesNamed;
import static io.opentelemetry.javaagent.tooling.bytebuddy.matcher.AgentElementMatchers.safeHasSuperType;
import static io.opentelemetry.javaagent.tooling.bytebuddy.matcher.ClassLoaderMatcher.hasClassesNamed;
import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class InputStreamInstrumentationModuleTest extends AbstractInstrumenterTe

@Test
public void read() {
InputStream inputStream = new TestByteArrayInputStream(STR.getBytes());
InputStream inputStream = new ByteArrayInputStream(STR.getBytes());
read(
inputStream,
() -> {
Expand All @@ -57,7 +57,7 @@ public void read() {

@Test
public void readBytes() {
InputStream inputStream = new TestByteArrayInputStream(STR.getBytes());
InputStream inputStream = new ByteArrayInputStream(STR.getBytes());
read(
inputStream,
() -> {
Expand All @@ -75,7 +75,7 @@ public void readBytes() {

@Test
public void readBytesOffset() {
InputStream inputStream = new TestByteArrayInputStream(STR.getBytes());
InputStream inputStream = new ByteArrayInputStream(STR.getBytes());
read(
inputStream,
() -> {
Expand Down Expand Up @@ -109,30 +109,4 @@ private void read(InputStream inputStream, Runnable read, String expected) {
SpanData spanData = trace.get(0);
Assertions.assertEquals(expected, spanData.getAttributes().get(ATTRIBUTE_KEY));
}

/**
* Each method has to be overridden because OTEL agent ignores classes from java.
* https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/8baa897e8bf09359da848aaaa98d2b4eb7fbf4c1/javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/matcher/GlobalIgnoresMatcher.java#L105
*/
static class TestByteArrayInputStream extends ByteArrayInputStream {

public TestByteArrayInputStream(byte[] buf) {
super(buf);
}

@Override
public synchronized int read() {
return super.read();
}

@Override
public int read(byte[] b) throws IOException {
return super.read(b);
}

@Override
public synchronized int read(byte[] b, int off, int len) {
return super.read(b, off, len);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class OutputStreamInstrumentationModuleTest extends AbstractInstrumenterTest {

@Test
public void write() {
OutputStream outputStream = new TestByteArrayOutputStream();
OutputStream outputStream = new ByteArrayOutputStream();
write(
outputStream,
() -> {
Expand All @@ -54,7 +54,7 @@ public void write() {

@Test
public void writeBytes() {
OutputStream outputStream = new TestByteArrayOutputStream();
OutputStream outputStream = new ByteArrayOutputStream();
write(
outputStream,
() -> {
Expand All @@ -70,7 +70,7 @@ public void writeBytes() {

@Test
public void writeBytesOffset() {
OutputStream outputStream = new TestByteArrayOutputStream();
OutputStream outputStream = new ByteArrayOutputStream();
write(
outputStream,
() -> {
Expand All @@ -92,26 +92,4 @@ private void write(OutputStream outputStream, Runnable read, String expected) {
read.run();
Assertions.assertEquals(expected, buffer.toString());
}

/**
* Each method has to be overridden because OTEL agent ignores classes from java.
* https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/8baa897e8bf09359da848aaaa98d2b4eb7fbf4c1/javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/matcher/GlobalIgnoresMatcher.java#L105
*/
static class TestByteArrayOutputStream extends ByteArrayOutputStream {

@Override
public synchronized void write(int b) {
super.write(b);
}

@Override
public void write(byte[] b) throws IOException {
super.write(b);
}

@Override
public synchronized void write(byte[] b, int off, int len) {
super.write(b, off, len);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

package io.opentelemetry.javaagent.instrumentation.hypertrace.jaxrs.v2_0;

import static io.opentelemetry.javaagent.tooling.ClassLoaderMatcher.hasClassesNamed;
import static io.opentelemetry.javaagent.tooling.bytebuddy.matcher.AgentElementMatchers.extendsClass;
import static io.opentelemetry.javaagent.tooling.bytebuddy.matcher.AgentElementMatchers.hasInterface;
import static io.opentelemetry.javaagent.tooling.bytebuddy.matcher.ClassLoaderMatcher.hasClassesNamed;
import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.returns;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,56 +17,20 @@
package io.opentelemetry.javaagent.instrumentation.hypertrace.netty.v4_0;

import io.netty.util.AttributeKey;
import io.opentelemetry.javaagent.instrumentation.api.WeakMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import org.hypertrace.agent.core.instrumentation.HypertraceSemanticAttributes;
import org.hypertrace.agent.core.instrumentation.buffer.BoundedByteArrayOutputStream;

/**
* Copied from
* https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/deda1af9c0e420b882164e5f8240b51678cd646f/instrumentation/netty/netty-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/v4_0/AttributeKeys.java#L14
*/
public class AttributeKeys {
private static final WeakMap<ClassLoader, ConcurrentMap<String, AttributeKey<?>>> map =
WeakMap.Implementation.DEFAULT.get();
private static final WeakMap.ValueSupplier<ClassLoader, ConcurrentMap<String, AttributeKey<?>>>
mapSupplier =
new WeakMap.ValueSupplier<ClassLoader, ConcurrentMap<String, AttributeKey<?>>>() {
@Override
public ConcurrentMap<String, AttributeKey<?>> get(ClassLoader ignore) {
return new ConcurrentHashMap<>();
}
};

public static final AttributeKey<BoundedByteArrayOutputStream> RESPONSE_BODY_BUFFER =
attributeKey(HypertraceSemanticAttributes.HTTP_RESPONSE_BODY.getKey());
io.opentelemetry.javaagent.instrumentation.netty.v4_0.AttributeKeys.attributeKey(
HypertraceSemanticAttributes.HTTP_RESPONSE_BODY.getKey());

public static final AttributeKey<BoundedByteArrayOutputStream> REQUEST_BODY_BUFFER =
attributeKey(HypertraceSemanticAttributes.HTTP_REQUEST_BODY.getKey());
io.opentelemetry.javaagent.instrumentation.netty.v4_0.AttributeKeys.attributeKey(
HypertraceSemanticAttributes.HTTP_REQUEST_BODY.getKey());

public static final AttributeKey<Map<String, String>> REQUEST_HEADERS =
attributeKey(AttributeKeys.class.getName() + ".request-headers");

/**
* Generate an attribute key or reuse the one existing in the global app map. This implementation
* creates attributes only once even if the current class is loaded by several class loaders and
* prevents an issue with Apache Atlas project were this class loaded by multiple class loaders,
* while the Attribute class is loaded by a third class loader and used internally for the
* cassandra driver.
*/
private static <T> AttributeKey<T> attributeKey(String key) {
ConcurrentMap<String, AttributeKey<?>> classLoaderMap =
map.computeIfAbsent(AttributeKey.class.getClassLoader(), mapSupplier);
if (classLoaderMap.containsKey(key)) {
@SuppressWarnings("unchecked")
AttributeKey<T> attrKey = (AttributeKey<T>) classLoaderMap.get(key);
return attrKey;
}

AttributeKey<T> value = new AttributeKey<>(key);
classLoaderMap.put(key, value);
return value;
}
io.opentelemetry.javaagent.instrumentation.netty.v4_0.AttributeKeys.attributeKey(
AttributeKeys.class.getName() + ".request-headers");
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

package io.opentelemetry.javaagent.instrumentation.hypertrace.netty.v4_0;

import static io.opentelemetry.javaagent.tooling.ClassLoaderMatcher.hasClassesNamed;
import static io.opentelemetry.javaagent.tooling.bytebuddy.matcher.AgentElementMatchers.implementsInterface;
import static io.opentelemetry.javaagent.tooling.bytebuddy.matcher.ClassLoaderMatcher.hasClassesNamed;
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
import static net.bytebuddy.matcher.ElementMatchers.nameStartsWith;
import static net.bytebuddy.matcher.ElementMatchers.named;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
import io.netty.handler.codec.http.LastHttpContent;
import io.netty.util.Attribute;
import io.opentelemetry.api.trace.Span;
import io.opentelemetry.api.trace.attributes.SemanticAttributes;
import io.opentelemetry.context.Context;
import io.opentelemetry.context.Scope;
import io.opentelemetry.instrumentation.api.tracer.HttpStatusConverter;
import io.opentelemetry.javaagent.instrumentation.hypertrace.netty.v4_0.AttributeKeys;
import io.opentelemetry.javaagent.instrumentation.hypertrace.netty.v4_0.DataCaptureUtils;
import io.opentelemetry.javaagent.instrumentation.netty.v4_0.client.NettyHttpClientTracer;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import java.nio.charset.Charset;
import java.util.Map;
import org.hypertrace.agent.config.Config.AgentConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@
import io.netty.handler.codec.http.LastHttpContent;
import io.netty.util.Attribute;
import io.opentelemetry.api.trace.Span;
import io.opentelemetry.api.trace.attributes.SemanticAttributes;
import io.opentelemetry.context.Context;
import io.opentelemetry.context.Scope;
import io.opentelemetry.instrumentation.api.tracer.HttpStatusConverter;
import io.opentelemetry.javaagent.instrumentation.hypertrace.netty.v4_0.AttributeKeys;
import io.opentelemetry.javaagent.instrumentation.hypertrace.netty.v4_0.DataCaptureUtils;
import io.opentelemetry.javaagent.instrumentation.netty.v4_0.server.NettyHttpServerTracer;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import java.nio.charset.Charset;
import java.util.Map;
import org.hypertrace.agent.config.Config.AgentConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

package io.opentelemetry.javaagent.instrumentation.hypertrace.netty.v4_1;

import static io.opentelemetry.javaagent.tooling.ClassLoaderMatcher.hasClassesNamed;
import static io.opentelemetry.javaagent.tooling.bytebuddy.matcher.AgentElementMatchers.implementsInterface;
import static io.opentelemetry.javaagent.tooling.bytebuddy.matcher.ClassLoaderMatcher.hasClassesNamed;
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
import static net.bytebuddy.matcher.ElementMatchers.nameStartsWith;
import static net.bytebuddy.matcher.ElementMatchers.named;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
import io.netty.handler.codec.http.LastHttpContent;
import io.netty.util.Attribute;
import io.opentelemetry.api.trace.Span;
import io.opentelemetry.api.trace.attributes.SemanticAttributes;
import io.opentelemetry.context.Context;
import io.opentelemetry.context.Scope;
import io.opentelemetry.instrumentation.api.tracer.HttpStatusConverter;
import io.opentelemetry.javaagent.instrumentation.hypertrace.netty.v4_1.AttributeKeys;
import io.opentelemetry.javaagent.instrumentation.hypertrace.netty.v4_1.DataCaptureUtils;
import io.opentelemetry.javaagent.instrumentation.netty.v4_1.client.NettyHttpClientTracer;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import java.nio.charset.Charset;
import java.util.Map;
import org.hypertrace.agent.config.Config.AgentConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
import io.netty.handler.codec.http.LastHttpContent;
import io.netty.util.Attribute;
import io.opentelemetry.api.trace.Span;
import io.opentelemetry.api.trace.attributes.SemanticAttributes;
import io.opentelemetry.context.Context;
import io.opentelemetry.context.Scope;
import io.opentelemetry.instrumentation.api.tracer.HttpStatusConverter;
import io.opentelemetry.javaagent.instrumentation.hypertrace.netty.v4_1.AttributeKeys;
import io.opentelemetry.javaagent.instrumentation.hypertrace.netty.v4_1.DataCaptureUtils;
import io.opentelemetry.javaagent.instrumentation.netty.v4_1.server.NettyHttpServerTracer;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import java.nio.charset.Charset;
import java.util.Map;
import org.hypertrace.agent.config.Config.AgentConfig;
Expand Down
Loading