Optional<ProducerStats> would work well, I don't believe that will make implementation easier. The ConsumerStats class will need a way of retrieving ProducerStats from the consumer at some point in the future, which isn't possible right now, since deadLetterProducer and retryLetterProducer are both private to ConsumerImpl.
Kai On Mon, Mar 6, 2023 at 1:44 PM Michael Marshall <mmarsh...@apache.org> wrote: > I support exposing these stats, and I don't have a preference > regarding where to put the method. > > > I believe the implementation will be harder that way > > Would it be sufficient to make the field return > Optional<ProducerStats> or to return `null`? I don't think we have > defined a convention stating we prefer to wrap fields with `Optional`, > but I think it'd be a reasonable use of the wrapper and it'd make it > clear to users that the value might not be present. > > Thanks, > Michael > > On Mon, Mar 6, 2023 at 10:24 AM Kai Levy <kl...@toasttab.com> wrote: > > > > I agree, adding it to the ConsumerStats interface makes more logical > sense, > > but I believe the implementation will be harder that way, since the > > producers are lazily initialized. They won't be available when > > ConsumerStats is created, and there isn't currently a way to access them > > directly from the consumer. > > > > Kai > > > > On Sun, Mar 5, 2023 at 5:19 AM Asaf Mesika <asaf.mes...@gmail.com> > wrote: > > > > > I would rather see them as attributes of ConsumerStats . > > > Add > > > > > > ProducerStats deadLetterProducerStats; > > > > > > ProducerStats retryLetterProducerStats(); > > > > > > > > > On Fri, Mar 3, 2023 at 2:54 AM Kai Levy <kl...@toasttab.com> wrote: > > > > > > > Hello! > > > > > > > > I created a new PIP because I discovered there's no way for a user to > > > > access the metrics for a consumer's deadLetterProducer / > > > > retryLetterProducer, since it is private to ConsumerImpl.java. I > would > > > like > > > > to propose an API change that would expose those statistics. More > details > > > > on the github issue: > > > > https://github.com/apache/pulsar/issues/19698 > > > > > > > > Thanks! > > > > Kai > > > > > > > > >