Skip to content

feat(ibm-mq-metrics): report queue manager uptime (#2823)#2835

Open
harshitt13 wants to merge 7 commits into
open-telemetry:mainfrom
harshitt13:feat/ibm-mq-uptime-2823
Open

feat(ibm-mq-metrics): report queue manager uptime (#2823)#2835
harshitt13 wants to merge 7 commits into
open-telemetry:mainfrom
harshitt13:feat/ibm-mq-uptime-2823

Conversation

@harshitt13

@harshitt13 harshitt13 commented May 14, 2026

Copy link
Copy Markdown
Member

Description:

Feature addition - This PR introduces a new metric to report the cumulative uptime of the queue manager in seconds, providing better visibility into queue manager restarts compared to the static heartbeat metric.

  • Added ibm_mq.queue_manager.uptime metric (Gauge, seconds) calculating uptime from PCF attributes CMQCFC.MQCACF_Q_MGR_START_DATE and CMQCFC.MQCACF_Q_MGR_START_TIME.
  • Eliminated timezone drift by securely anchoring the parsed IBM MQ local time to ZoneOffset.UTC.
  • Enabled the new metric in the default configuration.
  • Deprecated the existing heartbeat metric per the issue discussion, keeping it active with @SuppressWarnings during the transition period so users aren't immediately broken.

Existing Issue(s):

Fixes #2823

Testing:

  • Updated QueueManagerMetricsCollectorTest to inject mock start dates/times into the PCF response and verify the new gauge emission.
  • Created MessageBuddyTest to explicitly verify that the uptime calculation remains perfectly stable regardless of the collector host's underlying JVM default timezone.
  • Executed ./gradlew :ibm-mq-metrics:generateWeaver and verified existing module tests pass cleanly.

Documentation:

  • Updated model/metrics.yaml and config.yml to define and enable the new ibm_mq.queue_manager.uptime metric.
  • Added standard Java @Deprecated annotations and Javadoc for the heartbeat metric.

Outstanding items:

  • The heartbeat metric is currently deprecated but still emitting. It will need to be completely removed in a future major release.

Copilot AI review requested due to automatic review settings May 14, 2026 15:42
@harshitt13 harshitt13 requested a review from a team as a code owner May 14, 2026 15:42
@github-actions github-actions Bot requested review from atoulme and breedx-splk May 14, 2026 15:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a new ibm.mq.queue_manager.uptime gauge that reports cumulative queue-manager uptime in seconds (derived from PCF MQCA_Q_MGR_START_DATE/MQCA_Q_MGR_START_TIME), and deprecates the existing ibm.mq.heartbeat metric in favor of it.

Changes:

  • Adds Metrics.createIbmMqQueueManagerUptime, MetricsConfig.isIbmMqQueueManagerUptimeEnabled, a new MessageBuddy.queueManagerUptime helper, and emits the value in QueueManagerMetricsCollector.
  • Marks Metrics.createIbmMqHeartbeat as @Deprecated and wraps its consumer in WmqMonitor with @SuppressWarnings("OtelDeprecatedApiUsage").
  • Updates model/metrics.yaml with the new metric definition and a deprecation note on ibm.mq.heartbeat.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
ibm-mq-metrics/model/metrics.yaml Declares the new uptime metric and notes deprecation of heartbeat.
ibm-mq-metrics/src/main/java/io/opentelemetry/ibm/mq/metrics/Metrics.java Adds the uptime gauge factory and @Deprecated annotation on heartbeat.
ibm-mq-metrics/src/main/java/io/opentelemetry/ibm/mq/metrics/MetricsConfig.java Adds an enable flag for the new metric.
ibm-mq-metrics/src/main/java/io/opentelemetry/ibm/mq/metricscollector/MessageBuddy.java Parses PCF start date/time and computes uptime in seconds.
ibm-mq-metrics/src/main/java/io/opentelemetry/ibm/mq/metricscollector/QueueManagerMetricsCollector.java Registers the gauge and emits the new metric inside the collection loop.
ibm-mq-metrics/src/main/java/io/opentelemetry/ibm/mq/WmqMonitor.java Suppresses the deprecation warning for the still-active heartbeat gauge.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 895d64f00f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread ibm-mq-metrics/model/metrics.yaml Outdated
Comment thread ibm-mq-metrics/model/metrics.yaml Outdated
@harshitt13 harshitt13 requested a review from atoulme May 22, 2026 07:32
@atoulme

atoulme commented May 26, 2026

Copy link
Copy Markdown
Contributor

Please rebase, we have changed the way we record metrics to use a MetricProducer.

Signed-off-by: Harshit Kushwaha <find.harshitkushwaha@gmail.com>
Signed-off-by: Harshit Kushwaha <find.harshitkushwaha@gmail.com>
…ime counter and update related metrics

Signed-off-by: Harshit Kushwaha <find.harshitkushwaha@gmail.com>
@harshitt13 harshitt13 force-pushed the feat/ibm-mq-uptime-2823 branch from 6f8dc9f to b9af0d0 Compare May 27, 2026 08:02
…Producer for clarity

Signed-off-by: Harshit Kushwaha <find.harshitkushwaha@gmail.com>
@harshitt13

harshitt13 commented May 27, 2026

Copy link
Copy Markdown
Member Author

Please rebase, we have changed the way we record metrics to use a MetricProducer.

Rebased and refactored the implementation to utilize the new MetricProducer pattern as requested.
Ready for re-review.

Comment on lines +677 to +682
(k, v) -> {
if (v == null) {
return value;
} else {
return v + value;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nitpick:

Suggested change
(k, v) -> {
if (v == null) {
return value;
} else {
return v + value;
}
(k, v) -> v == null ? value : v + value

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oh, is the value coming in a cumulative value already? If so, doesn't this math make it incorrect?

I'm thinking we should just take the value that we're given and report it as a gauge. I'm not sure that he guidance to use a counter is correct, merely because it's monotonic. Since we're reporting a "current value" of the measured uptime, wouldn't a gauge be better?

Also, what if the manager restarted between collects, causing its uptime to drop?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

You are right. Because the value is already an absolute cumulative value. Adding it to the previous value (v + value) across collection intervals was a logic error.

I agree that an asynchronous Gauge is correct here. By simply reporting the latest calculated value as a Gauge, it also perfectly handles the restart scenario you mentioned: if the queue manager restarts between collections, the new start_time will simply result in a smaller reported value, which a Gauge handles natively without issue.

I will push a fix to remove the addition logic so it just reports the latest measured value.

Signed-off-by: Harshit Kushwaha <find.harshitkushwaha@gmail.com>
@harshitt13 harshitt13 requested a review from breedx-splk June 13, 2026 11:19
Signed-off-by: Harshit Kushwaha <find.harshitkushwaha@gmail.com>
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.

[ibm-mq-metrics] Report queue manager uptime

4 participants