From 83dc9f670d1b8ae8cc13010563851e10eca08bd7 Mon Sep 17 00:00:00 2001 From: Aseem Sharma Date: Wed, 19 Nov 2025 20:59:14 -0800 Subject: [PATCH 1/6] refactor(otel): use compatibility helpers instead of duplicating entire file Address PR review feedback to avoid copying entire OTelService.kt for version compatibility. Changes: - Move OTelService.kt to common src/ directory (168 lines, shared by all versions) - Create small version-specific HttpPostCompat.kt files (18-19 lines each) - Eliminates 137 lines of code duplication - Main logic now maintained in single location The httpPost API changed between IDE versions 2024.2-2025.2 and 2025.3+: - Old API uses contentLength parameter with streaming body - New API uses body parameter with byte array Follows existing codebase pattern (see PythonModuleUtil.kt, JavascriptLanguage.kt) for handling compile-time API incompatibilities with minimal duplication. --- .../services/telemetry/otel/HttpPostCompat.kt | 18 ++ .../services/telemetry/otel/HttpPostCompat.kt | 19 ++ .../services/telemetry/otel/OTelService.kt | 171 ------------------ .../services/telemetry/otel/OTelService.kt | 5 +- 4 files changed, 38 insertions(+), 175 deletions(-) create mode 100644 plugins/core/jetbrains-community/src-242-252/software/aws/toolkits/jetbrains/services/telemetry/otel/HttpPostCompat.kt create mode 100644 plugins/core/jetbrains-community/src-253+/software/aws/toolkits/jetbrains/services/telemetry/otel/HttpPostCompat.kt delete mode 100644 plugins/core/jetbrains-community/src-253+/software/aws/toolkits/jetbrains/services/telemetry/otel/OTelService.kt rename plugins/core/jetbrains-community/{src-242-252 => src}/software/aws/toolkits/jetbrains/services/telemetry/otel/OTelService.kt (97%) diff --git a/plugins/core/jetbrains-community/src-242-252/software/aws/toolkits/jetbrains/services/telemetry/otel/HttpPostCompat.kt b/plugins/core/jetbrains-community/src-242-252/software/aws/toolkits/jetbrains/services/telemetry/otel/HttpPostCompat.kt new file mode 100644 index 00000000000..2e749b3a455 --- /dev/null +++ b/plugins/core/jetbrains-community/src-242-252/software/aws/toolkits/jetbrains/services/telemetry/otel/HttpPostCompat.kt @@ -0,0 +1,18 @@ +// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +package software.aws.toolkits.jetbrains.services.telemetry.otel + +import com.intellij.platform.util.http.ContentType +import com.intellij.platform.util.http.httpPost +import io.opentelemetry.exporter.internal.otlp.traces.TraceRequestMarshaler + +/** + * Version-specific compatibility wrapper for httpPost (2024.2-2025.2) + * In these versions, httpPost uses contentLength parameter with streaming body + */ +internal suspend fun sendOtelTrace(url: String, marshaler: TraceRequestMarshaler) { + httpPost(url, contentLength = marshaler.binarySerializedSize.toLong(), contentType = ContentType.XProtobuf) { + marshaler.writeBinaryTo(this) + } +} diff --git a/plugins/core/jetbrains-community/src-253+/software/aws/toolkits/jetbrains/services/telemetry/otel/HttpPostCompat.kt b/plugins/core/jetbrains-community/src-253+/software/aws/toolkits/jetbrains/services/telemetry/otel/HttpPostCompat.kt new file mode 100644 index 00000000000..34a439378dd --- /dev/null +++ b/plugins/core/jetbrains-community/src-253+/software/aws/toolkits/jetbrains/services/telemetry/otel/HttpPostCompat.kt @@ -0,0 +1,19 @@ +// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +package software.aws.toolkits.jetbrains.services.telemetry.otel + +import com.intellij.platform.util.http.ContentType +import com.intellij.platform.util.http.httpPost +import io.opentelemetry.exporter.internal.otlp.traces.TraceRequestMarshaler +import java.io.ByteArrayOutputStream + +/** + * Version-specific compatibility wrapper for httpPost (2025.3+) + * In this version, httpPost uses body parameter with byte array + */ +internal suspend fun sendOtelTrace(url: String, marshaler: TraceRequestMarshaler) { + val output = ByteArrayOutputStream() + marshaler.writeBinaryTo(output) + httpPost(url, contentType = ContentType.XProtobuf, body = output.toByteArray()) +} diff --git a/plugins/core/jetbrains-community/src-253+/software/aws/toolkits/jetbrains/services/telemetry/otel/OTelService.kt b/plugins/core/jetbrains-community/src-253+/software/aws/toolkits/jetbrains/services/telemetry/otel/OTelService.kt deleted file mode 100644 index 698e6e43b95..00000000000 --- a/plugins/core/jetbrains-community/src-253+/software/aws/toolkits/jetbrains/services/telemetry/otel/OTelService.kt +++ /dev/null @@ -1,171 +0,0 @@ -// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 -@file:Suppress("UnusedPrivateClass") - -package software.aws.toolkits.jetbrains.services.telemetry.otel - -import com.intellij.openapi.Disposable -import com.intellij.openapi.components.Service -import com.intellij.openapi.components.service -import com.intellij.openapi.diagnostic.thisLogger -import com.intellij.openapi.util.SystemInfoRt -import com.intellij.platform.util.http.ContentType -import com.intellij.platform.util.http.httpPost -import com.intellij.serviceContainer.NonInjectable -import io.opentelemetry.api.common.AttributeKey -import io.opentelemetry.api.common.Attributes -import io.opentelemetry.api.trace.propagation.W3CTraceContextPropagator -import io.opentelemetry.context.Context -import io.opentelemetry.context.propagation.ContextPropagators -import io.opentelemetry.exporter.internal.otlp.traces.TraceRequestMarshaler -import io.opentelemetry.sdk.OpenTelemetrySdk -import io.opentelemetry.sdk.resources.Resource -import io.opentelemetry.sdk.trace.ReadWriteSpan -import io.opentelemetry.sdk.trace.ReadableSpan -import io.opentelemetry.sdk.trace.SdkTracerProvider -import io.opentelemetry.sdk.trace.SpanProcessor -import kotlinx.coroutines.CancellationException -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.launch -import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider -import software.amazon.awssdk.http.ContentStreamProvider -import software.amazon.awssdk.http.HttpExecuteRequest -import software.amazon.awssdk.http.SdkHttpMethod -import software.amazon.awssdk.http.SdkHttpRequest -import software.amazon.awssdk.http.apache.ApacheHttpClient -import software.amazon.awssdk.http.auth.aws.signer.AwsV4HttpSigner -import java.io.ByteArrayOutputStream -import java.net.ConnectException - -private class BasicOtlpSpanProcessor( - private val coroutineScope: CoroutineScope, - private val traceUrl: String = "http://127.0.0.1:4318/v1/traces", -) : SpanProcessor { - override fun onStart(parentContext: Context, span: ReadWriteSpan) {} - override fun isStartRequired() = false - override fun isEndRequired() = true - - override fun onEnd(span: ReadableSpan) { - val data = span.toSpanData() - coroutineScope.launch { - try { - val item = TraceRequestMarshaler.create(listOf(data)) - val output = ByteArrayOutputStream() - item.writeBinaryTo(output) - - httpPost(traceUrl, contentType = ContentType.XProtobuf, body = output.toByteArray()) - } catch (e: CancellationException) { - throw e - } catch (e: ConnectException) { - thisLogger().warn("Cannot export (url=$traceUrl): ${e.message}") - } catch (e: Throwable) { - thisLogger().error("Cannot export (url=$traceUrl)", e) - } - } - } -} - -private class SigV4OtlpSpanProcessor( - private val coroutineScope: CoroutineScope, - private val traceUrl: String, - private val creds: AwsCredentialsProvider, -) : SpanProcessor { - override fun onStart(parentContext: Context, span: ReadWriteSpan) {} - override fun isStartRequired() = false - override fun isEndRequired() = true - - private val client = ApacheHttpClient.create() - - override fun onEnd(span: ReadableSpan) { - coroutineScope.launch { - val data = span.toSpanData() - try { - val item = TraceRequestMarshaler.create(listOf(data)) - // calculate the sigv4 header - val signer = AwsV4HttpSigner.create() - val httpRequest = - SdkHttpRequest.builder() - .uri(traceUrl) - .method(SdkHttpMethod.POST) - .putHeader("Content-Type", "application/x-protobuf") - .build() - - val baos = ByteArrayOutputStream() - item.writeBinaryTo(baos) - val payload = ContentStreamProvider.fromByteArray(baos.toByteArray()) - val signedRequest = signer.sign { - it.identity(creds.resolveIdentity().get()) - it.request(httpRequest) - it.payload(payload) - it.putProperty(AwsV4HttpSigner.SERVICE_SIGNING_NAME, "osis") - it.putProperty(AwsV4HttpSigner.REGION_NAME, "us-west-2") - } - - // Create and HTTP client and send the request. ApacheHttpClient requires the 'apache-client' module. - client.prepareRequest( - HttpExecuteRequest.builder() - .request(signedRequest.request()) - .contentStreamProvider(signedRequest.payload().orElse(null)) - .build() - ).call() - } catch (e: CancellationException) { - throw e - } catch (e: ConnectException) { - thisLogger().warn("Cannot export (url=$traceUrl): ${e.message}") - } catch (e: Throwable) { - thisLogger().error("Cannot export (url=$traceUrl)", e) - } - } - } -} - -private object StdoutSpanProcessor : SpanProcessor { - override fun onStart(parentContext: Context, span: ReadWriteSpan) {} - override fun isStartRequired() = false - override fun isEndRequired() = true - - override fun onEnd(span: ReadableSpan) { - println(span.toSpanData()) - } -} - -@Service -class OTelService @NonInjectable internal constructor(spanProcessors: List) : Disposable { - @Suppress("unused") - constructor() : this(listOf(ToolkitTelemetryOTelSpanProcessor())) - - private val sdkDelegate = lazy { - OpenTelemetrySdk.builder() - .setTracerProvider( - SdkTracerProvider.builder() - .apply { - spanProcessors.forEach { - addSpanProcessor(it) - } - } - .setResource( - Resource.create( - Attributes.builder() - .put(AttributeKey.stringKey("os.type"), SystemInfoRt.OS_NAME) - .put(AttributeKey.stringKey("os.version"), SystemInfoRt.OS_VERSION) - .put(AttributeKey.stringKey("host.arch"), System.getProperty("os.arch")) - .build() - ) - ) - .build() - ) - .setPropagators(ContextPropagators.create(W3CTraceContextPropagator.getInstance())) - .build() - } - internal val sdk: OpenTelemetrySdk by sdkDelegate - - override fun dispose() { - if (sdkDelegate.isInitialized()) { - sdk.close() - } - } - - companion object { - fun getSdk() = service().sdk - } -} diff --git a/plugins/core/jetbrains-community/src-242-252/software/aws/toolkits/jetbrains/services/telemetry/otel/OTelService.kt b/plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/services/telemetry/otel/OTelService.kt similarity index 97% rename from plugins/core/jetbrains-community/src-242-252/software/aws/toolkits/jetbrains/services/telemetry/otel/OTelService.kt rename to plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/services/telemetry/otel/OTelService.kt index 19f1182b882..e970dd104db 100644 --- a/plugins/core/jetbrains-community/src-242-252/software/aws/toolkits/jetbrains/services/telemetry/otel/OTelService.kt +++ b/plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/services/telemetry/otel/OTelService.kt @@ -50,10 +50,7 @@ private class BasicOtlpSpanProcessor( coroutineScope.launch { try { val item = TraceRequestMarshaler.create(listOf(data)) - - httpPost(traceUrl, contentLength = item.binarySerializedSize.toLong(), contentType = ContentType.XProtobuf) { - item.writeBinaryTo(this) - } + sendOtelTrace(traceUrl, item) } catch (e: CancellationException) { throw e } catch (e: ConnectException) { From b356a385ae25698a9edf7cca31772c288805b048 Mon Sep 17 00:00:00 2001 From: Aseem Sharma Date: Wed, 19 Nov 2025 21:32:45 -0800 Subject: [PATCH 2/6] fix: remove unused NonInjectable import --- .../toolkits/jetbrains/services/telemetry/otel/OTelService.kt | 2 -- 1 file changed, 2 deletions(-) diff --git a/plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/services/telemetry/otel/OTelService.kt b/plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/services/telemetry/otel/OTelService.kt index e970dd104db..f4e440a5c7c 100644 --- a/plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/services/telemetry/otel/OTelService.kt +++ b/plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/services/telemetry/otel/OTelService.kt @@ -9,8 +9,6 @@ import com.intellij.openapi.components.Service import com.intellij.openapi.components.service import com.intellij.openapi.diagnostic.thisLogger import com.intellij.openapi.util.SystemInfoRt -import com.intellij.platform.util.http.ContentType -import com.intellij.platform.util.http.httpPost import com.intellij.serviceContainer.NonInjectable import io.opentelemetry.api.common.AttributeKey import io.opentelemetry.api.common.Attributes From 8337d9d15ce991bb34e6920ebea6ac5215d16371 Mon Sep 17 00:00:00 2001 From: Aseem Sharma Date: Thu, 20 Nov 2025 11:38:53 -0800 Subject: [PATCH 3/6] refactor(otel): use Apache HttpClient for cross-version compatibility Address PR review feedback - use Apache HttpClient instead of platform httpPost API. Changes: - Replace IntelliJ Platform httpPost with Apache HttpClient - Works consistently across all IDE versions (2024.2 - 2025.3+) - Matches existing pattern used in SigV4OtlpSpanProcessor - No version-specific compatibility wrappers needed - Single OTelService.kt in common src/ directory This approach: - Uses same HTTP library as CawsEnvironmentClient and SigV4OtlpSpanProcessor - Avoids platform API incompatibilities between IDE versions - Follows established codebase patterns for HTTP operations --- .../services/telemetry/otel/HttpPostCompat.kt | 18 ------------------ .../services/telemetry/otel/HttpPostCompat.kt | 19 ------------------- .../services/telemetry/otel/OTelService.kt | 17 ++++++++++++++++- 3 files changed, 16 insertions(+), 38 deletions(-) delete mode 100644 plugins/core/jetbrains-community/src-242-252/software/aws/toolkits/jetbrains/services/telemetry/otel/HttpPostCompat.kt delete mode 100644 plugins/core/jetbrains-community/src-253+/software/aws/toolkits/jetbrains/services/telemetry/otel/HttpPostCompat.kt diff --git a/plugins/core/jetbrains-community/src-242-252/software/aws/toolkits/jetbrains/services/telemetry/otel/HttpPostCompat.kt b/plugins/core/jetbrains-community/src-242-252/software/aws/toolkits/jetbrains/services/telemetry/otel/HttpPostCompat.kt deleted file mode 100644 index 2e749b3a455..00000000000 --- a/plugins/core/jetbrains-community/src-242-252/software/aws/toolkits/jetbrains/services/telemetry/otel/HttpPostCompat.kt +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -package software.aws.toolkits.jetbrains.services.telemetry.otel - -import com.intellij.platform.util.http.ContentType -import com.intellij.platform.util.http.httpPost -import io.opentelemetry.exporter.internal.otlp.traces.TraceRequestMarshaler - -/** - * Version-specific compatibility wrapper for httpPost (2024.2-2025.2) - * In these versions, httpPost uses contentLength parameter with streaming body - */ -internal suspend fun sendOtelTrace(url: String, marshaler: TraceRequestMarshaler) { - httpPost(url, contentLength = marshaler.binarySerializedSize.toLong(), contentType = ContentType.XProtobuf) { - marshaler.writeBinaryTo(this) - } -} diff --git a/plugins/core/jetbrains-community/src-253+/software/aws/toolkits/jetbrains/services/telemetry/otel/HttpPostCompat.kt b/plugins/core/jetbrains-community/src-253+/software/aws/toolkits/jetbrains/services/telemetry/otel/HttpPostCompat.kt deleted file mode 100644 index 34a439378dd..00000000000 --- a/plugins/core/jetbrains-community/src-253+/software/aws/toolkits/jetbrains/services/telemetry/otel/HttpPostCompat.kt +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -package software.aws.toolkits.jetbrains.services.telemetry.otel - -import com.intellij.platform.util.http.ContentType -import com.intellij.platform.util.http.httpPost -import io.opentelemetry.exporter.internal.otlp.traces.TraceRequestMarshaler -import java.io.ByteArrayOutputStream - -/** - * Version-specific compatibility wrapper for httpPost (2025.3+) - * In this version, httpPost uses body parameter with byte array - */ -internal suspend fun sendOtelTrace(url: String, marshaler: TraceRequestMarshaler) { - val output = ByteArrayOutputStream() - marshaler.writeBinaryTo(output) - httpPost(url, contentType = ContentType.XProtobuf, body = output.toByteArray()) -} diff --git a/plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/services/telemetry/otel/OTelService.kt b/plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/services/telemetry/otel/OTelService.kt index f4e440a5c7c..c1f753b2310 100644 --- a/plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/services/telemetry/otel/OTelService.kt +++ b/plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/services/telemetry/otel/OTelService.kt @@ -25,6 +25,9 @@ import io.opentelemetry.sdk.trace.SpanProcessor import kotlinx.coroutines.CancellationException import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.launch +import org.apache.http.client.methods.HttpPost +import org.apache.http.entity.ByteArrayEntity +import org.apache.http.impl.client.HttpClients import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider import software.amazon.awssdk.http.ContentStreamProvider import software.amazon.awssdk.http.HttpExecuteRequest @@ -48,7 +51,19 @@ private class BasicOtlpSpanProcessor( coroutineScope.launch { try { val item = TraceRequestMarshaler.create(listOf(data)) - sendOtelTrace(traceUrl, item) + val baos = ByteArrayOutputStream() + item.writeBinaryTo(baos) + + HttpClients.createDefault().use { client -> + val request = HttpPost(traceUrl).apply { + entity = ByteArrayEntity(baos.toByteArray()).apply { + setContentType("application/x-protobuf") + } + } + client.execute(request).use { + // Response consumed and closed + } + } } catch (e: CancellationException) { throw e } catch (e: ConnectException) { From 86f632cfd0a53e9f57f62a33f053621c1f77b294 Mon Sep 17 00:00:00 2001 From: Aseem Sharma Date: Thu, 20 Nov 2025 12:38:34 -0800 Subject: [PATCH 4/6] refactor(otel): use HttpRequests for proxy and user agent support Use IntelliJ's HttpRequests API instead of Apache HttpClient to respect IDE proxy settings and use AWS Toolkit user agent. --- .../services/telemetry/otel/OTelService.kt | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/services/telemetry/otel/OTelService.kt b/plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/services/telemetry/otel/OTelService.kt index c1f753b2310..efab5ceaa0f 100644 --- a/plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/services/telemetry/otel/OTelService.kt +++ b/plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/services/telemetry/otel/OTelService.kt @@ -10,6 +10,7 @@ import com.intellij.openapi.components.service import com.intellij.openapi.diagnostic.thisLogger import com.intellij.openapi.util.SystemInfoRt import com.intellij.serviceContainer.NonInjectable +import com.intellij.util.io.HttpRequests import io.opentelemetry.api.common.AttributeKey import io.opentelemetry.api.common.Attributes import io.opentelemetry.api.trace.propagation.W3CTraceContextPropagator @@ -25,9 +26,6 @@ import io.opentelemetry.sdk.trace.SpanProcessor import kotlinx.coroutines.CancellationException import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.launch -import org.apache.http.client.methods.HttpPost -import org.apache.http.entity.ByteArrayEntity -import org.apache.http.impl.client.HttpClients import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider import software.amazon.awssdk.http.ContentStreamProvider import software.amazon.awssdk.http.HttpExecuteRequest @@ -35,6 +33,7 @@ import software.amazon.awssdk.http.SdkHttpMethod import software.amazon.awssdk.http.SdkHttpRequest import software.amazon.awssdk.http.apache.ApacheHttpClient import software.amazon.awssdk.http.auth.aws.signer.AwsV4HttpSigner +import software.aws.toolkits.jetbrains.core.AwsClientManager import java.io.ByteArrayOutputStream import java.net.ConnectException @@ -54,16 +53,11 @@ private class BasicOtlpSpanProcessor( val baos = ByteArrayOutputStream() item.writeBinaryTo(baos) - HttpClients.createDefault().use { client -> - val request = HttpPost(traceUrl).apply { - entity = ByteArrayEntity(baos.toByteArray()).apply { - setContentType("application/x-protobuf") - } - } - client.execute(request).use { - // Response consumed and closed + HttpRequests.post(traceUrl, "application/x-protobuf") + .userAgent(AwsClientManager.getUserAgent()) + .connect { request -> + request.write(baos.toByteArray()) } - } } catch (e: CancellationException) { throw e } catch (e: ConnectException) { From 7f6e248798c4a0900721059b699e2bb5c7c07c71 Mon Sep 17 00:00:00 2001 From: Aseem Sharma Date: Mon, 1 Dec 2025 12:07:51 -0800 Subject: [PATCH 5/6] Optimize telemetry export by writing directly to output stream --- .../toolkits/jetbrains/services/telemetry/otel/OTelService.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/services/telemetry/otel/OTelService.kt b/plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/services/telemetry/otel/OTelService.kt index efab5ceaa0f..b6b2e2592f8 100644 --- a/plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/services/telemetry/otel/OTelService.kt +++ b/plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/services/telemetry/otel/OTelService.kt @@ -56,7 +56,7 @@ private class BasicOtlpSpanProcessor( HttpRequests.post(traceUrl, "application/x-protobuf") .userAgent(AwsClientManager.getUserAgent()) .connect { request -> - request.write(baos.toByteArray()) + item.writeBinaryTo(request.connection.outputStream) } } catch (e: CancellationException) { throw e From 80e2171a67e2a3e465902bbb1ef4c760e5fe4a79 Mon Sep 17 00:00:00 2001 From: Aseem Sharma Date: Mon, 1 Dec 2025 12:17:32 -0800 Subject: [PATCH 6/6] perf(otel): write telemetry directly to HTTP stream Address PR review feedback to avoid intermediate ByteArrayOutputStream. Instead of: 1. Write to ByteArrayOutputStream 2. Convert to byte array 3. Write byte array to HTTP connection Now: 1. Write directly to HTTP connection.outputStream This reduces memory allocation and improves performance by streaming data directly to the network without intermediate buffering. --- .../toolkits/jetbrains/services/telemetry/otel/OTelService.kt | 2 -- 1 file changed, 2 deletions(-) diff --git a/plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/services/telemetry/otel/OTelService.kt b/plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/services/telemetry/otel/OTelService.kt index b6b2e2592f8..bc804b3845d 100644 --- a/plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/services/telemetry/otel/OTelService.kt +++ b/plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/services/telemetry/otel/OTelService.kt @@ -50,8 +50,6 @@ private class BasicOtlpSpanProcessor( coroutineScope.launch { try { val item = TraceRequestMarshaler.create(listOf(data)) - val baos = ByteArrayOutputStream() - item.writeBinaryTo(baos) HttpRequests.post(traceUrl, "application/x-protobuf") .userAgent(AwsClientManager.getUserAgent())