nlopes / actix-web-prom

Actix-web middleware to expose Prometheus metrics
MIT License
89 stars 56 forks source link

feat: configurable path parameters cardinality #73

Closed lefuturiste closed 8 months ago

lefuturiste commented 1 year ago

the idea for this MR was originally discussed in #72

A change that allow developer to change the cardinality of a given param name for a specific route.

To define a config that goes down the line, we need to use actix extensions_mut() method. The external/user developer need to define a middleware that will pass some data down the middleware stack.

Example when defining a route:

    web::resource("/{source_ids}/{z}/{x}/{y}")
        .wrap_fn(|req, srv| {
            req.extensions_mut().insert::<MetricsConfig>(
                MetricsConfig { cardinality_keep_params: vec!["source_ids".to_string()] }
            );
            srv.call(req)
        })
        .route(web::get().to(get_tile_handler))

Feel free to comment or help.

lefuturiste commented 1 year ago

@nlopes You may take a look at this

nlopes commented 11 months ago

Thanks for sending over. I'll try to take a look sometime this week.

lefuturiste commented 10 months ago

Thanks for sending over. I'll try to take a look sometime this week.

Hello, I'm kindly asking if you have some update on this, thanks! 😄

nlopes commented 10 months ago

Apologies for taking so long. Can you modify your example please? As it stands I don't think it actually exemplifies your change. Or am I misunderstanding it?

lefuturiste commented 10 months ago

Apologies for taking so long. Can you modify your example please? As it stands I don't think it actually exemplifies your change. Or am I misunderstanding it?

Yes you are correct, I will update the example.

lefuturiste commented 10 months ago

In theory I should have rebased this fork, and now I added an example. I also need to fix the code so that 404 are not counting as new labels values.

TODO:

lefuturiste commented 10 months ago

@nlopes can you take a look at this? It should be better now

lefuturiste commented 9 months ago

Hello @nlopes sorry to ask you again, what can be done to get this forward? I know that maintaining opensource software is a burden 😢 .

lefuturiste commented 9 months ago

Almost there. Apologies, I've forgotten about this.

Thanks for your review, I've fix something