Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update attribute key of rocketmq's message tag #6677

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import java.net.SocketAddress;
import javax.annotation.Nullable;
import org.apache.rocketmq.common.message.MessageExt;
Expand All @@ -17,8 +18,6 @@ enum RocketMqConsumerExperimentalAttributeExtractor
implements AttributesExtractor<MessageExt, Void> {
INSTANCE;

private static final AttributeKey<String> MESSAGING_ROCKETMQ_TAGS =
AttributeKey.stringKey("messaging.rocketmq.tags");
private static final AttributeKey<Long> MESSAGING_ROCKETMQ_QUEUE_ID =
AttributeKey.longKey("messaging.rocketmq.queue_id");
private static final AttributeKey<Long> MESSAGING_ROCKETMQ_QUEUE_OFFSET =
Expand All @@ -30,7 +29,7 @@ enum RocketMqConsumerExperimentalAttributeExtractor
public void onStart(AttributesBuilder attributes, Context parentContext, MessageExt msg) {
String tags = msg.getTags();
if (tags != null) {
attributes.put(MESSAGING_ROCKETMQ_TAGS, tags);
attributes.put(SemanticAttributes.MESSAGING_ROCKETMQ_MESSAGE_TAG, tags);
}
attributes.put(MESSAGING_ROCKETMQ_QUEUE_ID, msg.getQueueId());
attributes.put(MESSAGING_ROCKETMQ_QUEUE_OFFSET, msg.getQueueOffset());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@
import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import javax.annotation.Nullable;
import org.apache.rocketmq.client.hook.SendMessageContext;

enum RocketMqProducerExperimentalAttributeExtractor
implements AttributesExtractor<SendMessageContext, Void> {
INSTANCE;

private static final AttributeKey<String> MESSAGING_ROCKETMQ_TAGS =
AttributeKey.stringKey("messaging.rocketmq.tags");
private static final AttributeKey<String> MESSAGING_ROCKETMQ_BROKER_ADDRESS =
AttributeKey.stringKey("messaging.rocketmq.broker_address");
private static final AttributeKey<String> MESSAGING_ROCKETMQ_SEND_RESULT =
Expand All @@ -29,7 +28,7 @@ public void onStart(
if (request.getMessage() != null) {
String tags = request.getMessage().getTags();
if (tags != null) {
attributes.put(MESSAGING_ROCKETMQ_TAGS, tags);
attributes.put(SemanticAttributes.MESSAGING_ROCKETMQ_MESSAGE_TAG, tags);
}
}
String brokerAddr = request.getBrokerAddr();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ abstract class AbstractRocketMqClientTest extends InstrumentationSpecification {
"$SemanticAttributes.MESSAGING_DESTINATION" sharedTopic
"$SemanticAttributes.MESSAGING_DESTINATION_KIND" "topic"
"$SemanticAttributes.MESSAGING_MESSAGE_ID" String
"messaging.rocketmq.tags" "TagA"
"$SemanticAttributes.MESSAGING_ROCKETMQ_MESSAGE_TAG" "TagA"
"messaging.rocketmq.broker_address" String
"messaging.rocketmq.send_result" "SEND_OK"
}
Expand All @@ -118,7 +118,7 @@ abstract class AbstractRocketMqClientTest extends InstrumentationSpecification {
"$SemanticAttributes.MESSAGING_OPERATION" "process"
"$SemanticAttributes.MESSAGING_MESSAGE_PAYLOAD_SIZE_BYTES" Long
"$SemanticAttributes.MESSAGING_MESSAGE_ID" String
"messaging.rocketmq.tags" "TagA"
"$SemanticAttributes.MESSAGING_ROCKETMQ_MESSAGE_TAG" "TagA"
"messaging.rocketmq.broker_address" String
"messaging.rocketmq.queue_id" Long
"messaging.rocketmq.queue_offset" Long
Expand Down Expand Up @@ -158,7 +158,7 @@ abstract class AbstractRocketMqClientTest extends InstrumentationSpecification {
"$SemanticAttributes.MESSAGING_DESTINATION" sharedTopic
"$SemanticAttributes.MESSAGING_DESTINATION_KIND" "topic"
"$SemanticAttributes.MESSAGING_MESSAGE_ID" String
"messaging.rocketmq.tags" "TagA"
"$SemanticAttributes.MESSAGING_ROCKETMQ_MESSAGE_TAG" "TagA"
"messaging.rocketmq.broker_address" String
"messaging.rocketmq.send_result" "SEND_OK"
}
Expand All @@ -174,7 +174,7 @@ abstract class AbstractRocketMqClientTest extends InstrumentationSpecification {
"$SemanticAttributes.MESSAGING_OPERATION" "process"
"$SemanticAttributes.MESSAGING_MESSAGE_PAYLOAD_SIZE_BYTES" Long
"$SemanticAttributes.MESSAGING_MESSAGE_ID" String
"messaging.rocketmq.tags" "TagA"
"$SemanticAttributes.MESSAGING_ROCKETMQ_MESSAGE_TAG" "TagA"
"messaging.rocketmq.broker_address" String
"messaging.rocketmq.queue_id" Long
"messaging.rocketmq.queue_offset" Long
Expand Down Expand Up @@ -261,7 +261,7 @@ abstract class AbstractRocketMqClientTest extends InstrumentationSpecification {
"$SemanticAttributes.MESSAGING_OPERATION" "process"
"$SemanticAttributes.MESSAGING_MESSAGE_PAYLOAD_SIZE_BYTES" Long
"$SemanticAttributes.MESSAGING_MESSAGE_ID" String
"messaging.rocketmq.tags" "TagA"
"$SemanticAttributes.MESSAGING_ROCKETMQ_MESSAGE_TAG" "TagA"
"messaging.rocketmq.broker_address" String
"messaging.rocketmq.queue_id" Long
"messaging.rocketmq.queue_offset" Long
Expand All @@ -279,7 +279,7 @@ abstract class AbstractRocketMqClientTest extends InstrumentationSpecification {
"$SemanticAttributes.MESSAGING_OPERATION" "process"
"$SemanticAttributes.MESSAGING_MESSAGE_PAYLOAD_SIZE_BYTES" Long
"$SemanticAttributes.MESSAGING_MESSAGE_ID" String
"messaging.rocketmq.tags" "TagB"
"$SemanticAttributes.MESSAGING_ROCKETMQ_MESSAGE_TAG" "TagB"
"messaging.rocketmq.broker_address" String
"messaging.rocketmq.queue_id" Long
"messaging.rocketmq.queue_offset" Long
Expand Down Expand Up @@ -323,7 +323,7 @@ abstract class AbstractRocketMqClientTest extends InstrumentationSpecification {
"$SemanticAttributes.MESSAGING_DESTINATION" sharedTopic
"$SemanticAttributes.MESSAGING_DESTINATION_KIND" "topic"
"$SemanticAttributes.MESSAGING_MESSAGE_ID" String
"messaging.rocketmq.tags" "TagA"
"$SemanticAttributes.MESSAGING_ROCKETMQ_MESSAGE_TAG" "TagA"
"messaging.rocketmq.broker_address" String
"messaging.rocketmq.send_result" "SEND_OK"
"messaging.header.test_message_header" { it == ["test"] }
Expand All @@ -340,7 +340,7 @@ abstract class AbstractRocketMqClientTest extends InstrumentationSpecification {
"$SemanticAttributes.MESSAGING_OPERATION" "process"
"$SemanticAttributes.MESSAGING_MESSAGE_PAYLOAD_SIZE_BYTES" Long
"$SemanticAttributes.MESSAGING_MESSAGE_ID" String
"messaging.rocketmq.tags" "TagA"
"$SemanticAttributes.MESSAGING_ROCKETMQ_MESSAGE_TAG" "TagA"
"messaging.rocketmq.broker_address" String
"messaging.rocketmq.queue_id" Long
"messaging.rocketmq.queue_offset" Long
Expand Down