-
Notifications
You must be signed in to change notification settings - Fork 35
Add support for the prometheus-client crate
#88
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
b255f8c
[WIP]
emschwartz 7cbe053
Update prometheus-client version
emschwartz ff161ea
Merge branch 'main' into prometheus-client-2
emschwartz 9e402eb
Finish support for prometheus-client
emschwartz f29aae1
Fix doc links
emschwartz 11d052f
Ensure that prometheus-client is actually being used
emschwartz 9817601
Work on fixing tests, remove const_format dep
emschwartz 8635ad7
Don't use regexes in tests (because different libraries order labels …
emschwartz 8130657
Make once_cell a required dependency
emschwartz 49410dc
Rename concurrency tracker to gauge
emschwartz 537553e
Merge branch 'main' into prometheus-client-2
emschwartz ecfe52f
Move PROMETHEUS_CLIENT_REGISTRY to integrations module
emschwartz e311510
Run all the other tests first
emschwartz ad830c3
Run the tests in the same order
emschwartz 4406f08
The prometheus-exporter feature needs to depend on the prometheus fea…
emschwartz 43bea12
Rename export to just REGISTRY
emschwartz 36f65e2
Mention prometheus-client in readme and changelog
emschwartz fb34b11
Merge branch 'main' into prometheus-client-2
emschwartz 8f263f8
Remove print statements
emschwartz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| use super::TrackMetrics; | ||
| use crate::labels::{BuildInfoLabels, CounterLabels, GaugeLabels, HistogramLabels}; | ||
| use crate::{constants::*, HISTOGRAM_BUCKETS}; | ||
| use once_cell::sync::Lazy; | ||
| use prometheus_client::metrics::{ | ||
| counter::Counter, family::Family, gauge::Gauge, histogram::Histogram, | ||
| }; | ||
| use prometheus_client::registry::Registry; | ||
|
|
||
| pub static PROMETHEUS_CLIENT_REGISTRY: Lazy<Registry> = Lazy::new(|| <Registry>::default()); | ||
|
|
||
| static METRICS: Lazy<Metrics> = Lazy::new(|| { | ||
| let counter = Family::<CounterLabels, Counter>::default(); | ||
| PROMETHEUS_CLIENT_REGISTRY.register(COUNTER_NAME, COUNTER_DESCRIPTION, counter.clone()); | ||
|
|
||
| let histogram = Family::<HistogramLabels, Histogram>::new_with_constructor(|| { | ||
| Histogram::new(HISTOGRAM_BUCKETS.into_iter()) | ||
| }); | ||
| PROMETHEUS_CLIENT_REGISTRY.register(HISTOGRAM_NAME, HISTOGRAM_DESCRIPTION, histogram.clone()); | ||
|
|
||
| let gauge = Family::<GaugeLabels, Gauge>::default(); | ||
| PROMETHEUS_CLIENT_REGISTRY.register(GAUGE_NAME, GAUGE_DESCRIPTION, gauge.clone()); | ||
|
|
||
| let build_info = Family::<BuildInfoLabels, Gauge>::default(); | ||
| PROMETHEUS_CLIENT_REGISTRY.register( | ||
| BUILD_INFO_NAME, | ||
| BUILD_INFO_DESCRIPTION, | ||
| build_info.clone(), | ||
| ); | ||
|
|
||
| Metrics { | ||
| counter, | ||
| histogram, | ||
| gauge, | ||
| build_info, | ||
| } | ||
| }); | ||
|
|
||
| struct Metrics { | ||
| counter: Family<CounterLabels, Counter>, | ||
| histogram: Family<HistogramLabels, Histogram>, | ||
| gauge: Family<GaugeLabels, Gauge>, | ||
| build_info: Family<BuildInfoLabels, Gauge>, | ||
| } | ||
|
|
||
| struct PrometheusClientTracker {} | ||
|
|
||
| impl TrackMetrics for PrometheusClientTracker { | ||
| fn set_build_info(build_info_labels: &BuildInfoLabels) { | ||
| todo!() | ||
| } | ||
|
|
||
| fn start(gauge_labels: Option<&GaugeLabels>) -> Self { | ||
| todo!() | ||
| } | ||
|
|
||
| fn finish(self, counter_labels: &CounterLabels, histogram_labels: &HistogramLabels) { | ||
| todo!() | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
can also be
Copy, which would make it easier to useThere 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.
Hmm, true. Do you think we should derive all of those traits all of the time (not just when using
prometheus-client)? I'm somewhat hesitant to do that proactively because it technically expands the surface area of the API and (maybe?) increases compile times. But maybe it's fine to just do it for this type of enumThere 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.
saving
Copymakes it way nicer to use. just be sure that u dont plan to add more in the future which may not beCopy, as removingCopyis a breaking change and requires a major version bump (unlike adding it)