Skip to content

Commit aa329c2

Browse files
committed
Remove messaging header normalization
1 parent a622d7c commit aa329c2

File tree

11 files changed

+141
-263
lines changed

11 files changed

+141
-263
lines changed

instrumentation/aws-sdk/aws-sdk-1.11/testing/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/AbstractSqsTracingTest.java

Lines changed: 16 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
package io.opentelemetry.instrumentation.awssdk.v1_11;
77

8-
import static io.opentelemetry.api.common.AttributeKey.stringArrayKey;
98
import static io.opentelemetry.api.common.AttributeKey.stringKey;
109
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo;
1110
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.satisfies;
@@ -40,9 +39,9 @@
4039
import com.amazonaws.services.sqs.model.SendMessageRequest;
4140
import io.opentelemetry.api.common.Attributes;
4241
import io.opentelemetry.api.trace.SpanKind;
43-
import io.opentelemetry.instrumentation.api.internal.SemconvStability;
4442
import io.opentelemetry.instrumentation.test.utils.PortUtils;
4543
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
44+
import io.opentelemetry.instrumentation.testing.junit.message.SemconvMessageStabilityUtil;
4645
import io.opentelemetry.sdk.testing.assertj.AttributeAssertion;
4746
import io.opentelemetry.sdk.testing.assertj.SpanDataAssert;
4847
import io.opentelemetry.sdk.trace.data.SpanData;
@@ -181,18 +180,11 @@ void testSimpleSqsProducerConsumerServicesCaptureHeaders(boolean testCaptureHead
181180
equalTo(NETWORK_PROTOCOL_VERSION, "1.1")));
182181

183182
if (testCaptureHeaders) {
184-
if (SemconvStability.isEmitOldMessageSemconv()) {
185-
attributes.add(
186-
satisfies(
187-
stringArrayKey("messaging.header.Test_Message_Header"),
188-
val -> val.isEqualTo(singletonList("test"))));
189-
}
190-
if (SemconvStability.isEmitStableMessageSemconv()) {
191-
attributes.add(
192-
satisfies(
193-
stringArrayKey("messaging.header.Test-Message-Header"),
194-
val -> val.isEqualTo(singletonList("test"))));
195-
}
183+
attributes.add(
184+
satisfies(
185+
SemconvMessageStabilityUtil.headerAttributeKey(
186+
"Test-Message-Header"),
187+
val -> val.isEqualTo(singletonList("test"))));
196188
}
197189

198190
span.hasName("testSdkSqs publish")
@@ -229,18 +221,11 @@ void testSimpleSqsProducerConsumerServicesCaptureHeaders(boolean testCaptureHead
229221
equalTo(NETWORK_PROTOCOL_VERSION, "1.1")));
230222

231223
if (testCaptureHeaders) {
232-
if (SemconvStability.isEmitOldMessageSemconv()) {
233-
attributes.add(
234-
satisfies(
235-
stringArrayKey("messaging.header.Test_Message_Header"),
236-
val -> val.isEqualTo(singletonList("test"))));
237-
}
238-
if (SemconvStability.isEmitStableMessageSemconv()) {
239-
attributes.add(
240-
satisfies(
241-
stringArrayKey("messaging.header.Test-Message-Header"),
242-
val -> val.isEqualTo(singletonList("test"))));
243-
}
224+
attributes.add(
225+
satisfies(
226+
SemconvMessageStabilityUtil.headerAttributeKey(
227+
"Test-Message-Header"),
228+
val -> val.isEqualTo(singletonList("test"))));
244229
}
245230

246231
span.hasName("testSdkSqs receive")
@@ -276,18 +261,11 @@ void testSimpleSqsProducerConsumerServicesCaptureHeaders(boolean testCaptureHead
276261
equalTo(NETWORK_PROTOCOL_VERSION, "1.1")));
277262

278263
if (testCaptureHeaders) {
279-
if (SemconvStability.isEmitOldMessageSemconv()) {
280-
attributes.add(
281-
satisfies(
282-
stringArrayKey("messaging.header.Test_Message_Header"),
283-
val -> val.isEqualTo(singletonList("test"))));
284-
}
285-
if (SemconvStability.isEmitStableMessageSemconv()) {
286-
attributes.add(
287-
satisfies(
288-
stringArrayKey("messaging.header.Test-Message-Header"),
289-
val -> val.isEqualTo(singletonList("test"))));
290-
}
264+
attributes.add(
265+
satisfies(
266+
SemconvMessageStabilityUtil.headerAttributeKey(
267+
"Test-Message-Header"),
268+
val -> val.isEqualTo(singletonList("test"))));
291269
}
292270
span.hasName("testSdkSqs process")
293271
.hasKind(SpanKind.CONSUMER)

instrumentation/aws-sdk/aws-sdk-2.2/testing/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AbstractAws2SqsTracingTest.java

Lines changed: 16 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
package io.opentelemetry.instrumentation.awssdk.v2_2;
77

8-
import static io.opentelemetry.api.common.AttributeKey.stringArrayKey;
98
import static io.opentelemetry.api.common.AttributeKey.stringKey;
109
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo;
1110
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.satisfies;
@@ -29,7 +28,7 @@
2928

3029
import io.opentelemetry.api.common.Attributes;
3130
import io.opentelemetry.api.trace.SpanKind;
32-
import io.opentelemetry.instrumentation.api.internal.SemconvStability;
31+
import io.opentelemetry.instrumentation.testing.junit.message.SemconvMessageStabilityUtil;
3332
import io.opentelemetry.sdk.testing.assertj.AttributeAssertion;
3433
import io.opentelemetry.sdk.testing.assertj.SpanDataAssert;
3534
import io.opentelemetry.sdk.trace.data.SpanData;
@@ -92,18 +91,11 @@ protected void assertSqsTraces(boolean withParent, boolean captureHeaders) {
9291
MESSAGING_MESSAGE_ID, v -> v.isInstanceOf(String.class))));
9392

9493
if (captureHeaders) {
95-
if (SemconvStability.isEmitOldMessageSemconv()) {
96-
attributes.add(
97-
satisfies(
98-
stringKey("messaging.header.Test_Message_Header"),
99-
v -> v.isEqualTo("test")));
100-
}
101-
if (SemconvStability.isEmitStableMessageSemconv()) {
102-
attributes.add(
103-
satisfies(
104-
stringArrayKey("messaging.header.Test-Message-Header"),
105-
v -> v.isEqualTo(ImmutableList.of("test"))));
106-
}
94+
attributes.add(
95+
satisfies(
96+
SemconvMessageStabilityUtil.headerAttributeKey(
97+
"Test-Message-Header"),
98+
v -> v.isEqualTo(ImmutableList.of("test"))));
10799
}
108100
span.hasName("testSdkSqs publish")
109101
.hasKind(SpanKind.PRODUCER)
@@ -170,18 +162,11 @@ protected void assertSqsTraces(boolean withParent, boolean captureHeaders) {
170162
equalTo(MESSAGING_BATCH_MESSAGE_COUNT, 1)));
171163

172164
if (captureHeaders) {
173-
if (SemconvStability.isEmitOldMessageSemconv()) {
174-
attributes.add(
175-
satisfies(
176-
stringKey("messaging.header.Test_Message_Header"),
177-
v -> v.isEqualTo("test")));
178-
}
179-
if (SemconvStability.isEmitStableMessageSemconv()) {
180-
attributes.add(
181-
satisfies(
182-
stringArrayKey("messaging.header.Test-Message-Header"),
183-
v -> v.isEqualTo(ImmutableList.of("test"))));
184-
}
165+
attributes.add(
166+
satisfies(
167+
SemconvMessageStabilityUtil.headerAttributeKey(
168+
"Test-Message-Header"),
169+
v -> v.isEqualTo(ImmutableList.of("test"))));
185170
}
186171

187172
if (withParent) {
@@ -216,18 +201,11 @@ protected void assertSqsTraces(boolean withParent, boolean captureHeaders) {
216201
MESSAGING_MESSAGE_ID, v -> v.isInstanceOf(String.class))));
217202

218203
if (captureHeaders) {
219-
if (SemconvStability.isEmitOldMessageSemconv()) {
220-
attributes.add(
221-
satisfies(
222-
stringKey("messaging.header.Test_Message_Header"),
223-
v -> v.isEqualTo("test")));
224-
}
225-
if (SemconvStability.isEmitStableMessageSemconv()) {
226-
attributes.add(
227-
satisfies(
228-
stringArrayKey("messaging.header.Test-Message-Header"),
229-
v -> v.isEqualTo(singletonList("test"))));
230-
}
204+
attributes.add(
205+
satisfies(
206+
SemconvMessageStabilityUtil.headerAttributeKey(
207+
"Test-Message-Header"),
208+
v -> v.isEqualTo(singletonList("test"))));
231209
}
232210

233211
span.hasName("testSdkSqs process")

instrumentation/kafka/kafka-clients/kafka-clients-0.11/testing/src/main/java/io/opentelemetry/instrumentation/kafkaclients/common/v0_11/internal/KafkaClientBaseTest.java

Lines changed: 13 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import static io.opentelemetry.semconv.incubating.MessagingIncubatingAttributes.MESSAGING_SYSTEM;
2020

2121
import io.opentelemetry.api.common.AttributeKey;
22-
import io.opentelemetry.instrumentation.api.internal.SemconvStability;
22+
import io.opentelemetry.instrumentation.testing.junit.message.SemconvMessageStabilityUtil;
2323
import io.opentelemetry.sdk.testing.assertj.AttributeAssertion;
2424
import java.nio.charset.StandardCharsets;
2525
import java.time.Duration;
@@ -187,18 +187,10 @@ protected static List<AttributeAssertion> sendAttributes(
187187
assertions.add(equalTo(MESSAGING_KAFKA_MESSAGE_TOMBSTONE, true));
188188
}
189189
if (testHeaders) {
190-
if (SemconvStability.isEmitOldMessageSemconv()) {
191-
assertions.add(
192-
equalTo(
193-
AttributeKey.stringArrayKey("messaging.header.Test_Message_Header"),
194-
Collections.singletonList("test")));
195-
}
196-
if (SemconvStability.isEmitStableMessageSemconv()) {
197-
assertions.add(
198-
equalTo(
199-
AttributeKey.stringArrayKey("messaging.header.Test-Message-Header"),
200-
Collections.singletonList("test")));
201-
}
190+
assertions.add(
191+
equalTo(
192+
SemconvMessageStabilityUtil.headerAttributeKey("Test-Message-Header"),
193+
Collections.singletonList("test")));
202194
}
203195
return assertions;
204196
}
@@ -218,18 +210,10 @@ protected static List<AttributeAssertion> receiveAttributes(boolean testHeaders)
218210
assertions.add(equalTo(MESSAGING_KAFKA_CONSUMER_GROUP, "test"));
219211
}
220212
if (testHeaders) {
221-
if (SemconvStability.isEmitOldMessageSemconv()) {
222-
assertions.add(
223-
equalTo(
224-
AttributeKey.stringArrayKey("messaging.header.Test_Message_Header"),
225-
Collections.singletonList("test")));
226-
}
227-
if (SemconvStability.isEmitStableMessageSemconv()) {
228-
assertions.add(
229-
equalTo(
230-
AttributeKey.stringArrayKey("messaging.header.Test-Message-Header"),
231-
Collections.singletonList("test")));
232-
}
213+
assertions.add(
214+
equalTo(
215+
SemconvMessageStabilityUtil.headerAttributeKey("Test-Message-Header"),
216+
Collections.singletonList("test")));
233217
}
234218
return assertions;
235219
}
@@ -264,18 +248,10 @@ protected static List<AttributeAssertion> processAttributes(
264248
MESSAGING_MESSAGE_BODY_SIZE, messageValue.getBytes(StandardCharsets.UTF_8).length));
265249
}
266250
if (testHeaders) {
267-
if (SemconvStability.isEmitOldMessageSemconv()) {
268-
assertions.add(
269-
equalTo(
270-
AttributeKey.stringArrayKey("messaging.header.Test_Message_Header"),
271-
Collections.singletonList("test")));
272-
}
273-
if (SemconvStability.isEmitStableMessageSemconv()) {
274-
assertions.add(
275-
equalTo(
276-
AttributeKey.stringArrayKey("messaging.header.Test-Message-Header"),
277-
Collections.singletonList("test")));
278-
}
251+
assertions.add(
252+
equalTo(
253+
SemconvMessageStabilityUtil.headerAttributeKey("Test-Message-Header"),
254+
Collections.singletonList("test")));
279255
}
280256

281257
if (testMultiBaggage) {

instrumentation/kafka/kafka-clients/kafka-clients-2.6/library/src/test/java/io/opentelemetry/instrumentation/kafkaclients/v2_6/InterceptorsTest.java

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,11 @@
1919
import static java.util.Collections.singletonList;
2020
import static org.assertj.core.api.Assertions.assertThat;
2121

22-
import io.opentelemetry.api.common.AttributeKey;
2322
import io.opentelemetry.api.trace.SpanContext;
2423
import io.opentelemetry.api.trace.SpanKind;
25-
import io.opentelemetry.instrumentation.api.internal.SemconvStability;
24+
import io.opentelemetry.instrumentation.testing.junit.message.SemconvMessageStabilityUtil;
2625
import io.opentelemetry.sdk.trace.data.LinkData;
2726
import java.nio.charset.StandardCharsets;
28-
import java.util.List;
2927
import java.util.concurrent.atomic.AtomicReference;
3028
import org.assertj.core.api.AbstractLongAssert;
3129
import org.assertj.core.api.AbstractStringAssert;
@@ -46,7 +44,9 @@ void assertTraces() {
4644
.hasKind(SpanKind.PRODUCER)
4745
.hasParent(trace.getSpan(0))
4846
.hasAttributesSatisfyingExactly(
49-
equalTo(headerAttributeKey(), singletonList("test")),
47+
equalTo(
48+
SemconvMessageStabilityUtil.headerAttributeKey("Test-Message-Header"),
49+
singletonList("test")),
5050
equalTo(MESSAGING_SYSTEM, "kafka"),
5151
equalTo(MESSAGING_DESTINATION_NAME, SHARED_TOPIC),
5252
equalTo(MESSAGING_OPERATION, "publish"),
@@ -69,7 +69,10 @@ void assertTraces() {
6969
.hasNoParent()
7070
.hasLinksSatisfying(links -> assertThat(links).isEmpty())
7171
.hasAttributesSatisfyingExactly(
72-
equalTo(headerAttributeKey(), singletonList("test")),
72+
equalTo(
73+
SemconvMessageStabilityUtil.headerAttributeKey(
74+
"Test-Message-Header"),
75+
singletonList("test")),
7376
equalTo(MESSAGING_SYSTEM, "kafka"),
7477
equalTo(MESSAGING_DESTINATION_NAME, SHARED_TOPIC),
7578
equalTo(MESSAGING_OPERATION, "receive"),
@@ -84,7 +87,10 @@ void assertTraces() {
8487
.hasParent(trace.getSpan(0))
8588
.hasLinks(LinkData.create(producerSpanContext.get()))
8689
.hasAttributesSatisfyingExactly(
87-
equalTo(headerAttributeKey(), singletonList("test")),
90+
equalTo(
91+
SemconvMessageStabilityUtil.headerAttributeKey(
92+
"Test-Message-Header"),
93+
singletonList("test")),
8894
equalTo(MESSAGING_SYSTEM, "kafka"),
8995
equalTo(MESSAGING_DESTINATION_NAME, SHARED_TOPIC),
9096
equalTo(MESSAGING_OPERATION, "process"),
@@ -111,12 +117,4 @@ void assertTraces() {
111117
span ->
112118
span.hasName("producer callback").hasKind(SpanKind.INTERNAL).hasNoParent()));
113119
}
114-
115-
private static AttributeKey<List<String>> headerAttributeKey() {
116-
if (SemconvStability.isEmitOldMessageSemconv()) {
117-
return AttributeKey.stringArrayKey("messaging.header.Test_Message_Header");
118-
} else {
119-
return AttributeKey.stringArrayKey("messaging.header.Test-Message-Header");
120-
}
121-
}
122120
}

instrumentation/kafka/kafka-clients/kafka-clients-2.6/library/src/test/java/io/opentelemetry/instrumentation/kafkaclients/v2_6/WrapperSuppressReceiveSpansTest.java

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
import io.opentelemetry.api.common.AttributeKey;
1919
import io.opentelemetry.api.trace.SpanKind;
20-
import io.opentelemetry.instrumentation.api.internal.SemconvStability;
20+
import io.opentelemetry.instrumentation.testing.junit.message.SemconvMessageStabilityUtil;
2121
import io.opentelemetry.sdk.testing.assertj.AttributeAssertion;
2222
import java.nio.charset.StandardCharsets;
2323
import java.util.ArrayList;
@@ -72,18 +72,10 @@ protected static List<AttributeAssertion> sendAttributes(boolean testHeaders) {
7272
satisfies(MESSAGING_DESTINATION_PARTITION_ID, AbstractStringAssert::isNotEmpty),
7373
satisfies(MESSAGING_KAFKA_MESSAGE_OFFSET, AbstractLongAssert::isNotNegative)));
7474
if (testHeaders) {
75-
if (SemconvStability.isEmitOldMessageSemconv()) {
76-
assertions.add(
77-
equalTo(
78-
AttributeKey.stringArrayKey("messaging.header.Test_Message_Header"),
79-
Collections.singletonList("test")));
80-
}
81-
if (SemconvStability.isEmitStableMessageSemconv()) {
82-
assertions.add(
83-
equalTo(
84-
AttributeKey.stringArrayKey("messaging.header.Test-Message-Header"),
85-
Collections.singletonList("test")));
86-
}
75+
assertions.add(
76+
equalTo(
77+
SemconvMessageStabilityUtil.headerAttributeKey("Test-Message-Header"),
78+
Collections.singletonList("test")));
8779
}
8880
return assertions;
8981
}
@@ -107,18 +99,10 @@ private static List<AttributeAssertion> processAttributes(String greeting, boole
10799
satisfies(
108100
MESSAGING_CLIENT_ID, stringAssert -> stringAssert.startsWith("consumer"))));
109101
if (testHeaders) {
110-
if (SemconvStability.isEmitOldMessageSemconv()) {
111-
assertions.add(
112-
equalTo(
113-
AttributeKey.stringArrayKey("messaging.header.Test_Message_Header"),
114-
Collections.singletonList("test")));
115-
}
116-
if (SemconvStability.isEmitStableMessageSemconv()) {
117-
assertions.add(
118-
equalTo(
119-
AttributeKey.stringArrayKey("messaging.header.Test-Message-Header"),
120-
Collections.singletonList("test")));
121-
}
102+
assertions.add(
103+
equalTo(
104+
SemconvMessageStabilityUtil.headerAttributeKey("Test-Message-Header"),
105+
Collections.singletonList("test")));
122106
}
123107
return assertions;
124108
}

0 commit comments

Comments
 (0)