cmd/mincatcher: more work to make it play nice with tailscaled
Signed-off-by: Christine Dodrill <me@christine.website>
This commit is contained in:
parent
36832af7ad
commit
5239861683
|
@ -706,30 +706,6 @@ dependencies = [
|
|||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "logcatcher"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"axum",
|
||||
"chrono",
|
||||
"futures",
|
||||
"headers",
|
||||
"hyper",
|
||||
"lazy_static",
|
||||
"logtail",
|
||||
"prometheus",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"structopt",
|
||||
"tokio",
|
||||
"tower",
|
||||
"tower-http",
|
||||
"tracing",
|
||||
"tracing-subscriber",
|
||||
"zstd",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "logtail"
|
||||
version = "0.1.0"
|
||||
|
@ -805,6 +781,30 @@ version = "0.3.16"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d"
|
||||
|
||||
[[package]]
|
||||
name = "mincatcher"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"axum",
|
||||
"chrono",
|
||||
"futures",
|
||||
"headers",
|
||||
"hyper",
|
||||
"lazy_static",
|
||||
"logtail",
|
||||
"prometheus",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"structopt",
|
||||
"tokio",
|
||||
"tower",
|
||||
"tower-http",
|
||||
"tracing",
|
||||
"tracing-subscriber",
|
||||
"zstd",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "miniz_oxide"
|
||||
version = "0.4.4"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[package]
|
||||
name = "logcatcher"
|
||||
name = "mincatcher"
|
||||
version = "0.1.0"
|
||||
edition = "2018"
|
||||
|
||||
|
|
|
@ -36,7 +36,10 @@ async fn main() -> Result<()> {
|
|||
tracing_subscriber::fmt::init();
|
||||
|
||||
let cfg = Config::from_args();
|
||||
println!("{:?}", cfg);
|
||||
info!(
|
||||
"listening on http://{} for logs and http://{} for metrics",
|
||||
cfg.http_host, cfg.debug_host
|
||||
);
|
||||
|
||||
let server = Server::new(cfg)?;
|
||||
server.run().await?;
|
||||
|
|
|
@ -9,9 +9,13 @@ use headers::{Header, HeaderName, HeaderValue};
|
|||
use hyper::http::StatusCode;
|
||||
use logtail::PublicID;
|
||||
use prometheus::{Encoder, IntCounterVec, IntGauge};
|
||||
use std::{convert::TryInto, net::SocketAddr};
|
||||
use std::net::SocketAddr;
|
||||
use tokio::sync::Semaphore;
|
||||
use tower_http::trace::TraceLayer;
|
||||
use tower_http::{
|
||||
trace::{DefaultOnResponse, TraceLayer},
|
||||
LatencyUnit,
|
||||
};
|
||||
use tracing::Level;
|
||||
|
||||
const BYTE_MAX: usize = 1048576000;
|
||||
|
||||
|
@ -57,7 +61,13 @@ impl Server {
|
|||
|
||||
let router = Router::new()
|
||||
.route("/c/:collection/:private_id", post(put_logs))
|
||||
.layer(TraceLayer::new_for_http());
|
||||
.layer(
|
||||
TraceLayer::new_for_http().on_response(
|
||||
DefaultOnResponse::new()
|
||||
.level(Level::INFO)
|
||||
.latency_unit(LatencyUnit::Micros),
|
||||
),
|
||||
);
|
||||
|
||||
hyper::Server::bind(&self.http_host)
|
||||
.serve(router.into_make_service())
|
||||
|
@ -145,7 +155,7 @@ async fn put_logs(
|
|||
.inc();
|
||||
}
|
||||
|
||||
StatusCode::NO_CONTENT
|
||||
StatusCode::OK
|
||||
}
|
||||
|
||||
async fn metrics(addr: SocketAddr) -> Result<()> {
|
||||
|
|
Loading…
Reference in New Issue