### Question:
SpanUtils { public static Tracer.SpanBuilder withMessageTags(Tracer.SpanBuilder spanBuilder, Message<?> message) { Tracer.SpanBuilder sb = spanBuilder.withTag(TAG_AXON_ID, message.getIdentifier()) .withTag(TAG_AXON_MESSAGE_TYPE, resolveMessageType(message)) .withTag(TAG_AXON_PAYLOAD_TYPE, message.getPayloadType().getName()); if (message instanceof CommandMessage || message instanceof QueryMessage) { return sb.withTag(TAG_AXON_MESSAGE_NAME, messageName(message)); } else if (message instanceof DomainEventMessage) { return sb.withTag(TAG_AXON_AGGREGATE_ID, ((DomainEventMessage<?>) message).getAggregateIdentifier()); } return sb; }  static Tracer.SpanBuilder withMessageTags(Tracer.SpanBuilder spanBuilder, Message<?> message); static Tracer.SpanBuilder withQueryMessageTags(Tracer.SpanBuilder spanBuilder,
                                                          Message<?> queryMessage,
                                                          String queryName); static String resolveMessageType(Message<?> message); static String messageName(Message<?> message);  }### Answer:
@Test void testWithTagsForEventMessage() { MockTracer.SpanBuilder spanBuilder = mockTracer.buildSpan("operation-name"); SpanUtils.withMessageTags(spanBuilder, TEST_EVENT); MockSpan resultSpan = spanBuilder.start(); Map<String, Object> resultTags = resultSpan.tags(); assertTrue(resultTags.containsKey("axon.message.id")); assertEquals(TEST_EVENT.getIdentifier(), resultTags.get("axon.message.id")); assertTrue(resultTags.containsKey("axon.message.type")); assertEquals("EventMessage", resultTags.get("axon.message.type")); assertTrue(resultTags.containsKey("axon.message.payload-type")); assertEquals(TEST_EVENT.getPayloadType().getName(), resultTags.get("axon.message.payload-type")); }
@Test void testWithTagsForDomainEventMessage() { MockTracer.SpanBuilder spanBuilder = mockTracer.buildSpan("operation-name"); SpanUtils.withMessageTags(spanBuilder, TEST_DOMAIN_EVENT); MockSpan resultSpan = spanBuilder.start(); Map<String, Object> resultTags = resultSpan.tags(); assertTrue(resultTags.containsKey("axon.message.id")); assertEquals(TEST_DOMAIN_EVENT.getIdentifier(), resultTags.get("axon.message.id")); assertTrue(resultTags.containsKey("axon.message.aggregate-identifier")); assertEquals(TEST_DOMAIN_EVENT.getAggregateIdentifier(), resultTags.get("axon.message.aggregate-identifier")); assertTrue(resultTags.containsKey("axon.message.type")); assertEquals("EventMessage", resultTags.get("axon.message.type")); assertTrue(resultTags.containsKey("axon.message.payload-type")); assertEquals(TEST_DOMAIN_EVENT.getPayloadType().getName(), resultTags.get("axon.message.payload-type")); }