tikv / rust-prometheus

Prometheus instrumentation library for Rust applications
Apache License 2.0
1.04k stars 182 forks source link

Arbitrary headers for `push_metrics` #507

Open felipesere opened 7 months ago

felipesere commented 7 months ago

Is your feature request related to a problem? Please describe. Our pushgateway is behind a gateway and we need to pass credentials through headers which are not basic auth.

Describe the solution you'd like When calling push_metrics I'd like pass a collection of arbitrary headers that get added to the request:

            let outcome = push_metrics::<RandomState>(
                "deployment-notifier",
                HashMap::from([
                    ("repo".to_string(), repo),
                    ("app".to_string(), workload.name),
                ]),
                "http://foo.example.com/bar",
                mfs,
                None, // basic auth here
                Some(HashMap::from([("key", "value"), ("other-key", "other-value")])), // <-- new map with headers that will be added to the request
            );

Describe alternatives you've considered In a different place we have basically vendored push_metrics but that feels too blunt. We already depend on rust-prometheus and this is such a tiny detail.