### Question:
OpenTraceHandlerInterceptor implements MessageHandlerInterceptor<Message<?>> { @Override public Object handle(UnitOfWork unitOfWork, InterceptorChain interceptorChain) throws Exception { Message<?> message = unitOfWork.getMessage(); String operationName = "handle_" + SpanUtils.messageName(message); Tracer.SpanBuilder spanBuilder = getParentSpan(message) .map(parentSpan -> tracer.buildSpan(operationName).asChildOf(parentSpan)) .orElse(tracer.buildSpan(operationName)); final Span span = withMessageTags(spanBuilder, unitOfWork.getMessage()).withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_SERVER).start(); try (Scope ignored = tracer.activateSpan(span)) { unitOfWork.onCleanup(u -> span.finish()); return interceptorChain.proceed(); } } OpenTraceHandlerInterceptor(Tracer tracer); @Override Object handle(UnitOfWork unitOfWork, InterceptorChain interceptorChain);  }### Answer:
@Test void testHandle() throws Exception { MockSpan test = mockTracer.buildSpan("test").start(); ScopeManager scopeManager = mockTracer.scopeManager(); scopeManager.activate(test); Message<MyEvent> message = new GenericDomainEventMessage<>("Payload", "aggregate_1", 0, new MyEvent()) .withMetaData(new HashMap<String, String>() {{ put("spanid", "1"); put("traceid", "2"); }}); unitOfWork.transformMessage(m -> message); openTraceDispatchInterceptor.handle(unitOfWork, mockInterceptorChain); unitOfWork.start(); unitOfWork.commit(); List<MockSpan> mockSpans = mockTracer.finishedSpans(); assertEquals(1, mockSpans.size()); MockSpan mockSpan = mockSpans.get(0); assertEquals(1, mockSpan.parentId()); assertEquals(2, mockSpan.context().traceId()); assertEquals("handle_MyEvent", mockSpan.operationName()); assertEquals(message.getIdentifier(), mockSpan.tags().get("axon.message.id")); assertEquals("EventMessage", mockSpan.tags().get("axon.message.type")); assertEquals("aggregate_1", mockSpan.tags().get("axon.message.aggregate-identifier")); assertEquals("org.axonframework.extensions.tracing.OpenTraceHandlerInterceptorTest$MyEvent", mockSpan.tags().get("axon.message.payload-type")); assertEquals(Tags.SPAN_KIND_SERVER, mockSpan.tags().get(Tags.SPAN_KIND.getKey())); }