For topic destinations, each subscriber dispatch creates its own span,
+ * so a single published message may produce multiple deliver spans.
+ *
+ * @org.apache.xbean.XBean element="openTelemetryPlugin"
+ */
+public class OpenTelemetryBrokerPlugin extends BrokerPluginSupport {
+
+ private static final Logger LOG = LoggerFactory.getLogger(OpenTelemetryBrokerPlugin.class);
+ private static final String INSTRUMENTATION_NAME = "org.apache.activemq";
+
+ // Cap in-flight dispatch spans to avoid unbounded growth when postProcessDispatch is missed.
+ // The eldest entry is ended and evicted if this limit is exceeded.
+ private static final int MAX_DISPATCH_SPANS = 1000;
+
+ private boolean traceProducer = true;
+ private boolean traceConsumer = true;
+ private boolean traceAcknowledge = true;
+
+ private final TextMapPropagator propagator;
+ private final Tracer tracer;
+
+ private final Map