Skip to content

Commit 2101007

Browse files
Copilotkaahos
authored andcommitted
test: stabilize traced native socket TaskBlock assertion
1 parent 956a362 commit 2101007

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

ddprof-test/src/test/java/com/datadoghq/profiler/wallclock/NativeSocketTaskBlockTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ public void tracedBlockingSocketReadDoesNotEmitTaskBlock() throws Exception {
211211

212212
stopProfiler();
213213
assertFalse(
214-
verifyEvents("datadog.TaskBlock", false).hasItems(),
214+
TaskBlockAssertions.containsSpan(verifyEvents("datadog.TaskBlock", false), 0x5101L),
215215
"Traced socket I/O must keep MethodSample wall-clock data instead of emitting TaskBlock");
216216
}
217217

ddprof-test/src/test/java/com/datadoghq/profiler/wallclock/TaskBlockAssertions.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,22 @@ static void assertContainsObservedState(IItemCollection events, String observedS
3939
"Expected TaskBlock with observedBlockingState=" + observedState);
4040
}
4141

42+
static boolean containsSpan(IItemCollection events, long spanId) {
43+
for (IItemIterable iterable : events) {
44+
IMemberAccessor<IQuantity, IItem> spanAccessor =
45+
AbstractProfilerTest.SPAN_ID.getAccessor(iterable.getType());
46+
if (spanAccessor == null) {
47+
continue;
48+
}
49+
for (IItem item : iterable) {
50+
if (spanAccessor.getMember(item).longValue() == spanId) {
51+
return true;
52+
}
53+
}
54+
}
55+
return false;
56+
}
57+
4258
private static boolean contains(
4359
IItemCollection events, long rootSpanId, long spanId, long blocker, long unblockingSpanId) {
4460
for (IItemIterable iterable : events) {

0 commit comments

Comments
 (0)