Add span_min_duration flag#1150
Conversation
eyalkoren
left a comment
There was a problem hiding this comment.
Very useful feature.
However, a risky one- may yield broken traces.
I spent some time looking into scenarios of non sampled transactions together with this and didn't find where it would break, but maybe add tests.
Specifically, the context propagation spans decide what to set as parent ID based on the sampling state, and they also modify the discard state. We DO have tests for those and it seems to be fine, so no real advice here other than think on related scenarios to test :)
apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/AbstractSpan.java
Outdated
Show resolved
Hide resolved
apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/TraceContextHolder.java
Outdated
Show resolved
Hide resolved
apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/Transaction.java
Show resolved
Hide resolved
apm-agent-core/src/test/java/co/elastic/apm/agent/impl/DiscardSpanTest.java
Show resolved
Hide resolved
Yeah, I have to agree. For example, if someone uses the API to propagate the context to another thread, we might discard the span even though it's a parent of a longer async operation that starts after the initial span has already finished. |
- More testing - Fixes for interactions of transaction_max_spans and span_min_duration - Revert removing noop
- TraceContext can't be de/activated anymore, only AbstractSpans
- Removes lots of baggage in the internal API
- This was only used to reduce (but not avoid) allocations when using the OpenTracing API bridge
- Historically, activating a TraceContext was also needed when activating an ended span.
Nowadays, we use reference counting to determine whether it's safe to recycle a span rather than recycling after it's ended and serialized.
- Avoids context propagation directly via TraceContext which would not mark the span as non-discardable
- Makes Spans used in OT API bridge non-recyclable
- Previously, TraceContext has been used for finished spans
- Now, TraceContext can't be activated anymore,
thus spans are GC'd rather than recycled so that OT spans can be activated after they have been finished
Codecov Report
@@ Coverage Diff @@
## master #1150 +/- ##
============================================
+ Coverage 59.37% 59.69% +0.31%
+ Complexity 2862 83 -2779
============================================
Files 331 328 -3
Lines 15017 14996 -21
Branches 2087 2086 -1
============================================
+ Hits 8917 8952 +35
+ Misses 5489 5433 -56
Partials 611 611
Continue to review full report at Codecov.
|
...t-core/src/main/java/co/elastic/apm/agent/bci/methodmatching/TraceMethodInstrumentation.java
Show resolved
Hide resolved
apm-agent-core/src/main/java/co/elastic/apm/agent/impl/ActivationListener.java
Show resolved
Hide resolved
apm-agent-core/src/main/java/co/elastic/apm/agent/impl/ActivationListener.java
Show resolved
Hide resolved
apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/AbstractSpan.java
Outdated
Show resolved
Hide resolved
apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/AbstractSpan.java
Outdated
Show resolved
Hide resolved
apm-agent-core/src/test/java/co/elastic/apm/agent/impl/DiscardSpanTest.java
Outdated
Show resolved
Hide resolved
apm-agent-core/src/test/java/co/elastic/apm/agent/impl/DiscardSpanTest.java
Show resolved
Hide resolved
apm-agent-core/src/test/java/co/elastic/apm/agent/impl/ElasticApmTracerTest.java
Outdated
Show resolved
Hide resolved
...lugin/src/main/java/co/elastic/apm/agent/opentracing/impl/ApmSpanBuilderInstrumentation.java
Show resolved
Hide resolved
apm-agent-core/src/main/java/co/elastic/apm/agent/impl/ElasticApmTracer.java
Show resolved
Hide resolved
💚 Build SucceededExpand to view the summary
Build stats
Test stats 🧪
|
|
@v1v I got a message regarding a build failure even though the tests are still running 🤔 Edit: Nevermind, that was because I added another commit that canceled the previous build. |
|
@eyalkoren raised some valid concerns:
In order to move forward with this, let's postpone whether or not to deprecate or replace or align the naming for the other configuration options. |
eyalkoren
left a comment
There was a problem hiding this comment.
Looks good. Several notes:
- Effectively, as it is now, when multiple threshold configs are set, the higher would determine which would be discarded. I think this makes sense. I updated the config doc accordingly.
- We have
AsyncTraceMethodInstrumentationTestas well, that should be used to test async scenarios as well - We need tests for the combinations of threshold settings
closes #1094