-
Notifications
You must be signed in to change notification settings - Fork 481
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
feat(prometheus-client): add metric label about root
on using PrometheusClientLayer
#4907
feat(prometheus-client): add metric label about root
on using PrometheusClientLayer
#4907
Conversation
a question I need to confirm about this PR: does this |
No. root is the base path for all opendal operations. You might want to include |
thank you for the suggestion, i've added a |
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.
Others LGTM, thanks!
45eccd4
to
82e050d
Compare
|
||
fn increment_errors_total(&self, scheme: Scheme, op: &'static str, err: ErrorKind) { | ||
fn increment_errors_total(&self, op: &'static str, err: ErrorKind) { |
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.
I'm thinking of implementing EncodeLabelSet
directly for our lables to avoid to_string()
here.
Would you like to start a new PR for this or just in this PR?
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.
let me have a try in this pr
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.
i switched to a Cow<'static, str>
in daab9db which helps reduces copy but can not reduce all the copies.
it turns out that we can not simply add lifetime annotations (for the labels like root
and namespace
which stored in a singleton struct) in the labels type within promtheus-client, because each metric (with labels together) will be registered into a global registry, which requires the metrics to be 'static
.
(imho it would be better to allow us make the label set as a trait object in a metric type, which help us decoupling the lifetime and metrics registration, however it's not allowed in prometheus-client yet)
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.
Hi, I'm thinking about making OperationLabels
a seperate struct and implement EncodeLabelSet
for it. For example:
struct OperationLabels {
scheme: Scheme,
op: &'static str,
namespace: Arc<String>,
root: Arc<String>,
}
impl EncodeLabelSet for OperationLabels { .. }
In this way, we can constrct OperationLabels
and use:
family.get_or_create(&OperationLabels { ... }).inc();
This design will also avoid unexpected breaking changes like field doesn't match.
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.
makes sense, i've changed them to structs, PTAL
daab9db
to
6dee3e6
Compare
f021eb5
to
23d0404
Compare
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.
Thanks a lot!
Which issue does this PR close?
Closes #4909.
Rationale for this change
I did not found the bucket value in the accessor, but i found a parameter called
root
might be helpful on this case. To make this PR work as expected, I need to make sure that the bucket should be the prefix of theroot
parameter.What changes are included in this PR?
Are there any user-facing changes?
this PR adds a new label on the prometheus metrics, if you had an existed dashboard, this change may make additional data lines on your chart. however it would not change your chart if you use
sum(xx) by (op)
or other metric aggregation operations.to make this change possible, we had to make the type of labels from
(&'static str, &'static str)
to(&'static str, String)
, this may degrade a bit performance.