-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #5664. Currently, Oximeter `FieldValue::String` fields are always represented by a `String` value. This is somewhat unfortunate, as it requires allocating a new `String` for every string field value that's emitted to Oximeter, even when the string value is fixed at compile-time --- for example, when an enum is used to generate a metric label with `&'static str` values, they must be alloced into new `String`s to record the metric. This commit changes `FieldValue::String` from holding a `String` to holding a `Cow<'static, str>`, so that static string constants need not be heap-allocated. Additionally, I've changed Oximeter's `self_stats` module to use `Cow<'static, str>` to represent the field value generated by the `FailureReason` enum. This way, a heap-allocated string is only necessary for dynamically formatted variants (the `FailureReason::Other` variant, which owns an HTTP `StatusCode`). For the `FailureReason::Unreachable` and `FailureReason::Deserialization` variants, we can just emit a `&'static str` without allocating. Hopefully, this reduces resident memory for the collector process somewhat when encountering a lot of failures.
- Loading branch information
Showing
6 changed files
with
61 additions
and
26 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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