Fix more lint warnings (#5174)
* Fix more lint warnings * Redisable lint * Drift Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com>
This commit is contained in:
parent
52394a2ff9
commit
ec375116be
|
@ -37,6 +37,9 @@ dependencies {
|
|||
exclude(group = "io.opentelemetry", module = "opentelemetry-sdk-logs")
|
||||
}
|
||||
|
||||
// Used by byte-buddy but not brought in as a transitive dependency
|
||||
compileOnly("com.google.code.findbugs:annotations")
|
||||
|
||||
testImplementation("io.opentelemetry.javaagent:opentelemetry-testing-common")
|
||||
}
|
||||
|
||||
|
|
|
@ -39,6 +39,11 @@ val DEPENDENCY_BOMS = listOf(
|
|||
)
|
||||
|
||||
val DEPENDENCY_SETS = listOf(
|
||||
DependencySet(
|
||||
"com.google.auto.service",
|
||||
"1.0.1",
|
||||
listOf("auto-service", "auto-service-annotations")
|
||||
),
|
||||
DependencySet(
|
||||
"com.google.auto.value",
|
||||
"1.9",
|
||||
|
@ -86,7 +91,6 @@ val DEPENDENCIES = listOf(
|
|||
"ch.qos.logback:logback-classic:1.2.10",
|
||||
"com.github.stefanbirkner:system-lambda:1.2.1",
|
||||
"com.github.stefanbirkner:system-rules:1.19.0",
|
||||
"com.google.auto.service:auto-service:1.0.1",
|
||||
"com.uber.nullaway:nullaway:0.9.5",
|
||||
"commons-beanutils:commons-beanutils:1.9.4",
|
||||
"commons-cli:commons-cli:1.5.0",
|
||||
|
|
|
@ -29,7 +29,7 @@ import org.junit.jupiter.params.provider.ArgumentsProvider;
|
|||
import org.junit.jupiter.params.provider.ArgumentsSource;
|
||||
|
||||
// suppress duration unit check, e.g. ofMillis(5000) -> ofSeconds(5)
|
||||
@SuppressWarnings("CanonicalDuration")
|
||||
@SuppressWarnings({"CanonicalDuration", "deprecation"})
|
||||
class ConfigTest {
|
||||
@Test
|
||||
void shouldGetString() {
|
||||
|
|
|
@ -746,6 +746,7 @@ class InstrumenterTest {
|
|||
}
|
||||
|
||||
@SafeVarargs
|
||||
@SuppressWarnings("varargs")
|
||||
private static Instrumenter<Map<String, String>, Map<String, String>> getInstrumenterWithType(
|
||||
boolean enableInstrumentation,
|
||||
AttributesExtractor<Map<String, String>, Map<String, String>>... attributeExtractors) {
|
||||
|
|
|
@ -18,7 +18,7 @@ import io.opentelemetry.context.Context;
|
|||
import io.opentelemetry.instrumentation.api.instrumenter.RequestListener;
|
||||
import io.opentelemetry.sdk.metrics.SdkMeterProvider;
|
||||
import io.opentelemetry.sdk.metrics.data.MetricData;
|
||||
import io.opentelemetry.sdk.metrics.testing.InMemoryMetricReader;
|
||||
import io.opentelemetry.sdk.testing.exporter.InMemoryMetricReader;
|
||||
import java.util.Collection;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
|
|
@ -18,7 +18,7 @@ import io.opentelemetry.context.Context;
|
|||
import io.opentelemetry.instrumentation.api.instrumenter.RequestListener;
|
||||
import io.opentelemetry.sdk.metrics.SdkMeterProvider;
|
||||
import io.opentelemetry.sdk.metrics.data.MetricData;
|
||||
import io.opentelemetry.sdk.metrics.testing.InMemoryMetricReader;
|
||||
import io.opentelemetry.sdk.testing.exporter.InMemoryMetricReader;
|
||||
import java.util.Collection;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
|
|
@ -18,8 +18,8 @@ import io.opentelemetry.context.Context;
|
|||
import io.opentelemetry.instrumentation.api.instrumenter.RequestListener;
|
||||
import io.opentelemetry.sdk.metrics.SdkMeterProvider;
|
||||
import io.opentelemetry.sdk.metrics.data.MetricData;
|
||||
import io.opentelemetry.sdk.metrics.testing.InMemoryMetricReader;
|
||||
import io.opentelemetry.sdk.testing.assertj.MetricAssertions;
|
||||
import io.opentelemetry.sdk.testing.exporter.InMemoryMetricReader;
|
||||
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
|
||||
import java.util.Collection;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
|
|
@ -18,8 +18,8 @@ import io.opentelemetry.context.Context;
|
|||
import io.opentelemetry.instrumentation.api.instrumenter.RequestListener;
|
||||
import io.opentelemetry.sdk.metrics.SdkMeterProvider;
|
||||
import io.opentelemetry.sdk.metrics.data.MetricData;
|
||||
import io.opentelemetry.sdk.metrics.testing.InMemoryMetricReader;
|
||||
import io.opentelemetry.sdk.testing.assertj.MetricAssertions;
|
||||
import io.opentelemetry.sdk.testing.exporter.InMemoryMetricReader;
|
||||
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
|
||||
import java.util.Collection;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
|
|
@ -174,7 +174,7 @@ public class ApacheHttpClientInstrumentation implements TypeInstrumentation {
|
|||
// Wrap the handler so we capture the status code
|
||||
if (handler != null) {
|
||||
handler =
|
||||
new WrappingStatusSettingResponseHandler(context, parentContext, request, handler);
|
||||
new WrappingStatusSettingResponseHandler<>(context, parentContext, request, handler);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -214,7 +214,7 @@ public class ApacheHttpClientInstrumentation implements TypeInstrumentation {
|
|||
// Wrap the handler so we capture the status code
|
||||
if (handler != null) {
|
||||
handler =
|
||||
new WrappingStatusSettingResponseHandler(context, parentContext, request, handler);
|
||||
new WrappingStatusSettingResponseHandler<>(context, parentContext, request, handler);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -294,7 +294,8 @@ public class ApacheHttpClientInstrumentation implements TypeInstrumentation {
|
|||
// Wrap the handler so we capture the status code
|
||||
if (handler != null) {
|
||||
handler =
|
||||
new WrappingStatusSettingResponseHandler(context, parentContext, fullRequest, handler);
|
||||
new WrappingStatusSettingResponseHandler<>(
|
||||
context, parentContext, fullRequest, handler);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -338,7 +339,8 @@ public class ApacheHttpClientInstrumentation implements TypeInstrumentation {
|
|||
// Wrap the handler so we capture the status code
|
||||
if (handler != null) {
|
||||
handler =
|
||||
new WrappingStatusSettingResponseHandler(context, parentContext, fullRequest, handler);
|
||||
new WrappingStatusSettingResponseHandler<>(
|
||||
context, parentContext, fullRequest, handler);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ public class NettyRequestSenderInstrumentation implements TypeInstrumentation {
|
|||
public static class RememberNettyRequestAdvice {
|
||||
|
||||
@Advice.OnMethodExit
|
||||
public static void rememberNettyRequest(@Advice.Return NettyResponseFuture responseFuture) {
|
||||
public static void rememberNettyRequest(@Advice.Return NettyResponseFuture<?> responseFuture) {
|
||||
RequestContext requestContext =
|
||||
VirtualField.find(AsyncHandler.class, RequestContext.class)
|
||||
.get(responseFuture.getAsyncHandler());
|
||||
|
|
|
@ -26,7 +26,13 @@ import org.joda.time.format.DateTimeFormatter;
|
|||
*
|
||||
* <p>Supporting custom POJOs using Joda is out of the scope of this class.
|
||||
*/
|
||||
// Matches implementation of AWS Lambda runtime which targets an older version of Jackson than we
|
||||
// do.
|
||||
@SuppressWarnings("deprecation")
|
||||
class CustomJodaModule extends SimpleModule {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public CustomJodaModule() {
|
||||
super();
|
||||
addDeserializer(DateTime.class, new DateTimeDeserialiser());
|
||||
|
|
|
@ -49,8 +49,8 @@ public class AbstractClientInstrumentation implements TypeInstrumentation {
|
|||
|
||||
@Advice.OnMethodEnter(suppress = Throwable.class)
|
||||
public static void onEnter(
|
||||
@Advice.Argument(0) Action action,
|
||||
@Advice.Argument(1) ActionRequest actionRequest,
|
||||
@Advice.Argument(0) Action<?, ?, ?> action,
|
||||
@Advice.Argument(1) ActionRequest<?> actionRequest,
|
||||
@Advice.Local("otelContext") Context context,
|
||||
@Advice.Local("otelScope") Scope scope,
|
||||
@Advice.Local("otelRequest") ElasticTransportRequest transportRequest,
|
||||
|
|
|
@ -49,7 +49,7 @@ public class AbstractClientInstrumentation implements TypeInstrumentation {
|
|||
|
||||
@Advice.OnMethodEnter(suppress = Throwable.class)
|
||||
public static void onEnter(
|
||||
@Advice.Argument(0) Action action,
|
||||
@Advice.Argument(0) Action<?, ?, ?> action,
|
||||
@Advice.Argument(1) ActionRequest actionRequest,
|
||||
@Advice.Local("otelContext") Context context,
|
||||
@Advice.Local("otelScope") Scope scope,
|
||||
|
|
|
@ -21,3 +21,13 @@ dependencies {
|
|||
implementation("io.opentelemetry:opentelemetry-api")
|
||||
implementation("org.spockframework:spock-core")
|
||||
}
|
||||
|
||||
tasks {
|
||||
compileJava {
|
||||
with(options) {
|
||||
// We generate stubs using an old version of protobuf to test old versions of gRPC,
|
||||
// where this lint error triggers.
|
||||
compilerArgs.add("-Xlint:-cast")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -101,13 +101,13 @@ public class HttpClientInstrumentation implements TypeInstrumentation {
|
|||
@Advice.OnMethodEnter(suppress = Throwable.class)
|
||||
public static void methodEnter(
|
||||
@Advice.Argument(value = 0) HttpRequest httpRequest,
|
||||
@Advice.Argument(value = 1, readOnly = false) HttpResponse.BodyHandler bodyHandler,
|
||||
@Advice.Argument(value = 1, readOnly = false) HttpResponse.BodyHandler<?> bodyHandler,
|
||||
@Advice.Local("otelContext") Context context,
|
||||
@Advice.Local("otelParentContext") Context parentContext,
|
||||
@Advice.Local("otelScope") Scope scope) {
|
||||
parentContext = currentContext();
|
||||
if (bodyHandler != null) {
|
||||
bodyHandler = new BodyHandlerWrapper(bodyHandler, parentContext);
|
||||
bodyHandler = new BodyHandlerWrapper<>(bodyHandler, parentContext);
|
||||
}
|
||||
if (!instrumenter().shouldStart(parentContext, httpRequest)) {
|
||||
return;
|
||||
|
|
|
@ -35,9 +35,10 @@ public class TrustedSubscriberInstrumentation implements TypeInstrumentation {
|
|||
|
||||
@Advice.OnMethodEnter(suppress = Throwable.class)
|
||||
public static void methodEnter(
|
||||
@Advice.Argument(value = 0, readOnly = false) HttpResponse.BodySubscriber bodySubscriber) {
|
||||
@Advice.Argument(value = 0, readOnly = false)
|
||||
HttpResponse.BodySubscriber<?> bodySubscriber) {
|
||||
if (bodySubscriber instanceof BodySubscriberWrapper) {
|
||||
bodySubscriber = ((BodySubscriberWrapper) bodySubscriber).getDelegate();
|
||||
bodySubscriber = ((BodySubscriberWrapper<?>) bodySubscriber).getDelegate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ public final class MetroHelper {
|
|||
|
||||
private MetroHelper() {}
|
||||
|
||||
public static void start(WSEndpoint endpoint, Packet packet) {
|
||||
public static void start(WSEndpoint<?> endpoint, Packet packet) {
|
||||
Context parentContext = Context.current();
|
||||
|
||||
MetroRequest request = new MetroRequest(endpoint, packet);
|
||||
|
|
|
@ -12,7 +12,7 @@ public class MetroRequest {
|
|||
private final Packet packet;
|
||||
private final String spanName;
|
||||
|
||||
public MetroRequest(WSEndpoint endpoint, Packet packet) {
|
||||
public MetroRequest(WSEndpoint<?> endpoint, Packet packet) {
|
||||
this.packet = packet;
|
||||
this.spanName = getSpanName(endpoint, packet);
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ public class MetroRequest {
|
|||
return packet;
|
||||
}
|
||||
|
||||
private static String getSpanName(WSEndpoint endpoint, Packet packet) {
|
||||
private static String getSpanName(WSEndpoint<?> endpoint, Packet packet) {
|
||||
String serviceName = endpoint.getServiceName().getLocalPart();
|
||||
String operationName = packet.getWSDLOperation().getLocalPart();
|
||||
return serviceName + "/" + operationName;
|
||||
|
|
|
@ -15,9 +15,9 @@ import com.sun.xml.ws.api.pipe.helper.AbstractTubeImpl;
|
|||
import com.sun.xml.ws.api.server.WSEndpoint;
|
||||
|
||||
public class TracingTube extends AbstractFilterTubeImpl {
|
||||
private final WSEndpoint endpoint;
|
||||
private final WSEndpoint<?> endpoint;
|
||||
|
||||
public TracingTube(WSEndpoint endpoint, Tube next) {
|
||||
public TracingTube(WSEndpoint<?> endpoint, Tube next) {
|
||||
super(next);
|
||||
this.endpoint = endpoint;
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import java.util.concurrent.CountDownLatch;
|
|||
import java.util.concurrent.ForkJoinTask;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
public class JavaAsyncChild extends ForkJoinTask implements Runnable, Callable {
|
||||
public class JavaAsyncChild extends ForkJoinTask<Object> implements Runnable, Callable<Object> {
|
||||
private static final Tracer tracer = GlobalOpenTelemetry.getTracer("test");
|
||||
|
||||
private final AtomicBoolean blockThread;
|
||||
|
|
|
@ -13,6 +13,7 @@ enum MessagePropertyGetter implements TextMapGetter<MessageWithDestination> {
|
|||
INSTANCE;
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Iterable<String> keys(MessageWithDestination message) {
|
||||
try {
|
||||
return Collections.list(message.message().getPropertyNames());
|
||||
|
|
|
@ -71,7 +71,7 @@ public class KafkaConsumerInstrumentation implements TypeInstrumentation {
|
|||
// context even though the span has ended
|
||||
// this is the suggested behavior according to the spec batch receive scenario:
|
||||
// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/messaging.md#batch-receiving
|
||||
VirtualField<ConsumerRecords, Context> consumerRecordsContext =
|
||||
VirtualField<ConsumerRecords<?, ?>, Context> consumerRecordsContext =
|
||||
VirtualField.find(ConsumerRecords.class, Context.class);
|
||||
consumerRecordsContext.set(records, context);
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ public class TracingList<K, V> extends TracingIterable<K, V> implements List<Con
|
|||
}
|
||||
|
||||
@Override
|
||||
public ConsumerRecord<K, V> set(int index, ConsumerRecord element) {
|
||||
public ConsumerRecord<K, V> set(int index, ConsumerRecord<K, V> element) {
|
||||
return delegate.set(index, element);
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ public class RecordDeserializerInstrumentation implements TypeInstrumentation {
|
|||
}
|
||||
|
||||
// copy the receive CONSUMER span association
|
||||
VirtualField<ConsumerRecord, Context> singleRecordReceiveContext =
|
||||
VirtualField<ConsumerRecord<?, ?>, Context> singleRecordReceiveContext =
|
||||
VirtualField.find(ConsumerRecord.class, Context.class);
|
||||
singleRecordReceiveContext.set(result, singleRecordReceiveContext.get(incoming));
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ public class SourceNodeRecordDeserializerInstrumentation implements TypeInstrume
|
|||
}
|
||||
|
||||
// copy the receive CONSUMER span association
|
||||
VirtualField<ConsumerRecord, Context> singleRecordReceiveContext =
|
||||
VirtualField<ConsumerRecord<?, ?>, Context> singleRecordReceiveContext =
|
||||
VirtualField.find(ConsumerRecord.class, Context.class);
|
||||
singleRecordReceiveContext.set(result, singleRecordReceiveContext.get(incoming));
|
||||
}
|
||||
|
|
|
@ -5,4 +5,6 @@
|
|||
|
||||
package io.opentelemetry.javaagent.instrumentation.kubernetesclient;
|
||||
|
||||
class ParseKubernetesResourceException extends Exception {}
|
||||
class ParseKubernetesResourceException extends Exception {
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ public class LettuceFluxTerminationRunnable implements Consumer<Signal<?>>, Runn
|
|||
}
|
||||
|
||||
@Override
|
||||
public void accept(Signal signal) {
|
||||
public void accept(Signal<?> signal) {
|
||||
if (SignalType.ON_COMPLETE.equals(signal.getType())
|
||||
|| SignalType.ON_ERROR.equals(signal.getType())) {
|
||||
finishSpan(/* isCommandCancelled= */ false, signal.getThrowable());
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.util.function.Supplier;
|
|||
import net.bytebuddy.asm.Advice;
|
||||
import net.bytebuddy.description.type.TypeDescription;
|
||||
import net.bytebuddy.matcher.ElementMatcher;
|
||||
import org.reactivestreams.Subscription;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
|
@ -53,18 +54,20 @@ public class LettuceReactiveCommandsInstrumentation implements TypeInstrumentati
|
|||
public static class CreateMonoAdvice {
|
||||
|
||||
@Advice.OnMethodEnter(suppress = Throwable.class)
|
||||
public static RedisCommand extractCommandName(
|
||||
@Advice.Argument(0) Supplier<RedisCommand> supplier) {
|
||||
public static <K, V, T> RedisCommand<K, V, T> extractCommandName(
|
||||
@Advice.Argument(0) Supplier<RedisCommand<K, V, T>> supplier) {
|
||||
return supplier.get();
|
||||
}
|
||||
|
||||
// throwables wouldn't matter here, because no spans have been started due to redis command not
|
||||
// being run until the user subscribes to the Mono publisher
|
||||
@Advice.OnMethodExit(suppress = Throwable.class)
|
||||
public static void monitorSpan(
|
||||
@Advice.Enter RedisCommand command, @Advice.Return(readOnly = false) Mono<?> publisher) {
|
||||
public static <K, V, T> void monitorSpan(
|
||||
@Advice.Enter RedisCommand<K, V, T> command,
|
||||
@Advice.Return(readOnly = false) Mono<T> publisher) {
|
||||
boolean finishSpanOnClose = !expectsResponse(command);
|
||||
LettuceMonoDualConsumer mdc = new LettuceMonoDualConsumer(command, finishSpanOnClose);
|
||||
LettuceMonoDualConsumer<? super Subscription, T> mdc =
|
||||
new LettuceMonoDualConsumer<>(command, finishSpanOnClose);
|
||||
publisher = publisher.doOnSubscribe(mdc);
|
||||
// register the call back to close the span only if necessary
|
||||
if (!finishSpanOnClose) {
|
||||
|
@ -77,15 +80,16 @@ public class LettuceReactiveCommandsInstrumentation implements TypeInstrumentati
|
|||
public static class CreateFluxAdvice {
|
||||
|
||||
@Advice.OnMethodEnter(suppress = Throwable.class)
|
||||
public static RedisCommand extractCommandName(
|
||||
@Advice.Argument(0) Supplier<RedisCommand> supplier) {
|
||||
public static <K, V, T> RedisCommand<K, V, T> extractCommandName(
|
||||
@Advice.Argument(0) Supplier<RedisCommand<K, V, T>> supplier) {
|
||||
return supplier.get();
|
||||
}
|
||||
|
||||
// if there is an exception thrown, then don't make spans
|
||||
@Advice.OnMethodExit(suppress = Throwable.class)
|
||||
public static void monitorSpan(
|
||||
@Advice.Enter RedisCommand command, @Advice.Return(readOnly = false) Flux<?> publisher) {
|
||||
public static <K, V, T> void monitorSpan(
|
||||
@Advice.Enter RedisCommand<K, V, T> command,
|
||||
@Advice.Return(readOnly = false) Flux<T> publisher) {
|
||||
|
||||
boolean expectsResponse = expectsResponse(command);
|
||||
LettuceFluxTerminationRunnable handler =
|
||||
|
|
|
@ -76,7 +76,7 @@ public class NettyFutureInstrumentation implements TypeInstrumentation {
|
|||
GenericFutureListener<? extends Future<?>>[] listeners) {
|
||||
|
||||
Context context = Java8BytecodeBridge.currentContext();
|
||||
@SuppressWarnings("unchecked")
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
GenericFutureListener<? extends Future<?>>[] wrappedListeners =
|
||||
new GenericFutureListener[listeners.length];
|
||||
for (int i = 0; i < listeners.length; ++i) {
|
||||
|
@ -107,7 +107,7 @@ public class NettyFutureInstrumentation implements TypeInstrumentation {
|
|||
@Advice.Argument(value = 0, readOnly = false)
|
||||
GenericFutureListener<? extends Future<?>>[] listeners) {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
GenericFutureListener<? extends Future<?>>[] wrappedListeners =
|
||||
new GenericFutureListener[listeners.length];
|
||||
for (int i = 0; i < listeners.length; ++i) {
|
||||
|
|
|
@ -143,6 +143,7 @@ public class AgentContextStorage implements ContextStorage, AutoCloseable {
|
|||
static final io.opentelemetry.context.ContextKey<Context> APPLICATION_CONTEXT =
|
||||
io.opentelemetry.context.ContextKey.named("otel-context");
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
static final ContextKeyBridge<?, ?>[] CONTEXT_KEY_BRIDGES =
|
||||
new ContextKeyBridge[] {
|
||||
new ContextKeyBridge<Span, io.opentelemetry.api.trace.Span>(
|
||||
|
@ -290,7 +291,6 @@ public class AgentContextStorage implements ContextStorage, AutoCloseable {
|
|||
private final Function<APPLICATION, AGENT> toAgent;
|
||||
private final Function<AGENT, APPLICATION> toApplication;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
ContextKeyBridge(
|
||||
String applicationKeyHolderClassName,
|
||||
String agentKeyHolderClassName,
|
||||
|
@ -299,6 +299,7 @@ public class AgentContextStorage implements ContextStorage, AutoCloseable {
|
|||
this(applicationKeyHolderClassName, agentKeyHolderClassName, "KEY", toApplication, toAgent);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
ContextKeyBridge(
|
||||
String applicationKeyHolderClassName,
|
||||
String agentKeyHolderClassName,
|
||||
|
|
|
@ -18,8 +18,6 @@ import application.io.opentelemetry.context.Context;
|
|||
import io.opentelemetry.javaagent.instrumentation.opentelemetryapi.context.AgentContextStorage;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import javax.annotation.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
class ApplicationSpan implements Span {
|
||||
|
||||
|
@ -59,6 +57,7 @@ class ApplicationSpan implements Span {
|
|||
|
||||
@Override
|
||||
public <T> Span setAttribute(AttributeKey<T> applicationKey, T value) {
|
||||
@SuppressWarnings("unchecked")
|
||||
io.opentelemetry.api.common.AttributeKey<T> agentKey = Bridging.toAgent(applicationKey);
|
||||
if (agentKey != null) {
|
||||
agentSpan.setAttribute(agentKey, value);
|
||||
|
@ -165,8 +164,6 @@ class ApplicationSpan implements Span {
|
|||
|
||||
static class Builder implements SpanBuilder {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(Builder.class);
|
||||
|
||||
private final io.opentelemetry.api.trace.SpanBuilder agentBuilder;
|
||||
|
||||
Builder(io.opentelemetry.api.trace.SpanBuilder agentBuilder) {
|
||||
|
@ -224,6 +221,7 @@ class ApplicationSpan implements Span {
|
|||
|
||||
@Override
|
||||
public <T> SpanBuilder setAttribute(AttributeKey<T> applicationKey, T value) {
|
||||
@SuppressWarnings("unchecked")
|
||||
io.opentelemetry.api.common.AttributeKey<T> agentKey = Bridging.toAgent(applicationKey);
|
||||
if (agentKey != null) {
|
||||
agentBuilder.setAttribute(agentKey, value);
|
||||
|
|
|
@ -102,12 +102,12 @@ public class Bridging {
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
public static io.opentelemetry.api.common.Attributes toAgent(Attributes applicationAttributes) {
|
||||
io.opentelemetry.api.common.AttributesBuilder agentAttributes =
|
||||
io.opentelemetry.api.common.Attributes.builder();
|
||||
applicationAttributes.forEach(
|
||||
(key, value) -> {
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
io.opentelemetry.api.common.AttributeKey agentKey = toAgent(key);
|
||||
if (agentKey != null) {
|
||||
agentAttributes.put(agentKey, value);
|
||||
|
|
|
@ -13,6 +13,8 @@ muzzle {
|
|||
dependencies {
|
||||
implementation(project(":instrumentation:oshi:library"))
|
||||
|
||||
compileOnly("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure")
|
||||
|
||||
library("com.github.oshi:oshi-core:5.3.1")
|
||||
|
||||
testImplementation("com.google.guava:guava")
|
||||
|
|
|
@ -8,6 +8,7 @@ package io.opentelemetry.javaagent.instrumentation.oshi;
|
|||
import com.google.auto.service.AutoService;
|
||||
import io.opentelemetry.instrumentation.api.config.Config;
|
||||
import io.opentelemetry.javaagent.extension.AgentListener;
|
||||
import io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdk;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Collections;
|
||||
|
||||
|
@ -18,7 +19,7 @@ import java.util.Collections;
|
|||
@AutoService(AgentListener.class)
|
||||
public class OshiMetricsInstaller implements AgentListener {
|
||||
@Override
|
||||
public void afterAgent(Config config) {
|
||||
public void afterAgent(Config config, AutoConfiguredOpenTelemetrySdk unused) {
|
||||
if (config.isInstrumentationEnabled(
|
||||
Collections.singleton("oshi"), /* defaultEnabled= */ true)) {
|
||||
try {
|
||||
|
|
|
@ -16,8 +16,8 @@ import play.shaded.ahc.org.asynchttpclient.HttpResponseStatus;
|
|||
import play.shaded.ahc.org.asynchttpclient.Request;
|
||||
import play.shaded.ahc.org.asynchttpclient.Response;
|
||||
|
||||
public class AsyncHandlerWrapper implements AsyncHandler {
|
||||
private final AsyncHandler delegate;
|
||||
public class AsyncHandlerWrapper<T> implements AsyncHandler<T> {
|
||||
private final AsyncHandler<T> delegate;
|
||||
private final Request request;
|
||||
private final Context context;
|
||||
private final Context parentContext;
|
||||
|
@ -25,7 +25,7 @@ public class AsyncHandlerWrapper implements AsyncHandler {
|
|||
private final Response.ResponseBuilder builder = new Response.ResponseBuilder();
|
||||
|
||||
public AsyncHandlerWrapper(
|
||||
AsyncHandler delegate, Request request, Context context, Context parentContext) {
|
||||
AsyncHandler<T> delegate, Request request, Context context, Context parentContext) {
|
||||
this.delegate = delegate;
|
||||
this.request = request;
|
||||
this.context = context;
|
||||
|
@ -56,7 +56,7 @@ public class AsyncHandlerWrapper implements AsyncHandler {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Object onCompleted() throws Exception {
|
||||
public T onCompleted() throws Exception {
|
||||
instrumenter().end(context, request, builder.build(), null);
|
||||
|
||||
try (Scope ignored = parentContext.makeCurrent()) {
|
||||
|
|
|
@ -56,11 +56,11 @@ public class PlayWsInstrumentationModule extends InstrumentationModule {
|
|||
|
||||
if (asyncHandler instanceof StreamedAsyncHandler) {
|
||||
asyncHandler =
|
||||
new StreamedAsyncHandlerWrapper(
|
||||
new StreamedAsyncHandlerWrapper<>(
|
||||
(StreamedAsyncHandler<?>) asyncHandler, request, context, parentContext);
|
||||
} else if (!(asyncHandler instanceof WebSocketUpgradeHandler)) {
|
||||
// websocket upgrade handlers aren't supported
|
||||
asyncHandler = new AsyncHandlerWrapper(asyncHandler, request, context, parentContext);
|
||||
asyncHandler = new AsyncHandlerWrapper<>(asyncHandler, request, context, parentContext);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,21 +8,22 @@ package io.opentelemetry.javaagent.instrumentation.playws.v1_0;
|
|||
import io.opentelemetry.context.Context;
|
||||
import io.opentelemetry.context.Scope;
|
||||
import org.reactivestreams.Publisher;
|
||||
import play.shaded.ahc.org.asynchttpclient.HttpResponseBodyPart;
|
||||
import play.shaded.ahc.org.asynchttpclient.Request;
|
||||
import play.shaded.ahc.org.asynchttpclient.handler.StreamedAsyncHandler;
|
||||
|
||||
public class StreamedAsyncHandlerWrapper extends AsyncHandlerWrapper
|
||||
implements StreamedAsyncHandler {
|
||||
private final StreamedAsyncHandler streamedDelegate;
|
||||
public class StreamedAsyncHandlerWrapper<T> extends AsyncHandlerWrapper<T>
|
||||
implements StreamedAsyncHandler<T> {
|
||||
private final StreamedAsyncHandler<T> streamedDelegate;
|
||||
|
||||
public StreamedAsyncHandlerWrapper(
|
||||
StreamedAsyncHandler delegate, Request request, Context context, Context parentContext) {
|
||||
StreamedAsyncHandler<T> delegate, Request request, Context context, Context parentContext) {
|
||||
super(delegate, request, context, parentContext);
|
||||
streamedDelegate = delegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public State onStream(Publisher publisher) {
|
||||
public State onStream(Publisher<HttpResponseBodyPart> publisher) {
|
||||
try (Scope ignored = getParentContext().makeCurrent()) {
|
||||
return streamedDelegate.onStream(publisher);
|
||||
}
|
||||
|
|
|
@ -20,8 +20,8 @@ import play.shaded.ahc.org.asynchttpclient.Request;
|
|||
import play.shaded.ahc.org.asynchttpclient.Response;
|
||||
import play.shaded.ahc.org.asynchttpclient.netty.request.NettyRequest;
|
||||
|
||||
public class AsyncHandlerWrapper implements AsyncHandler {
|
||||
private final AsyncHandler delegate;
|
||||
public class AsyncHandlerWrapper<T> implements AsyncHandler<T> {
|
||||
private final AsyncHandler<T> delegate;
|
||||
private final Request request;
|
||||
private final Context context;
|
||||
private final Context parentContext;
|
||||
|
@ -29,7 +29,7 @@ public class AsyncHandlerWrapper implements AsyncHandler {
|
|||
private final Response.ResponseBuilder builder = new Response.ResponseBuilder();
|
||||
|
||||
public AsyncHandlerWrapper(
|
||||
AsyncHandler delegate, Request request, Context context, Context parentContext) {
|
||||
AsyncHandler<T> delegate, Request request, Context context, Context parentContext) {
|
||||
this.delegate = delegate;
|
||||
this.request = request;
|
||||
this.context = context;
|
||||
|
@ -60,7 +60,7 @@ public class AsyncHandlerWrapper implements AsyncHandler {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Object onCompleted() throws Exception {
|
||||
public T onCompleted() throws Exception {
|
||||
Response response = builder.build();
|
||||
instrumenter().end(context, request, response, null);
|
||||
|
||||
|
@ -89,7 +89,7 @@ public class AsyncHandlerWrapper implements AsyncHandler {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onHostnameResolutionSuccess(String name, List list) {
|
||||
public void onHostnameResolutionSuccess(String name, List<InetSocketAddress> list) {
|
||||
delegate.onHostnameResolutionSuccess(name, list);
|
||||
}
|
||||
|
||||
|
|
|
@ -54,11 +54,11 @@ public class PlayWsInstrumentationModule extends InstrumentationModule {
|
|||
|
||||
if (asyncHandler instanceof StreamedAsyncHandler) {
|
||||
asyncHandler =
|
||||
new StreamedAsyncHandlerWrapper(
|
||||
new StreamedAsyncHandlerWrapper<>(
|
||||
(StreamedAsyncHandler<?>) asyncHandler, request, context, parentContext);
|
||||
} else if (!(asyncHandler instanceof WebSocketUpgradeHandler)) {
|
||||
// websocket upgrade handlers aren't supported
|
||||
asyncHandler = new AsyncHandlerWrapper(asyncHandler, request, context, parentContext);
|
||||
asyncHandler = new AsyncHandlerWrapper<>(asyncHandler, request, context, parentContext);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,21 +8,22 @@ package io.opentelemetry.javaagent.instrumentation.playws.v2_0;
|
|||
import io.opentelemetry.context.Context;
|
||||
import io.opentelemetry.context.Scope;
|
||||
import org.reactivestreams.Publisher;
|
||||
import play.shaded.ahc.org.asynchttpclient.HttpResponseBodyPart;
|
||||
import play.shaded.ahc.org.asynchttpclient.Request;
|
||||
import play.shaded.ahc.org.asynchttpclient.handler.StreamedAsyncHandler;
|
||||
|
||||
public class StreamedAsyncHandlerWrapper extends AsyncHandlerWrapper
|
||||
implements StreamedAsyncHandler {
|
||||
private final StreamedAsyncHandler streamedDelegate;
|
||||
public class StreamedAsyncHandlerWrapper<T> extends AsyncHandlerWrapper<T>
|
||||
implements StreamedAsyncHandler<T> {
|
||||
private final StreamedAsyncHandler<T> streamedDelegate;
|
||||
|
||||
public StreamedAsyncHandlerWrapper(
|
||||
StreamedAsyncHandler delegate, Request request, Context context, Context parentContext) {
|
||||
StreamedAsyncHandler<T> delegate, Request request, Context context, Context parentContext) {
|
||||
super(delegate, request, context, parentContext);
|
||||
streamedDelegate = delegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public State onStream(Publisher publisher) {
|
||||
public State onStream(Publisher<HttpResponseBodyPart> publisher) {
|
||||
try (Scope ignored = getParentContext().makeCurrent()) {
|
||||
return streamedDelegate.onStream(publisher);
|
||||
}
|
||||
|
|
|
@ -21,8 +21,8 @@ import play.shaded.ahc.org.asynchttpclient.Request;
|
|||
import play.shaded.ahc.org.asynchttpclient.Response;
|
||||
import play.shaded.ahc.org.asynchttpclient.netty.request.NettyRequest;
|
||||
|
||||
public class AsyncHandlerWrapper implements AsyncHandler {
|
||||
private final AsyncHandler delegate;
|
||||
public class AsyncHandlerWrapper<T> implements AsyncHandler<T> {
|
||||
private final AsyncHandler<T> delegate;
|
||||
private final Request request;
|
||||
private final Context context;
|
||||
private final Context parentContext;
|
||||
|
@ -30,7 +30,7 @@ public class AsyncHandlerWrapper implements AsyncHandler {
|
|||
private final Response.ResponseBuilder builder = new Response.ResponseBuilder();
|
||||
|
||||
public AsyncHandlerWrapper(
|
||||
AsyncHandler delegate, Request request, Context context, Context parentContext) {
|
||||
AsyncHandler<T> delegate, Request request, Context context, Context parentContext) {
|
||||
this.delegate = delegate;
|
||||
this.request = request;
|
||||
this.context = context;
|
||||
|
@ -61,7 +61,7 @@ public class AsyncHandlerWrapper implements AsyncHandler {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Object onCompleted() throws Exception {
|
||||
public T onCompleted() throws Exception {
|
||||
Response response = builder.build();
|
||||
instrumenter().end(context, request, response, null);
|
||||
|
||||
|
@ -90,7 +90,7 @@ public class AsyncHandlerWrapper implements AsyncHandler {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onHostnameResolutionSuccess(String name, List list) {
|
||||
public void onHostnameResolutionSuccess(String name, List<InetSocketAddress> list) {
|
||||
delegate.onHostnameResolutionSuccess(name, list);
|
||||
}
|
||||
|
||||
|
|
|
@ -54,11 +54,11 @@ public class PlayWsInstrumentationModule extends InstrumentationModule {
|
|||
|
||||
if (asyncHandler instanceof StreamedAsyncHandler) {
|
||||
asyncHandler =
|
||||
new StreamedAsyncHandlerWrapper(
|
||||
new StreamedAsyncHandlerWrapper<>(
|
||||
(StreamedAsyncHandler<?>) asyncHandler, request, context, parentContext);
|
||||
} else if (!(asyncHandler instanceof WebSocketUpgradeHandler)) {
|
||||
// websocket upgrade handlers aren't supported
|
||||
asyncHandler = new AsyncHandlerWrapper(asyncHandler, request, context, parentContext);
|
||||
asyncHandler = new AsyncHandlerWrapper<>(asyncHandler, request, context, parentContext);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,21 +8,22 @@ package io.opentelemetry.javaagent.instrumentation.playws.v2_1;
|
|||
import io.opentelemetry.context.Context;
|
||||
import io.opentelemetry.context.Scope;
|
||||
import org.reactivestreams.Publisher;
|
||||
import play.shaded.ahc.org.asynchttpclient.HttpResponseBodyPart;
|
||||
import play.shaded.ahc.org.asynchttpclient.Request;
|
||||
import play.shaded.ahc.org.asynchttpclient.handler.StreamedAsyncHandler;
|
||||
|
||||
public class StreamedAsyncHandlerWrapper extends AsyncHandlerWrapper
|
||||
implements StreamedAsyncHandler {
|
||||
private final StreamedAsyncHandler streamedDelegate;
|
||||
public class StreamedAsyncHandlerWrapper<T> extends AsyncHandlerWrapper<T>
|
||||
implements StreamedAsyncHandler<T> {
|
||||
private final StreamedAsyncHandler<T> streamedDelegate;
|
||||
|
||||
public StreamedAsyncHandlerWrapper(
|
||||
StreamedAsyncHandler delegate, Request request, Context context, Context parentContext) {
|
||||
StreamedAsyncHandler<T> delegate, Request request, Context context, Context parentContext) {
|
||||
super(delegate, request, context, parentContext);
|
||||
streamedDelegate = delegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public State onStream(Publisher publisher) {
|
||||
public State onStream(Publisher<HttpResponseBodyPart> publisher) {
|
||||
try (Scope ignored = getParentContext().makeCurrent()) {
|
||||
return streamedDelegate.onStream(publisher);
|
||||
}
|
||||
|
|
|
@ -73,12 +73,11 @@ public final class Play26Singletons {
|
|||
Option<HandlerDef> defOption = null;
|
||||
if (typedKeyGetUnderlying != null) { // Should always be non-null but just to make sure
|
||||
try {
|
||||
defOption =
|
||||
request
|
||||
.attrs()
|
||||
.get(
|
||||
(play.api.libs.typedmap.TypedKey<HandlerDef>)
|
||||
typedKeyGetUnderlying.invoke(Router.Attrs.HANDLER_DEF));
|
||||
@SuppressWarnings("unchecked")
|
||||
play.api.libs.typedmap.TypedKey<HandlerDef> handlerDef =
|
||||
(play.api.libs.typedmap.TypedKey<HandlerDef>)
|
||||
typedKeyGetUnderlying.invoke(Router.Attrs.HANDLER_DEF);
|
||||
defOption = request.attrs().get(handlerDef);
|
||||
} catch (IllegalAccessException | InvocationTargetException ignored) {
|
||||
// Ignore
|
||||
}
|
||||
|
|
|
@ -36,6 +36,6 @@ public class ActionWrapper<T> implements Action<T> {
|
|||
// Skip wrapping, there is no need to propagate root context.
|
||||
return delegate;
|
||||
}
|
||||
return new ActionWrapper(delegate, context);
|
||||
return new ActionWrapper<>(delegate, context);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,9 +19,12 @@ import java.util.function.BiFunction;
|
|||
import net.bytebuddy.asm.Advice;
|
||||
import net.bytebuddy.description.type.TypeDescription;
|
||||
import net.bytebuddy.matcher.ElementMatcher;
|
||||
import org.reactivestreams.Publisher;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.netty.ByteBufFlux;
|
||||
import reactor.netty.ByteBufMono;
|
||||
import reactor.netty.Connection;
|
||||
import reactor.netty.http.client.HttpClient;
|
||||
import reactor.netty.http.client.HttpClientResponse;
|
||||
|
||||
|
@ -121,10 +124,12 @@ public class ResponseReceiverInstrumentation implements TypeInstrumentation {
|
|||
}
|
||||
|
||||
@Advice.OnMethodExit(suppress = Throwable.class)
|
||||
public static void onExit(
|
||||
public static <T extends HttpClient.ResponseReceiver<?>> void onExit(
|
||||
@Advice.Local("otelCallDepth") CallDepth callDepth,
|
||||
@Advice.Enter HttpClient.ResponseReceiver<?> modifiedReceiver,
|
||||
@Advice.Argument(0) BiFunction receiveFunction,
|
||||
@Advice.Enter HttpClient.ResponseReceiver<T> modifiedReceiver,
|
||||
@Advice.Argument(0)
|
||||
BiFunction<? super HttpClientResponse, ? super ByteBufFlux, ? extends Publisher<T>>
|
||||
receiveFunction,
|
||||
@Advice.Return(readOnly = false) Flux<?> returnValue) {
|
||||
|
||||
try {
|
||||
|
@ -157,10 +162,12 @@ public class ResponseReceiverInstrumentation implements TypeInstrumentation {
|
|||
}
|
||||
|
||||
@Advice.OnMethodExit(suppress = Throwable.class)
|
||||
public static void onExit(
|
||||
public static <T extends HttpClient.ResponseReceiver<?>> void onExit(
|
||||
@Advice.Local("otelCallDepth") CallDepth callDepth,
|
||||
@Advice.Enter HttpClient.ResponseReceiver<?> modifiedReceiver,
|
||||
@Advice.Argument(0) BiFunction receiveFunction,
|
||||
@Advice.Enter HttpClient.ResponseReceiver<T> modifiedReceiver,
|
||||
@Advice.Argument(0)
|
||||
BiFunction<? super HttpClientResponse, ? super Connection, ? extends Publisher<T>>
|
||||
receiveFunction,
|
||||
@Advice.Return(readOnly = false) Flux<?> returnValue) {
|
||||
|
||||
try {
|
||||
|
@ -228,10 +235,12 @@ public class ResponseReceiverInstrumentation implements TypeInstrumentation {
|
|||
}
|
||||
|
||||
@Advice.OnMethodExit(suppress = Throwable.class)
|
||||
public static void onExit(
|
||||
public static <T extends HttpClient.ResponseReceiver<?>> void onExit(
|
||||
@Advice.Local("otelCallDepth") CallDepth callDepth,
|
||||
@Advice.Enter HttpClient.ResponseReceiver<?> modifiedReceiver,
|
||||
@Advice.Argument(0) BiFunction receiveFunction,
|
||||
@Advice.Enter HttpClient.ResponseReceiver<T> modifiedReceiver,
|
||||
@Advice.Argument(0)
|
||||
BiFunction<? super HttpClientResponse, ? super ByteBufMono, ? extends Mono<T>>
|
||||
receiveFunction,
|
||||
@Advice.Return(readOnly = false) Mono<?> returnValue) {
|
||||
|
||||
try {
|
||||
|
|
|
@ -44,7 +44,9 @@ public class ContextPayload {
|
|||
try {
|
||||
Object object = oi.readObject();
|
||||
if (object instanceof Map) {
|
||||
return new ContextPayload((Map<String, String>) object);
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, String> map = (Map<String, String>) object;
|
||||
return new ContextPayload(map);
|
||||
}
|
||||
} catch (ClassCastException | ClassNotFoundException ex) {
|
||||
logger.debug("Error reading object", ex);
|
||||
|
|
|
@ -16,7 +16,6 @@ import io.opentelemetry.javaagent.instrumentation.rmi.context.ContextPayload;
|
|||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.rmi.Remote;
|
||||
import java.rmi.server.RemoteCall;
|
||||
import sun.rmi.server.Dispatcher;
|
||||
import sun.rmi.transport.Target;
|
||||
|
||||
|
@ -41,7 +40,9 @@ public class ContextDispatcher implements Dispatcher {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void dispatch(Remote obj, RemoteCall call) throws IOException {
|
||||
// Instrumenting deprecated class
|
||||
@SuppressWarnings("deprecation")
|
||||
public void dispatch(Remote obj, java.rmi.server.RemoteCall call) throws IOException {
|
||||
ObjectInput in = call.getInputStream();
|
||||
int operationId = in.readInt();
|
||||
in.readLong(); // skip 8 bytes
|
||||
|
|
|
@ -4,4 +4,6 @@ plugins {
|
|||
|
||||
dependencies {
|
||||
implementation(project(":instrumentation:runtime-metrics:library"))
|
||||
|
||||
compileOnly("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure")
|
||||
}
|
||||
|
|
|
@ -10,13 +10,14 @@ import io.opentelemetry.instrumentation.api.config.Config;
|
|||
import io.opentelemetry.instrumentation.runtimemetrics.GarbageCollector;
|
||||
import io.opentelemetry.instrumentation.runtimemetrics.MemoryPools;
|
||||
import io.opentelemetry.javaagent.extension.AgentListener;
|
||||
import io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdk;
|
||||
import java.util.Collections;
|
||||
|
||||
/** An {@link AgentListener} that enables runtime metrics during agent startup. */
|
||||
@AutoService(AgentListener.class)
|
||||
public class RuntimeMetricsInstaller implements AgentListener {
|
||||
@Override
|
||||
public void afterAgent(Config config) {
|
||||
public void afterAgent(Config config, AutoConfiguredOpenTelemetrySdk unused) {
|
||||
if (config.isInstrumentationEnabled(
|
||||
Collections.singleton("runtime-metrics"), /* defaultEnabled= */ true)) {
|
||||
GarbageCollector.registerObservers();
|
||||
|
|
|
@ -22,7 +22,7 @@ public class AsyncRunnableWrapper<REQUEST> implements Runnable {
|
|||
if (runnable == null || runnable instanceof AsyncRunnableWrapper) {
|
||||
return runnable;
|
||||
}
|
||||
return new AsyncRunnableWrapper(helper, request, runnable);
|
||||
return new AsyncRunnableWrapper<>(helper, request, runnable);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -92,7 +92,10 @@ public class ServletHelper<REQUEST, RESPONSE> extends BaseServletHelper<REQUEST,
|
|||
}
|
||||
|
||||
public RESPONSE getAsyncListenerResponse(REQUEST request) {
|
||||
return (RESPONSE) accessor.getRequestAttribute(request, ASYNC_LISTENER_RESPONSE_ATTRIBUTE);
|
||||
@SuppressWarnings("unchecked")
|
||||
RESPONSE response =
|
||||
(RESPONSE) accessor.getRequestAttribute(request, ASYNC_LISTENER_RESPONSE_ATTRIBUTE);
|
||||
return response;
|
||||
}
|
||||
|
||||
public void attachAsyncListener(REQUEST request) {
|
||||
|
|
|
@ -82,13 +82,16 @@ public abstract class JavaxServletAccessor<R> implements ServletAccessor<HttpSer
|
|||
|
||||
@Override
|
||||
public List<String> getRequestHeaderValues(HttpServletRequest request, String name) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Enumeration<String> values = request.getHeaders(name);
|
||||
return values == null ? Collections.emptyList() : Collections.list(values);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<String> getRequestHeaderNames(HttpServletRequest httpServletRequest) {
|
||||
return Collections.list(httpServletRequest.getHeaderNames());
|
||||
@SuppressWarnings("unchecked")
|
||||
Enumeration<String> names = httpServletRequest.getHeaderNames();
|
||||
return Collections.list(names);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -14,6 +14,8 @@ import com.vaadin.flow.router.Route;
|
|||
@Route("main")
|
||||
public class MainView extends VerticalLayout {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public MainView() {
|
||||
Label label = new Label("Main view");
|
||||
label.setId("main.label");
|
||||
|
|
|
@ -12,6 +12,8 @@ import com.vaadin.flow.router.Route;
|
|||
@Route("other")
|
||||
public class OtherView extends VerticalLayout {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public OtherView() {
|
||||
Label label = new Label("Other view");
|
||||
label.setId("other.label");
|
||||
|
|
|
@ -14,6 +14,9 @@ muzzle {
|
|||
dependencies {
|
||||
library("io.vertx:vertx-core:3.0.0")
|
||||
|
||||
compileOnly("io.vertx:vertx-codegen:3.0.0")
|
||||
compileOnly("io.vertx:vertx-docgen:3.0.0")
|
||||
|
||||
compileOnly("com.google.auto.value:auto-value-annotations")
|
||||
annotationProcessor("com.google.auto.value:auto-value")
|
||||
|
||||
|
|
|
@ -14,6 +14,8 @@ muzzle {
|
|||
dependencies {
|
||||
library("io.vertx:vertx-core:4.0.0")
|
||||
|
||||
compileOnly("io.vertx:vertx-codegen:4.0.0")
|
||||
|
||||
implementation(project(":instrumentation:vertx:vertx-http-client:vertx-http-client-common:javaagent"))
|
||||
|
||||
testInstrumentation(project(":instrumentation:netty:netty-4.1:javaagent"))
|
||||
|
|
|
@ -4,4 +4,6 @@ plugins {
|
|||
|
||||
dependencies {
|
||||
compileOnly("io.vertx:vertx-core:3.0.0")
|
||||
compileOnly("io.vertx:vertx-codegen:3.0.0")
|
||||
compileOnly("io.vertx:vertx-docgen:3.0.0")
|
||||
}
|
||||
|
|
|
@ -7,6 +7,9 @@ dependencies {
|
|||
|
||||
implementation("io.vertx:vertx-web:3.0.0")
|
||||
|
||||
compileOnly("io.vertx:vertx-codegen:3.0.0")
|
||||
compileOnly("io.vertx:vertx-docgen:3.0.0")
|
||||
|
||||
implementation("org.codehaus.groovy:groovy-all")
|
||||
implementation("io.opentelemetry:opentelemetry-api")
|
||||
implementation("org.spockframework:spock-core")
|
||||
|
|
|
@ -22,19 +22,6 @@ import net.bytebuddy.agent.builder.AgentBuilder;
|
|||
*/
|
||||
public interface AgentListener extends Ordered {
|
||||
|
||||
/**
|
||||
* Runs before {@link AgentBuilder} construction, before any instrumentation is added.
|
||||
*
|
||||
* <p>Execute only minimal code because any classes loaded before the agent installation will have
|
||||
* to be retransformed, which takes extra time, and more importantly means that fields can't be
|
||||
* added to those classes - which causes {@link VirtualField} to fall back to the less performant
|
||||
* {@link Cache} implementation for those classes.
|
||||
*
|
||||
* @deprecated Use {@link #beforeAgent(Config, AutoConfiguredOpenTelemetrySdk)}
|
||||
*/
|
||||
@Deprecated
|
||||
default void beforeAgent(Config config) {}
|
||||
|
||||
/**
|
||||
* Runs before {@link AgentBuilder} construction, before any instrumentation is added. Not called
|
||||
* if noop api enabled via {@code otel.javaagent.experimental.use-noop-api}.
|
||||
|
@ -47,15 +34,6 @@ public interface AgentListener extends Ordered {
|
|||
default void beforeAgent(
|
||||
Config config, AutoConfiguredOpenTelemetrySdk autoConfiguredOpenTelemetrySdk) {}
|
||||
|
||||
/**
|
||||
* Runs after instrumentations are added to {@link AgentBuilder} and after the agent is installed
|
||||
* on an {@link Instrumentation}.
|
||||
*
|
||||
* @deprecated Use {@link #afterAgent(Config, AutoConfiguredOpenTelemetrySdk)}
|
||||
*/
|
||||
@Deprecated
|
||||
default void afterAgent(Config config) {}
|
||||
|
||||
/**
|
||||
* Runs after instrumentations are added to {@link AgentBuilder} and after the agent is installed
|
||||
* on an {@link Instrumentation}. Not called if noop api enabled via {@code
|
||||
|
|
|
@ -38,10 +38,11 @@ dependencies {
|
|||
implementation("org.slf4j:slf4j-api")
|
||||
|
||||
annotationProcessor("com.google.auto.service:auto-service")
|
||||
compileOnly("com.google.auto.service:auto-service")
|
||||
compileOnly("com.google.auto.service:auto-service-annotations")
|
||||
|
||||
// Used by byte-buddy but not brought in as a transitive dependency.
|
||||
compileOnly("com.google.code.findbugs:annotations")
|
||||
testCompileOnly("com.google.code.findbugs:annotations")
|
||||
|
||||
testImplementation(project(":testing-common"))
|
||||
testImplementation("com.google.guava:guava")
|
||||
|
|
|
@ -11,6 +11,9 @@ dependencies {
|
|||
implementation("net.bytebuddy:byte-buddy-dep")
|
||||
implementation("org.slf4j:slf4j-api")
|
||||
|
||||
// Used by byte-buddy but not brought in as a transitive dependency.
|
||||
compileOnly("com.google.code.findbugs:annotations")
|
||||
|
||||
testImplementation("net.bytebuddy:byte-buddy-agent")
|
||||
}
|
||||
|
||||
|
|
|
@ -202,7 +202,6 @@ public class AgentInstaller {
|
|||
Config config,
|
||||
AutoConfiguredOpenTelemetrySdk autoConfiguredSdk) {
|
||||
for (AgentListener agentListener : agentListeners) {
|
||||
agentListener.beforeAgent(config);
|
||||
agentListener.beforeAgent(config, autoConfiguredSdk);
|
||||
}
|
||||
}
|
||||
|
@ -252,7 +251,6 @@ public class AgentInstaller {
|
|||
new DelayedAfterAgentCallback(config, agentListeners, autoConfiguredSdk));
|
||||
} else {
|
||||
for (AgentListener agentListener : agentListeners) {
|
||||
agentListener.afterAgent(config);
|
||||
agentListener.afterAgent(config, autoConfiguredSdk);
|
||||
}
|
||||
}
|
||||
|
@ -384,7 +382,6 @@ public class AgentInstaller {
|
|||
private void runAgentListeners() {
|
||||
for (AgentListener agentListener : agentListeners) {
|
||||
try {
|
||||
agentListener.afterAgent(config);
|
||||
agentListener.afterAgent(config, autoConfiguredSdk);
|
||||
} catch (RuntimeException e) {
|
||||
logger.error("Failed to execute {}", agentListener.getClass().getName(), e);
|
||||
|
|
|
@ -92,6 +92,7 @@ final class TrieImpl<V> implements Trie<V> {
|
|||
Node<V> build() {
|
||||
int size = children.size();
|
||||
char[] chars = new char[size];
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
Node<V>[] nodes = new Node[size];
|
||||
|
||||
int i = 0;
|
||||
|
|
|
@ -133,6 +133,7 @@ public class IntegrationTestUtils {
|
|||
return className.replace('.', '/') + ".class";
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static List<String> getBootstrapPackagePrefixes() throws Exception {
|
||||
Field f =
|
||||
getAgentClassLoader()
|
||||
|
|
|
@ -164,6 +164,8 @@ public class TestAgentListener implements AgentBuilder.Listener {
|
|||
|
||||
/** Used to signal that a transformation was intentionally aborted and is not an error. */
|
||||
private static class AbortTransformationException extends RuntimeException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public AbortTransformationException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue