-
Notifications
You must be signed in to change notification settings - Fork 315
Avoid pending queue wedge if tracer flare is generated multiple times #9757
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -460,36 +460,65 @@ class PendingTraceBufferTest extends DDSpecification { | |
| def parent2 = newSpanOf(trace2, UNSET, System.currentTimeMillis() * 2000) | ||
| def child2 = newSpanOf(parent2) | ||
|
|
||
| when: | ||
| when: "first flare dump with two traces" | ||
| parent1.finish() | ||
| parent2.finish() | ||
| buffer.start() | ||
| def entries = buildAndExtractZip() | ||
| def entries1 = buildAndExtractZip() | ||
|
|
||
| then: | ||
| 1 * dumpReporter.prepareForFlare() | ||
| 1 * dumpReporter.addReportToFlare(_) | ||
| 1 * dumpReporter.cleanupAfterFlare() | ||
| entries.size() == 1 | ||
| def pendingTraceText = entries["pending_traces.txt"] as String | ||
| (entries["pending_traces.txt"] as String).startsWith('[{"service":"fakeService","name":"fakeOperation","resource":"fakeResource","trace_id":1,"span_id":1,"parent_id":0') // Rest of dump is timestamp specific | ||
|
|
||
| def parsedTraces = pendingTraceText.split('\n').collect { new JsonSlurper().parseText(it) }.flatten() | ||
| parsedTraces.size() == 2 | ||
| parsedTraces[0]["trace_id"] == 1 //Asserting both traces exist | ||
| parsedTraces[1]["trace_id"] == 2 | ||
| parsedTraces[0]["start"] < parsedTraces[1]["start"] //Asserting the dump has the oldest trace first | ||
| entries1.size() == 1 | ||
| def pendingTraceText1 = entries1["pending_traces.txt"] as String | ||
| pendingTraceText1.startsWith('[{"service":"fakeService","name":"fakeOperation","resource":"fakeResource","trace_id":1,"span_id":1,"parent_id":0') // Rest of dump is timestamp specific | ||
|
|
||
| def parsedTraces1 = pendingTraceText1.split('\n').collect { new JsonSlurper().parseText(it) }.flatten() | ||
| parsedTraces1.size() == 2 | ||
| parsedTraces1[0]["trace_id"] == 1 //Asserting both traces exist | ||
| parsedTraces1[1]["trace_id"] == 2 | ||
| parsedTraces1[0]["start"] < parsedTraces1[1]["start"] //Asserting the dump has the oldest trace first | ||
|
|
||
| // New pending traces are needed here because generating the first flare takes long enough that the | ||
| // earlier pending traces are flushed (within 500ms). | ||
| when: "second flare dump with new pending traces" | ||
| // Finish the first set of traces | ||
| child1.finish() | ||
| child2.finish() | ||
| // Create new pending traces | ||
| def trace3 = factory.create(DDTraceId.from(3)) | ||
| def parent3 = newSpanOf(trace3, UNSET, System.currentTimeMillis() * 3000) | ||
| def child3 = newSpanOf(parent3) | ||
| def trace4 = factory.create(DDTraceId.from(4)) | ||
| def parent4 = newSpanOf(trace4, UNSET, System.currentTimeMillis() * 4000) | ||
| def child4 = newSpanOf(parent4) | ||
| parent3.finish() | ||
| parent4.finish() | ||
| def entries2 = buildAndExtractZip() | ||
|
|
||
| then: | ||
| 1 * dumpReporter.prepareForFlare() | ||
| 1 * dumpReporter.addReportToFlare(_) | ||
| 1 * dumpReporter.cleanupAfterFlare() | ||
| entries2.size() == 1 | ||
| def pendingTraceText2 = entries2["pending_traces.txt"] as String | ||
| def parsedTraces2 = pendingTraceText2.split('\n').collect { new JsonSlurper().parseText(it) }.flatten() | ||
| parsedTraces2.size() == 2 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question: would it be better to assert on the trace ids as well ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The specific trace IDs don't really matter, so I think it is better to leave them out and not make the test over-specific. We mainly want to make sure:
I only generate a second set of traces because the first set is gone from the pending queue by the time the second dump is performed (well, they are still there, actually, but the traces have no pending spans left--they've been written within 500ms). |
||
|
|
||
| then: | ||
| child1.finish() | ||
| child2.finish() | ||
| child3.finish() | ||
| child4.finish() | ||
|
|
||
| then: | ||
| trace1.size() == 0 | ||
| trace1.pendingReferenceCount == 0 | ||
| trace2.size() == 0 | ||
| trace2.pendingReferenceCount == 0 | ||
| trace3.size() == 0 | ||
| trace3.pendingReferenceCount == 0 | ||
| trace4.size() == 0 | ||
| trace4.pendingReferenceCount == 0 | ||
| } | ||
|
|
||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.