8181import org .apache .pulsar .client .impl .conf .ProducerConfigurationData ;
8282import org .apache .pulsar .client .impl .crypto .MessageCryptoBc ;
8383import org .apache .pulsar .client .impl .metrics .InstrumentProvider ;
84- import org .apache .pulsar .client .impl .metrics .LatencyHistogram ;
8584import org .apache .pulsar .client .impl .metrics .ProducerMetrics ;
8685import org .apache .pulsar .client .impl .schema .JSONSchema ;
8786import org .apache .pulsar .client .impl .schema .SchemaUtils ;
@@ -182,8 +181,7 @@ public class ProducerImpl<T> extends ProducerBase<T> implements TimerTask, Conne
182181
183182 private boolean errorState ;
184183
185- private final ProducerMetrics producerMetrics ;
186- final LatencyHistogram rpcLatencyHistogram ;
184+ final ProducerMetrics producerMetrics ;
187185 private final boolean pauseSendingToPreservePublishOrderOnSchemaRegFailure ;
188186 // This variable can be exposed as a metrics in the future, a PIP is needed.
189187 private final AtomicInteger pendingQueueFullCounter ;
@@ -288,7 +286,6 @@ public ProducerImpl(PulsarClientImpl client, String topic, ProducerConfiguration
288286
289287 InstrumentProvider ip = client .instrumentProvider ();
290288 producerMetrics = new ProducerMetrics (ip , topic );
291- rpcLatencyHistogram = producerMetrics .getRpcLatencyHistogram ();
292289 pendingQueueFullCounter = new AtomicInteger ();
293290
294291 this .connectionHandler = initConnectionHandler ();
@@ -797,9 +794,11 @@ private void serializeAndSendMessage(MessageImpl<?> msg,
797794 if (msg .getSchemaState () == MessageImpl .SchemaState .Ready ) {
798795 ByteBufPair cmd = sendMessage (producerId , sequenceId , numMessages , messageId , msgMetadata ,
799796 encryptedPayload );
800- op = OpSendMsg .create (rpcLatencyHistogram , msg , cmd , sequenceId , callback );
797+ op = OpSendMsg .create (producerMetrics , msg , cmd , sequenceId , callback );
798+
801799 } else {
802- op = OpSendMsg .create (rpcLatencyHistogram , msg , null , sequenceId , callback );
800+ op = OpSendMsg .create (producerMetrics , msg , null , sequenceId , callback );
801+
803802 final MessageMetadata finalMsgMetadata = msgMetadata ;
804803 op .rePopulate = () -> {
805804 if (msgMetadata .hasChunkId ()) {
@@ -1549,7 +1548,7 @@ public ReferenceCounted touch(Object hint) {
15491548 }
15501549
15511550 protected static final class OpSendMsg {
1552- LatencyHistogram rpcLatencyHistogram ;
1551+ ProducerMetrics producerMetrics ;
15531552 MessageImpl <?> msg ;
15541553 List <MessageImpl <?>> msgs ;
15551554 ByteBufPair cmd ;
@@ -1569,7 +1568,7 @@ protected static final class OpSendMsg {
15691568 int chunkId = -1 ;
15701569
15711570 void initialize () {
1572- rpcLatencyHistogram = null ;
1571+ producerMetrics = null ;
15731572 msg = null ;
15741573 msgs = null ;
15751574 cmd = null ;
@@ -1589,11 +1588,11 @@ void initialize() {
15891588 chunkedMessageCtx = null ;
15901589 }
15911590
1592- static OpSendMsg create (LatencyHistogram rpcLatencyHistogram , MessageImpl <?> msg , ByteBufPair cmd ,
1591+ static OpSendMsg create (ProducerMetrics producerMetrics , MessageImpl <?> msg , ByteBufPair cmd ,
15931592 long sequenceId , SendCallback callback ) {
15941593 OpSendMsg op = RECYCLER .get ();
15951594 op .initialize ();
1596- op .rpcLatencyHistogram = rpcLatencyHistogram ;
1595+ op .producerMetrics = producerMetrics ;
15971596 op .msg = msg ;
15981597 op .cmd = cmd ;
15991598 op .callback = callback ;
@@ -1603,11 +1602,11 @@ static OpSendMsg create(LatencyHistogram rpcLatencyHistogram, MessageImpl<?> msg
16031602 return op ;
16041603 }
16051604
1606- static OpSendMsg create (LatencyHistogram rpcLatencyHistogram , List <MessageImpl <?>> msgs , ByteBufPair cmd ,
1605+ static OpSendMsg create (ProducerMetrics producerMetrics , List <MessageImpl <?>> msgs , ByteBufPair cmd ,
16071606 long sequenceId , SendCallback callback , int batchAllocatedSize ) {
16081607 OpSendMsg op = RECYCLER .get ();
16091608 op .initialize ();
1610- op .rpcLatencyHistogram = rpcLatencyHistogram ;
1609+ op .producerMetrics = producerMetrics ;
16111610 op .msgs = msgs ;
16121611 op .cmd = cmd ;
16131612 op .callback = callback ;
@@ -1621,12 +1620,12 @@ static OpSendMsg create(LatencyHistogram rpcLatencyHistogram, List<MessageImpl<?
16211620 return op ;
16221621 }
16231622
1624- static OpSendMsg create (LatencyHistogram rpcLatencyHistogram , List <MessageImpl <?>> msgs , ByteBufPair cmd ,
1623+ static OpSendMsg create (ProducerMetrics producerMetrics , List <MessageImpl <?>> msgs , ByteBufPair cmd ,
16251624 long lowestSequenceId ,
16261625 long highestSequenceId , SendCallback callback , int batchAllocatedSize ) {
16271626 OpSendMsg op = RECYCLER .get ();
16281627 op .initialize ();
1629- op .rpcLatencyHistogram = rpcLatencyHistogram ;
1628+ op .producerMetrics = producerMetrics ;
16301629 op .msgs = msgs ;
16311630 op .cmd = cmd ;
16321631 op .callback = callback ;
@@ -1678,9 +1677,9 @@ void sendComplete(final Exception e) {
16781677 }
16791678
16801679 if (e == null ) {
1681- rpcLatencyHistogram . recordSuccess (now - this .lastSentAt );
1680+ producerMetrics . recordRpcLatencySuccess (now - this .lastSentAt );
16821681 } else {
1683- rpcLatencyHistogram . recordFailure (now - this .lastSentAt );
1682+ producerMetrics . recordRpcLatencyFailure (now - this .lastSentAt );
16841683 }
16851684
16861685 OpSendMsgStats opSendMsgStats = OpSendMsgStatsImpl .builder ()
0 commit comments