-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create fetch_metrics function for use in multitenant, as it contains …
…logic
- Loading branch information
1 parent
17c09e6
commit a0aec3e
Showing
3 changed files
with
34 additions
and
25 deletions.
There are no files selected for viewing
This file contains 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 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,18 @@ | ||
use crate::connector::{Connector, FetchMetricsError}; | ||
use prometheus::{Registry, TextEncoder}; | ||
|
||
pub fn fetch_metrics<C: Connector>( | ||
configuration: &C::Configuration, | ||
state: &C::State, | ||
metrics: &Registry, | ||
) -> Result<String, FetchMetricsError> { | ||
let encoder = TextEncoder::new(); | ||
|
||
C::fetch_metrics(configuration, state)?; | ||
|
||
let metric_families = &metrics.gather(); | ||
|
||
encoder | ||
.encode_to_string(metric_families) | ||
.map_err(|_| FetchMetricsError::new("Unable to encode metrics")) | ||
} |
This file contains 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