Skip to content
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package datadog.trace.instrumentation.datanucleus;

import static java.util.Arrays.asList;

import com.google.auto.service.AutoService;
import datadog.trace.agent.tooling.Instrumenter;
import datadog.trace.agent.tooling.InstrumenterModule;
import java.util.List;

@AutoService(InstrumenterModule.class)
public class DatanucleusModule extends InstrumenterModule.Tracing {
public DatanucleusModule() {
super("datanucleus");
}

@Override
public String[] helperClassNames() {
return new String[] {
packageName + ".DatanucleusDecorator",
};
}

@Override
public List<Instrumenter> typeInstrumentations() {
return asList(
new ExecutionContextInstrumentation(),
new JDOQueryInstrumentation(),
new JDOTransactionInstrumentation());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,27 @@
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.startSpan;
import static datadog.trace.instrumentation.datanucleus.DatanucleusDecorator.DATANUCLEUS_FIND_OBJECT;
import static datadog.trace.instrumentation.datanucleus.DatanucleusDecorator.DECORATE;
import static java.util.Collections.singleton;
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
import static net.bytebuddy.matcher.ElementMatchers.takesArguments;

import com.google.auto.service.AutoService;
import datadog.trace.agent.tooling.Instrumenter;
import datadog.trace.agent.tooling.InstrumenterModule;
import datadog.trace.api.InstrumenterConfig;
import datadog.trace.bootstrap.instrumentation.api.AgentScope;
import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
import org.datanucleus.ExecutionContext;

@AutoService(InstrumenterModule.class)
public class ExecutionContextInstrumentation extends InstrumenterModule.Tracing
public class ExecutionContextInstrumentation
implements Instrumenter.CanShortcutTypeMatching, Instrumenter.HasMethodAdvice {
public ExecutionContextInstrumentation() {
super("datanucleus");
}

@Override
public boolean onlyMatchKnownTypes() {
return isShortcutMatchingEnabled(false);
return InstrumenterConfig.get()
.isIntegrationShortcutMatchingEnabled(singleton("datanucleus"), false);
}

@Override
Expand All @@ -50,13 +47,6 @@ public ElementMatcher<TypeDescription> hierarchyMatcher() {
return implementsInterface(named(hierarchyMarkerType()));
}

@Override
public String[] helperClassNames() {
return new String[] {
packageName + ".DatanucleusDecorator",
};
}

@Override
public void methodAdvice(MethodTransformer transformer) {
transformer.applyAdvice(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,22 @@
import static datadog.trace.instrumentation.datanucleus.DatanucleusDecorator.DECORATE;
import static net.bytebuddy.matcher.ElementMatchers.isMethod;

import com.google.auto.service.AutoService;
import datadog.trace.agent.tooling.Instrumenter;
import datadog.trace.agent.tooling.InstrumenterModule;
import datadog.trace.bootstrap.CallDepthThreadLocalMap;
import datadog.trace.bootstrap.instrumentation.api.AgentScope;
import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
import net.bytebuddy.asm.Advice;
import org.datanucleus.api.jdo.JDOQuery;
import org.datanucleus.store.query.Query;

@AutoService(InstrumenterModule.class)
public class JDOQueryInstrumentation extends InstrumenterModule.Tracing
public class JDOQueryInstrumentation
implements Instrumenter.ForSingleType, Instrumenter.HasMethodAdvice {

public JDOQueryInstrumentation() {
super("datanucleus");
}

@Override
public String instrumentedType() {
return "org.datanucleus.api.jdo.JDOQuery";
}

@Override
public String[] helperClassNames() {
return new String[] {
packageName + ".DatanucleusDecorator",
};
}

@Override
public void methodAdvice(MethodTransformer transformer) {
// All of these methods delegate to *Internal() but have parameter checking and exceptions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,19 @@
import static datadog.trace.instrumentation.datanucleus.DatanucleusDecorator.DECORATE;
import static net.bytebuddy.matcher.ElementMatchers.isMethod;

import com.google.auto.service.AutoService;
import datadog.trace.agent.tooling.Instrumenter;
import datadog.trace.agent.tooling.InstrumenterModule;
import datadog.trace.bootstrap.instrumentation.api.AgentScope;
import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
import net.bytebuddy.asm.Advice;

@AutoService(InstrumenterModule.class)
public class JDOTransactionInstrumentation extends InstrumenterModule.Tracing
public class JDOTransactionInstrumentation
implements Instrumenter.ForSingleType, Instrumenter.HasMethodAdvice {

public JDOTransactionInstrumentation() {
super("datanucleus");
}

@Override
public String instrumentedType() {
return "org.datanucleus.api.jdo.JDOTransaction";
}

@Override
public String[] helperClassNames() {
return new String[] {
packageName + ".DatanucleusDecorator",
};
}

@Override
public void methodAdvice(MethodTransformer transformer) {
transformer.applyAdvice(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package datadog.trace.instrumentation.googlepubsub;

import static datadog.trace.bootstrap.instrumentation.java.concurrent.ExcludeFilter.ExcludeType.RUNNABLE;
import static java.util.Arrays.asList;
import static java.util.Collections.singletonList;
import static java.util.Collections.singletonMap;

import com.google.auto.service.AutoService;
import datadog.trace.agent.tooling.ExcludeFilterProvider;
import datadog.trace.agent.tooling.Instrumenter;
import datadog.trace.agent.tooling.InstrumenterModule;
import datadog.trace.bootstrap.instrumentation.java.concurrent.ExcludeFilter;
import java.util.Collection;
import java.util.List;
import java.util.Map;

@AutoService(InstrumenterModule.class)
public class GooglePubSubModule extends InstrumenterModule.Tracing
implements ExcludeFilterProvider {
public GooglePubSubModule() {
super("google-pubsub");
}

@Override
public String[] helperClassNames() {
return new String[] {
packageName + ".PubSubDecorator",
packageName + ".PubSubDecorator$RegexExtractor",
packageName + ".TextMapInjectAdapter",
packageName + ".TextMapExtractAdapter",
packageName + ".MessageReceiverWrapper",
packageName + ".MessageReceiverWithAckResponseWrapper",
};
}

@Override
public Map<ExcludeFilter.ExcludeType, ? extends Collection<String>> excludedClasses() {
return singletonMap(RUNNABLE, singletonList("com.google.api.gax.rpc.Watchdog"));
}

@Override
public List<Instrumenter> typeInstrumentations() {
return asList(
new PublisherInstrumentation(),
new ReceiverInstrumentation(),
new ReceiverWithAckInstrumentation());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,51 +6,22 @@
import static datadog.trace.api.datastreams.DataStreamsTags.create;
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activateSpan;
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.startSpan;
import static datadog.trace.bootstrap.instrumentation.java.concurrent.ExcludeFilter.ExcludeType.RUNNABLE;
import static datadog.trace.instrumentation.googlepubsub.PubSubDecorator.PRODUCER_DECORATE;
import static datadog.trace.instrumentation.googlepubsub.PubSubDecorator.PUBSUB_PRODUCE;
import static datadog.trace.instrumentation.googlepubsub.TextMapInjectAdapter.SETTER;
import static java.util.Collections.singletonList;
import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.isMethod;

import com.google.auto.service.AutoService;
import com.google.cloud.pubsub.v1.Publisher;
import com.google.pubsub.v1.PubsubMessage;
import datadog.trace.agent.tooling.ExcludeFilterProvider;
import datadog.trace.agent.tooling.Instrumenter;
import datadog.trace.agent.tooling.InstrumenterModule;
import datadog.trace.api.datastreams.DataStreamsContext;
import datadog.trace.api.datastreams.DataStreamsTags;
import datadog.trace.bootstrap.instrumentation.api.AgentScope;
import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
import datadog.trace.bootstrap.instrumentation.java.concurrent.ExcludeFilter;
import java.util.Collection;
import java.util.Map;
import net.bytebuddy.asm.Advice;

@AutoService(InstrumenterModule.class)
public final class PublisherInstrumentation extends InstrumenterModule.Tracing
implements Instrumenter.ForSingleType, Instrumenter.HasMethodAdvice, ExcludeFilterProvider {

public PublisherInstrumentation() {
super("google-pubsub", "google-pubsub-publisher");
}

@Override
public String[] helperClassNames() {
return new String[] {
packageName + ".PubSubDecorator",
packageName + ".PubSubDecorator$RegexExtractor",
packageName + ".TextMapInjectAdapter",
packageName + ".TextMapExtractAdapter",
};
}

@Override
public Map<ExcludeFilter.ExcludeType, ? extends Collection<String>> excludedClasses() {
return singletonMap(RUNNABLE, singletonList("com.google.api.gax.rpc.Watchdog"));
}
public final class PublisherInstrumentation
implements Instrumenter.ForSingleType, Instrumenter.HasMethodAdvice {

@Override
public String instrumentedType() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,13 @@
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;

import com.google.auto.service.AutoService;
import com.google.cloud.pubsub.v1.MessageReceiver;
import datadog.trace.agent.tooling.Instrumenter;
import datadog.trace.agent.tooling.InstrumenterModule;
import net.bytebuddy.asm.Advice;

@AutoService(InstrumenterModule.class)
public class ReceiverInstrumentation extends InstrumenterModule.Tracing
public class ReceiverInstrumentation
implements Instrumenter.ForSingleType, Instrumenter.HasMethodAdvice {

public ReceiverInstrumentation() {
super("google-pubsub", "google-pubsub-receiver");
}

@Override
public String[] helperClassNames() {
return new String[] {
packageName + ".PubSubDecorator",
packageName + ".PubSubDecorator$RegexExtractor",
packageName + ".TextMapInjectAdapter",
packageName + ".TextMapExtractAdapter",
packageName + ".MessageReceiverWrapper",
};
}

@Override
public String instrumentedType() {
return "com.google.cloud.pubsub.v1.Subscriber";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,13 @@
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;

import com.google.auto.service.AutoService;
import com.google.cloud.pubsub.v1.MessageReceiverWithAckResponse;
import datadog.trace.agent.tooling.Instrumenter;
import datadog.trace.agent.tooling.InstrumenterModule;
import net.bytebuddy.asm.Advice;

@AutoService(InstrumenterModule.class)
public final class ReceiverWithAckInstrumentation extends InstrumenterModule.Tracing
public final class ReceiverWithAckInstrumentation
implements Instrumenter.ForSingleType, Instrumenter.HasMethodAdvice {

public ReceiverWithAckInstrumentation() {
super("google-pubsub", "google-pubsub-receiver");
}

@Override
public String[] helperClassNames() {
return new String[] {
packageName + ".PubSubDecorator",
packageName + ".PubSubDecorator$RegexExtractor",
packageName + ".TextMapInjectAdapter",
packageName + ".TextMapExtractAdapter",
packageName + ".MessageReceiverWithAckResponseWrapper",
};
}

@Override
public String instrumentedType() {
return "com.google.cloud.pubsub.v1.Subscriber";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package datadog.trace.instrumentation.graal.nativeimage;

import datadog.trace.agent.tooling.Instrumenter;
import datadog.trace.agent.tooling.InstrumenterModule;
import datadog.trace.api.Platform;
import java.util.Set;

public abstract class AbstractNativeImageInstrumentation extends InstrumenterModule
implements Instrumenter.HasMethodAdvice {
public AbstractNativeImageInstrumentation() {
public abstract class AbstractNativeImageModule extends InstrumenterModule {
public AbstractNativeImageModule() {
super("native-image");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,11 @@
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;

import com.google.auto.service.AutoService;
import datadog.trace.agent.tooling.Instrumenter;
import datadog.trace.agent.tooling.InstrumenterModule;
import java.util.List;
import net.bytebuddy.asm.Advice;

@AutoService(InstrumenterModule.class)
public final class AnnotationSubstitutionProcessorInstrumentation
extends AbstractNativeImageInstrumentation
implements Instrumenter.ForSingleType, Instrumenter.HasMethodAdvice {

@Override
Expand All @@ -26,39 +22,13 @@ public void methodAdvice(MethodTransformer transformer) {
isMethod()
.and(named("lookup"))
.and(takesArgument(0, named("jdk.vm.ci.meta.ResolvedJavaField"))),
packageName + ".DeleteFieldAdvice");
"datadog.trace.instrumentation.graal.nativeimage.DeleteFieldAdvice");
transformer.applyAdvice(
isMethod().and(named("findTargetClasses")),
AnnotationSubstitutionProcessorInstrumentation.class.getName()
+ "$FindTargetClassesAdvice");
}

@Override
public String[] helperClassNames() {
return new String[] {
packageName + ".Target_com_datadog_profiling_agent_ProcessContext",
packageName + ".Target_datadog_jctools_util_UnsafeRefArrayAccess",
packageName + ".Target_org_datadog_jmxfetch_App",
packageName + ".Target_org_datadog_jmxfetch_Status",
packageName + ".Target_org_datadog_jmxfetch_reporter_JsonReporter",
};
}

@Override
public String[] muzzleIgnoredClassNames() {
// JVMCI classes which are part of GraalVM but aren't available in public repositories
return new String[] {
"jdk.vm.ci.meta.ResolvedJavaType",
"jdk.vm.ci.meta.ResolvedJavaField",
// ignore helper class names as usual
packageName + ".Target_com_datadog_profiling_agent_ProcessContext",
packageName + ".Target_datadog_jctools_util_UnsafeRefArrayAccess",
packageName + ".Target_org_datadog_jmxfetch_App",
packageName + ".Target_org_datadog_jmxfetch_Status",
packageName + ".Target_org_datadog_jmxfetch_reporter_JsonReporter",
};
}

public static class FindTargetClassesAdvice {
@Advice.OnMethodExit(suppress = Throwable.class)
public static void onExit(@Advice.Return(readOnly = false) List<Class<?>> result) {
Expand Down
Loading