Skip to content

Commit 6dd3f8e

Browse files
committed
Address review comments from copilot-pull-request-reviewer: fix stable batch receive destination
1 parent 22ddf57 commit 6dd3f8e

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

instrumentation/rocketmq/rocketmq-client-4.8/library/src/main/java/io/opentelemetry/instrumentation/rocketmqclient/v4_8/RocketMqInstrumenterFactory.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ class RocketMqInstrumenterFactory {
3838
// copied from MessagingIncubatingAttributes
3939
private static final AttributeKey<String> MESSAGING_CONSUMER_GROUP_NAME =
4040
AttributeKey.stringKey("messaging.consumer.group.name");
41+
private static final AttributeKey<String> MESSAGING_DESTINATION_NAME =
42+
AttributeKey.stringKey("messaging.destination.name");
4143
private static final AttributeKey<String> MESSAGING_OPERATION =
4244
AttributeKey.stringKey("messaging.operation");
4345
private static final AttributeKey<String> MESSAGING_OPERATION_NAME =
@@ -119,6 +121,7 @@ public void onStart(
119121
RocketMqConsumerRequest request) {
120122
attributes.put(MESSAGING_BATCH_MESSAGE_COUNT, request.getBatchSize());
121123
attributes.put(MESSAGING_CONSUMER_GROUP_NAME, request.getConsumerGroup());
124+
attributes.put(MESSAGING_DESTINATION_NAME, request.getMessage().getTopic());
122125
attributes.put(MESSAGING_ROCKETMQ_NAMESPACE, request.getNamespace());
123126
}
124127

@@ -209,8 +212,10 @@ private static <T, R> AttributesExtractor<T, R> buildMessagingAttributesExtracto
209212
.build();
210213
}
211214

212-
private static String spanNameOnReceive(RocketMqConsumerRequest unused) {
213-
return emitStableMessagingSemconv() ? "receive multiple_sources" : "multiple_sources receive";
215+
private static String spanNameOnReceive(RocketMqConsumerRequest request) {
216+
return emitStableMessagingSemconv()
217+
? "receive " + request.getMessage().getTopic()
218+
: "multiple_sources receive";
214219
}
215220

216221
private RocketMqInstrumenterFactory() {}

instrumentation/rocketmq/rocketmq-client-4.8/testing/src/main/java/io/opentelemetry/instrumentation/rocketmqclient/v4_8/AbstractRocketMqClientTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,13 +422,16 @@ private void runBatchConsumeTest(boolean failConsumption) throws Exception {
422422
span ->
423423
span.hasName(
424424
emitStableMessagingSemconv()
425-
? "receive multiple_sources"
425+
? "receive " + sharedTopic
426426
: "multiple_sources receive")
427427
.hasKind(emitStableMessagingSemconv() ? CLIENT : CONSUMER)
428428
.hasAttributesSatisfyingExactly(
429429
equalTo(MESSAGING_SYSTEM, "rocketmq"),
430430
namespace(),
431431
consumerGroup(),
432+
equalTo(
433+
MESSAGING_DESTINATION_NAME,
434+
emitStableMessagingSemconv() ? sharedTopic : null),
432435
equalTo(
433436
MESSAGING_BATCH_MESSAGE_COUNT,
434437
emitStableMessagingSemconv() ? Long.valueOf(2) : null),

0 commit comments

Comments
 (0)