Skip to content

Commit

Permalink
Appying Ktlint format changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mariusc83 committed Mar 27, 2024
1 parent 86b40e3 commit 364a08b
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,11 @@ class OtelTracerProvider(

internal const val TRACING_NOT_ENABLED_ERROR_MESSAGE =
"You're trying to create an OtelTracerProvider instance, " +
"but either the SDK was not initialized or the Tracing feature was " +
"disabled in your Configuration. No tracing data will be sent."
"but either the SDK was not initialized or the Tracing feature was " +
"disabled in your Configuration. No tracing data will be sent."
internal const val DEFAULT_SERVICE_NAME_IS_MISSING_ERROR_MESSAGE =
"Default service name is missing during" +
" OtelTracerProvider creation, did you initialize SDK?"
" OtelTracerProvider creation, did you initialize SDK?"

// the minimum closed spans required for triggering a flush and deliver
// everything to the writer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ internal class OtelTraceWriter(
override fun write(trace: MutableList<DDSpan>?) {
if (trace == null) return
sdkCore.getFeature(Feature.TRACING_FEATURE_NAME)
?.withWriteContext { datadogContext, eventBatchWriter ->
trace.forEach { span ->
@Suppress("ThreadSafety") // called in the worker context
writeSpan(datadogContext, eventBatchWriter, span)
}
?.withWriteContext { datadogContext, eventBatchWriter ->
trace.forEach { span ->
@Suppress("ThreadSafety") // called in the worker context
writeSpan(datadogContext, eventBatchWriter, span)
}
}
}

override fun flush(): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ import org.mockito.kotlin.whenever
import org.mockito.quality.Strictness

@Extensions(
ExtendWith(MockitoExtension::class), ExtendWith(ForgeExtension::class)
ExtendWith(MockitoExtension::class),
ExtendWith(ForgeExtension::class)
)
@MockitoSettings(strictness = Strictness.LENIENT)
@ForgeConfiguration(Configurator::class)
Expand Down Expand Up @@ -206,7 +207,8 @@ internal class OtelDdSpanToSpanEventMapperTest {

@Test
fun `M not mark the SpanEvent as top span W map() { parentId is different than 0 }`(
forge: Forge, @Forgery fakeSpan: DDSpan
forge: Forge,
@Forgery fakeSpan: DDSpan
) {
// Given
whenever(fakeSpan.parentId).thenReturn(forge.aLong(min = 1))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,15 +354,15 @@ internal class CoreSpanBuilderTest : DDCoreSpecification() {
assertThat(span.context().baggageItems).isEqualTo(emptyMap<String, String>())
assertThat(span.context().tags).containsExactlyInAnyOrderEntriesOf(
tagContext.tags +
mapOf(
DDTags.RUNTIME_ID_TAG to Config.get().getRuntimeId(),
DDTags.LANGUAGE_TAG_KEY to DDTags.LANGUAGE_TAG_VALUE,
DDTags.THREAD_NAME to thread.name,
DDTags.THREAD_ID to thread.id,
DDTags.PID_TAG to Config.get().processId,
DDTags.SCHEMA_VERSION_TAG_KEY to SpanNaming.instance().version(),
DDTags.PROFILING_ENABLED to if (Config.get().isProfilingEnabled()) 1 else 0
)
mapOf(
DDTags.RUNTIME_ID_TAG to Config.get().getRuntimeId(),
DDTags.LANGUAGE_TAG_KEY to DDTags.LANGUAGE_TAG_VALUE,
DDTags.THREAD_NAME to thread.name,
DDTags.THREAD_ID to thread.id,
DDTags.PID_TAG to Config.get().processId,
DDTags.SCHEMA_VERSION_TAG_KEY to SpanNaming.instance().version(),
DDTags.PROFILING_ENABLED to if (Config.get().isProfilingEnabled()) 1 else 0
)
)
}

Expand All @@ -378,15 +378,15 @@ internal class CoreSpanBuilderTest : DDCoreSpecification() {
// Then
assertThat(span.tags).containsExactlyInAnyOrderEntriesOf(
tags +
mapOf(
DDTags.THREAD_NAME to Thread.currentThread().name,
DDTags.THREAD_ID to Thread.currentThread().id,
DDTags.RUNTIME_ID_TAG to Config.get().getRuntimeId(),
DDTags.LANGUAGE_TAG_KEY to DDTags.LANGUAGE_TAG_VALUE,
DDTags.PID_TAG to Config.get().getProcessId(),
DDTags.SCHEMA_VERSION_TAG_KEY to SpanNaming.instance().version(),
DDTags.PROFILING_ENABLED to if (Config.get().isProfilingEnabled()) 1 else 0
)
mapOf(
DDTags.THREAD_NAME to Thread.currentThread().name,
DDTags.THREAD_ID to Thread.currentThread().id,
DDTags.RUNTIME_ID_TAG to Config.get().getRuntimeId(),
DDTags.LANGUAGE_TAG_KEY to DDTags.LANGUAGE_TAG_VALUE,
DDTags.PID_TAG to Config.get().getProcessId(),
DDTags.SCHEMA_VERSION_TAG_KEY to SpanNaming.instance().version(),
DDTags.PROFILING_ENABLED to if (Config.get().isProfilingEnabled()) 1 else 0
)
)

// Tear down
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ internal class DDSpanContextTest : DDCoreSpecification() {
val expectedTags = mapOf(DDTags.THREAD_NAME to thread.name, DDTags.THREAD_ID to thread.id)
assertThat(context.tags).containsAllEntriesOf(expectedTags)
assertThat(
context::class.java.getMethod(method)
.invoke(context)
context::class.java.getMethod(method)
.invoke(context)
)
.isEqualTo(value)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ internal class DDSpanTest : DDCoreSpecification() {

// Then
val timeDifference = TimeUnit.NANOSECONDS.toSeconds(span.startTime) -
TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis())
TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis())
assertThat(timeDifference).isLessThan(5)
assertThat(span.durationNano).isGreaterThan(betweenDur)
assertThat(span.durationNano).isLessThan(total)
Expand Down Expand Up @@ -184,7 +184,7 @@ internal class DDSpanTest : DDCoreSpecification() {
assertThat(writer).isEmpty()
val actualDurationNano = span.durationNano and Long.MAX_VALUE
val timeDifference = TimeUnit.NANOSECONDS.toSeconds(span.startTime) -
TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis())
TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis())
assertThat(timeDifference).isLessThan(5)
assertThat(actualDurationNano).isGreaterThan(betweenDur)
assertThat(actualDurationNano).isLessThan(total)
Expand Down Expand Up @@ -230,7 +230,7 @@ internal class DDSpanTest : DDCoreSpecification() {
// Then
val total = Math.max(1, System.currentTimeMillis() - start)
val timeDifference = TimeUnit.NANOSECONDS.toSeconds(span.startTime) -
TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis())
TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis())
assertThat(timeDifference).isLessThan(5)
assertThat(span.durationNano).isGreaterThanOrEqualTo(TimeUnit.MILLISECONDS.toNanos(betweenDur))
assertThat(span.durationNano).isLessThanOrEqualTo(TimeUnit.MILLISECONDS.toNanos(total))
Expand All @@ -251,7 +251,7 @@ internal class DDSpanTest : DDCoreSpecification() {
span.finish(TimeUnit.MILLISECONDS.toMicros(System.currentTimeMillis() + 1))
val total = System.currentTimeMillis() - start + 1
val timeDifference = TimeUnit.NANOSECONDS.toSeconds(span.startTime) -
TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis())
TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis())

// Then
assertThat(timeDifference).isLessThan(5)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ internal class PendingTraceTest : PendingTraceTestBase() {

private fun createSimpleSpanWithID(trace: PendingTrace, id: Long): DDSpan {
return DDSpan(
"test", 0L,
"test",
0L,
DDSpanContext(
DDTraceId.from(1),
id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ internal abstract class PendingTraceTestBase : DDCoreSpecification() {
assertThat(
Math.abs(
TimeUnit.NANOSECONDS.toSeconds(trace.currentTimeNano) -
TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis())
TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis())
)
).isLessThan(5)
}
Expand Down

0 comments on commit 364a08b

Please sign in to comment.