Skip to content

[processor/deltatorate] Correctly transform unit of rates#46841

Open
mx-psi wants to merge 1 commit intoopen-telemetry:mainfrom
mx-psi:mx-psi/unit-rates
Open

[processor/deltatorate] Correctly transform unit of rates#46841
mx-psi wants to merge 1 commit intoopen-telemetry:mainfrom
mx-psi:mx-psi/unit-rates

Conversation

@mx-psi
Copy link
Member

@mx-psi mx-psi commented Mar 11, 2026

Description

Since we are calculating a rate per second, we want the unit to be transformed to "original units" per second.
This PR appends /s to the unit of generated rates if the unit is set.

I argue this is compliant with UCUM (the unit spec used by OpenTelemetry) no matter what the original unit is, because (quoting the UCUM spec):

The semantics of The Unified Code for Units of Measure implies equivalence classes such that different expressions may have the same meaning.

and

Terms are evaluated from left to right with the period and the solidus having the same operator precedence. Multiple division operators are allowed within one term.

Therefore units like m/s/s or ms/s are valid UCUM units.

Since the unit may be missing, to avoid assuming the unit is "1" we don't add /s in that case.

@mx-psi mx-psi force-pushed the mx-psi/unit-rates branch from b1d6ce8 to 500ec2b Compare March 11, 2026 11:46
@mx-psi mx-psi marked this pull request as ready for review March 11, 2026 11:46
@mx-psi mx-psi requested a review from a team as a code owner March 11, 2026 11:46
@mx-psi mx-psi requested a review from edmocosta March 11, 2026 11:46
@github-actions github-actions bot added the processor/deltatorate Delta To Rate processor label Mar 11, 2026
@github-actions github-actions bot requested a review from Aneurysm9 March 11, 2026 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

processor/deltatorate Delta To Rate processor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants