Skip to content

Metric unit strings use Groovy GString syntax instead of UCUM annotation syntax #1273

Description

@esosaoh

Description

Several metric instruments across the plugin are registered with unit strings that use "${description}" (Groovy GString interpolation syntax) instead of the correct "{description}" form required by the OTel Semantic Conventions — Instrument Units.

The OpenTelemetry Metrics API specifies that dimensionless, countable quantities must use UCUM annotation syntax: curly braces {...} wrapping a free-text description. The $ prefix has no meaning in this context — it is Groovy GString interpolation syntax accidentally applied to Java string literals where it has no effect on the value at the call site, but produces an invalid unit string in the emitted telemetry.

Affected Instruments

File Metric Current (wrong) Expected (correct)
MonitoringQueueListener.java jenkins.queue.count "${tasks}" "{tasks}"
JenkinsExecutorMonitoringInitializer.java jenkins.executor.queue "${items}" "{items}"
JenkinsExecutorMonitoringInitializer.java jenkins.executor.total, jenkins.executor.count, jenkins.executor.available, jenkins.executor.busy, jenkins.executor.idle, jenkins.executor.online, jenkins.executor.connecting, jenkins.executor.defined "${executors}" "{executors}"
JenkinsExecutorMonitoringInitializer.java jenkins.node "${nodes}" "{nodes}"
PluginMonitoringInitializer.java jenkins.plugins.count, jenkins.plugins.updates "${plugins}" "{plugins}"
AuditingSecurityListener.java login, login_success, login_failure "${logins}" "{logins}"

Impact

Observability backends that interpret UCUM units (e.g. Prometheus via the OTel→Prometheus unit mapping, Grafana) will receive malformed unit labels and may reject, ignore, or misformat them. Other instruments in this codebase — SCMEventMonitoringInitializer.java and MonitoringCloudListener.java — already use the correct {...} form, confirming the intended convention.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions