Commit Graph

274 Commits

Author SHA1 Message Date
Tyler Benson 188bdf498f Add comments and remove unneeded code. 2018-10-23 16:40:39 +10:00
Tyler Benson a603eee841 Fix issue with saving tags when not propagating trace.
Previously, when setting headers as tags, the tags would only be saved if the request was propagated from another trace.
2018-10-23 16:37:22 +10: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
Isak W 57f021c631 Add test case for trace/span id serialization 2018-10-18 00:45:23 +02:00
Tyler Benson 8ffeb5bedf Add instrumentation for RabbitMQ’s AMQP library 2018-10-17 16:32:24 +10:00
Isak W 484d54d796 Parse trace/span id as BigInteger rather than letting msgpack parse it 2018-10-16 23:07:50 +02: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
Doug Roper 2aa7ffbcbf
Fix a couple typos. 2018-10-02 21:51:04 -04:00
Tyler Benson 8b822ff26d Fix AWS tests and change span type to http-client
There seems to be a bug.  I would expect the aws span to be the parent of the apache http span, but that is not the case.

Removed the now unused HTTPComponent decorator.
2018-09-28 21:23:30 -04:00
Tyler Benson 4eb0cd4097 Refactor Apache HttpClient Instrumentation.
Removes the need for DDTracingClientExec.
Reduces extra spans.
Does not include a span for each redirect.
Compatible with 4.0+ instead of just 4.3+.
2018-09-28 17:52:39 -04:00
Nikolay Martynov caa799ddc1 Refactor DDTraceConfig to a Config we can use globally
This would allow us to use same configuration ingrastructure in
different modules. E.g. upcoming JMX.
2018-09-12 17:14:58 -04: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 e565205d77 TraceInterceptor registration api 2018-08-27 12:04:26 -07:00
Andrew Kent ab14c85fcf
Merge pull request #459 from DataDog/ark/gc-span-closing
gc span closing
2018-08-27 11:57:37 -07:00
Andrew Kent bc105af06f Doc PendingTrace's root span. 2018-08-27 11:33:21 -07:00
Andrew Kent 29b9da5fb1 Add getRootSpan() to MutableSpan 2018-08-27 11:02:29 -07:00
Andrew Kent e0837efb5b Fix remove PendingTrace from span cleaner bug 2018-08-27 10:58:07 -07:00
Andrew Kent 9d4933011e Fix flickering PendingTraceTest 2018-08-27 10:58:07 -07:00
Andrew Kent a6b2e1f27c Don't report traces closed by garbage collection. 2018-08-24 10:13:32 -07: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 a0036a76cc Add `runFinalization` to `waitForGC` 2018-08-19 00:49:27 -04:00
Tyler Benson 20993e7e16 Allow tests to run on all JDKs 2018-08-16 14:23:58 +10:00
Tyler Benson e07dfffe5f Migrate tests to new TestHttpServer 2018-08-16 14:23:58 +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 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 847484cd47 Use WeakConcurrentMap
Instead of `Collections.synchronizedMap(new WeakHashMap<>())`.
2018-08-06 14:14:57 +10:00
Nikolay Martynov e517080234 Fix span cleaner executor to use correct span cleaner reference 2018-08-01 14:59:22 -04:00
Nikolay Martynov afc16a0dd5
Merge pull request #418 from DataDog/mar-kolya/ignore-empty-tags-in-config
Ignore empty entries in tags config strings
2018-07-30 23:24:19 -04:00
Tyler Benson 3856e7fd1a http clients 2018-07-31 12:53:50 +10:00
Tyler Benson 561eb0fcd9 Update span types to be consistent with other tracers 2018-07-31 12:40:03 +10:00
Nikolay Martynov db2f3c8e0a Ignore empty entries in tags config strings
Empty tags (or service names) do not make sense. Currently we ignore
whole config line which is too harsh. Instead just ignore a key with
empty value.
2018-07-30 22:32:04 -04:00
Tyler Benson 8dd87a8d30
Merge pull request #415 from DataDog/tyler/resolver-config
Allow DDTracerResolver to be disabled.
2018-07-31 12:24:50 +10:00
Tyler Benson 12e41be258
Merge pull request #416 from DataDog/tyler/contributing
Add contributing document and apply formatting.
2018-07-31 12:24:23 +10:00
Nikolay Martynov b58bf1a2bb
Merge pull request #419 from DataDog/mar-kolya/simplify-default-tags-handling
Simplify default tags handling
2018-07-30 22:19:20 -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 4139af73fa DDTracer: add some asserts into constructor 2018-07-30 21:28:22 -04:00
Nikolay Martynov 2c0702f278 Simplify default tags handling
Remove special case of tags beng empty - it is unlikely to improve
performance but it complicated code unnecessarily.
2018-07-30 21:14:52 -04:00
Tyler Benson f2dbeecdf5
Merge pull request #394 from DataDog/tyler/peer-service
Add support for OT’s `service` and `peer.service` tags
2018-07-31 10:26:22 +10:00
Tyler Benson 2dd62bbab1 Optimization to avoid serialization when logging disabled. 2018-07-31 10:17:05 +10:00
Gary Huang 4c88e1a0a8
Merge pull request #392 from DataDog/gary/uint64-id-support
Change the internal storage and handling of trace ID, span ID, and pa…
2018-07-30 15:01:10 -04:00
Tyler Benson d3e0323b04 Allow DDTracerResolver to be disabled. 2018-07-30 15:17:27 +10:00
Tyler Benson 4e60246e17
Merge pull request #405 from DataDog/tyler/servlet-async
Refactor servlet instrumentation and disable async on response.
2018-07-30 10:27:54 +10:00
Gary Huang 0d9a461b87 Add NumberFormatException as cause to IllegalArgumentException if extracted ID is not a number. Also change uint64 max BigInteger initialization to be more readable. 2018-07-26 11:26:56 -04:00
Gary Huang 6317b21d5c Fix merge conflicts with service mapping change 2018-07-26 09:16:41 -04:00
Tyler Benson 2651dec616 Add support for OT’s `service` and `peer.service` tags
Sets DD’s `service.name` on the span.
2018-07-26 16:29:04 +10:00
Tyler Benson 1e36343485 Null or empty tags should remove previously set values.
Add context to servlet2 test.

Clean up some declared tracers that mess up the classpath.
2018-07-26 12:20:37 +10:00
Nikolay Martynov baa54c3553 Disable coverage checks for LoggingWriter
The build fails from time to time complaining about this class not
being tested. Looks like randomness of thi is due to Gradle's caching.

Ideally we would like to have this class tested, but Lombok injecting
logger doesn't really provide much of a room to test there.
2018-07-25 12:13:29 -04:00
Tyler Benson 5fe08d20fc Only apply service name mapping on finish
If done in the decorator, it would be applied twice.  Only want it done once.
2018-07-25 14:58:55 +10:00
Gary Huang 93e70dcef6 Address comments and add test case for extracting non numeric IDs 2018-07-24 14:04:52 -04:00
Tyler Benson 7807615605 This actually must be done at the span finish, rather than creation.
Otherwise the context decorator doesn’t know if it should change the span name or not.
2018-07-23 13:59:01 +10:00
Tyler Benson de5d108afc Allow service name mapping to apply without setting the tag.
Previously the mapping only applied when the `service.name` tag was set, not on the default or configured service name.
2018-07-23 13:46:48 +10:00
Gary Huang 96f79a8aba Change the internal storage and handling of trace ID, span ID, and parent IDs' to use String instead of long primitive.
This will allow the java agent to receive unsigned 64 bit integers without overflow.

Also upgraded MsgPack to handle the serialization of such Strings as numbers in JSONs.
2018-07-20 17:19:04 -04:00
Tyler Benson 12a2fce96d Upgrade java formatter version. 2018-07-19 14:10:53 +10:00
Andrew Kent 4401779aad Fix priority sampling implementation bugs
- use correct sampling flag name
- set sampling rate
- set sampling flags on root span metrics only
- tests to assert correct behavior
2018-06-26 10:19:28 -07:00
Andrew Kent 224f65a0c2 rootSpan hack for PendingTrace 2018-06-26 10:19:28 -07:00
Nikolay Martynov 088402beed
Merge pull request #358 from DataDog/mar-kolya/fix-span-time-boundaries-poc
Fix span time boundaries
2018-06-26 12:48:49 -04:00
Tyler Benson 17c2f28947 Upgrade to gradle 4.8.1 2018-06-26 10:33:35 +10:00
Nikolay Martynov d50154f159 PendingTrace: add a TODO to move time fields into DDTracer 2018-06-25 09:28:01 -04:00
Nikolay Martynov 2bdf54bd6e Fix span start boundaries
Before: span start had millisecond precision because we just use
`currentTimeMillis` to get span start time.

This creates weirdly looking traces where spans 'fly' way out of
parent spans if they have sub-ms length.

After: we establish 'trace start time' with millisecond precision and
measure all span start and stop times from that. This means all
relative times are maintained with nanosecond precision (or whateve OS
clock fives us).

This is POC and some things are not yet fixed. E.g. JMS1
instrumentation injects time into span manually - and it is not
apparent how to pake it do so relative to trace clock.

Note: going forward this should allow us to completely get rid of
'double time keeping' we currently have in `DDSpan`.
2018-06-22 17:17:53 -04: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
Nikolay Martynov d3aa982082 Add tests for OTTraceCorrelation 2018-06-18 17:57:02 -04:00
Andrew Kent 519f15bcc6
Merge pull request #357 from DataDog/ark/servlet-async
Close scope for async servlet requests
2018-06-17 23:44:24 -07:00
Nikolay Martynov f9cc33c7c8
Merge pull request #353 from DataDog/mar-kolya/spymemcached-instrumentation
Mar kolya/spymemcached instrumentation
2018-06-15 12:44:42 -04:00
Andrew Kent 6cd8be67d5 Close scope for async servlet requests 2018-06-14 20:23:54 -07:00
Andrew Kent f28445c45f CorrelationIdentifier for MDC frameworks. 2018-06-14 15:33:15 -07:00
Nikolay Martynov 1e4c88ffcb Merge branch 'master' into mar-kolya/spymemcached-instrumentation 2018-06-14 15:38:01 -04:00
Nikolay Martynov ba37ccc552 Spymemcached: use cache span type 2018-06-14 13:37:35 -04:00
Tyler Benson ff56389a56 Upgrade some versions. 2018-06-14 11:56:56 +10:00
Gary Huang e89cbd0bb1 set span cleaner threads to be daemon threads so that applications can exit without explicit exit statement. 2018-06-07 17:09:59 -04: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
Tyler Benson de74eb1938 Add additional metadata to ES client calls. 2018-05-25 13:58:44 +10:00
Tyler Benson 0cf8fef8d8 Elasticsearch Instrumentation 2018-05-23 11:29:13 +10:00
Tyler Benson 024d414844 Move Apache HttpClient tests to instrumentation
And add latest test.
2018-05-18 12:01:12 +10:00
Tyler Benson 69ee39bfc2
Merge pull request #317 from DataDog/tyler/tagged-headers
Add setting for collecting headers as tags during extraction
2018-05-15 10:43:54 +10:00
Tyler Benson c011eb0fbd
Merge pull request #320 from DataDog/tyler/servlet-context-naming
Name service based on servlet context
2018-05-15 10:27:06 +10:00
Tyler Benson dc814aeb6d Fix tests. 2018-05-11 15:19:30 +10:00
Tyler Benson 6767785e0f Try cleaning more than once in test. 2018-05-11 14:27:44 +10: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 97b3e537bd Add shutdown hook to span-cleaner thread 2018-05-11 13:55:05 +10:00
Tyler Benson 891b46f0d1 Add setting for collecting headers as tags during extraction 2018-05-11 09:32:07 +10:00
Tyler Benson d5d24c50c7 Replace @Unroll’s with a rule to always unroll. 2018-05-10 15:24:59 +10:00
Tyler Benson 2595ca5128 Refactor decorators and add service name mapping 2018-05-08 16:13:48 +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 7c4d42ef8a Add additional test task for testing latest versions of a dependency 2018-05-04 14:04:30 +10:00
Tyler Benson 3fa0eb0296 Remove dependency on guava for dd-trace-ot 2018-05-03 16:11:15 +10:00
Tyler Benson 63d308e50d Misc cleanup/minor changes 2018-05-01 10:24:14 +10:00
Tyler Benson cd289308bb Remove timeouts.
Not helping as much as was hoped.  Causing extra noise in CI.
2018-04-30 11:10:18 +10:00
Tyler Benson 3db2d654f1 Fix spark instrumentation
and rebase off master.
2018-04-26 17:01:45 +10:00
Andrew Kent 64ce961c32 Debug logs for hot paths 2018-04-23 11:06:45 -07:00
Andrew Kent c3feb3b878
Merge pull request #290 from DataDog/ark/pending_expire
Handle spans registered after trace is written
2018-04-23 10:00:38 -07:00
Andrew Kent bb69666e9f Handle spans registered after trace is written
Decrement the pending trace count when spans are registered after a
trace writes. Log certain pending trace messages at debug.
2018-04-18 12:37:14 -07:00
Tyler Benson e7604bfd3f Report X-Datadog-Trace-Count header with traces
Also remove unused services endpoint code.
2018-04-18 10:27:51 +08:00
Andrew Kent c7cf1cf36d
Merge pull request #282 from DataDog/ark/async-refactor
Toggleable Async Propgation on the trace context
2018-04-17 09:44:41 -07:00
Andrew Kent 5f5d654a4c
Merge pull request #288 from DataDog/ark/agent_priority_sampling
Move PrioritySampling flags to dd-trace-api project
2018-04-17 09:26:45 -07:00
Andrew Kent 9bcd5677ed
Merge pull request #287 from DataDog/ark/logging
Logging
2018-04-17 09:26:32 -07:00
Tyler Benson c796260a39
Merge pull request #285 from DataDog/tyler/build-workspace
Build with Java 8, but run tests with other JDKs
2018-04-17 13:14:54 +08:00
Andrew Kent 32272a4aa7 Move PrioritySampling flags to dd-trace-api project. 2018-04-16 12:46:26 -07:00
Andrew Kent 364b3e999a Remove warning from mongo listener. Add injection debug logging. 2018-04-16 10:34:46 -07:00
Tyler Benson 001e59e0cc Build with Java 8, but run tests with other JDKs
Use workspaces to persist build between jobs.
2018-04-16 14:36:38 +08:00
Andrew Kent 03b96ca567 Increase agent writer max trace limit 2018-04-11 14:35:30 -07:00
Andrew Kent d594d6e8db Don't create continuations when async propagation is off 2018-04-11 13:32:58 -07:00
Andrew Kent a0a11a51d0 Use ScopeManager to enable/disable low level async instrumentation. 2018-04-11 13:32:58 -07:00
Andrew Kent 0d7aa022db Refactor ContinuableScope 2018-04-11 13:32:58 -07:00
Andrew Kent 01c707787f Fix name: timestampMillis -> timestampMicroseconds 2018-04-10 16:53:58 -07:00
Tyler Benson f05ddaa19d
Merge pull request #283 from DataDog/tyler/span-times
Add startTime and Duration methods to MutableSpan interface
2018-04-09 23:46:23 +08:00
Tyler Benson fcb1e1c564 Add startTime and Duration methods to MutableSpan interface 2018-04-09 23:25:35 +08:00
Tyler Benson 79a9826863 Add the errorprone compiler. 2018-04-04 20:48:28 +08:00
Tyler Benson 5a61124cae Add tests against an actual trace agent. 2018-03-28 22:31:15 +08:00
Tyler Benson 19b94da7bb JAX-RS Client Tracing 2018-03-20 08:54:09 +08:00
Andrew Kent 783a6d88e2 Increase Test timeouts 2018-03-15 13:23:57 -07:00
Andrew Kent 10e12a666a Use builtin decorators for every DDTracer 2018-03-13 12:46:48 -07:00
Andrew Kent b5b38ee4b1 Mark all http status codes 5xx as an error. 2018-03-13 12:46:48 -07:00
Tyler Benson 0fbec69b6d
Merge pull request #253 from DataDog/tyler/traceinterceptor
Implement the TraceInterceptor API
2018-03-13 08:30:01 +10:00
Andrew Kent 428e304164 Rename ContextPropagator to TraceScope 2018-03-12 10:29:50 -07:00
Andrew Kent 21180530ea Remove opentracing from dd-trace-api 2018-03-09 11:50:39 -08:00
Andrew Kent 9a83413141 Executor Instrumentation for Scala 2018-03-09 11:50:39 -08: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
Tyler Benson d073cd8a17 Initial pass at TraceInterceptor API 2018-03-09 14:32:41 +10:00
Tyler Benson f57faba5db Allow closing of continuation explicitly
to allow a completed trace to be reported more timely.
Continuation is closed when the returned scope is closed, but can also be closed directly.
2018-03-09 14:31:48 +10:00
Tyler Benson 087b2e7298 Fix tests 2018-03-09 14:31:48 +10:00
Tyler Benson 5c3e4c91fd Rename to PendingTrace 2018-03-09 14:31:48 +10:00
Tyler Benson 2b1c9aabfb Force traces to wait Continuation dereferencing before reporting
If all the current spans on a trace complete before a continuation can be activated, previously the trace could have been reported, not allowing additional spans to be added.

This PR changes it so any created continuations must be dereferenced (GC’d) before allowing the trace to be reported.
2018-03-09 14:31:48 +10:00
Tyler Benson c99f10c0d2 Decouple trace flush from collection
Wait until all spans are finished or garbage collected before reporting trace.
2018-03-09 14:31:48 +10:00
Tyler Benson 5cbc11415d Move SpanFactory to correct package. 2018-03-09 14:31:48 +10:00
Tyler Benson f31632be33 Remove deprecated usage. 2018-03-09 14:31:48 +10:00
Tyler Benson 5d1297f125 Extract a trace out to a specific class
Rather than it just be a list of spans…
This allows for tracking of if the trace was reported or not, and in the future to do so independently of finishing the span.
2018-03-09 14:31:48 +10:00
Tyler Benson 8da3a0492d Improve threadsafety and organization 2018-03-09 14:31:48 +10:00
Tyler Benson 9b1d454eb9 Combine Threadlocal and RefCounting into single Scope
Also added additional tests.
2018-03-09 14:31:48 +10:00
Tyler Benson 27c1d71504 Introduce ScopeContext and ReferenceCountingScopes 2018-03-09 14:31:48 +10:00
Jon Mort f78c290b40 Closes #222: Introduce a ScopeManager property 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 759fb4e815 Configure tags to be added to every span 2018-03-01 17:19:52 +10:00
Tyler Benson ac1b57d7a2 Fix test for v0.4 endpoint
Agent returns an error if no content sent, so test was failing.  Need to send empty content for test to succeed.
2018-02-26 13:50:32 +10:00
Tyler Benson 4c66bc8ed2 Use nanotime for additional clock resolution
If a start or stop timestamp on a span is provided, the nanotime is ignored.
2018-02-23 13:13:34 +10:00
Tyler Benson 163b285868 Rename to jedis-1.4 since that’s the earliest working version
Also change instrumentation binding for better coverage.
2018-02-23 13:04:46 +10:00
Tyler Benson 903248ddf2 Set timeouts on all the tests. 2018-02-21 12:09:57 +10:00
Tyler Benson c1224eaa9f Set short timeouts for api test to prevent startup delays
Since endpointAvailable is called on construct, this can happen in premain when running with the agent. I included a simple retry just in case…

Not sure in what case the trace agent would respond so slowly…
2018-02-20 17:43:26 +10:00
Andrew Kent 0864f81e45 whitelist ConfigUtils from jacoco 2018-02-15 18:50:18 -08:00
Tyler Benson c9da16f334 Add resource naming instrumentation for jax-rs 2018-02-14 19:18:01 +10:00
Tyler Benson 0299a7b9ae Remove unused config utils file. 2018-02-13 09:07:53 +10:00
Tyler Benson 9fc5cf6a4b Add exception for version segments in URLs
This seems like a common enough segment and useful to not remove.
2018-02-09 12:54:13 +10:00
Tyler Benson 0b4bf16f97 Remove configuration of ResourceName Decorator
Improve name sanitizing to reduce high cardinality issues.
2018-02-08 17:26:04 +10:00
Tyler Benson 4958a3d306 Fix dependency problem in dropwizard example
There was an incompatible mix of jackson dependencies which caused the app to not start up.  Changed the tracer client to use an old version, but allow the agent to still use a newer version (since it is shadowed).
2018-02-07 12:41:18 +10:00