Skip to content
This repository has been archived by the owner on Apr 28, 2024. It is now read-only.

WIP ✨ add probe endpoint to allow overrides from prometheus #12

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::error::Error;
use std::fs::File;
use std::io::prelude::*;
use std::io::stdout;
use std::sync::Arc;

use std::time::{Duration, SystemTime};
use structured_logger::{json::new_writer, Builder};

Expand Down Expand Up @@ -56,16 +56,11 @@ async fn main() -> Result<(), Box<dyn Error>> {

let addr = ([0, 0, 0, 0], 9898).into();

let client = Arc::new(PrometheusClient::from_config(&config)?);
let client = PrometheusClient::from_config(&config)?;

let metrics = make_service_fn(move |_| {
let client = client.clone();
async move {
Ok::<_, hyper::Error>(service_fn(move |req| {
let client = client.clone();
handler(req, client)
}))
}
async move { Ok::<_, hyper::Error>(service_fn(move |req| handler(req, client.to_owned()))) }
});

let server = Server::bind(&addr).serve(metrics);
Expand Down Expand Up @@ -208,7 +203,7 @@ impl PrometheusClient {

async fn handler(
_req: Request<Body>,
pc: Arc<PrometheusClient>,
pc: PrometheusClient,
) -> Result<Response<Body>, hyper::Error> {
let encoder = TextEncoder::new();

Expand Down