endpoints comments
test-org/prometheus-exporter/pipeline/pr-rc This commit looks good
Details
test-org/prometheus-exporter/pipeline/pr-rc This commit looks good
Details
parent
1bf6595bbc
commit
83516e5fbc
|
|
@ -10,6 +10,17 @@ use crate::AppState;
|
||||||
use tracing::{ error, info, warn };
|
use tracing::{ error, info, warn };
|
||||||
use crate::metrics::{MetricsProcesser, MetricsValueType};
|
use crate::metrics::{MetricsProcesser, MetricsValueType};
|
||||||
|
|
||||||
|
/// An `Update` endpoint
|
||||||
|
///
|
||||||
|
/// Used to registrate new metrics and to update already
|
||||||
|
/// existing in local metrics `Registry`
|
||||||
|
///
|
||||||
|
/// # Usage
|
||||||
|
///
|
||||||
|
/// ``` bash
|
||||||
|
/// curl -X POST -d '"id" : ...' 'http::/localhost:9100/update'
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
pub async fn update_metrics(
|
pub async fn update_metrics(
|
||||||
State(state): State<Arc<AppState>>,
|
State(state): State<Arc<AppState>>,
|
||||||
Json(request) : Json<PrometheusMetrics<'_>>
|
Json(request) : Json<PrometheusMetrics<'_>>
|
||||||
|
|
@ -59,6 +70,17 @@ pub async fn update_metrics(
|
||||||
(http::StatusCode::ACCEPTED, "Ok")
|
(http::StatusCode::ACCEPTED, "Ok")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// An `Metrics` endpoint
|
||||||
|
///
|
||||||
|
/// Needed in sharing current local metrics `Registry` state
|
||||||
|
/// and all stored metrics
|
||||||
|
///
|
||||||
|
/// # Usage
|
||||||
|
///
|
||||||
|
/// ``` bash
|
||||||
|
/// curl -X GET 'http::/localhost:9100/metrics'
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
pub async fn metrics_handler(State(state): State<Arc<AppState>>) -> String {
|
pub async fn metrics_handler(State(state): State<Arc<AppState>>) -> String {
|
||||||
let registry = state.registry.lock();
|
let registry = state.registry.lock();
|
||||||
|
|
||||||
|
|
@ -76,6 +98,11 @@ pub async fn metrics_handler(State(state): State<Arc<AppState>>) -> String {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A function-registrator
|
||||||
|
///
|
||||||
|
/// Registrates or updates metrics state in local
|
||||||
|
/// `Registry`
|
||||||
|
///
|
||||||
pub fn update_or_insert_metric<'a>(
|
pub fn update_or_insert_metric<'a>(
|
||||||
metric: Gauge,
|
metric: Gauge,
|
||||||
registry: MutexGuard<'a, Registry>,
|
registry: MutexGuard<'a, Registry>,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue