-
Notifications
You must be signed in to change notification settings - Fork 410
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: Make PrometheusClientLayer Clonable #3352
Conversation
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 don't like the idea of implementing Layer for a reference. Do we have better choices? For example, changing the PromClientLayer's API to avoid such thing happens.
Seems We need to make The API will be: #[derive(Default, Clone)]
struct PrometheusClientMetrics {..}
impl PrometheusClientMetrics {
pub fn register(&self, registry: &mut Registry);
}
struct PrometheusClientLayer {..}
impl PrometheusClientLayer {
pub fn new(metrics: PrometheusClientMetrics) -> Self;
} In this way, users only need to store |
IMHO this api is also error prone as the PrometheusClientMetrics struct is passed by moving instead of a reference. We have no way to pass a PrometheusClientMetrics singleton from adhoc any other suggestion about the API design? or just use interior mutability? |
|
if do not want using reference on the Layer side, I think we need an however this may introduce an extra
|
no. not all metrics are |
But all metrics in opendal will be |
no, Family is used for the metrics with labels. if your labels exploded, you'd like to replace some families with simple metrics to make the metrics crapper happy. |
I didn't get this. Are you talking about changing |
oh I got it wrong, the simple metrics like Counter, Gauge are also wrapped within an |
so we can consider just make |
LGTM. |
updated the PR, after when only one line of code is changed, PTAL @Xuanwo |
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.
Mostly LGTM, please make rustfmt
happy.
we met an issue in datafuselabs/databend#13373 , as sometimes we'd call
build_operator()
on some queries, this causes duplicated metrics get registered into the registry, which finally produced millions of metrics.the solution is to make the PrometheusClientLayer a singleton, but currently the PrometheusClientLayer have to be moved. we need allow it passing a reference before making the singleton in the
layer()
call.