Skip to content
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

Compressed spans #432

Open
7 of 8 tasks
AlexanderWert opened this issue Apr 15, 2021 · 0 comments
Open
7 of 8 tasks

Compressed spans #432

AlexanderWert opened this issue Apr 15, 2021 · 0 comments

Comments

@AlexanderWert AlexanderWert added this to the 7.14 milestone Apr 15, 2021
@AlexanderWert AlexanderWert modified the milestones: 7.14, 7.15 Jun 8, 2021
@felixbarny felixbarny modified the milestones: 7.15, 7.16 Aug 25, 2021
@AlexanderWert AlexanderWert changed the title Handling huge traces Compressed spans Aug 25, 2021
beniwohli added a commit to beniwohli/apm-agent-python that referenced this issue Sep 9, 2021
marclop added a commit to elastic/apm-agent-go that referenced this issue Oct 13, 2021
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`) in `TransactionData`
and `SpanData` which is used to cache compressed or compression eligible
spans in that field. An additional `composite` field has also been added
to the `SpanData` and `TransactionData`.

The algorithm states that any exit span that is lower or equal duration
than the set `ELASTIC_APM_SPAN_COMPRESSION_EXACT_MATCH_MAX_DURATION` or
`ELASTIC_APM_SPAN_COMPRESSION_SAME_KIND_MAX_DURATION` with a destination
service 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` or `exact_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 to `Calls 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` and `WriteTraceWaterfall`, which help with
understanding why a test is failing if they are and debugging those.

Signed-off-by: Marc Lopez Rubio <[email protected]>
@AlexanderWert AlexanderWert modified the milestones: 7.16, 8.0 Oct 15, 2021
beniwohli added a commit to elastic/apm-agent-python that referenced this issue Oct 16, 2021
* Implemented span compression algorithm

See elastic/apm#432

* disable span compression by default in tests

* make _try_to_compress_composite and _try_to_compress_regular side effect free

* fix issue with compression buffer not being reported

* fix some type hinting issues/errors

* move traceparent initialization into Transaction constructor

This cleans up a wart where `traceparent` is initialized to
None, and needs to be set by the callee right after, as there
is code that assumes `traceparent` to be set.

* fix breakdown metrics calculation

* fix breakdown metrics test

we no longer only call `child_ended` for breakdown metrics

* update duration of the composite span based on compressed spans

* add docs for compressed span config options

* clean up merge

Co-authored-by: Colton Myers <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants