Skip to content

[improve][monitor] Upgrade OpenTelemetry libraries - #25662

Merged
lhotari merged 6 commits into
apache:masterfrom
lhotari:lh-opentelemetry-1.61
May 4, 2026
Merged

[improve][monitor] Upgrade OpenTelemetry libraries#25662
lhotari merged 6 commits into
apache:masterfrom
lhotari:lh-opentelemetry-1.61

Conversation

@lhotari

@lhotari lhotari commented May 4, 2026

Copy link
Copy Markdown
Member

Motivation

Keep Pulsar's OpenTelemetry stack on supported, non-deprecated APIs by upgrading the three OTel artifacts together:

  • opentelemetry-java: 1.56.0 → 1.61.0
  • opentelemetry-java-instrumentation: 2.21.0 → 2.27.0
  • opentelemetry-semantic-conventions: 1.37.0 → 1.41.0

The instrumentation 2.27.0 release deprecates the opentelemetry-runtime-telemetry-java17 module (and its RuntimeMetrics / RuntimeMetricsBuilder API) in favor of the unified opentelemetry-runtime-telemetry module's RuntimeTelemetry API, so this PR also migrates OpenTelemetryService off that deprecated API.

Modifications

  • gradle/libs.versions.toml: bump the three OTel version refs and switch the runtime-telemetry library coordinate from opentelemetry-runtime-telemetry-java17 to the unified opentelemetry-runtime-telemetry.
  • pulsar-opentelemetry/build.gradle.kts: use the renamed library alias.
  • pulsar-opentelemetry/.../OpenTelemetryService.java: replace RuntimeMetrics.builder(...).disableAllFeatures().emitExperimentalTelemetry().build() with RuntimeTelemetry.builder(...) plus Internal.setDisableAllJfrFeatures(builder, true) and Experimental.setEmitExperimentalMetrics(builder, true) (the replacements named in the deprecation javadoc), preserving the existing JMX-only, experimental-enabled behavior.
  • distribution/server/src/assemble/LICENSE.bin.txt: update the bundled-jar list (the two runtime-telemetry-java17 / -java8 entries collapse into a single runtime-telemetry jar — verified via :dependencies against pulsar-broker, pulsar-proxy, pulsar-functions-worker, pulsar-testclient, and pulsar-opentelemetry runtime classpaths).

A clean recompile of all OTel-touching modules (pulsar-opentelemetry, pulsar-broker, pulsar-client-original, pulsar-broker-common, pulsar-metadata, pulsar-proxy, pulsar-functions-worker, pulsar-transaction-coordinator, pulsar-testclient) emits zero OTel-related deprecation warnings after this change.

Verifying this change

  • Make sure that the change passes the CI checks.

This change is already covered by existing tests, specifically pulsar-opentelemetry's OpenTelemetryServiceTest — including testJvmRuntimeMetrics, which asserts that JMX-sourced runtime metrics (jvm.cpu.time, jvm.memory.used, jvm.gc.duration, jvm.thread.count, jvm.class.count, etc.) are still emitted after the runtime-telemetry API switch.

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

  • Dependencies (add or upgrade a dependency)

The OpenTelemetry Java SDK, instrumentation, and semantic-conventions artifacts are upgraded; the runtime-telemetry dependency coordinate changes from opentelemetry-runtime-telemetry-java17 to the unified opentelemetry-runtime-telemetry. No public Pulsar API changes.

lhotari added 4 commits May 4, 2026 19:52
The opentelemetry-runtime-telemetry-java17 module and its
RuntimeMetrics/RuntimeMetricsBuilder API were deprecated in
opentelemetry-java-instrumentation 2.27.0 in favor of the unified
opentelemetry-runtime-telemetry module's RuntimeTelemetry API.

Switch the dependency and update OpenTelemetryService to call
Internal.setDisableAllJfrFeatures + Experimental.setEmitExperimentalMetrics
on the new builder, preserving the previous JMX-only, experimental-enabled
behavior.
The OpenTelemetry 1.61.0 upgrade transitively bumps the bundled
prometheus-metrics-* jars from 1.3.10 to 1.5.1.
@lhotari

lhotari commented May 4, 2026

Copy link
Copy Markdown
Member Author

Similar change in BookKeeper: apache/bookkeeper#4773

@lhotari
lhotari requested a review from merlimat May 4, 2026 18:15
In opentelemetry-java 1.61 the BatchSpanProcessor's "queueSize"
self-monitoring gauge is registered lazily on the first addSpan(...)
call (via LegacySpanProcessorInstrumentation.buildQueueMetricsOnce);
in 1.56 it was registered eagerly in the BatchSpanProcessor
constructor. Pulsar emits no spans, so under 1.61 the gauge never
appears at the OTel collector and the test times out waiting for
queueSize_ratio.

Assert on jvm_cpu_count instead. It is unconditionally emitted by
RuntimeTelemetry, which OpenTelemetryService always configures, and
the sibling testOpenTelemetryMetricsPrometheusExport already uses
the same metric.
@lhotari
lhotari merged commit 077b61e into apache:master May 4, 2026
43 checks passed
poorbarcode pushed a commit to poorbarcode/pulsar that referenced this pull request May 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants