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

Fixed excessive logs + default level + environment label for Loki logs #226

Merged
merged 1 commit into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions api/configs/grafana-logs.config.river
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ loki.source.file "logs" {
}

loki.write "logs" {
external_labels = {
environment = env("ENVIRONMENT"),
}
endpoint {
url = "https://logs-prod-us-central1.grafana.net/loki/api/v1/push"
basic_auth {
Expand Down
6 changes: 3 additions & 3 deletions api/src/handlers/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use tracing::{error, info};

pub(crate) const COMPILATION_LABEL_VALUE: &str = "compilation";

#[instrument]
#[instrument(skip(request_json, _rate_limited, engine))]
#[post("/compile", format = "json", data = "<request_json>")]
pub async fn compile(
request_json: Json<CompilationRequest>,
Expand All @@ -43,7 +43,7 @@ pub async fn compile(
})
}

#[instrument]
#[instrument(skip(request_json, _rate_limited, engine))]
#[post("/compile-async", format = "json", data = "<request_json>")]
pub async fn compile_async(
request_json: Json<CompilationRequest>,
Expand All @@ -55,7 +55,7 @@ pub async fn compile_async(
do_process_command(ApiCommand::Compile(request_json.0), engine)
}

#[instrument]
#[instrument(skip(engine))]
#[get("/compile-result/<process_id>")]
pub async fn get_compile_result(process_id: String, engine: &State<WorkerEngine>) -> String {
info!("/compile-result/{:?}", process_id);
Expand Down
2 changes: 1 addition & 1 deletion api/src/handlers/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use rocket::State;
use tracing::{info, instrument};
use uuid::Uuid;

#[instrument]
#[instrument(skip(engine))]
#[get("/process_status/<process_id>")]
pub async fn get_process_status(process_id: String, engine: &State<WorkerEngine>) -> String {
info!("/process_status/{:?}", process_id);
Expand Down
10 changes: 5 additions & 5 deletions api/src/handlers/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ use crate::worker::WorkerEngine;

pub(crate) const VERIFICATION_LABEL_VALUE: &str = "compilation";

#[instrument]
#[instrument(skip(verification_request_json, _rate_limited, engine))]
#[post("/verify", format = "json", data = "<verification_request_json>")]
pub async fn verify(
verification_request_json: Json<VerificationRequest>,
_rate_limited: RateLimited,
engine: &State<WorkerEngine>,
) -> Json<VerifyResponse> {
info!("/verify");
info!("/verify/{:?}", verification_request_json.config);

do_verify(verification_request_json.0, &engine.metrics)
.await
Expand All @@ -40,19 +40,19 @@ pub async fn verify(
})
}

#[instrument]
#[instrument(skip(_rate_limited, engine))]
#[post("/verify-async", format = "json", data = "<verification_request_json>")]
pub fn verify_async(
verification_request_json: Json<VerificationRequest>,
_rate_limited: RateLimited,
engine: &State<WorkerEngine>,
) -> String {
info!("/verify-async",);
info!("/verify-async/{:?}", verification_request_json.config);

do_process_command(ApiCommand::Verify(verification_request_json.0), engine)
}

#[instrument]
#[instrument(skip(engine))]
#[get("/verify-result/<process_id>")]
pub async fn get_verify_result(process_id: String, engine: &State<WorkerEngine>) -> String {
info!("/verify-result/{:?}", process_id);
Expand Down
2 changes: 1 addition & 1 deletion api/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ pub(crate) fn create_metrics(registry: Registry) -> Result<Metrics, CoreError> {
})
}

#[instrument]
#[instrument(skip(registry))]
#[get("/metrics")]
pub(crate) async fn metrics(registry: &State<Registry>) -> String {
let metric_families = registry.gather();
Expand Down
4 changes: 2 additions & 2 deletions api/src/tracing_log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ pub fn filter_layer(level: LogLevel) -> EnvFilter {
LogLevel::Off => "off",
};

tracing_subscriber::filter::EnvFilter::try_new(filter_str).expect("filter string must parse")
EnvFilter::try_new(filter_str).expect("filter string must parse")
}

pub fn init_logger() -> Result<(), CoreError> {
Expand All @@ -120,7 +120,7 @@ pub fn init_logger() -> Result<(), CoreError> {
let log_type = LogType::from(std::env::var("LOG_TYPE").unwrap_or_else(|_| "json".to_string()));
let log_level = LogLevel::from(
std::env::var("LOG_LEVEL")
.unwrap_or_else(|_| "debug".to_string())
.unwrap_or_else(|_| "normal".to_string())
.as_str(),
);

Expand Down
Loading