Skip to content

Commit c34c51c

Browse files
committed
lint
1 parent 0a4e9ca commit c34c51c

File tree

3 files changed

+29
-27
lines changed

3 files changed

+29
-27
lines changed

plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/services/telemetry/otel/OTelService.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ private object StdoutSpanProcessor : SpanProcessor {
130130
}
131131

132132
@Service
133-
class OTelService @NonInjectable internal constructor(spanProcessors: List<SpanProcessor>): Disposable {
133+
class OTelService @NonInjectable internal constructor(spanProcessors: List<SpanProcessor>) : Disposable {
134134
@Suppress("unused")
135135
constructor() : this(listOf(StdoutSpanProcessor))
136136

plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/services/telemetry/otel/OtelBase.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
package software.aws.toolkits.jetbrains.services.telemetry.otel
55

6-
import com.intellij.platform.diagnostic.telemetry.helpers.use as ijUse
7-
import com.intellij.platform.diagnostic.telemetry.helpers.useWithScope as ijUseWithScope
86
import io.opentelemetry.api.common.AttributeKey
97
import io.opentelemetry.api.common.Attributes
108
import io.opentelemetry.api.trace.Span
@@ -23,6 +21,8 @@ import java.time.Instant
2321
import java.util.concurrent.TimeUnit
2422
import kotlin.coroutines.CoroutineContext
2523
import kotlin.coroutines.EmptyCoroutineContext
24+
import com.intellij.platform.diagnostic.telemetry.helpers.use as ijUse
25+
import com.intellij.platform.diagnostic.telemetry.helpers.useWithScope as ijUseWithScope
2626

2727
val AWS_PRODUCT_CONTEXT_KEY = ContextKey.named<AWSProduct>("pluginDescriptor")
2828
internal val PLUGIN_ATTRIBUTE_KEY = AttributeKey.stringKey("plugin")
@@ -49,7 +49,7 @@ abstract class AbstractSpanBuilder<Builder : AbstractSpanBuilder<Builder, Span>,
4949
*/
5050
suspend inline fun<T> useWithScope(
5151
context: CoroutineContext = EmptyCoroutineContext,
52-
crossinline operation: suspend CoroutineScope.(Span) -> T
52+
crossinline operation: suspend CoroutineScope.(Span) -> T,
5353
): T =
5454
ijUseWithScope(context) { span ->
5555
operation(span as Span)

plugins/core/jetbrains-community/tst/software/aws/toolkits/jetbrains/services/telemetry/otel/OtelBaseTest.kt

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ class OtelBaseTest {
144144
}
145145

146146
@Test
147-
fun `context override propagates from parent to child when only child is coroutine`() {
147+
fun `context override propagates from parent to child when only child is coroutine`() {
148148
spanBuilder("tracer", "parentSpan").setParent(Context.current().with(AWS_PRODUCT_CONTEXT_KEY, AWSProduct.AMAZON_Q_FOR_VS_CODE)).use {
149149
runTest {
150150
spanBuilder("anotherTracer", "childSpan").useWithScope {
@@ -199,7 +199,7 @@ class OtelBaseTest {
199199
}
200200

201201
@Test
202-
fun `context override does not propagate from parent to child coroutines if context is not preserved`() {
202+
fun `context override does not propagate from parent to child coroutines if context is not preserved`() {
203203
spanBuilder("tracer", "parentSpan").setParent(Context.current().with(AWS_PRODUCT_CONTEXT_KEY, AWSProduct.AMAZON_Q_FOR_VS_CODE)).use {
204204
runBlocking(getCoroutineBgContext()) {
205205
spanBuilder("anotherTracer", "childSpan").use {}
@@ -218,7 +218,7 @@ class OtelBaseTest {
218218
}
219219

220220
@Test
221-
fun `context override propagates from parent to child coroutines with manual coroutine context propagation`() {
221+
fun `context override propagates from parent to child coroutines with manual coroutine context propagation`() {
222222
spanBuilder("tracer", "parentSpan").setParent(Context.current().with(AWS_PRODUCT_CONTEXT_KEY, AWSProduct.AMAZON_Q_FOR_VS_CODE)).use {
223223
runBlocking(getCoroutineBgContext() + Context.current().asContextElement()) {
224224
spanBuilder("anotherTracer", "childSpan").use {}
@@ -277,32 +277,34 @@ class OtelExtension : AfterEachCallback, AfterAllCallback {
277277
val completedSpans
278278
get() = _completedSpans.reversed().toList()
279279

280-
val sdk = OTelService(listOf(
281-
// should probably be a service loader
282-
object : SpanProcessor {
283-
override fun isStartRequired() = true
284-
override fun isEndRequired() = true
280+
val sdk = OTelService(
281+
listOf(
282+
// should probably be a service loader
283+
object : SpanProcessor {
284+
override fun isStartRequired() = true
285+
override fun isEndRequired() = true
285286

286-
override fun onStart(parentContext: Context, span: ReadWriteSpan) {
287-
openSpans.add(span)
288-
}
287+
override fun onStart(parentContext: Context, span: ReadWriteSpan) {
288+
openSpans.add(span)
289+
}
289290

290-
override fun onEnd(span: ReadableSpan) {
291-
println(span)
292-
_completedSpans.add(span)
291+
override fun onEnd(span: ReadableSpan) {
292+
println(span)
293+
_completedSpans.add(span)
293294

294-
if (!openSpans.contains(span)) {
295-
LOG.warn(RuntimeException("Span ended without corresponding start")) { span.toString() }
295+
if (!openSpans.contains(span)) {
296+
LOG.warn(RuntimeException("Span ended without corresponding start")) { span.toString() }
297+
}
298+
openSpans.remove(span)
296299
}
297-
openSpans.remove(span)
298-
}
299300

300-
override fun forceFlush(): CompletableResultCode {
301-
assert(openSpans.isEmpty()) { "Not all open spans were closed: ${openSpans.joinToString(", ")}" }
302-
return CompletableResultCode.ofSuccess()
301+
override fun forceFlush(): CompletableResultCode {
302+
assert(openSpans.isEmpty()) { "Not all open spans were closed: ${openSpans.joinToString(", ")}" }
303+
return CompletableResultCode.ofSuccess()
304+
}
303305
}
304-
}
305-
))
306+
)
307+
)
306308

307309
override fun afterEach(context: ExtensionContext?) {
308310
reset()

0 commit comments

Comments
 (0)