Commit Graph

308 Commits

Author SHA1 Message Date
Tyler Benson 6cebabbada Move integrations config to Config class. 2019-02-05 08:20:49 -08:00
Nikolay Martynov a086f38f2f Fix webflux integration to not rely in active span
Netty event loop instrumentation doesn't allow us to attribute work to
correct span so we have to maintain that manually.
2019-02-05 10:38:21 -05:00
Daniel Solano Gómez 4953a6c417 Skip clojure.lang.DynamicClassLoader
Not doing this seems to cause issues with Clojure protocols.
An application instrumented with the dd-java-agent that will
otherwise run fine will fail with ClassNotFoundException for
classes pertaining to Clojure protocols.
2019-02-04 07:12:29 -06:00
Tyler Benson 03bcdc97cc Move awaitGC to common utility package 2019-01-25 10:32:09 -08:00
Nikolay Martynov b3ad700b34
Merge pull request #666 from DataDog/mar-kolya/aws-sdk2
Initial AWS2 SDK instrumentation
2019-01-25 13:01:32 -05:00
Nikolay Martynov 6563a711c2
Merge pull request #671 from DataDog/osgi-fix
Improve OSGi class loader instrumentation
2019-01-25 12:48:45 -05:00
Nikolay Martynov 04fbb5085f Improve OSGi class loader instrumentation
It turns out that Eclipse's OSGi implementation has two problems:
* It doesn't respect system properties by default
* It has tricky classloader implementation that loads bootstrap
  classes from the classloader-has-delegation-to-bootstrap check but
  doesn't load bootstrap classes from 'normal' code.

This should address second problem and make Eclipse's OSGi
implementation 'safe' by default.
2019-01-25 08:52:07 -05:00
Tyler Benson 146a16df25 Upgrade weak-lock-free to 0.15 2019-01-24 11:44:28 -08:00
Nikolay Martynov 6471a1a81e Add $ separate to state field name 2019-01-23 22:32:00 -05:00
Andrew Kent 097c557651 Delay jmxfetch init when custom log manager is used by client's app 2019-01-16 12:18:29 -08:00
Andrew Kent cc8db0b11f Workaround module bug by skipping LogManager$Cleaner instrumentation 2019-01-09 15:03:43 -08:00
Tyler Benson fe52180bfc Apply proper generic signature for Instrumenter.Default transformers()
Previously it was missing the MethodDescription portion.
2019-01-04 15:25:12 -08:00
Andrew Kent 2861d87071 slf4j MDC autoinjection integration 2018-12-19 17:09:00 -08:00
Andrew Kent 4dc3528097 Add post-match hook to default instrumenter api 2018-12-19 17:07:43 -08:00
Andrew Kent d0f3cfa3d6 Use asm bundled by bytebuddy in field-backed provider
JVM's ASM is not bundled with the agent and may not be present at runtime.
2018-12-19 12:37:47 -08:00
Andrew Kent 0b92413d4a Move JvmBootstrapTest into a fork inside a groovy test 2018-12-12 20:17:48 -08:00
Andrew Kent 0240ad5154 Move default instrumentation declarations to Instrumenter.Default 2018-12-11 18:01:40 -08:00
Andrew Kent 1004ee4ef7 Patch java.util.logging.Logger for safe use with jmxfetch 2018-12-11 17:26:02 -08:00
Nikolay Martynov 3225c8fd03 Fix wildfly startup by injecting context classes into bootstrap package 2018-12-07 09:56:04 -05:00
Nikolay Martynov 600674b03a Put back muzzle check for 'dd-' threads 2018-12-05 17:20:50 -05:00
Nikolay Martynov 4deb68bfd7 Fix memory leak in WeakMapSuppliers.WeakConcurrent
The problem there is that it references JVM shutdown hook that keeps
reference to cleanup executor which potentially can keep references to
all sort of things - and this doesn't get cleaned up untill JVM
shutdown.

Solution is to remove shutdown hook when supplier is being GCed.
2018-12-05 15:02:40 -05:00
Nikolay Martynov ad98ebc01f Add some comments and some other minor CR tweaks 2018-11-29 15:18:46 -08:00
Nikolay Martynov 1509286b15 Remove MapBackedProvider 2018-11-29 15:18:46 -08:00
Nikolay Martynov 118a61cc67 Add field backed context provider 2018-11-29 15:18:46 -08:00
Nikolay Martynov b89e73b3c0 Switch executor instrumentation to use context storage 2018-11-29 15:18:46 -08:00
Andrew Kent 3c4b480a18 Share tooling loader across muzzle runs 2018-11-28 13:01:01 -08:00
Andrew Kent 6ee5fd27b0 Guard against invoking WeakConcurrent constructor 2018-11-28 12:05:47 -08:00
Gary 50c2af9abb
remove classloader matcher 2018-11-26 16:57:12 -05:00
Gary bf30d73746
remove skipping of ratpack helper checks 2018-11-26 16:55:36 -05:00
Andrew Kent 1667e590b9 Log Java and JVM version info. 2018-11-02 17:12:00 -07:00
Nikolay Martynov 3c0ba56d2c Make context maps 'global' for a given key class name
This ensures that different instrumenters using same key class can see
each others state
2018-11-02 12:59:30 -04:00
Nikolay Martynov 98df97af3e First iteration on a better context store api
Separate context storage from actual fetching/putting
2018-11-02 10:46:57 -04:00
Andrew Kent d0b00e0dc0 Inject all map holder classes into the bootstrap 2018-11-01 15:05:20 -07:00
Andrew Kent 5f0f6f1474 Inject dynamic classes into topmost class loader 2018-10-31 16:11:52 -07:00
Andrew Kent 5824eb83b8
Merge pull request #537 from DataDog/ark/instrumentation-context-outline
instrumentation context map-backed impl
2018-10-29 18:48:23 +00:00
Andrew Kent b89aa54a93 Move ASM visiting method into context-store impl 2018-10-26 14:06:57 -07:00
Andrew Kent cc27f1507e Javadoc for map-backed context store. Type info on context store api 2018-10-26 13:41:24 -07:00
Nikolay Martynov fc13d7db2b Reorganize WeakConcurrent implementation to allow cleanup thread GC when map is out of scope 2018-10-23 16:30:51 -04:00
Tyler Benson 13c91d11e5 Upgrade shadow to 4.0.1 and exclude module-info.class files. 2018-10-22 10:44:04 +10:00
Tyler Benson 192b0fd478 misc minor changes 2018-10-22 10:44:04 +10:00
Andrew Kent 7547e0fc5e Cleanup and javadoc 2018-10-19 13:07:11 -07:00
Andrew Kent 131074c255 Move InstrumentationContext api to bootstrap 2018-10-18 10:16:15 -07:00
Andrew Kent b02ed4e813 Initial Map-backed implementation and test 2018-10-17 15:29:59 -07:00
Andrew Kent f098b8027e Basic implementation outline and happy-path test 2018-10-16 10:22:36 -07:00
Andrew Kent 7330ceaf4e Instrumentation Context outline for HttpURLConnection as an example 2018-10-15 11:05:23 -07:00
Andrew Kent 13c96bba33 Additional test for shared field 2018-10-10 10:40:04 -07:00
Tyler Benson 330e09d0b3
Merge pull request #477 from DataDog/tyler/bb-upgrade
Upgrade Byte Buddy to 1.9.0
2018-10-02 11:31:11 -04:00
Tyler Benson 6b8eb60ca2 Upgrade Byte Buddy to 1.9.0 2018-10-01 13:31:03 -04:00
Andrew Kent 5864dd90e7 Allow instrumenting com.sun.messaging. namespace 2018-09-28 14:37:32 -07:00
Tyler Benson 3d78afbc2c Disable Executor instrumentation ThreadPoolExecutor instances
If we can’t add generic runnables to the queue.

This won’t solve the problem for all cases, but it will help with some.

Tests forthcoming.
2018-09-20 16:06:01 +10:00
Tyler Benson f9f0438e85 Initialize WeakMapProvider even earlier
It is used by classes delcared as static fields in AgentInstaller, so there were some cases where the fallback is being used.
2018-09-19 08:37:08 +10:00
Tyler Benson 296f9adfc2 Ignore byte buddy classes
not having this produced the following error on startup:

```
Cannot resolve type description for net.bytebuddy.dynamic.Nexus
```
2018-09-18 17:20:36 +10:00
Tyler Benson 8061bd2471 Add comment. 2018-08-31 16:27:31 +10:00
Tyler Benson 2d04ef292e
Merge pull request #468 from DataDog/tyler/evict-typepool
Add eviction to a TypePool.CacheProvider’s cache
2018-08-31 08:57:18 +10:00
Tyler Benson 6b0f20fc05 Add eviction to a TypePool.CacheProvider’s cache
Most items loaded are probably not often used.  Puts an upper limit on the size and evicts unused Resolution’s over time.
2018-08-30 11:56:53 +10:00
Andrew Kent 61aaebfc97 Create muzzle references from ldc instructions 2018-08-29 17:18:11 -07:00
Andrew Kent 7154b54e10 Rename TracerBridge and Provider 2018-08-27 12:04:26 -07:00
Andrew Kent 9f1d22ea6b Register TracerBridge in TracerInstaller instead of DDTracer init 2018-08-27 12:04:26 -07:00
Andrew Kent c6841c9d06 Add maven version scanning to muzzle 2018-08-24 10:47:37 -07:00
Tyler Benson 36b49c7de3
Merge pull request #451 from DataDog/tyler/netty-client-fixes
Allow trace to persist across netty connect.
2018-08-23 16:03:58 +10:00
Tyler Benson 898647e000 Allow trace to persist across netty connect.
Also create span with error on connection failure.

Add tests for connection failure.
2018-08-22 09:45:33 +10:00
Nikolay Martynov c95baef487 Wait for given reference to get GCed in `waitGC`
This should help to make sure that object we are interested in
actually gets GCed.

This change also improves tests for PendingTrace and ScopeManager to
make sure that trace gets cleaned up.
2018-08-21 10:05:10 -04:00
Nikolay Martynov 138f78ce4b Make Muzzle log class being instrumented 2018-08-16 17:28:32 -04:00
Andrew Kent 3c1bf569ea Add reference pretty-printer to muzzle plugin 2018-08-15 10:01:19 -07:00
Andrew Kent c351a4825e Regenerate muzzle bytecode when run multiple times 2018-08-15 09:49:50 -07:00
Nikolay Martynov 36ec5d51e5 SafeHasSuperTypeMatcher: handle exceptions when getting class erasure 2018-08-15 09:49:50 -07:00
Andrew Kent a7c63b9261 Clarify comment for safe interface iteration. 2018-08-15 09:49:50 -07:00
Andrew Kent 57e85d4a13 Catch and log instrumentation matcher exception
Catching instrumentation matcher exceptions at the Instrumenter level
allows other, unrelated instrumentation to match.
2018-08-15 09:49:50 -07:00
Andrew Kent d64b162539 Remove safeMatch from element matcher and document bb cache class 2018-08-15 09:49:50 -07:00
Andrew Kent 260e3520aa Fix classloading integration tests 2018-08-15 09:49:50 -07:00
Andrew Kent 35c6fa2343 More error catching in safe matcher and reduce log level 2018-08-15 09:49:50 -07:00
Andrew Kent 75a6cee068 Add DDCachingPoolStrategy to reuse type descriptions 2018-08-15 09:49:50 -07:00
Ark f01c8349cc Deep-merge Reference fields and methods
Plus misc cleanup.
2018-08-15 09:49:50 -07:00
Andrew Kent e7bb7cfb3e Remove findLoadedClass 2018-08-15 09:49:50 -07:00
Andrew Kent 50c5a57c49 Replace UnloadedType with ByteBuddy TypeDescription 2018-08-15 09:49:50 -07:00
Andrew Kent 27cade057c Delegate bootstrap resource loading for unloaded types 2018-08-15 09:49:37 -07:00
Andrew Kent f8f45d7f14 Muzzle field matching 2018-08-15 09:49:37 -07:00
Andrew Kent c4daf007e3 Muzzle method and access matching 2018-08-15 09:49:37 -07:00
Andrew Kent 4887822eba Muzzle method ref creation and matching 2018-08-15 09:46:30 -07:00
Andrew Kent 0f6761dd4b Optimize Instrumenter logging 2018-08-15 09:46:30 -07:00
Andrew Kent 55a0abce68 Add notes of potential references to ReferenceCreator 2018-08-15 09:46:30 -07:00
Tyler Benson 84d38a8270
Merge pull request #439 from DataDog/tyler/method-signatures
Cleanup method signatures and servlet 2 instrumentation
2018-08-13 17:29:02 +10:00
Tyler Benson f801cbd466
Merge pull request #428 from DataDog/tyler/use-WeakConcurrentMap
Use WeakConcurrentMap
2018-08-13 16:44:16 +10:00
Tyler Benson 232708e457 Prevent abstract classes from going through the muzzle plugin. 2018-08-13 15:35:46 +10:00
Tyler Benson 4583d12b31 Cleanup method signatures and servlet 2 instrumentation
adding the abstract servlet instrumentation reduces code duplication and makes it more similar to servlet 3 instrumentation.
2018-08-13 15:14:10 +10:00
Nikolay Martynov fc8cc47f85 WeakMap improvements
* Improve tests to not depend on thread schedulting
* Test all underlying implementations
* Reduce number of static values
2018-08-10 22:16:21 -07:00
Tyler Benson 6cef9b89b0 Make some things non-static 2018-08-10 15:41:26 +10:00
Tyler Benson b220309a68 PR review changes. 2018-08-10 12:23:13 +10:00
Tyler Benson a3875aff2c Logging improvements and other misc
from reviewing a customer’s logs.
2018-08-09 15:59:59 +10:00
Tyler Benson eacc2d6402 Restructure how WeakMap is implemented
Use an interface.
Use a provider/supplier to avoid loading more onto the bootstrap classpath.
2018-08-08 16:54:44 +10:00
Tyler Benson 5e55defeb3 Fix bootstrap classpath. 2018-08-07 17:11:42 +10:00
Tyler Benson 847484cd47 Use WeakConcurrentMap
Instead of `Collections.synchronizedMap(new WeakHashMap<>())`.
2018-08-06 14:14:57 +10:00
Tyler Benson 064ae4c238 Separate span for input and output streams. 2018-08-03 15:41:16 +10:00
Nikolay Martynov 7ad9305927 Add some integration tests to check ByteBuddy's behavoir on class loading and parsing 2018-08-01 14:17:12 -04:00
Nikolay Martynov bb2126bd9a Improve ByteBuddyElementMatchers javadoc 2018-07-31 20:14:03 -04:00
Nikolay Martynov 78e6a9c336 Get rid of DDAdvice
Newer ByteBuddy api simplifies things.
2018-07-31 20:14:03 -04:00
Nikolay Martynov 6bc1d1ab8e Implement `saveHasSuperType` and use it instead of `hasSuperType`
The idea is to just 'trim' type hierarchy 'up-trees' that we cannot
resolve dring instrumentation instead of failing to instrument completely.
2018-07-31 20:13:59 -04:00
Nikolay Martynov bae79514c0 Fix DDLocationStrategy to use DataDog ClassLoader
This allows ByteBuddy to properly find classes injected into the
agent.

Thanks @realark for providing a fix!
2018-07-31 20:12:17 -04:00
Nikolay Martynov 4ae9263e1c Set POOL_ONLY DescriptionStrategy for ByteBuddy
This makes sure no classes are loaded during instrumentation
transformation which allows us to safely instrument depndent classes.
2018-07-31 20:12:17 -04:00
Tyler Benson ff9ef671f3 Apply formatter on groovy files. 2018-07-31 12:09:28 +10:00
Tyler Benson 51919a77bb Apply formatter on java files. 2018-07-31 12:07:43 +10:00
Tyler Benson b5c8a8b8fc Apply formatter on gradle files. 2018-07-31 12:04:00 +10:00
Nikolay Martynov f6edf913b7 Remove functions that do reflection which is not Java10 compliant
These functions are not used anylonger
2018-07-27 14:56:28 -04:00
Andrew Kent b64be6228c Don't check for helper classes in muzzle reference check 2018-07-27 11:03:02 -07:00
Nikolay Martynov 0f80f7dd40 Remove old checks from HelperInjector
They are not really producing anything useful anf they depend on API
that is forbidden in Java9+
2018-07-26 10:11:24 -04:00
Nikolay Martynov 8cc2f6cbb2 Skip `jdk.internal.reflect.DelegatingClassLoader` in `ClassLoaderMatcher`
This is the same thing as `sun.reflect.DelegatingClassLoader` in older JVMs
2018-07-26 10:01:55 -04:00
Tyler Benson aa3fc0717e Fix some formatting changes. 2018-07-20 10:31:14 +10:00
Tyler Benson 12a2fce96d Upgrade java formatter version. 2018-07-19 14:10:53 +10:00
Andrew Kent 23d0439b12 Remove muzzle dead code, doc cleanup, and better logging 2018-07-13 16:24:01 -07:00
Andrew Kent 2925df8de5 Clean up and document 2018-07-10 17:26:49 -04:00
Andrew Kent 8e182edc03 Replace BIPUSH with LDC to prevent overflow 2018-07-10 17:26:49 -04:00
Andrew Kent 628f4929dc Muzzle Assertions and gradle plugin 2018-07-10 17:26:49 -04:00
Andrew Kent 541a6998a4 Hook up muzzle to Instrumenter.Default's matcher 2018-07-10 17:26:49 -04:00
Andrew Kent d61f65f4ff Muzzle outline in Instrumenter.Default 2018-07-10 17:26:49 -04:00
Andrew Kent 836f49205b TraceConfigInstrumentation implements Instrumenter directly 2018-07-10 17:26:49 -04:00
Andrew Kent 02a3e6a5d3 New Instrumentation API 2018-07-06 17:17:32 -04:00
Andrew Kent 33a139cdcb New Instrumentation outline 2018-06-28 14:54:14 -07:00
Andrew Kent f8e3ac3097 New instrumentation api outline 2018-06-28 14:54:14 -07:00
Andrew Kent 3894f829bb Remove most shadow relocates
Shadow relocates are no longer needed because of our new bootstrapping
process.
It's no longer possible for agent dependencies to interfere with the
user's classpath.

The immediate reason for this change is a bug created in the Cassandra
instrumentation.
The Cassandra instrumentation references guava transitive deps from
the datastax driver. These references are re-written by shadow,
causing the instrumentation to reference 'datadog.agent.deps.google.*'
instead of the guava class.
2018-06-27 09:35:54 -07:00
Tyler Benson 83db4e8c4d
Merge pull request #352 from DataDog/tyler/netty
Netty HTTP client and server instrumentation
2018-06-21 14:11:12 +10:00
Nikolay Martynov 9cc99bafbf Simplify Jacoco configuration 2018-06-20 17:13:30 -04:00
Nikolay Martynov e070a9be4a Fix jacoco excluded classes concatenation 2018-06-20 17:05:16 -04:00
Tyler Benson 9b3df4ff9e Netty HTTP client and server instrumentation first pass
Doesn’t target right versions. Needs lots of testing.
2018-06-18 12:52:42 +10:00
Gary Huang fdc56c0e13 change the way classes are loaded so that classLoaderHasClasses would still work for the classes that are being instrumented and being matched at the same time. 2018-06-08 23:53:13 -04:00
Tyler Benson 206de0fb54 Add some more missing helper classes 2018-06-09 10:59:08 +10:00
Tyler Benson d235618a6e Add instrumentation for Java’s UrlConnection
For HttpUrlConnection, trace propagation headers are added to the outgoing request.

Due to the awkward design of the API, the ability to instrument in a natural way was limited, thus the main points instrumented are the get{Input,Output}Stream methods.
2018-06-06 09:12:48 +10:00
Andrew Kent 217dd411de Disable muzzle 2018-05-21 10:58:30 -07:00
Andrew Kent 0bd7a62464 Flags, Fields, Methods, and builder logic for References 2018-05-18 10:45:05 -07:00
Andrew Kent bf70b3031b Cache classloaders for reference checking 2018-05-18 10:45:05 -07:00
Andrew Kent ad7f6a5e71 Generate at compile-time and lazy-load reference matchers 2018-05-18 10:45:05 -07:00
Andrew Kent 98b44c1dfb Remove ReplaceIsSafeVisitor 2018-05-18 10:45:05 -07:00
Andrew Kent 08df3cef35 Use bytebuddy plugin to add safety checks to instrumentation 2018-05-18 10:45:05 -07:00
Tyler Benson 46878d24d3 Name service based on servlet context
This only applies if a service name hasn’t been set or is empty.

This is particularly useful for environments that deploy multiple war files to the same app server.
2018-05-11 13:59:03 +10:00
Tyler Benson d5d24c50c7 Replace @Unroll’s with a rule to always unroll. 2018-05-10 15:24:59 +10:00
Tyler Benson 9a52303376 Apply jacoco to every java project
Some projects have ignores/whitelists, but generally coverage is pretty high.

AFAIK, this doesn’t really capture instrumentation test coverage though.
2018-05-04 16:23:32 +10:00
Tyler Benson f35e2e6ebe Remove various warnings and other cleanup
Also upgrade some plugins.
2018-05-04 14:05:06 +10:00
Tyler Benson 2561e72824 Do we do want to ignore proxies?
If so, we have to change the test to be compatible.
2018-05-04 14:03:48 +10:00
Tyler Benson 84b7080860 Fix AgentInstaller ignores and @Trace naming 2018-05-03 13:03:53 +10:00
Tyler Benson 57eade612f Upgrade Byte-buddy to 1.8.8
Also remove some erronously checked in files.
2018-04-26 22:53:45 +10:00
Andrew Kent 35c40846ad Accept string for method params on classloader method matcher 2018-04-11 13:32:58 -07:00
Andrew Kent 06b80351e3 Log where all version files are visible 2018-04-10 16:54:22 -07:00
Andrew Kent 63ae144734
Merge pull request #277 from DataDog/ark/play
Play 2.4-2.6 Instrumentation
2018-04-09 13:39:03 -04:00
Andrew Kent 2449810ce0 Play 2.4 and 2.6 testing 2018-04-05 17:58:04 -04:00
Tyler Benson 79a9826863 Add the errorprone compiler. 2018-04-04 20:48:28 +08:00
Andrew Kent 123c5beab3 Enable instrumenting old java bytecode 2018-03-20 15:59:11 -07:00
Andrew Kent 37a24107b0 Resurrect tooling test into agent-tooling 2018-03-19 10:10:38 -07:00
Andrew Kent 84fe1fc0e3 Organize bootstrap and agent classes by known prefix. 2018-03-15 12:17:03 -07:00
Andrew Kent 878d92f5b2 Test under custom classloader 2018-03-15 12:17:03 -07:00
Andrew Kent d7c2155054 Check parent classloaders when resource location fails. 2018-03-12 18:03:52 -07:00
Tyler Benson 286e9d2d00 Add instrumentation to catch additional classloaders.
Still doesn’t work with Spring Boot because the way they structure their Jars.
2018-03-09 14:32:41 +10:00
Andrew Kent 4fffb61a32 Enable bootstrap instrumentation and helper injection. 2018-03-09 14:31:48 +10:00
Andrew Kent 5ffd2142e9 Set max stack size in bytebuddy exception handler 2018-03-07 13:14:41 -05:00
Tyler Benson a3a70e6ea3 Remove unneeded dependency on dd-trace-ot. 2018-02-21 12:08:05 +10:00
Andrew Kent c6e883e042 Move bootstrap prefixes to classloader matcher 2018-02-15 19:17:19 -08:00
Andrew Kent d0982ada9d Skip unsafe classloaders. 2018-02-15 19:17:19 -08:00
Andrew Kent 4a1db505db Enhance logging and cleanup. 2018-02-15 19:17:19 -08:00
Andrew Kent a28a7abd4e Run api classes on bootstrap and core agent on custom classloader 2018-02-15 19:17:19 -08:00
Andrew Kent cfef64b026 Reorganize dd-java-agent subprojects 2018-02-15 18:55:02 -08:00