Commit Graph

152 Commits

Author SHA1 Message Date
Tyler Benson 579b6dd929 Add transient modifier to added context fields. 2019-05-02 15:52:43 -07:00
Tyler Benson c971c434d1 Fix propagation and add onUnsubscribe handler
Ensures that span is closed when Observable is unsubscribed from.

Also added retransform error logger since retransforms might be missed if an exception is thrown, leading to odd behavior.
2019-04-30 11:52:20 -07:00
Tyler Benson 6414de82d9 Add support for HystrixObservableCommand
This change is slightly breaking for existing hystrixCommand code since the resource name changes from run->execute and getFallback->fallback.  The fallback span is also now a child of the execute span.
2019-04-29 12:04:27 -07:00
Tyler Benson 68a68f1057 Ensure that http.url tag doesn’t have query params set
Make handling of it more consistent in decorator.
2019-04-26 09:48:34 -07:00
Tyler Benson 9ad06a6791 Add instrumentation for Apache HttpAsyncClient
Extract http client tests to shared class.
2019-04-23 17:10:40 -07:00
Tyler Benson ec91a75848 Add config allowing classes to be excluded from transformation
Add the following system property or corresponding environment variable:
```
dd.trace.classes.exclude=some.packagename.*,some.classname.MyClass$NestedClass
```
2019-04-19 10:41:13 -07:00
Tyler Benson dc2e435de9
Merge pull request #797 from DataDog/tyler/ratpack
Update ratpack instrumentation and remove default disabled.
2019-04-16 08:14:10 -07:00
Luca Abbati f4a17ba4c5
Remove tests that relied on inner knowledge of the class. Feature still tested with cglib test. 2019-04-12 17:12:50 +02:00
Luca Abbati ff021f34db
Add minor fixes to comments and typos as per code reviewer suggestions 2019-04-12 16:51:49 +02:00
Luca Abbati c6863f0ca3
Use groovy class reference style in Spock tests 2019-04-11 16:06:46 +02:00
Luca Abbati 3a6fedda14
Add context getter/setter methods to an object only if not already defined
Class `FieldBackedProvider` uses ByteBuddy to add a field and its respective getters and setters to store the context object.
Assuming that we have a class `A` that implements runnable and that we wrap with a `FieldBackedProvider`
`Runnable` interfaces, if later on we use a cglib's `Enancher` class on `A` then the our mechanism will kick in again and try
to add the methods again. This causes a `java.lang.ClassFormatError: Duplicate method name "get__datadogContext$java$lang$Runnable" with signature "()Ljava.lang.Object;"`
to be thrown because CGLIB already copied over those methods from the original class `A` to the newly created class.

With this commit we now check that method were not previously defined before adding them, and if they were then we avoid adding them
again.

The reason why it wasn't faiing before is that we only checked on context field existence, not methods and cglib do not copy over fields, it copies only methods. E.g.

```
public class Main {

    public static class A {
        private String name = "hey";
        public String getName() {
            return this.name;
        }
    }

    public static void main(String[] args) {
        System.out.println("----- 'A' declared fields -----");
        A s = new A();
        for (Field f : s.getClass().getDeclaredFields()) {
            System.out.println("field: " + f.getName());
        }
        for (Method m : s.getClass().getDeclaredMethods()) {
            System.out.println("method: " + m.getName());
        }

        System.out.println("----- Proxy declared fields -----");
        Enhancer enhancer = new Enhancer();
        enhancer.setSuperclass(A.class);
        enhancer.setCallback((FixedValue) () -> null);
        A proxy = (A) enhancer.create();
        for (Field f : proxy.getClass().getDeclaredFields()) {
            System.out.println("field: " + f.getName());
        }
        for (Method m : proxy.getClass().getDeclaredMethods()) {
            System.out.println("method: " + m.getName());
        }
    }
}
```

Results in:

```
----- 'A' declared fields -----
field: name
method: getName
----- Proxy declared fields -----
field: CGLIB$BOUND
field: CGLIB$FACTORY_DATA
field: CGLIB$THREAD_CALLBACKS
field: CGLIB$STATIC_CALLBACKS
field: CGLIB$CALLBACK_0
field: CGLIB$CALLBACK_FILTER
method: equals
method: toString
method: hashCode
method: clone
method: getName
method: newInstance
method: newInstance
method: newInstance
method: setCallbacks
method: CGLIB$SET_STATIC_CALLBACKS
method: CGLIB$SET_THREAD_CALLBACKS
method: getCallback
method: getCallbacks
method: CGLIB$STATICHOOK1
method: CGLIB$BIND_CALLBACKS
method: setCallback
```
2019-04-11 15:45:43 +02:00
Tyler Benson c4ac5b94ec Fix span relationships and other review issues. 2019-04-10 17:31:22 -07:00
Tyler Benson a11b888d7a Update ratpack instrumentation and remove default disabled. 2019-04-08 18:26:08 -07:00
Ben Keith 446591240c Avoid race in TestHttpServer port selection
I notice occasionally some of the instrumentation tests fail due to port
conflicts in TestHttpServer, esp when using the `--parallel` option in
gradle. I think the previous method is subject to a race where two
concurrent workers will both get the same port from `randomOpenPort()`.
2019-03-06 12:55:02 -05:00
Tyler Benson 576e554445 Migrate Mongo to Decorator 2019-03-05 20:50:06 -05:00
Tyler Benson 50279d64fe Span type should only be an attribute and not inherited
Previously we were inheriting from the parent and also often setting as a tag.

Apply default span assertion to verify the spanType is being checked properly. (Include error state too.)
2019-02-28 12:39:51 -08:00
Tyler Benson 133460a79a Stop making hard references in HelperInjector
Also make awaitGC interruptable.
2019-02-27 19:09:01 -08:00
Tyler Benson 1644de3969 Migrate Jax-rs client instrumentation to Decorator 2019-02-27 09:40:08 -08:00
Tyler Benson a33b6ddaa0 Implement trace origin header and propagation support 2019-02-26 08:26:31 -08:00
Tyler Benson 5bc3ec82c2
Merge pull request #697 from DataDog/tyler/gradle-upgrade
Upgrade Gradle to 4.10.3
2019-02-11 16:01:35 -08:00
Nikolay Martynov 05731c3c45 Log when test starts
This is helpful to see what logs belong to what test
2019-02-11 12:21:20 -05:00
Nikolay Martynov bae2d7dde8 Allow non-wrapped tasks in disabled executors
Some executors cannot handle tasks that have been wrapped into
`{Runnable,Callable}Wrapper` because they require certain subclass of
`{Callable,Runnable}` in order to work. We have a test that
effectively disables instrumentation for such executors.

This change makes sure that tasks that do not need to be
wrapped (which essentially means anything that is not lambda) still
get traced in such executors. One notable example of affected executor
type is `ScheduledThreadPoolExecutor`.
2019-02-11 11:47:34 -05:00
Tyler Benson 000c0e4644 Upgrade Gradle to 4.10.3
Also try to improve build time performance by reducing the required configuration:
https://blog.gradle.org/preview-avoiding-task-configuration-time
2019-02-07 09:43:36 -08:00
Nikolay Martynov 6de4f1b0ba
Merge pull request #694 from DataDog/mar-kolya/split-service-http-client-suggestions
Mar kolya/split service http client suggestions
2019-02-05 16:07:54 -05:00
Nikolay Martynov a46d6a2e8f Use config inheritance in `withConfigOverride`.
This moves us forward to abstract 'Config' and away from depending in
specific config data source (e.g. system properties).
2019-02-05 15:51:05 -05:00
Tyler Benson 65cece6741 Fix code coverage ignores. 2019-02-05 12:15:14 -08:00
Tyler Benson bbcd2f6949 Move other Utils to utils package 2019-02-05 11:43:05 -08:00
Tyler Benson 6aa371d790 Encapsulate config override reflection 2019-02-05 11:30:07 -08:00
Tyler Benson 1a54e8179a Add setting to set service name by domain for http clients
This will allow better metric collection and identification of trends for individual services/hosts.

This is not enabled by default because it can result in a high cardinality of services.
2019-02-05 08:20:49 -08: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 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
Nikolay Martynov e9745e6775 Log active span in test assert 2019-01-23 22:31:59 -05: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
Tyler Benson 8b910b46d1 Update tests for `language` tag in root span 2018-12-27 16:00:47 -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 177c1432e3 Add tests to verify that fields are not injected when feature is disabled 2018-11-29 15:18:46 -08:00
Nikolay Martynov ad98ebc01f Add some comments and some other minor CR tweaks 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 80cd7cd500 Do testAnnotationProcessor deps.autoservice in modules with services in tests
Otherwise sometimes tests cannod discover services
2018-11-23 09:44:49 -05:00
Tyler Benson 9bd2b86d2e Add assertion to ensure latestDepTest dependencies are different from test. 2018-11-12 08:15:24 -08: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
Nikolay Martynov 34372533c1 Add config for tags that propagate to JMXFetch and spans
Also add runtime-id tag to root span and JMXFetch metrics
2018-10-22 15:51:20 -04:00
Tyler Benson 78c6f881ed
Merge pull request #535 from DataDog/tyler/rabbit
Add instrumentation for RabbitMQ’s AMQP library
2018-10-19 23:26:50 +10:00
Tyler Benson 64595cf485 Add type hints and parent assertion 2018-10-19 11:51:57 +10:00
Nikolay Martynov e02f889f09 Remove some dead code from SpockRunner
And also reformat it
2018-10-18 10:06:41 -04:00
Tyler Benson 8ff5c7c36c Review fix comments and version range. 2018-10-18 16:08:37 +10:00
Tyler Benson 8ffeb5bedf Add instrumentation for RabbitMQ’s AMQP library 2018-10-17 16:32:24 +10:00
Tyler Benson 432ce89a07 Add assertTraces to AgentTestRunner with implied argument
This will also help with auto complete when writing tests.
2018-10-15 10:19:00 +10:00