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

Rename messaging operation "send" to "publish" per spec #8929

Merged
merged 4 commits into from
Jul 12, 2023
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 @@ -13,7 +13,7 @@
* that may be used in a messaging system.
*/
public enum MessageOperation {
SEND,
PUBLISH,
RECEIVE,
PROCESS;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public void onEnd(
@Override
public SpanKey internalGetSpanKey() {
switch (operation) {
case SEND:
case PUBLISH:
return SpanKey.PRODUCER;
case RECEIVE:
return SpanKey.CONSUMER_RECEIVE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ static Stream<Arguments> destinations() {
void shouldExtractNoAttributesIfNoneAreAvailable() {
// given
AttributesExtractor<Map<String, String>, String> underTest =
MessagingAttributesExtractor.create(TestGetter.INSTANCE, MessageOperation.SEND);
MessagingAttributesExtractor.create(TestGetter.INSTANCE, MessageOperation.PUBLISH);

Context context = Context.root();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void shouldExtractSpanName(

static Stream<Arguments> spanNameParams() {
return Stream.of(
Arguments.of(false, "destination", MessageOperation.SEND, "destination send"),
Arguments.of(false, "destination", MessageOperation.PUBLISH, "destination publish"),
Arguments.of(true, null, MessageOperation.PROCESS, "(temporary) process"),
Arguments.of(false, null, MessageOperation.RECEIVE, "unknown receive"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ class Jms2Test extends AgentInstrumentationSpecification {

static producerSpan(TraceAssert trace, int index, String destinationName, SpanData parentSpan = null) {
trace.span(index) {
name destinationName + " send"
name destinationName + " publish"
kind PRODUCER
if (parentSpan == null) {
hasNoParent()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ class Jms1Test extends AgentInstrumentationSpecification {

static producerSpan(TraceAssert trace, int index, String destinationName, SpanData parentSpan = null, boolean testHeaders = false) {
trace.span(index) {
name destinationName + " send"
name destinationName + " publish"
kind PRODUCER
if (parentSpan == null) {
hasNoParent()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ void testMessageConsumer(DestinationFactory destinationFactory, boolean isTempor
trace.hasSpansSatisfyingExactly(
span -> span.hasName("producer parent").hasNoParent(),
span ->
span.hasName(producerDestinationName + " send")
span.hasName(producerDestinationName + " publish")
.hasKind(PRODUCER)
.hasParent(trace.getSpan(0))
.hasAttributesSatisfyingExactly(
Expand Down Expand Up @@ -206,7 +206,7 @@ void testMessageListener(DestinationFactory destinationFactory, boolean isTempor
trace.hasSpansSatisfyingExactly(
span -> span.hasName("parent").hasNoParent(),
span ->
span.hasName(producerDestinationName + " send")
span.hasName(producerDestinationName + " publish")
.hasKind(PRODUCER)
.hasParent(trace.getSpan(0))
.hasAttributesSatisfyingExactly(
Expand Down Expand Up @@ -289,7 +289,7 @@ void shouldCaptureMessageHeaders(DestinationFactory destinationFactory, boolean
trace.hasSpansSatisfyingExactly(
span -> span.hasName("parent").hasNoParent(),
span ->
span.hasName(producerDestinationName + " send")
span.hasName(producerDestinationName + " publish")
.hasKind(PRODUCER)
.hasParent(trace.getSpan(0))
.hasAttributesSatisfyingExactly(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public JmsInstrumenterFactory setMessagingReceiveInstrumentationEnabled(

public Instrumenter<MessageWithDestination, Void> createProducerInstrumenter() {
JmsMessageAttributesGetter getter = JmsMessageAttributesGetter.INSTANCE;
MessageOperation operation = MessageOperation.SEND;
MessageOperation operation = MessageOperation.PUBLISH;

return Instrumenter.<MessageWithDestination, Void>builder(
openTelemetry,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void testKafkaProducerAndConsumerSpan(boolean testHeaders) throws Exception {
trace.hasSpansSatisfyingExactly(
span -> span.hasName("parent").hasKind(SpanKind.INTERNAL).hasNoParent(),
span ->
span.hasName(SHARED_TOPIC + " send")
span.hasName(SHARED_TOPIC + " publish")
.hasKind(SpanKind.PRODUCER)
.hasParent(trace.getSpan(0))
.hasAttributesSatisfyingExactly(sendAttributes("10", greeting, testHeaders)),
Expand Down Expand Up @@ -134,7 +134,7 @@ void testPassThroughTombstone()
trace -> {
trace.hasSpansSatisfyingExactly(
span ->
span.hasName(SHARED_TOPIC + " send")
span.hasName(SHARED_TOPIC + " publish")
.hasKind(SpanKind.PRODUCER)
.hasNoParent()
.hasAttributesSatisfyingExactly(sendAttributes(null, null, false)));
Expand Down Expand Up @@ -185,7 +185,7 @@ void testRecordsWithTopicPartitionKafkaConsume()
trace -> {
trace.hasSpansSatisfyingExactly(
span ->
span.hasName(SHARED_TOPIC + " send")
span.hasName(SHARED_TOPIC + " publish")
.hasKind(SpanKind.PRODUCER)
.hasNoParent()
.hasAttributesSatisfyingExactly(sendAttributes(null, greeting, false)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void testReadRemoteContextWhenPropagationIsDisabled() throws InterruptedExceptio
trace ->
trace.hasSpansSatisfyingExactly(
span ->
span.hasName(SHARED_TOPIC + " send")
span.hasName(SHARED_TOPIC + " publish")
.hasKind(SpanKind.PRODUCER)
.hasNoParent()
.hasAttributesSatisfyingExactly(sendAttributes(null, message, false))));
Expand All @@ -54,7 +54,7 @@ void testReadRemoteContextWhenPropagationIsDisabled() throws InterruptedExceptio
trace ->
trace.hasSpansSatisfyingExactly(
span ->
span.hasName(SHARED_TOPIC + " send")
span.hasName(SHARED_TOPIC + " publish")
.hasKind(SpanKind.PRODUCER)
.hasNoParent()
.hasAttributesSatisfyingExactly(sendAttributes(null, message, false))),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void testKafkaProduceAndConsume() throws InterruptedException {
trace.hasSpansSatisfyingExactly(
span -> span.hasName("parent").hasKind(SpanKind.INTERNAL).hasNoParent(),
span ->
span.hasName(SHARED_TOPIC + " send")
span.hasName(SHARED_TOPIC + " publish")
.hasKind(SpanKind.PRODUCER)
.hasParent(trace.getSpan(0))
.hasAttributesSatisfyingExactly(sendAttributes("10", greeting, false)),
Expand Down Expand Up @@ -100,7 +100,7 @@ void testPassThroughTombstone()
trace ->
trace.hasSpansSatisfyingExactly(
span ->
span.hasName(SHARED_TOPIC + " send")
span.hasName(SHARED_TOPIC + " publish")
.hasKind(SpanKind.PRODUCER)
.hasNoParent()
.hasAttributesSatisfyingExactly(sendAttributes(null, null, false)),
Expand Down Expand Up @@ -138,7 +138,7 @@ void testRecordsWithTopicPartitionKafkaConsume()
trace ->
trace.hasSpansSatisfyingExactly(
span ->
span.hasName(SHARED_TOPIC + " send")
span.hasName(SHARED_TOPIC + " publish")
.hasKind(SpanKind.PRODUCER)
.hasNoParent()
.hasAttributesSatisfyingExactly(sendAttributes(null, greeting, false)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ void testInterceptors() throws InterruptedException {
span.hasName("parent").hasKind(SpanKind.INTERNAL).hasNoParent();
},
span -> {
span.hasName(SHARED_TOPIC + " send")
span.hasName(SHARED_TOPIC + " publish")
.hasKind(SpanKind.PRODUCER)
.hasParent(trace.getSpan(0))
.hasAttributesSatisfyingExactly(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void testWrappers(boolean testHeaders) throws InterruptedException {
span.hasName("parent").hasKind(SpanKind.INTERNAL).hasNoParent();
},
span -> {
span.hasName(SHARED_TOPIC + " send")
span.hasName(SHARED_TOPIC + " publish")
.hasKind(SpanKind.PRODUCER)
.hasParent(trace.getSpan(0))
.hasAttributesSatisfyingExactly(sendAttributes(testHeaders));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public Instrumenter<KafkaProducerRequest, RecordMetadata> createProducerInstrume
Iterable<AttributesExtractor<KafkaProducerRequest, RecordMetadata>> extractors) {

KafkaProducerAttributesGetter getter = KafkaProducerAttributesGetter.INSTANCE;
MessageOperation operation = MessageOperation.SEND;
MessageOperation operation = MessageOperation.PUBLISH;

return Instrumenter.<KafkaProducerRequest, RecordMetadata>builder(
openTelemetry,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class KafkaStreamsDefaultTest extends KafkaStreamsBaseTest {

assertTraces(3) {
traces.sort(orderByRootSpanName(
STREAM_PENDING + " send",
STREAM_PENDING + " publish",
STREAM_PENDING + " receive",
STREAM_PROCESSED + " receive"))

Expand All @@ -93,7 +93,7 @@ class KafkaStreamsDefaultTest extends KafkaStreamsBaseTest {
trace(0, 1) {
// kafka-clients PRODUCER
span(0) {
name STREAM_PENDING + " send"
name STREAM_PENDING + " publish"
kind PRODUCER
hasNoParent()
attributes {
Expand Down Expand Up @@ -150,7 +150,7 @@ class KafkaStreamsDefaultTest extends KafkaStreamsBaseTest {
}
// kafka-clients PRODUCER
span(2) {
name STREAM_PROCESSED + " send"
name STREAM_PROCESSED + " publish"
kind PRODUCER
childOf span(1)
attributes {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class KafkaStreamsSuppressReceiveSpansTest extends KafkaStreamsBaseTest {
trace(0, 4) {
// kafka-clients PRODUCER
span(0) {
name STREAM_PENDING + " send"
name STREAM_PENDING + " publish"
kind PRODUCER
hasNoParent()
attributes {
Expand Down Expand Up @@ -127,7 +127,7 @@ class KafkaStreamsSuppressReceiveSpansTest extends KafkaStreamsBaseTest {

// kafka-clients PRODUCER
span(2) {
name STREAM_PROCESSED + " send"
name STREAM_PROCESSED + " publish"
kind PRODUCER
childOf span(1)
attributes {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ private static Instrumenter<PulsarRequest, Void> createProducerInstrumenter() {
Instrumenter.<PulsarRequest, Void>builder(
TELEMETRY,
INSTRUMENTATION_NAME,
MessagingSpanNameExtractor.create(getter, MessageOperation.SEND))
MessagingSpanNameExtractor.create(getter, MessageOperation.PUBLISH))
.addAttributesExtractor(
createMessagingAttributesExtractor(getter, MessageOperation.SEND))
createMessagingAttributesExtractor(getter, MessageOperation.PUBLISH))
.addAttributesExtractor(
NetClientAttributesExtractor.create(new PulsarNetClientAttributesGetter()));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ class PulsarClientTest extends AgentInstrumentationSpecification {
kind INTERNAL
hasNoParent()
}
producerSpan(it, 1, span(0), topic, ~/${topic}-partition-.*send/, { it.startsWith(topic) }, msgId)
producerSpan(it, 1, span(0), topic, ~/${topic}-partition-.*publish/, { it.startsWith(topic) }, msgId)
}
}
}
Expand Down Expand Up @@ -503,7 +503,7 @@ class PulsarClientTest extends AgentInstrumentationSpecification {
kind INTERNAL
hasNoParent()
}
producerSpan(it, 1, span(0), topic, ~/${topic}-partition-.*send/, { it.startsWith(topic) }, msgId)
producerSpan(it, 1, span(0), topic, ~/${topic}-partition-.*publish/, { it.startsWith(topic) }, msgId)
receiveSpan(it, 2, span(1), topic, ~/${topic}-partition-.*receive/, { it.startsWith(topic) }, msgId)
processSpan(it, 3, span(2), topic, ~/${topic}-partition-.*process/, { it.startsWith(topic) }, msgId)
}
Expand Down Expand Up @@ -578,7 +578,7 @@ class PulsarClientTest extends AgentInstrumentationSpecification {
if (namePattern != null) {
name namePattern
} else {
name "$topic send"
name "$topic publish"
}
kind PRODUCER
childOf parentSpan
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static RabbitInstrumenterHelper helper() {
public void onPublish(Span span, String exchange, String routingKey) {
String exchangeName = normalizeExchangeName(exchange);
span.setAttribute(SemanticAttributes.MESSAGING_DESTINATION_NAME, exchangeName);
span.updateName(exchangeName + " send");
span.updateName(exchangeName + " publish");
if (routingKey != null && !routingKey.isEmpty()) {
span.setAttribute(SemanticAttributes.MESSAGING_RABBITMQ_DESTINATION_ROUTING_KEY, routingKey);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ private static Instrumenter<ChannelAndMethod, Void> createChannelInstrumenter()
GlobalOpenTelemetry.get(), instrumentationName, ChannelAndMethod::getMethod)
.addAttributesExtractor(
buildMessagingAttributesExtractor(
RabbitChannelAttributesGetter.INSTANCE, MessageOperation.SEND))
RabbitChannelAttributesGetter.INSTANCE, MessageOperation.PUBLISH))
.addAttributesExtractor(
NetClientAttributesExtractor.create(new RabbitChannelNetAttributesGetter()))
.addContextCustomizer(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class RabbitMqTest extends AgentInstrumentationSpecification implements WithRabb
rabbitSpan(it, 1, null, null, null, "exchange.declare", span(0))
rabbitSpan(it, 2, null, null, null, "queue.declare", span(0))
rabbitSpan(it, 3, null, null, null, "queue.bind", span(0))
rabbitSpan(it, 4, exchangeName, routingKey, "send", "$exchangeName", span(0))
rabbitSpan(it, 4, exchangeName, routingKey, "publish", "$exchangeName", span(0))

producerSpan = span(4)
}
Expand Down Expand Up @@ -124,7 +124,7 @@ class RabbitMqTest extends AgentInstrumentationSpecification implements WithRabb
hasNoParent()
}
rabbitSpan(it, 1, null, null, null, "queue.declare", span(0))
rabbitSpan(it, 2, "<default>", null, "send", "<default>", span(0))
rabbitSpan(it, 2, "<default>", null, "publish", "<default>", span(0))

producerSpan = span(2)
}
Expand Down Expand Up @@ -185,7 +185,7 @@ class RabbitMqTest extends AgentInstrumentationSpecification implements WithRabb
}
(1..messageCount).each {
trace(3 + it, 2) {
rabbitSpan(it, 0, exchangeName, null, "send", "$exchangeName")
rabbitSpan(it, 0, exchangeName, null, "publish", "$exchangeName")
rabbitSpan(it, 1, exchangeName, null, "process", resource, span(0), null, null, null, setTimestamp)
}
}
Expand Down Expand Up @@ -239,7 +239,7 @@ class RabbitMqTest extends AgentInstrumentationSpecification implements WithRabb
rabbitSpan(it, 0, null, null, null, "basic.consume")
}
trace(4, 2) {
rabbitSpan(it, 0, exchangeName, null, "send", "$exchangeName")
rabbitSpan(it, 0, exchangeName, null, "publish", "$exchangeName")
rabbitSpan(it, 1, exchangeName, null, "process", "<generated>", span(0), null, error, error.message)
}
}
Expand Down Expand Up @@ -304,7 +304,7 @@ class RabbitMqTest extends AgentInstrumentationSpecification implements WithRabb
hasNoParent()
}
rabbitSpan(it, 1, null, null, null, "queue.declare", span(0))
rabbitSpan(it, 2, "<default>", "some-routing-queue", "send", "<default>", span(0))
rabbitSpan(it, 2, "<default>", "some-routing-queue", "publish", "<default>", span(0))

producerSpan = span(2)
}
Expand Down Expand Up @@ -351,7 +351,7 @@ class RabbitMqTest extends AgentInstrumentationSpecification implements WithRabb
rabbitSpan(it, 0, null, null, null, "queue.declare")
}
trace(1, 2) {
rabbitSpan(it, 0, "<default>", null, "send", "<default>", null, null, null, null, false, true)
rabbitSpan(it, 0, "<default>", null, "publish", "<default>", null, null, null, null, false, true)
rabbitSpan(it, 1, "<default>", null, "process", "<generated>", span(0), null, null, null, false, true)
}
trace(2, 1) {
Expand Down Expand Up @@ -428,7 +428,7 @@ class RabbitMqTest extends AgentInstrumentationSpecification implements WithRabb
"$SemanticAttributes.MESSAGING_DESTINATION_NAME" exchange

"$SemanticAttributes.MESSAGING_RABBITMQ_DESTINATION_ROUTING_KEY" { it == null || it == routingKey || it.startsWith("amq.gen-") }
if (operation != null && operation != "send") {
if (operation != null && operation != "publish") {
"$SemanticAttributes.MESSAGING_OPERATION" operation
}
if (expectTimestamp) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ protected void testSingleRecordProcess(
trace.hasSpansSatisfyingExactly(
span -> span.hasName("producer"),
span ->
span.hasName("testTopic send")
span.hasName("testTopic publish")
.hasKind(SpanKind.PRODUCER)
.hasParent(trace.getSpan(0))
.hasAttributesSatisfyingExactly(sendAttributes(record)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ static Instrumenter<SendMessageContext, Void> createProducerInstrumenter(
boolean propagationEnabled) {

RocketMqProducerAttributeGetter getter = RocketMqProducerAttributeGetter.INSTANCE;
MessageOperation operation = MessageOperation.SEND;
MessageOperation operation = MessageOperation.PUBLISH;

InstrumenterBuilder<SendMessageContext, Void> instrumenterBuilder =
Instrumenter.<SendMessageContext, Void>builder(
Expand Down
Loading