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

fix span stacktrace capture #3474

Merged
merged 5 commits into from Jan 8, 2024

Conversation

SylvainJuge
Copy link
Member

@SylvainJuge SylvainJuge commented Dec 21, 2023

What does this PR do?

Span stack trace is captured when the span ends, currently when the span is reported to the tracer. This implementation worked well until the introduction of compressed spans because the call to ElasticApmTracer.report(Span) was synchronous.

However, with the addition of compressed spans now the calls to ElasticApmTracer.report(...) can happen while the compression algorithm is executed, thus after the span has already been ended. As a consequence, the captured stack trace needs to be captured when the span ends and not when it's reported.

Checklist

  • This is a bugfix

@SylvainJuge SylvainJuge added the bug Bugs label Dec 21, 2023
@elastic-apm-tech elastic-apm-tech added this to In Progress in APM-Agents (OLD) Dec 21, 2023
Comment on lines +169 to +172
assertThat(Arrays.stream(stackTrace.getStackTrace()).filter(stackTraceElement ->
stackTraceElement.getMethodName().equals("stackTraceEndSpan")
&& stackTraceElement.getClassName().equals(ElasticApmTracerTest.class.getName()))).hasSize(1);
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[for reviewer] this test does not actually check that the bugfix is effective, but just improves a bit the heuristic because until now there was none.

JonasKunz
JonasKunz previously approved these changes Dec 22, 2023
@SylvainJuge SylvainJuge marked this pull request as ready for review January 8, 2024 08:59
@SylvainJuge SylvainJuge merged commit f98c48d into elastic:main Jan 8, 2024
17 of 24 checks passed
APM-Agents (OLD) automation moved this from In Progress to Done Jan 8, 2024
@SylvainJuge SylvainJuge deleted the fix-span-stacktrace-capture branch January 8, 2024 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

None yet

2 participants