From 3330bcd5d77f90ddcb74f115eacbc2cf3678332e Mon Sep 17 00:00:00 2001 From: Lauri Tulmin Date: Thu, 14 Dec 2023 15:24:11 +0200 Subject: [PATCH] Add http client response attributes to aws sqs process spans --- .../src/test/groovy/S3TracingTest.groovy | 7 ++-- .../src/test/groovy/SnsTracingTest.groovy | 4 +-- .../v1_11/AwsSdkInstrumenterFactory.java | 32 +++++++------------ .../awssdk/v1_11/AwsSdkTelemetry.java | 2 +- .../instrumentation/awssdk/v1_11/SqsImpl.java | 9 ++++-- .../SqsProcessRequestAttributesGetter.java | 5 +-- .../awssdk/v1_11/TracingIterator.java | 15 ++++++--- .../awssdk/v1_11/TracingList.java | 15 ++++++--- .../awssdk/v1_11/TracingRequestHandler.java | 6 ++-- ...AbstractSqsSuppressReceiveSpansTest.groovy | 7 ++-- .../v1_11/AbstractSqsTracingTest.groovy | 7 ++-- .../v2_2/AwsSdkInstrumenterFactory.java | 31 +++++++----------- .../awssdk/v2_2/AwsSdkTelemetry.java | 2 +- .../instrumentation/awssdk/v2_2/SqsImpl.java | 1 + .../SqsProcessRequestAttributesGetter.java | 4 +-- .../v2_2/TracingExecutionInterceptor.java | 6 ++-- .../awssdk/v2_2/TracingIterator.java | 15 ++++++--- .../awssdk/v2_2/TracingList.java | 16 +++++++--- ...ractAws2SqsSuppressReceiveSpansTest.groovy | 7 ++-- .../v2_2/AbstractAws2SqsTracingTest.groovy | 5 ++- .../apachecamel/aws/AwsSpanAssertions.java | 10 ++---- 21 files changed, 105 insertions(+), 101 deletions(-) diff --git a/instrumentation/aws-sdk/aws-sdk-1.11/javaagent/src/test/groovy/S3TracingTest.groovy b/instrumentation/aws-sdk/aws-sdk-1.11/javaagent/src/test/groovy/S3TracingTest.groovy index ab79d3aa2daa..3f9a94db6aef 100644 --- a/instrumentation/aws-sdk/aws-sdk-1.11/javaagent/src/test/groovy/S3TracingTest.groovy +++ b/instrumentation/aws-sdk/aws-sdk-1.11/javaagent/src/test/groovy/S3TracingTest.groovy @@ -3,7 +3,6 @@ * SPDX-License-Identifier: Apache-2.0 */ -import io.opentelemetry.instrumentation.api.semconv.http.internal.HttpAttributes import io.opentelemetry.instrumentation.test.AgentInstrumentationSpecification import io.opentelemetry.semconv.SemanticAttributes import spock.lang.Shared @@ -190,6 +189,7 @@ class S3TracingTest extends AgentInstrumentationSpecification { "rpc.system" "aws-api" "rpc.service" "AmazonSQS" "$SemanticAttributes.HTTP_REQUEST_METHOD" "POST" + "$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200 "$SemanticAttributes.URL_FULL" { it.startsWith("http://") } "$SemanticAttributes.SERVER_ADDRESS" String "$SemanticAttributes.SERVER_PORT" { it == null || Number } @@ -197,7 +197,7 @@ class S3TracingTest extends AgentInstrumentationSpecification { "$SemanticAttributes.MESSAGING_DESTINATION_NAME" "s3ToSqsTestQueue" "$SemanticAttributes.MESSAGING_OPERATION" "process" "$SemanticAttributes.MESSAGING_MESSAGE_ID" String - "$HttpAttributes.ERROR_TYPE" "_OTHER" + "$SemanticAttributes.NETWORK_PROTOCOL_VERSION" "1.1" } } span(2) { @@ -523,6 +523,7 @@ class S3TracingTest extends AgentInstrumentationSpecification { "rpc.system" "aws-api" "rpc.service" "AmazonSQS" "$SemanticAttributes.HTTP_REQUEST_METHOD" "POST" + "$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200 "$SemanticAttributes.URL_FULL" { it.startsWith("http://") } "$SemanticAttributes.SERVER_ADDRESS" String "$SemanticAttributes.SERVER_PORT" { it == null || Number } @@ -530,7 +531,7 @@ class S3TracingTest extends AgentInstrumentationSpecification { "$SemanticAttributes.MESSAGING_DESTINATION_NAME" "s3ToSnsToSqsTestQueue" "$SemanticAttributes.MESSAGING_OPERATION" "process" "$SemanticAttributes.MESSAGING_MESSAGE_ID" String - "$HttpAttributes.ERROR_TYPE" "_OTHER" + "$SemanticAttributes.NETWORK_PROTOCOL_VERSION" "1.1" } } span(1) { diff --git a/instrumentation/aws-sdk/aws-sdk-1.11/javaagent/src/test/groovy/SnsTracingTest.groovy b/instrumentation/aws-sdk/aws-sdk-1.11/javaagent/src/test/groovy/SnsTracingTest.groovy index e7d6e4018370..8e532232671d 100644 --- a/instrumentation/aws-sdk/aws-sdk-1.11/javaagent/src/test/groovy/SnsTracingTest.groovy +++ b/instrumentation/aws-sdk/aws-sdk-1.11/javaagent/src/test/groovy/SnsTracingTest.groovy @@ -3,7 +3,6 @@ * SPDX-License-Identifier: Apache-2.0 */ -import io.opentelemetry.instrumentation.api.semconv.http.internal.HttpAttributes import io.opentelemetry.instrumentation.test.AgentInstrumentationSpecification import io.opentelemetry.semconv.SemanticAttributes import spock.lang.Shared @@ -179,6 +178,7 @@ class SnsTracingTest extends AgentInstrumentationSpecification { "rpc.service" "AmazonSQS" "rpc.method" "ReceiveMessage" "$SemanticAttributes.HTTP_REQUEST_METHOD" "POST" + "$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200 "$SemanticAttributes.URL_FULL" String "$SemanticAttributes.SERVER_ADDRESS" String "$SemanticAttributes.SERVER_PORT" { it == null || Number } @@ -186,7 +186,7 @@ class SnsTracingTest extends AgentInstrumentationSpecification { "$SemanticAttributes.MESSAGING_DESTINATION_NAME" "snsToSqsTestQueue" "$SemanticAttributes.MESSAGING_OPERATION" "process" "$SemanticAttributes.MESSAGING_MESSAGE_ID" String - "$HttpAttributes.ERROR_TYPE" "_OTHER" + "$SemanticAttributes.NETWORK_PROTOCOL_VERSION" "1.1" } } span(2) { diff --git a/instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/AwsSdkInstrumenterFactory.java b/instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/AwsSdkInstrumenterFactory.java index b782ddc0025b..b4613dd9edb2 100644 --- a/instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/AwsSdkInstrumenterFactory.java +++ b/instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/AwsSdkInstrumenterFactory.java @@ -28,7 +28,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.function.Function; import javax.annotation.Nullable; final class AwsSdkInstrumenterFactory { @@ -98,23 +97,23 @@ Instrumenter> consumerReceiveInstrumenter() { openTelemetry, MessagingSpanNameExtractor.create(getter, operation), SpanKindExtractor.alwaysConsumer(), - toSqsRequestExtractors(attributesExtractors(), Function.identity()), + toSqsRequestExtractors(attributesExtractors()), singletonList(messagingAttributeExtractor), messagingReceiveInstrumentationEnabled); } - Instrumenter consumerProcessInstrumenter() { + Instrumenter> consumerProcessInstrumenter() { MessageOperation operation = MessageOperation.PROCESS; SqsProcessRequestAttributesGetter getter = SqsProcessRequestAttributesGetter.INSTANCE; - AttributesExtractor messagingAttributeExtractor = + AttributesExtractor> messagingAttributeExtractor = messagingAttributesExtractor(getter, operation); - InstrumenterBuilder builder = - Instrumenter.builder( + InstrumenterBuilder> builder = + Instrumenter.>builder( openTelemetry, INSTRUMENTATION_NAME, MessagingSpanNameExtractor.create(getter, operation)) - .addAttributesExtractors(toSqsRequestExtractors(attributesExtractors(), unused -> null)) + .addAttributesExtractors(toSqsRequestExtractors(attributesExtractors())) .addAttributesExtractor(messagingAttributeExtractor); if (messagingReceiveInstrumentationEnabled) { @@ -128,14 +127,12 @@ Instrumenter consumerProcessInstrumenter() { return builder.buildInstrumenter(SpanKindExtractor.alwaysConsumer()); } - private static - List> toSqsRequestExtractors( - List, Response>> extractors, - Function> responseConverter) { - List> result = new ArrayList<>(); + private static List>> toSqsRequestExtractors( + List, Response>> extractors) { + List>> result = new ArrayList<>(); for (AttributesExtractor, Response> extractor : extractors) { result.add( - new AttributesExtractor() { + new AttributesExtractor>() { @Override public void onStart( AttributesBuilder attributes, @@ -149,14 +146,9 @@ public void onEnd( AttributesBuilder attributes, Context context, AbstractSqsRequest sqsRequest, - @Nullable RESPONSE response, + @Nullable Response response, @Nullable Throwable error) { - extractor.onEnd( - attributes, - context, - sqsRequest.getRequest(), - responseConverter.apply(response), - error); + extractor.onEnd(attributes, context, sqsRequest.getRequest(), response, error); } }); } diff --git a/instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/AwsSdkTelemetry.java b/instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/AwsSdkTelemetry.java index 8cf95e73a91d..a5b7df063be3 100644 --- a/instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/AwsSdkTelemetry.java +++ b/instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/AwsSdkTelemetry.java @@ -47,7 +47,7 @@ public static AwsSdkTelemetryBuilder builder(OpenTelemetry openTelemetry) { private final Instrumenter, Response> requestInstrumenter; private final Instrumenter> consumerReceiveInstrumenter; - private final Instrumenter consumerProcessInstrumenter; + private final Instrumenter> consumerProcessInstrumenter; private final Instrumenter, Response> producerInstrumenter; AwsSdkTelemetry( diff --git a/instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/SqsImpl.java b/instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/SqsImpl.java index 41c772692d05..65fabf76b1a8 100644 --- a/instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/SqsImpl.java +++ b/instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/SqsImpl.java @@ -57,7 +57,7 @@ private static void afterConsumerResponse( Instrumenter> consumerReceiveInstrumenter = requestHandler.getConsumerReceiveInstrumenter(); - Instrumenter consumerProcessInstrumenter = + Instrumenter> consumerProcessInstrumenter = requestHandler.getConsumerProcessInstrumenter(); Context receiveContext = null; @@ -75,7 +75,8 @@ private static void afterConsumerResponse( timer.now()); } - addTracing(receiveMessageResult, request, consumerProcessInstrumenter, receiveContext); + addTracing( + receiveMessageResult, request, response, consumerProcessInstrumenter, receiveContext); } private static final Field messagesField = getMessagesField(); @@ -93,7 +94,8 @@ private static Field getMessagesField() { private static void addTracing( ReceiveMessageResult receiveMessageResult, Request request, - Instrumenter consumerProcessInstrumenter, + Response response, + Instrumenter> consumerProcessInstrumenter, Context receiveContext) { if (messagesField == null) { return; @@ -107,6 +109,7 @@ private static void addTracing( receiveMessageResult.getMessages(), consumerProcessInstrumenter, request, + response, receiveContext)); } catch (IllegalAccessException ignored) { // should not happen, we call setAccessible on the field diff --git a/instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/SqsProcessRequestAttributesGetter.java b/instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/SqsProcessRequestAttributesGetter.java index 3b1d5f0e216c..d3c8d4486364 100644 --- a/instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/SqsProcessRequestAttributesGetter.java +++ b/instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/SqsProcessRequestAttributesGetter.java @@ -5,13 +5,14 @@ package io.opentelemetry.instrumentation.awssdk.v1_11; +import com.amazonaws.Response; import io.opentelemetry.instrumentation.api.incubator.semconv.messaging.MessagingAttributesGetter; import java.util.Collections; import java.util.List; import javax.annotation.Nullable; enum SqsProcessRequestAttributesGetter - implements MessagingAttributesGetter { + implements MessagingAttributesGetter> { INSTANCE; @Override @@ -52,7 +53,7 @@ public Long getMessagePayloadCompressedSize(SqsProcessRequest request) { @Override @Nullable - public String getMessageId(SqsProcessRequest request, @Nullable Void response) { + public String getMessageId(SqsProcessRequest request, @Nullable Response response) { return request.getMessage().getMessageId(); } diff --git a/instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/TracingIterator.java b/instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/TracingIterator.java index 6c476f38adb0..8984c38202e1 100644 --- a/instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/TracingIterator.java +++ b/instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/TracingIterator.java @@ -6,6 +6,7 @@ package io.opentelemetry.instrumentation.awssdk.v1_11; import com.amazonaws.Request; +import com.amazonaws.Response; import com.amazonaws.services.sqs.model.Message; import io.opentelemetry.context.Context; import io.opentelemetry.context.Scope; @@ -16,8 +17,9 @@ class TracingIterator implements Iterator { private final Iterator delegateIterator; - private final Instrumenter instrumenter; + private final Instrumenter> instrumenter; private final Request request; + private final Response response; private final Context receiveContext; /* @@ -30,21 +32,24 @@ class TracingIterator implements Iterator { private TracingIterator( Iterator delegateIterator, - Instrumenter instrumenter, + Instrumenter> instrumenter, Request request, + Response response, Context receiveContext) { this.delegateIterator = delegateIterator; this.instrumenter = instrumenter; this.request = request; + this.response = response; this.receiveContext = receiveContext; } public static Iterator wrap( Iterator delegateIterator, - Instrumenter instrumenter, + Instrumenter> instrumenter, Request request, + Response response, Context receiveContext) { - return new TracingIterator(delegateIterator, instrumenter, request, receiveContext); + return new TracingIterator(delegateIterator, instrumenter, request, response, receiveContext); } @Override @@ -80,7 +85,7 @@ public Message next() { private void closeScopeAndEndSpan() { if (currentScope != null) { currentScope.close(); - instrumenter.end(currentContext, currentRequest, null, null); + instrumenter.end(currentContext, currentRequest, response, null); currentScope = null; currentRequest = null; currentContext = null; diff --git a/instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/TracingList.java b/instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/TracingList.java index a0977017aaf6..f003d23a2929 100644 --- a/instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/TracingList.java +++ b/instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/TracingList.java @@ -6,6 +6,7 @@ package io.opentelemetry.instrumentation.awssdk.v1_11; import com.amazonaws.Request; +import com.amazonaws.Response; import com.amazonaws.internal.SdkInternalList; import com.amazonaws.services.sqs.AmazonSQSClient; import com.amazonaws.services.sqs.model.Message; @@ -18,28 +19,32 @@ class TracingList extends SdkInternalList { private static final long serialVersionUID = 1L; - private final transient Instrumenter instrumenter; + private final transient Instrumenter> instrumenter; private final transient Request request; + private final transient Response response; private final transient Context receiveContext; private boolean firstIterator = true; private TracingList( List list, - Instrumenter instrumenter, + Instrumenter> instrumenter, Request request, + Response response, Context receiveContext) { super(list); this.instrumenter = instrumenter; this.request = request; + this.response = response; this.receiveContext = receiveContext; } public static SdkInternalList wrap( List list, - Instrumenter instrumenter, + Instrumenter> instrumenter, Request request, + Response response, Context receiveContext) { - return new TracingList(list, instrumenter, request, receiveContext); + return new TracingList(list, instrumenter, request, response, receiveContext); } @Override @@ -49,7 +54,7 @@ public Iterator iterator() { // However, this is not thread-safe, but usually the first (hopefully only) traversal of // List is performed in the same thread that called receiveMessage() if (firstIterator && !inAwsClient()) { - it = TracingIterator.wrap(super.iterator(), instrumenter, request, receiveContext); + it = TracingIterator.wrap(super.iterator(), instrumenter, request, response, receiveContext); firstIterator = false; } else { it = super.iterator(); diff --git a/instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/TracingRequestHandler.java b/instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/TracingRequestHandler.java index 6a43b5ff51a4..e2abe662c7db 100644 --- a/instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/TracingRequestHandler.java +++ b/instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/TracingRequestHandler.java @@ -34,13 +34,13 @@ final class TracingRequestHandler extends RequestHandler2 { private final Instrumenter, Response> requestInstrumenter; private final Instrumenter> consumerReceiveInstrumenter; - private final Instrumenter consumerProcessInstrumenter; + private final Instrumenter> consumerProcessInstrumenter; private final Instrumenter, Response> producerInstrumenter; TracingRequestHandler( Instrumenter, Response> requestInstrumenter, Instrumenter> consumerReceiveInstrumenter, - Instrumenter consumerProcessInstrumenter, + Instrumenter> consumerProcessInstrumenter, Instrumenter, Response> producerInstrumenter) { this.requestInstrumenter = requestInstrumenter; this.consumerReceiveInstrumenter = consumerReceiveInstrumenter; @@ -103,7 +103,7 @@ Instrumenter> getConsumerReceiveInstrumenter() { return consumerReceiveInstrumenter; } - Instrumenter getConsumerProcessInstrumenter() { + Instrumenter> getConsumerProcessInstrumenter() { return consumerProcessInstrumenter; } diff --git a/instrumentation/aws-sdk/aws-sdk-1.11/testing/src/main/groovy/io/opentelemetry/instrumentation/awssdk/v1_11/AbstractSqsSuppressReceiveSpansTest.groovy b/instrumentation/aws-sdk/aws-sdk-1.11/testing/src/main/groovy/io/opentelemetry/instrumentation/awssdk/v1_11/AbstractSqsSuppressReceiveSpansTest.groovy index d62f8a924c77..66aebca87807 100644 --- a/instrumentation/aws-sdk/aws-sdk-1.11/testing/src/main/groovy/io/opentelemetry/instrumentation/awssdk/v1_11/AbstractSqsSuppressReceiveSpansTest.groovy +++ b/instrumentation/aws-sdk/aws-sdk-1.11/testing/src/main/groovy/io/opentelemetry/instrumentation/awssdk/v1_11/AbstractSqsSuppressReceiveSpansTest.groovy @@ -12,7 +12,6 @@ import com.amazonaws.services.sqs.AmazonSQSAsyncClient import com.amazonaws.services.sqs.AmazonSQSAsyncClientBuilder import com.amazonaws.services.sqs.model.ReceiveMessageRequest import com.amazonaws.services.sqs.model.SendMessageRequest -import io.opentelemetry.instrumentation.api.semconv.http.internal.HttpAttributes import io.opentelemetry.instrumentation.test.InstrumentationSpecification import io.opentelemetry.instrumentation.test.utils.PortUtils import io.opentelemetry.semconv.SemanticAttributes @@ -121,6 +120,7 @@ abstract class AbstractSqsSuppressReceiveSpansTest extends InstrumentationSpecif "rpc.system" "aws-api" "rpc.service" "AmazonSQS" "$SemanticAttributes.HTTP_REQUEST_METHOD" "POST" + "$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200 "$SemanticAttributes.URL_FULL" "http://localhost:$sqsPort" "$SemanticAttributes.SERVER_ADDRESS" "localhost" "$SemanticAttributes.SERVER_PORT" sqsPort @@ -128,7 +128,7 @@ abstract class AbstractSqsSuppressReceiveSpansTest extends InstrumentationSpecif "$SemanticAttributes.MESSAGING_DESTINATION_NAME" "testSdkSqs" "$SemanticAttributes.MESSAGING_OPERATION" "process" "$SemanticAttributes.MESSAGING_MESSAGE_ID" String - "$HttpAttributes.ERROR_TYPE" "_OTHER" + "$SemanticAttributes.NETWORK_PROTOCOL_VERSION" "1.1" } } span(2) { @@ -213,6 +213,7 @@ abstract class AbstractSqsSuppressReceiveSpansTest extends InstrumentationSpecif "rpc.system" "aws-api" "rpc.service" "AmazonSQS" "$SemanticAttributes.HTTP_REQUEST_METHOD" "POST" + "$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200 "$SemanticAttributes.URL_FULL" "http://localhost:$sqsPort" "$SemanticAttributes.SERVER_ADDRESS" "localhost" "$SemanticAttributes.SERVER_PORT" sqsPort @@ -220,7 +221,7 @@ abstract class AbstractSqsSuppressReceiveSpansTest extends InstrumentationSpecif "$SemanticAttributes.MESSAGING_DESTINATION_NAME" "testSdkSqs" "$SemanticAttributes.MESSAGING_OPERATION" "process" "$SemanticAttributes.MESSAGING_MESSAGE_ID" String - "$HttpAttributes.ERROR_TYPE" "_OTHER" + "$SemanticAttributes.NETWORK_PROTOCOL_VERSION" "1.1" } } span(2) { diff --git a/instrumentation/aws-sdk/aws-sdk-1.11/testing/src/main/groovy/io/opentelemetry/instrumentation/awssdk/v1_11/AbstractSqsTracingTest.groovy b/instrumentation/aws-sdk/aws-sdk-1.11/testing/src/main/groovy/io/opentelemetry/instrumentation/awssdk/v1_11/AbstractSqsTracingTest.groovy index 92650ccac0c7..9132a8cd8bba 100644 --- a/instrumentation/aws-sdk/aws-sdk-1.11/testing/src/main/groovy/io/opentelemetry/instrumentation/awssdk/v1_11/AbstractSqsTracingTest.groovy +++ b/instrumentation/aws-sdk/aws-sdk-1.11/testing/src/main/groovy/io/opentelemetry/instrumentation/awssdk/v1_11/AbstractSqsTracingTest.groovy @@ -13,7 +13,6 @@ import com.amazonaws.services.sqs.AmazonSQSAsyncClientBuilder import com.amazonaws.services.sqs.model.MessageAttributeValue import com.amazonaws.services.sqs.model.ReceiveMessageRequest import com.amazonaws.services.sqs.model.SendMessageRequest -import io.opentelemetry.instrumentation.api.semconv.http.internal.HttpAttributes import io.opentelemetry.instrumentation.test.InstrumentationSpecification import io.opentelemetry.instrumentation.test.utils.PortUtils import io.opentelemetry.sdk.trace.data.SpanData @@ -172,6 +171,7 @@ abstract class AbstractSqsTracingTest extends InstrumentationSpecification { "rpc.system" "aws-api" "rpc.service" "AmazonSQS" "$SemanticAttributes.HTTP_REQUEST_METHOD" "POST" + "$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200 "$SemanticAttributes.URL_FULL" "http://localhost:$sqsPort" "$SemanticAttributes.SERVER_ADDRESS" "localhost" "$SemanticAttributes.SERVER_PORT" sqsPort @@ -179,10 +179,10 @@ abstract class AbstractSqsTracingTest extends InstrumentationSpecification { "$SemanticAttributes.MESSAGING_DESTINATION_NAME" "testSdkSqs" "$SemanticAttributes.MESSAGING_OPERATION" "process" "$SemanticAttributes.MESSAGING_MESSAGE_ID" String + "$SemanticAttributes.NETWORK_PROTOCOL_VERSION" "1.1" if (testCaptureHeaders) { "messaging.header.test_message_header" { it == ["test"] } } - "$HttpAttributes.ERROR_TYPE" "_OTHER" } } span(2) { @@ -335,6 +335,7 @@ abstract class AbstractSqsTracingTest extends InstrumentationSpecification { "rpc.system" "aws-api" "rpc.service" "AmazonSQS" "$SemanticAttributes.HTTP_REQUEST_METHOD" "POST" + "$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200 "$SemanticAttributes.URL_FULL" "http://localhost:$sqsPort" "$SemanticAttributes.SERVER_ADDRESS" "localhost" "$SemanticAttributes.SERVER_PORT" sqsPort @@ -342,7 +343,7 @@ abstract class AbstractSqsTracingTest extends InstrumentationSpecification { "$SemanticAttributes.MESSAGING_DESTINATION_NAME" "testSdkSqs" "$SemanticAttributes.MESSAGING_OPERATION" "process" "$SemanticAttributes.MESSAGING_MESSAGE_ID" String - "$HttpAttributes.ERROR_TYPE" "_OTHER" + "$SemanticAttributes.NETWORK_PROTOCOL_VERSION" "1.1" } } span(4) { diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AwsSdkInstrumenterFactory.java b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AwsSdkInstrumenterFactory.java index 6e7c5400d2ed..0b04496debc6 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AwsSdkInstrumenterFactory.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AwsSdkInstrumenterFactory.java @@ -27,7 +27,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.function.Function; import javax.annotation.Nullable; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; import software.amazon.awssdk.core.interceptor.SdkExecutionAttribute; @@ -129,22 +128,21 @@ Instrumenter consumerReceiveInstrumenter() { openTelemetry, MessagingSpanNameExtractor.create(getter, operation), SpanKindExtractor.alwaysConsumer(), - toSqsRequestExtractors(consumerAttributesExtractors(), Function.identity()), + toSqsRequestExtractors(consumerAttributesExtractors()), singletonList(messagingAttributeExtractor), messagingReceiveInstrumentationEnabled); } - Instrumenter consumerProcessInstrumenter() { + Instrumenter consumerProcessInstrumenter() { MessageOperation operation = MessageOperation.PROCESS; SqsProcessRequestAttributesGetter getter = SqsProcessRequestAttributesGetter.INSTANCE; - InstrumenterBuilder builder = - Instrumenter.builder( + InstrumenterBuilder builder = + Instrumenter.builder( openTelemetry, INSTRUMENTATION_NAME, MessagingSpanNameExtractor.create(getter, operation)) - .addAttributesExtractors( - toSqsRequestExtractors(consumerAttributesExtractors(), unused -> null)) + .addAttributesExtractors(toSqsRequestExtractors(consumerAttributesExtractors())) .addAttributesExtractor(messagingAttributesExtractor(getter, operation)); if (messagingReceiveInstrumentationEnabled) { @@ -159,14 +157,12 @@ Instrumenter consumerProcessInstrumenter() { return builder.buildInstrumenter(SpanKindExtractor.alwaysConsumer()); } - private static - List> toSqsRequestExtractors( - List> extractors, - Function responseConverter) { - List> result = new ArrayList<>(); + private static List> toSqsRequestExtractors( + List> extractors) { + List> result = new ArrayList<>(); for (AttributesExtractor extractor : extractors) { result.add( - new AttributesExtractor() { + new AttributesExtractor() { @Override public void onStart( AttributesBuilder attributes, @@ -180,14 +176,9 @@ public void onEnd( AttributesBuilder attributes, Context context, AbstractSqsRequest sqsRequest, - @Nullable RESPONSE response, + @Nullable Response response, @Nullable Throwable error) { - extractor.onEnd( - attributes, - context, - sqsRequest.getRequest(), - responseConverter.apply(response), - error); + extractor.onEnd(attributes, context, sqsRequest.getRequest(), response, error); } }); } diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AwsSdkTelemetry.java b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AwsSdkTelemetry.java index afa27630626a..0a938e45967b 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AwsSdkTelemetry.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AwsSdkTelemetry.java @@ -46,7 +46,7 @@ public static AwsSdkTelemetryBuilder builder(OpenTelemetry openTelemetry) { private final Instrumenter requestInstrumenter; private final Instrumenter consumerReceiveInstrumenter; - private final Instrumenter consumerProcessInstrumenter; + private final Instrumenter consumerProcessInstrumenter; private final Instrumenter producerInstrumenter; private final boolean captureExperimentalSpanAttributes; @Nullable private final TextMapPropagator messagingPropagator; diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/SqsImpl.java b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/SqsImpl.java index cad1cf4a3ee5..bca3a6c49c69 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/SqsImpl.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/SqsImpl.java @@ -102,6 +102,7 @@ static boolean afterReceiveMessageExecution( response.messages(), config.getConsumerProcessInstrumenter(), copy, + new Response(context.httpResponse(), response), config, receiveContext); diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/SqsProcessRequestAttributesGetter.java b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/SqsProcessRequestAttributesGetter.java index f1aaf6b46ef3..eff4c09fe680 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/SqsProcessRequestAttributesGetter.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/SqsProcessRequestAttributesGetter.java @@ -12,7 +12,7 @@ import software.amazon.awssdk.core.SdkRequest; enum SqsProcessRequestAttributesGetter - implements MessagingAttributesGetter { + implements MessagingAttributesGetter { INSTANCE; @Override @@ -59,7 +59,7 @@ public Long getMessagePayloadCompressedSize(SqsProcessRequest request) { @Override @Nullable - public String getMessageId(SqsProcessRequest request, @Nullable Void response) { + public String getMessageId(SqsProcessRequest request, @Nullable Response response) { return request.getMessage().getMessageId(); } diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/TracingExecutionInterceptor.java b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/TracingExecutionInterceptor.java index f717b1efc44c..b2aa73a20816 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/TracingExecutionInterceptor.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/TracingExecutionInterceptor.java @@ -65,7 +65,7 @@ final class TracingExecutionInterceptor implements ExecutionInterceptor { private final Instrumenter requestInstrumenter; private final Instrumenter consumerReceiveInstrumenter; - private final Instrumenter consumerProcessInstrumenter; + private final Instrumenter consumerProcessInstrumenter; private final Instrumenter producerInstrumenter; private final boolean captureExperimentalSpanAttributes; @@ -77,7 +77,7 @@ Instrumenter getConsumerReceiveInstrumenter() { return consumerReceiveInstrumenter; } - Instrumenter getConsumerProcessInstrumenter() { + Instrumenter getConsumerProcessInstrumenter() { return consumerProcessInstrumenter; } @@ -98,7 +98,7 @@ boolean shouldUseXrayPropagator() { TracingExecutionInterceptor( Instrumenter requestInstrumenter, Instrumenter consumerReceiveInstrumenter, - Instrumenter consumerProcessInstrumenter, + Instrumenter consumerProcessInstrumenter, Instrumenter producerInstrumenter, boolean captureExperimentalSpanAttributes, TextMapPropagator messagingPropagator, diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/TracingIterator.java b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/TracingIterator.java index 633301e90a3b..8d2e1e4d99c4 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/TracingIterator.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/TracingIterator.java @@ -16,8 +16,9 @@ class TracingIterator implements Iterator { private final Iterator delegateIterator; - private final Instrumenter instrumenter; + private final Instrumenter instrumenter; private final ExecutionAttributes request; + private final Response response; private final TracingExecutionInterceptor config; private final Context receiveContext; @@ -31,24 +32,28 @@ class TracingIterator implements Iterator { private TracingIterator( Iterator delegateIterator, - Instrumenter instrumenter, + Instrumenter instrumenter, ExecutionAttributes request, + Response response, TracingExecutionInterceptor config, Context receiveContext) { this.delegateIterator = delegateIterator; this.instrumenter = instrumenter; this.request = request; + this.response = response; this.config = config; this.receiveContext = receiveContext; } public static Iterator wrap( Iterator delegateIterator, - Instrumenter instrumenter, + Instrumenter instrumenter, ExecutionAttributes request, + Response response, TracingExecutionInterceptor config, Context receiveContext) { - return new TracingIterator(delegateIterator, instrumenter, request, config, receiveContext); + return new TracingIterator( + delegateIterator, instrumenter, request, response, config, receiveContext); } @Override @@ -85,7 +90,7 @@ public Message next() { private void closeScopeAndEndSpan() { if (currentScope != null) { currentScope.close(); - instrumenter.end(currentContext, currentRequest, null, null); + instrumenter.end(currentContext, currentRequest, response, null); currentScope = null; currentRequest = null; currentContext = null; diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/TracingList.java b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/TracingList.java index 46491f501bb8..b2b262b3c3a0 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/TracingList.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/TracingList.java @@ -17,32 +17,36 @@ class TracingList extends ArrayList { private static final long serialVersionUID = 1L; - private final Instrumenter instrumenter; + private final Instrumenter instrumenter; private final ExecutionAttributes request; + private final Response response; private final TracingExecutionInterceptor config; private final Context receiveContext; private boolean firstIterator = true; private TracingList( List list, - Instrumenter instrumenter, + Instrumenter instrumenter, ExecutionAttributes request, + Response response, TracingExecutionInterceptor config, Context receiveContext) { super(list); this.instrumenter = instrumenter; this.request = request; + this.response = response; this.config = config; this.receiveContext = receiveContext; } public static TracingList wrap( List list, - Instrumenter instrumenter, + Instrumenter instrumenter, ExecutionAttributes request, + Response response, TracingExecutionInterceptor config, Context receiveContext) { - return new TracingList(list, instrumenter, request, config, receiveContext); + return new TracingList(list, instrumenter, request, response, config, receiveContext); } @Override @@ -52,7 +56,9 @@ public Iterator iterator() { // However, this is not thread-safe, but usually the first (hopefully only) traversal of // List is performed in the same thread that called receiveMessage() if (firstIterator) { - it = TracingIterator.wrap(super.iterator(), instrumenter, request, config, receiveContext); + it = + TracingIterator.wrap( + super.iterator(), instrumenter, request, response, config, receiveContext); firstIterator = false; } else { it = super.iterator(); diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/testing/src/main/groovy/io/opentelemetry/instrumentation/awssdk/v2_2/AbstractAws2SqsSuppressReceiveSpansTest.groovy b/instrumentation/aws-sdk/aws-sdk-2.2/testing/src/main/groovy/io/opentelemetry/instrumentation/awssdk/v2_2/AbstractAws2SqsSuppressReceiveSpansTest.groovy index dad5b2051163..e9ecb1579819 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/testing/src/main/groovy/io/opentelemetry/instrumentation/awssdk/v2_2/AbstractAws2SqsSuppressReceiveSpansTest.groovy +++ b/instrumentation/aws-sdk/aws-sdk-2.2/testing/src/main/groovy/io/opentelemetry/instrumentation/awssdk/v2_2/AbstractAws2SqsSuppressReceiveSpansTest.groovy @@ -5,7 +5,6 @@ package io.opentelemetry.instrumentation.awssdk.v2_2 -import io.opentelemetry.instrumentation.api.semconv.http.internal.HttpAttributes import io.opentelemetry.instrumentation.test.InstrumentationSpecification import io.opentelemetry.semconv.SemanticAttributes import org.elasticmq.rest.sqs.SQSRestServerBuilder @@ -172,6 +171,7 @@ abstract class AbstractAws2SqsSuppressReceiveSpansTest extends InstrumentationSp "rpc.system" "aws-api" "rpc.service" "Sqs" "$SemanticAttributes.HTTP_REQUEST_METHOD" "POST" + "$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200 "$SemanticAttributes.URL_FULL" { it.startsWith("http://localhost:$sqsPort") } "$SemanticAttributes.SERVER_ADDRESS" "localhost" "$SemanticAttributes.SERVER_PORT" sqsPort @@ -179,7 +179,6 @@ abstract class AbstractAws2SqsSuppressReceiveSpansTest extends InstrumentationSp "$SemanticAttributes.MESSAGING_DESTINATION_NAME" "testSdkSqs" "$SemanticAttributes.MESSAGING_OPERATION" "process" "$SemanticAttributes.MESSAGING_MESSAGE_ID" String - "$HttpAttributes.ERROR_TYPE" "_OTHER" } } span(2) { @@ -345,6 +344,7 @@ abstract class AbstractAws2SqsSuppressReceiveSpansTest extends InstrumentationSp "rpc.system" "aws-api" "rpc.service" "Sqs" "$SemanticAttributes.HTTP_REQUEST_METHOD" "POST" + "$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200 "$SemanticAttributes.URL_FULL" { it.startsWith("http://localhost:$sqsPort") } "$SemanticAttributes.SERVER_ADDRESS" "localhost" "$SemanticAttributes.SERVER_PORT" sqsPort @@ -352,7 +352,6 @@ abstract class AbstractAws2SqsSuppressReceiveSpansTest extends InstrumentationSp "$SemanticAttributes.MESSAGING_DESTINATION_NAME" "testSdkSqs" "$SemanticAttributes.MESSAGING_OPERATION" "process" "$SemanticAttributes.MESSAGING_MESSAGE_ID" String - "$HttpAttributes.ERROR_TYPE" "_OTHER" } } } @@ -373,6 +372,7 @@ abstract class AbstractAws2SqsSuppressReceiveSpansTest extends InstrumentationSp "rpc.system" "aws-api" "rpc.service" "Sqs" "$SemanticAttributes.HTTP_REQUEST_METHOD" "POST" + "$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200 "$SemanticAttributes.URL_FULL" { it.startsWith("http://localhost:$sqsPort") } "$SemanticAttributes.SERVER_ADDRESS" "localhost" "$SemanticAttributes.SERVER_PORT" sqsPort @@ -380,7 +380,6 @@ abstract class AbstractAws2SqsSuppressReceiveSpansTest extends InstrumentationSp "$SemanticAttributes.MESSAGING_DESTINATION_NAME" "testSdkSqs" "$SemanticAttributes.MESSAGING_OPERATION" "process" "$SemanticAttributes.MESSAGING_MESSAGE_ID" String - "$HttpAttributes.ERROR_TYPE" "_OTHER" } } } diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/testing/src/main/groovy/io/opentelemetry/instrumentation/awssdk/v2_2/AbstractAws2SqsTracingTest.groovy b/instrumentation/aws-sdk/aws-sdk-2.2/testing/src/main/groovy/io/opentelemetry/instrumentation/awssdk/v2_2/AbstractAws2SqsTracingTest.groovy index 973e5df649e1..da79705253f5 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/testing/src/main/groovy/io/opentelemetry/instrumentation/awssdk/v2_2/AbstractAws2SqsTracingTest.groovy +++ b/instrumentation/aws-sdk/aws-sdk-2.2/testing/src/main/groovy/io/opentelemetry/instrumentation/awssdk/v2_2/AbstractAws2SqsTracingTest.groovy @@ -5,7 +5,6 @@ package io.opentelemetry.instrumentation.awssdk.v2_2 -import io.opentelemetry.instrumentation.api.semconv.http.internal.HttpAttributes import io.opentelemetry.instrumentation.test.InstrumentationSpecification import io.opentelemetry.sdk.trace.data.SpanData import io.opentelemetry.semconv.SemanticAttributes @@ -237,6 +236,7 @@ abstract class AbstractAws2SqsTracingTest extends InstrumentationSpecification { "rpc.system" "aws-api" "rpc.service" "Sqs" "$SemanticAttributes.HTTP_REQUEST_METHOD" "POST" + "$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200 "$SemanticAttributes.URL_FULL" { it.startsWith("http://localhost:$sqsPort") } "$SemanticAttributes.SERVER_ADDRESS" "localhost" "$SemanticAttributes.SERVER_PORT" sqsPort @@ -247,7 +247,6 @@ abstract class AbstractAws2SqsTracingTest extends InstrumentationSpecification { if (captureHeaders) { "messaging.header.test_message_header" { it == ["test"] } } - "$HttpAttributes.ERROR_TYPE" "_OTHER" } } span(2 + offset) { @@ -450,6 +449,7 @@ abstract class AbstractAws2SqsTracingTest extends InstrumentationSpecification { "rpc.system" "aws-api" "rpc.service" "Sqs" "$SemanticAttributes.HTTP_REQUEST_METHOD" "POST" + "$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200 "$SemanticAttributes.URL_FULL" { it.startsWith("http://localhost:$sqsPort") } "$SemanticAttributes.SERVER_ADDRESS" "localhost" "$SemanticAttributes.SERVER_PORT" sqsPort @@ -457,7 +457,6 @@ abstract class AbstractAws2SqsTracingTest extends InstrumentationSpecification { "$SemanticAttributes.MESSAGING_DESTINATION_NAME" "testSdkSqs" "$SemanticAttributes.MESSAGING_OPERATION" "process" "$SemanticAttributes.MESSAGING_MESSAGE_ID" String - "$HttpAttributes.ERROR_TYPE" "_OTHER" } } span(1 + 2*i + 1) { diff --git a/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/aws/AwsSpanAssertions.java b/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/aws/AwsSpanAssertions.java index c39f008636d4..eace1083f778 100644 --- a/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/aws/AwsSpanAssertions.java +++ b/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/aws/AwsSpanAssertions.java @@ -12,7 +12,6 @@ import static org.assertj.core.api.Assertions.assertThat; import io.opentelemetry.api.trace.SpanKind; -import io.opentelemetry.instrumentation.api.semconv.http.internal.HttpAttributes; import io.opentelemetry.sdk.testing.assertj.AttributeAssertion; import io.opentelemetry.sdk.testing.assertj.SpanDataAssert; import io.opentelemetry.semconv.SemanticAttributes; @@ -67,6 +66,7 @@ static SpanDataAssert sqs( val.satisfiesAnyOf( v -> assertThat(v).isEqualTo(queueUrl), v -> assertThat(v).isNull())), equalTo(SemanticAttributes.HTTP_REQUEST_METHOD, "POST"), + equalTo(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 200), satisfies(SemanticAttributes.URL_FULL, val -> val.isInstanceOf(String.class)), satisfies( SemanticAttributes.SERVER_ADDRESS, @@ -77,16 +77,11 @@ static SpanDataAssert sqs( val.satisfiesAnyOf( v -> assertThat(v).isNull(), v -> assertThat(v).isInstanceOf(Number.class))), + equalTo(SemanticAttributes.NETWORK_PROTOCOL_VERSION, "1.1"), equalTo(stringKey("rpc.system"), "aws-api"), satisfies(stringKey("rpc.method"), stringAssert -> stringAssert.isEqualTo(rpcMethod)), equalTo(stringKey("rpc.service"), "AmazonSQS"))); - if (!spanName.endsWith("process")) { - attributeAssertions.addAll( - Arrays.asList( - equalTo(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 200), - equalTo(SemanticAttributes.NETWORK_PROTOCOL_VERSION, "1.1"))); - } if (spanName.endsWith("receive") || spanName.endsWith("process") || spanName.endsWith("publish")) { @@ -100,7 +95,6 @@ static SpanDataAssert sqs( attributeAssertions.add(equalTo(SemanticAttributes.MESSAGING_OPERATION, "process")); attributeAssertions.add( satisfies(SemanticAttributes.MESSAGING_MESSAGE_ID, val -> assertThat(val).isNotNull())); - attributeAssertions.add(equalTo(HttpAttributes.ERROR_TYPE, "_OTHER")); } else if (spanName.endsWith("publish")) { attributeAssertions.add(equalTo(SemanticAttributes.MESSAGING_OPERATION, "publish")); attributeAssertions.add(