-
Notifications
You must be signed in to change notification settings - Fork 80
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
Encoder without EOF #153
Comments
I'm happy to raise a PR, but if I am wondering if you'd have a better suggestion, especially in the context of these upcoming changes: #149. |
Good to hear.
:D
Generally yes. I see the use-case of wanting to combine multiple That said, in case performance is not an issue for you and you are fine with a small hack, why not encode into a |
I don't see how #149 would help or effect your situation. You could implement your own |
Ours is a performance-sensitive application and I'd rather not have to double-buffer :-) We embed Rust, rather than the other way around. |
The reason why I was mentioning PR #149 is that as I was looking at it I noticed the new /// Encode the metrics registered with the provided [`Registry`] into the
/// provided [`Write`]r using the OpenMetrics text format.
pub fn encode<W>(writer: &mut W, registry: &Registry) -> Result<(), std::fmt::Error>
where
W: Write,
{
registry.encode(&mut DescriptorEncoder::new(writer).into())?;
writer.write_str("# EOF\n")?;
Ok(())
}
pub(crate) struct DescriptorEncoder<'a> {
writer: &'a mut dyn Write,
prefix: Option<&'a Prefix>,
labels: &'a [(Cow<'static, str>, Cow<'static, str>)],
} The alternative here might be to expose the If not, I'll wait for PR #149 to be merged and raise mine after (given that code is changing anyways). |
All credits on the initial idea, implementation, and testing belong to @amunra, who is the original author of this PR prometheus#154. From the original PR description: Adds new `encode_registry` and `encode_eof` functions to allow encoding of parts of the response. This is useful when there are multiple registries at play, or when composing metrics for a process that embeds Rust as part of its logic whilst serving metrics to Prometheus outside of Rust. Fixes: prometheus#153 Refs: prometheus#154, prometheus#204 Co-authored-by: Adam Cimarosti <amunra@users.noreply.github.com> Signed-off-by: Tyrone Wu <wudevelops@gmail.com>
All credits on the initial idea, implementation, and testing belong to @amunra, who is the original author of this PR prometheus#154. From the original PR description: Adds new `encode_registry` and `encode_eof` functions to allow encoding of parts of the response. This is useful when there are multiple registries at play, or when composing metrics for a process that embeds Rust as part of its logic whilst serving metrics to Prometheus outside of Rust. Fixes: prometheus#153 Refs: prometheus#154, prometheus#204 Co-authored-by: amunra <amunra@users.noreply.github.com> Signed-off-by: tyrone-wu <wudevelops@gmail.com>
All credits on the initial idea, implementation, and testing belong to @amunra, who is the original author of this PR prometheus#154. From the original PR description: Adds new `encode_registry` and `encode_eof` functions to allow encoding of parts of the response. This is useful when there are multiple registries at play, or when composing metrics for a process that embeds Rust as part of its logic whilst serving metrics to Prometheus outside of Rust. Fixes: prometheus#153 Refs: prometheus#154, prometheus#204 Co-authored-by: amunra <cimarosti@gmail.com> Signed-off-by: tyrone-wu <wudevelops@gmail.com>
All credits on the initial idea, implementation, and testing belong to @amunra, who is the original author of this PR prometheus#154. From the original PR description: Adds new `encode_registry` and `encode_eof` functions to allow encoding of parts of the response. This is useful when there are multiple registries at play, or when composing metrics for a process that embeds Rust as part of its logic whilst serving metrics to Prometheus outside of Rust. Fixes: prometheus#153 Refs: prometheus#154, prometheus#204 Co-authored-by: amunra <cimarosti@gmail.com> Signed-off-by: tyrone-wu <wudevelops@gmail.com>
Hello!
I have a more uncommon use case where I'm using Rust in a multi-language setup.
The rest of the system is already serving requests to Prometheus and I'd like to slot in a few metrics for the parts of my application written in Rust.
I like that the client doesn't do HTTP serving and stick to the protocol, so it's 99% of what I need.
What causes me trouble is just a single line of code:
which prevents me from using this crate in a way that's composable with other output.
Would you consider a variant of the
encode
function that doesn't write out the# EOF
?Maybe called
pub fn encode_metrics
?The text was updated successfully, but these errors were encountered: