-
Notifications
You must be signed in to change notification settings - Fork 197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
span (experimental): Compress short exit spans #1134
span (experimental): Compress short exit spans #1134
Conversation
Signed-off-by: Marc Lopez Rubio <[email protected]>
Signed-off-by: Marc Lopez Rubio <[email protected]>
Signed-off-by: Marc Lopez Rubio <[email protected]>
Signed-off-by: Marc Lopez Rubio <[email protected]>
Signed-off-by: Marc Lopez Rubio <[email protected]>
Signed-off-by: Marc Lopez Rubio <[email protected]>
Signed-off-by: Marc Lopez Rubio <[email protected]>
💚 Build Succeeded
Expand to view the summary
Build stats
Test stats 🧪
🤖 GitHub commentsTo re-run your PR in the CI, just comment with:
|
Signed-off-by: Marc Lopez Rubio <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The approach looks good. I haven't looked at all of the finer details, just left a few initial comments. I'm not entirely convinced by the locking, but again I haven't pored over all the details.
Signed-off-by: Marc Lopez Rubio <[email protected]>
Signed-off-by: Marc Lopez Rubio <[email protected]>
Removes the `spanBuffer`, adding a new field to `Transaction` and `Span` instead and handling the caching directly on that field. `evictCache` is used to flush the `TransactionData.cache` and `SpanData.cache` Also simplifies a few functions and uses a `strings.Builder` with the total capacity set beforehand to update the `span.Name` since that seems to be the fastest and most efficient way to concatenate the two strings, the allocation is unavoidable. Signed-off-by: Marc Lopez Rubio <[email protected]>
Signed-off-by: Marc Lopez Rubio <[email protected]>
Signed-off-by: Marc Lopez Rubio <[email protected]>
I'll tidy the tests up a little bit before setting the PR for review, but I believe that the implementation should be complete. I'll update the PR description with the current implementation's details as well. |
Signed-off-by: Marc Lopez Rubio <[email protected]>
Signed-off-by: Marc Lopez Rubio <[email protected]>
Signed-off-by: Marc Lopez Rubio <[email protected]>
Signed-off-by: Marc Lopez Rubio <[email protected]>
Avoid `s.enqueue` from `s.attemptCompress` function and instead, return the evicted span from the cache and use the `span.End()` function. A new bool field has been introduced (in `Span.fromCache`), set to `true` when the a span has been evicted from the cache. The purpose of this flag is to avoid reporting the span timers since they've already been reported on each `span.End`, and to prevent the `span.End()` from going into an infinite loop, trying to compress a span that has already been evicted. Also, updates the mutex operations to make all operations concurrently safe. Signed-off-by: Marc Lopez Rubio <[email protected]>
Adds a new `s.compressOrEvictCache`, and simplifies `s.attemptCompress`. The new method compresses or evicts the span into / from the cache. Also modifies the `s.evict()` to set the cached span compression options to `false` so the span doesn't go through the compression flow again and causes infinite loop. Last, it splits the compression and enqueuing portion of `s.End()` into a new `s.end()` method which is called only for spans that have been evicted from the cache. Signed-off-by: Marc Lopez Rubio <[email protected]>
Signed-off-by: Marc Lopez Rubio <[email protected]>
Signed-off-by: Marc Lopez Rubio <[email protected]>
Signed-off-by: Marc Lopez Rubio <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Nice work!
Description
Implements the span compression algorithm described in elastic/apm#432.
The implementation pretty close to what the spec describes, with a few
modifications due to the differences in the Go agent implementation. The
span compression is experimental and is disabled by default with the
default thresholds for the different compression strategies set:
ELASTIC_APM_SPAN_COMPRESSION_ENABLED=false
ELASTIC_APM_SPAN_COMPRESSION_EXACT_MATCH_MAX_DURATION=50ms
ELASTIC_APM_SPAN_COMPRESSION_SAME_KIND_MAX_DURATION=5ms
The implementation uses a new field (cache
*Span
) inTransactionData
and
SpanData
which is used to cache compressed or compression eligiblespans in that field. An additional
composite
field has also been addedto the
SpanData
andTransactionData
.The algorithm states that any exit span that is lower or equal duration
than the set
ELASTIC_APM_SPAN_COMPRESSION_EXACT_MATCH_MAX_DURATION
orELASTIC_APM_SPAN_COMPRESSION_SAME_KIND_MAX_DURATION
with a destinationservice set is compressable into a composite span using the appropriate
strategy. Compressable spans need to be "exit" and siblings which have
not propagated their context downstream. Sibling spans are spans that
share the same parent span (or transaction).
Spans can be compressed with
same_kind
orexact_match
as a strategy,and their sum is the aggregated duration of of all
When a compressed span has been compressed into a composite using the
same_kind
strategy, its name is mutated toCalls to <span.Type>
.Spans will be compressed into a composite only when the siblings are
consecutive and any compression attempt that doesn't meet that,
will cause the cache to be evicted.
Additionally, two helper functions have been added under the
apmtest
:package:
WriteTraceTable
andWriteTraceWaterfall
, which help withunderstanding why a test is failing if they are and debugging those.
TODO
Related issues
Closes #972