Skip to content

Commit c6b8e05

Browse files
committed
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
1 parent 543169d commit c6b8e05

File tree

3 files changed

+16
-38
lines changed
  • plugins/core/jetbrains-community

3 files changed

+16
-38
lines changed

plugins/core/jetbrains-community/src-242-252/software/aws/toolkits/jetbrains/services/telemetry/otel/HttpPostCompat.kt

Lines changed: 0 additions & 18 deletions
This file was deleted.

plugins/core/jetbrains-community/src-253+/software/aws/toolkits/jetbrains/services/telemetry/otel/HttpPostCompat.kt

Lines changed: 0 additions & 19 deletions
This file was deleted.

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ import io.opentelemetry.sdk.trace.SpanProcessor
2525
import kotlinx.coroutines.CancellationException
2626
import kotlinx.coroutines.CoroutineScope
2727
import kotlinx.coroutines.launch
28+
import org.apache.http.client.methods.HttpPost
29+
import org.apache.http.entity.ByteArrayEntity
30+
import org.apache.http.impl.client.HttpClients
2831
import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider
2932
import software.amazon.awssdk.http.ContentStreamProvider
3033
import software.amazon.awssdk.http.HttpExecuteRequest
@@ -48,7 +51,19 @@ private class BasicOtlpSpanProcessor(
4851
coroutineScope.launch {
4952
try {
5053
val item = TraceRequestMarshaler.create(listOf(data))
51-
sendOtelTrace(traceUrl, item)
54+
val baos = ByteArrayOutputStream()
55+
item.writeBinaryTo(baos)
56+
57+
HttpClients.createDefault().use { client ->
58+
val request = HttpPost(traceUrl).apply {
59+
entity = ByteArrayEntity(baos.toByteArray()).apply {
60+
setContentType("application/x-protobuf")
61+
}
62+
}
63+
client.execute(request).use {
64+
// Response consumed and closed
65+
}
66+
}
5267
} catch (e: CancellationException) {
5368
throw e
5469
} catch (e: ConnectException) {

0 commit comments

Comments
 (0)