-
Notifications
You must be signed in to change notification settings - Fork 17
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
Capture span stack trace #21
Conversation
Make |
assertThat(testExporter.getFinishedSpanItems()) | ||
.hasSize(1) | ||
.first() | ||
.satisfies( | ||
spanData -> | ||
assertThat(spanData) | ||
.hasAttributesSatisfying( | ||
satisfies( | ||
ElasticAttributes.SPAN_STACKTRACE, | ||
AbstractCharSequenceAssert::isNotEmpty))); |
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.
[for reviewer] otel test utilities provide the assertj extension for easily testing for custom attributes.
.addSpanProcessor(elasticSpanProcessor) | ||
.addSpanProcessor(SimpleSpanProcessor.create(elasticSpanExporter)) |
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.
[for reviewer] this emulates how our exporter is usually set up in the agent: first our exporter that modifies spans, then another that exports it. Here we are using the simple exporter that does not use batching and is synchronous.
|
||
// do not overwrite stacktrace if present | ||
if (span.getAttribute(ElasticAttributes.SPAN_STACKTRACE) == null) { | ||
// TODO should we filter-out the calling code that is within the agent: at least onEnd + |
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.
[for reviewer] I don't know if any filtering on the stack trace is applied here, thus I'll leave it as-it for now and wait to have the kibana implementation to see if any filtering is applied on the UI side.
|
||
// unfortunately here we get a read-only span that has already been ended, thus even a cast to | ||
// ReadWriteSpan | ||
// does not allow us from adding extra span attributes | ||
if (spanExporter != null) { | ||
spanContextData.setSelfTime(selfTime); | ||
spanExporter.report(spanContext, spanContextData); | ||
spanExporter.addAttribute( | ||
spanContext, ElasticAttributes.SELF_TIME, spanContextData.getSelfTime()); |
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.
[for reviewer] this is the only change in this file, the rest is mostly renaming things.
testImplementation("io.opentelemetry:opentelemetry-sdk") | ||
testImplementation("io.opentelemetry.javaagent:opentelemetry-testing-common") | ||
testImplementation("io.opentelemetry:opentelemetry-sdk-testing") | ||
testImplementation("org.assertj:assertj-core:3.24.2") // TODO : remove version for assertj |
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.
[for reviewer] this will likely be handled with #8
Capture span stack trace with a simple exception
Refers to #16