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 ;
@@ -180,8 +179,7 @@ public class ProducerImpl<T> extends ProducerBase<T> implements TimerTask, Conne
180179
181180 private boolean errorState ;
182181
183- private final ProducerMetrics producerMetrics ;
184- final LatencyHistogram rpcLatencyHistogram ;
182+ final ProducerMetrics producerMetrics ;
185183 private final boolean pauseSendingToPreservePublishOrderOnSchemaRegFailure ;
186184 // This variable can be exposed as a metrics in the future, a PIP is needed.
187185 private final AtomicInteger pendingQueueFullCounter ;
@@ -286,7 +284,6 @@ public ProducerImpl(PulsarClientImpl client, String topic, ProducerConfiguration
286284
287285 InstrumentProvider ip = client .instrumentProvider ();
288286 producerMetrics = new ProducerMetrics (ip , topic );
289- rpcLatencyHistogram = producerMetrics .getRpcLatencyHistogram ();
290287 pendingQueueFullCounter = new AtomicInteger ();
291288
292289 this .connectionHandler = initConnectionHandler ();
@@ -794,9 +791,11 @@ private void serializeAndSendMessage(MessageImpl<?> msg,
794791 if (msg .getSchemaState () == MessageImpl .SchemaState .Ready ) {
795792 ByteBufPair cmd = sendMessage (producerId , sequenceId , numMessages , messageId , msgMetadata ,
796793 encryptedPayload );
797- op = OpSendMsg .create (rpcLatencyHistogram , msg , cmd , sequenceId , callback );
794+ op = OpSendMsg .create (producerMetrics , msg , cmd , sequenceId , callback );
795+
798796 } else {
799- op = OpSendMsg .create (rpcLatencyHistogram , msg , null , sequenceId , callback );
797+ op = OpSendMsg .create (producerMetrics , msg , null , sequenceId , callback );
798+
800799 final MessageMetadata finalMsgMetadata = msgMetadata ;
801800 op .rePopulate = () -> {
802801 if (msgMetadata .hasChunkId ()) {
@@ -1527,7 +1526,7 @@ public ReferenceCounted touch(Object hint) {
15271526 }
15281527
15291528 protected static final class OpSendMsg {
1530- LatencyHistogram rpcLatencyHistogram ;
1529+ ProducerMetrics producerMetrics ;
15311530 MessageImpl <?> msg ;
15321531 List <MessageImpl <?>> msgs ;
15331532 ByteBufPair cmd ;
@@ -1547,7 +1546,7 @@ protected static final class OpSendMsg {
15471546 int chunkId = -1 ;
15481547
15491548 void initialize () {
1550- rpcLatencyHistogram = null ;
1549+ producerMetrics = null ;
15511550 msg = null ;
15521551 msgs = null ;
15531552 cmd = null ;
@@ -1567,11 +1566,11 @@ void initialize() {
15671566 chunkedMessageCtx = null ;
15681567 }
15691568
1570- static OpSendMsg create (LatencyHistogram rpcLatencyHistogram , MessageImpl <?> msg , ByteBufPair cmd ,
1569+ static OpSendMsg create (ProducerMetrics producerMetrics , MessageImpl <?> msg , ByteBufPair cmd ,
15711570 long sequenceId , SendCallback callback ) {
15721571 OpSendMsg op = RECYCLER .get ();
15731572 op .initialize ();
1574- op .rpcLatencyHistogram = rpcLatencyHistogram ;
1573+ op .producerMetrics = producerMetrics ;
15751574 op .msg = msg ;
15761575 op .cmd = cmd ;
15771576 op .callback = callback ;
@@ -1581,11 +1580,11 @@ static OpSendMsg create(LatencyHistogram rpcLatencyHistogram, MessageImpl<?> msg
15811580 return op ;
15821581 }
15831582
1584- static OpSendMsg create (LatencyHistogram rpcLatencyHistogram , List <MessageImpl <?>> msgs , ByteBufPair cmd ,
1583+ static OpSendMsg create (ProducerMetrics producerMetrics , List <MessageImpl <?>> msgs , ByteBufPair cmd ,
15851584 long sequenceId , SendCallback callback , int batchAllocatedSize ) {
15861585 OpSendMsg op = RECYCLER .get ();
15871586 op .initialize ();
1588- op .rpcLatencyHistogram = rpcLatencyHistogram ;
1587+ op .producerMetrics = producerMetrics ;
15891588 op .msgs = msgs ;
15901589 op .cmd = cmd ;
15911590 op .callback = callback ;
@@ -1599,12 +1598,12 @@ static OpSendMsg create(LatencyHistogram rpcLatencyHistogram, List<MessageImpl<?
15991598 return op ;
16001599 }
16011600
1602- static OpSendMsg create (LatencyHistogram rpcLatencyHistogram , List <MessageImpl <?>> msgs , ByteBufPair cmd ,
1601+ static OpSendMsg create (ProducerMetrics producerMetrics , List <MessageImpl <?>> msgs , ByteBufPair cmd ,
16031602 long lowestSequenceId ,
16041603 long highestSequenceId , SendCallback callback , int batchAllocatedSize ) {
16051604 OpSendMsg op = RECYCLER .get ();
16061605 op .initialize ();
1607- op .rpcLatencyHistogram = rpcLatencyHistogram ;
1606+ op .producerMetrics = producerMetrics ;
16081607 op .msgs = msgs ;
16091608 op .cmd = cmd ;
16101609 op .callback = callback ;
@@ -1656,9 +1655,9 @@ void sendComplete(final Exception e) {
16561655 }
16571656
16581657 if (e == null ) {
1659- rpcLatencyHistogram . recordSuccess (now - this .lastSentAt );
1658+ producerMetrics . recordRpcLatencySuccess (now - this .lastSentAt );
16601659 } else {
1661- rpcLatencyHistogram . recordFailure (now - this .lastSentAt );
1660+ producerMetrics . recordRpcLatencyFailure (now - this .lastSentAt );
16621661 }
16631662
16641663 OpSendMsgStats opSendMsgStats = OpSendMsgStatsImpl .builder ()
0 commit comments