From 364a08b51848c505e46134d962d3f2fb44e78619 Mon Sep 17 00:00:00 2001 From: Marius Constantin Date: Wed, 27 Mar 2024 17:50:08 +0100 Subject: [PATCH] Appying Ktlint format changes --- .../android/trace/OtelTracerProvider.kt | 6 ++-- .../trace/internal/data/OtelTraceWriter.kt | 10 +++--- .../event/OtelDdSpanToSpanEventMapperTest.kt | 6 ++-- .../datadog/trace/core/CoreSpanBuilderTest.kt | 36 +++++++++---------- .../datadog/trace/core/DDSpanContextTest.kt | 4 +-- .../com/datadog/trace/core/DDSpanTest.kt | 8 ++--- .../datadog/trace/core/PendingTraceTest.kt | 3 +- .../trace/core/PendingTraceTestBase.kt | 2 +- 8 files changed, 39 insertions(+), 36 deletions(-) diff --git a/features/dd-sdk-android-trace/src/main/kotlin/com/datadog/android/trace/OtelTracerProvider.kt b/features/dd-sdk-android-trace/src/main/kotlin/com/datadog/android/trace/OtelTracerProvider.kt index fce85e11e8..34079345fd 100644 --- a/features/dd-sdk-android-trace/src/main/kotlin/com/datadog/android/trace/OtelTracerProvider.kt +++ b/features/dd-sdk-android-trace/src/main/kotlin/com/datadog/android/trace/OtelTracerProvider.kt @@ -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 diff --git a/features/dd-sdk-android-trace/src/main/kotlin/com/datadog/android/trace/internal/data/OtelTraceWriter.kt b/features/dd-sdk-android-trace/src/main/kotlin/com/datadog/android/trace/internal/data/OtelTraceWriter.kt index 72d680c863..6d01e6a106 100644 --- a/features/dd-sdk-android-trace/src/main/kotlin/com/datadog/android/trace/internal/data/OtelTraceWriter.kt +++ b/features/dd-sdk-android-trace/src/main/kotlin/com/datadog/android/trace/internal/data/OtelTraceWriter.kt @@ -38,12 +38,12 @@ internal class OtelTraceWriter( override fun write(trace: MutableList?) { 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 { diff --git a/features/dd-sdk-android-trace/src/test/kotlin/com/datadog/android/trace/internal/domain/event/OtelDdSpanToSpanEventMapperTest.kt b/features/dd-sdk-android-trace/src/test/kotlin/com/datadog/android/trace/internal/domain/event/OtelDdSpanToSpanEventMapperTest.kt index 453898bb0f..d7323aded0 100644 --- a/features/dd-sdk-android-trace/src/test/kotlin/com/datadog/android/trace/internal/domain/event/OtelDdSpanToSpanEventMapperTest.kt +++ b/features/dd-sdk-android-trace/src/test/kotlin/com/datadog/android/trace/internal/domain/event/OtelDdSpanToSpanEventMapperTest.kt @@ -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) @@ -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)) diff --git a/features/dd-sdk-android-trace/src/test/kotlin/com/datadog/trace/core/CoreSpanBuilderTest.kt b/features/dd-sdk-android-trace/src/test/kotlin/com/datadog/trace/core/CoreSpanBuilderTest.kt index 14dbbfdccc..0c9c73f6b2 100644 --- a/features/dd-sdk-android-trace/src/test/kotlin/com/datadog/trace/core/CoreSpanBuilderTest.kt +++ b/features/dd-sdk-android-trace/src/test/kotlin/com/datadog/trace/core/CoreSpanBuilderTest.kt @@ -354,15 +354,15 @@ internal class CoreSpanBuilderTest : DDCoreSpecification() { assertThat(span.context().baggageItems).isEqualTo(emptyMap()) 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 + ) ) } @@ -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 diff --git a/features/dd-sdk-android-trace/src/test/kotlin/com/datadog/trace/core/DDSpanContextTest.kt b/features/dd-sdk-android-trace/src/test/kotlin/com/datadog/trace/core/DDSpanContextTest.kt index 984e5b22b8..d1a867ab46 100644 --- a/features/dd-sdk-android-trace/src/test/kotlin/com/datadog/trace/core/DDSpanContextTest.kt +++ b/features/dd-sdk-android-trace/src/test/kotlin/com/datadog/trace/core/DDSpanContextTest.kt @@ -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) } diff --git a/features/dd-sdk-android-trace/src/test/kotlin/com/datadog/trace/core/DDSpanTest.kt b/features/dd-sdk-android-trace/src/test/kotlin/com/datadog/trace/core/DDSpanTest.kt index 464503c666..464db52566 100644 --- a/features/dd-sdk-android-trace/src/test/kotlin/com/datadog/trace/core/DDSpanTest.kt +++ b/features/dd-sdk-android-trace/src/test/kotlin/com/datadog/trace/core/DDSpanTest.kt @@ -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) @@ -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) @@ -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)) @@ -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) diff --git a/features/dd-sdk-android-trace/src/test/kotlin/com/datadog/trace/core/PendingTraceTest.kt b/features/dd-sdk-android-trace/src/test/kotlin/com/datadog/trace/core/PendingTraceTest.kt index 9c8e1473ec..e4b3ddba48 100644 --- a/features/dd-sdk-android-trace/src/test/kotlin/com/datadog/trace/core/PendingTraceTest.kt +++ b/features/dd-sdk-android-trace/src/test/kotlin/com/datadog/trace/core/PendingTraceTest.kt @@ -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, diff --git a/features/dd-sdk-android-trace/src/test/kotlin/com/datadog/trace/core/PendingTraceTestBase.kt b/features/dd-sdk-android-trace/src/test/kotlin/com/datadog/trace/core/PendingTraceTestBase.kt index ad02b38085..637aaedfad 100644 --- a/features/dd-sdk-android-trace/src/test/kotlin/com/datadog/trace/core/PendingTraceTestBase.kt +++ b/features/dd-sdk-android-trace/src/test/kotlin/com/datadog/trace/core/PendingTraceTestBase.kt @@ -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) }