-
Notifications
You must be signed in to change notification settings - Fork 330
Provide unit conversion for common non-second duration instruments (TSH-20621) #8415
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4bb451f
Provide unit conversion for common non-second duration instruments
theJC 70e5df5
Add changeset
theJC 093de82
Update documentation
theJC 6486219
Update doc to incorporate suggested changes from Apollo librarian (AI…
theJC 0186eb9
Apply lint formatting fixes
theJC 3e997f1
Update doc to incorporate suggested changes from Apollo librarian (AI…
theJC 2a688cc
Update changeset content per MR feedback
theJC e1951ce
Update .changesets/feat_convertNonSecondTimeUnits.md
theJC File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| ### Automatic unit conversion for duration instruments with non-second units | ||
|
|
||
| The Router now automatically converts duration measurements to match the configured unit for telemetry instruments. | ||
| Previously, duration instruments always recorded values in seconds regardless of the configured `unit` field. | ||
| With this enhancement, when you specify units like `"ms"` (milliseconds), `"us"` (microseconds), or `"ns"` (nanoseconds), | ||
| the Router will automatically convert the measured duration to the appropriate scale. | ||
|
|
||
| **Supported units:** | ||
| - `"s"` - seconds (default) | ||
| - `"ms"` - milliseconds | ||
| - `"us"` - microseconds | ||
| - `"ns"` - nanoseconds | ||
|
|
||
| Important Note: This should only be used in cases where you are required to integrate with an observability platform that does not properly translate from source timeunit into the necessary target timeunit (ie: seconds to milliseconds). In all other cases, | ||
| customers should follow the OLTP convention indicating you "SHOULD" use seconds as the unit. | ||
|
|
||
| **Example:** | ||
| ```yaml title="router.yaml" | ||
| telemetry: | ||
| instrumentation: | ||
| instruments: | ||
| subgraph: | ||
| acme.request.duration: | ||
| value: duration | ||
| type: histogram | ||
| unit: ms # Values are now automatically converted to milliseconds | ||
| description: "Metric to get the request duration in milliseconds" | ||
| ``` | ||
|
|
||
| By [Jon Christiansen](https://github.com/theJC) in https://github.com/apollographql/router/pull/8415 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not
as_millis() as f64for consistency with the other units?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good 👀. I'm using as_secs_f64() * 1000 here because:
Duration::as_millis_{f64,f32}rust-lang/rust#122451)