Skip to content

Conversation

equanz
Copy link
Contributor

@equanz equanz commented Oct 3, 2025

PIP: #21080

Motivation

Please see the PIP-264 doc.

ref.

Modifications

  • Added ML write latency histogram and entry size histogram as OTel metrics

Verifying this change

  • Make sure that the change passes the CI checks.

This change added tests and can be verified as follows:

  • Added a simple E2E test to verify the expected metrics is exposed

Does this pull request potentially affect one of the following parts:

If the box was checked, please highlight the changes

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
    • Introducing the new OTel metrics
      • pulsar.broker.managed_ledger.message.outgoing.latency
      • pulsar.broker.managed_ledger.message.outgoing.ledger.latency
      • pulsar.broker.managed_ledger.ledger.switch.latency
      • pulsar.broker.managed_ledger.entry.size
  • Anything that affects deployment

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository: equanz#14

@equanz
Copy link
Contributor Author

equanz commented Oct 3, 2025

Note:
In my understanding, implementing AutoConfigurationCustomizerProvider allows you to customize the histogram buckets.

Here is an example.

import com.google.auto.service.AutoService;
import io.opentelemetry.sdk.autoconfigure.spi.AutoConfigurationCustomizer;
import io.opentelemetry.sdk.autoconfigure.spi.AutoConfigurationCustomizerProvider;
import io.opentelemetry.sdk.metrics.Aggregation;
import io.opentelemetry.sdk.metrics.InstrumentSelector;
import io.opentelemetry.sdk.metrics.View;
import java.util.Arrays;

@AutoService(AutoConfigurationCustomizerProvider.class)
public class MyCustomizerProvider implements AutoConfigurationCustomizerProvider {

    @Override
    public void customize(AutoConfigurationCustomizer customizer) {
        customizer.addMeterProviderCustomizer(((sdkMeterProviderBuilder, configProperties) -> {
            sdkMeterProviderBuilder.registerView(InstrumentSelector.builder()
                            .setName("pulsar.broker.topic.publish.latency").build(),
                    View.builder()
                            .setAggregation(Aggregation.explicitBucketHistogram(Arrays.asList(0.001, 30.0))).build());
            return sdkMeterProviderBuilder;
        }));
    }
}
$ PULSAR_EXTRA_CLASSPATH='path/to/custom-provider.jar' PULSAR_EXTRA_OPTS=' -Dotel.sdk.disabled=false -Dotel.metrics.exporter=prometheus ' ./bin/pulsar standalone

ref.

@equanz equanz force-pushed the add_ml_write_latency_and_size_histo branch from f65a473 to 14d025c Compare October 7, 2025 05:44
Copy link
Member

@lhotari lhotari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lhotari lhotari added this to the 4.2.0 milestone Oct 7, 2025
@codecov-commenter
Copy link

codecov-commenter commented Oct 7, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.25%. Comparing base (fc65db6) to head (08617a2).

Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff              @@
##             master   #24815       +/-   ##
=============================================
+ Coverage     36.04%   74.25%   +38.20%     
- Complexity    13055    33403    +20348     
=============================================
  Files          1855     1912       +57     
  Lines        144926   149140     +4214     
  Branches      16814    17300      +486     
=============================================
+ Hits          52243   110741    +58498     
+ Misses        85439    29556    -55883     
- Partials       7244     8843     +1599     
Flag Coverage Δ
inttests 26.35% <90.19%> (?)
systests 22.73% <100.00%> (-0.04%) ⬇️
unittests 73.77% <100.00%> (+39.28%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...he/bookkeeper/mledger/ManagedLedgerAttributes.java 100.00% <100.00%> (ø)
...kkeeper/mledger/impl/ManagedLedgerFactoryImpl.java 58.86% <ø> (+25.94%) ⬆️
...ookkeeper/mledger/impl/ManagedLedgerMBeanImpl.java 90.38% <100.00%> (+16.73%) ⬆️
.../mledger/impl/OpenTelemetryManagedLedgerStats.java 100.00% <100.00%> (+28.12%) ⬆️

... and 1437 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@equanz equanz force-pushed the add_ml_write_latency_and_size_histo branch from 14d025c to 08617a2 Compare October 8, 2025 02:24
@equanz
Copy link
Contributor Author

equanz commented Oct 8, 2025

Rebased to the master to resolve conflicts.

@codelipenghui codelipenghui merged commit 91121d3 into apache:master Oct 8, 2025
142 of 146 checks passed
lhotari pushed a commit that referenced this pull request Oct 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/metrics cherry-picked/branch-4.1 doc-required Your PR changes impact docs and you will update later. release/4.1.2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants