Return span handler (#261)

This commit is contained in:
KirillPamPam
2023-07-28 17:48:32 +04:00
committed by GitHub
parent fc2354f9c3
commit b0af3ab3b3
5 changed files with 115 additions and 121 deletions

View File

@@ -1,85 +0,0 @@
package io.emeraldpay.dshackle.config.spans
import brave.handler.MutableSpan
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.Arguments
import org.junit.jupiter.params.provider.MethodSource
import java.util.stream.Stream
class ProviderSpanHandlerTest {
companion object {
@JvmStatic
fun data(): Stream<Arguments> {
return Stream.of(
Arguments.of(
false, null,
MutableSpan().apply {
startTimestamp(0)
finishTimestamp(1000000)
},
true
),
Arguments.of(
false, 1000L,
MutableSpan().apply {
startTimestamp(0)
finishTimestamp(999999)
},
false
),
Arguments.of(
false, 1000L,
MutableSpan().apply {
startTimestamp(0)
finishTimestamp(1000000)
},
true
),
Arguments.of(
true, null,
MutableSpan().apply {
startTimestamp(0)
finishTimestamp(1000000)
},
false
),
Arguments.of(
true, null,
MutableSpan().apply {
startTimestamp(0)
finishTimestamp(1000000)
tag("error", "true")
},
true
),
Arguments.of(
false, null,
MutableSpan().apply {
startTimestamp(0)
finishTimestamp(1000000)
tag("error", "true")
},
true
),
Arguments.of(
true, 1000L,
MutableSpan().apply {
startTimestamp(0)
finishTimestamp(1000000)
},
true
),
)
}
}
@ParameterizedTest
@MethodSource("data")
fun end(onlyErrors: Boolean?, timeThreshold: Long?, span: MutableSpan, expected: Boolean) {
val handler = ProviderSpanHandler(onlyErrors, timeThreshold)
val res = handler.end(null, span, null)
assertEquals(expected, res)
}
}