From 135e845c84f3935c27b140713c55cdcc39bb8d4c Mon Sep 17 00:00:00 2001 From: zhuliquan Date: Thu, 31 Oct 2024 00:32:51 +0800 Subject: [PATCH] fix: crlf => lf for profile.rs (#771) --- crates/arroyo-server-common/src/profile.rs | 118 ++++++++++----------- 1 file changed, 59 insertions(+), 59 deletions(-) diff --git a/crates/arroyo-server-common/src/profile.rs b/crates/arroyo-server-common/src/profile.rs index fae2d784f..8d26cb299 100644 --- a/crates/arroyo-server-common/src/profile.rs +++ b/crates/arroyo-server-common/src/profile.rs @@ -1,59 +1,59 @@ -use axum::{ - extract::Query, - http::StatusCode, - response::{IntoResponse, Response}, -}; -use flate2::write::GzEncoder; -use flate2::Compression; -use pprof::{protos::Message, ProfilerGuardBuilder}; -use std::time::Duration; -use tokio::time::sleep; - -pub async fn handle_get_profile( - Query(params): Query, -) -> Result { - let frequency = params.frequency.unwrap_or(3000); - let duration = params.duration.unwrap_or(30); - match generate_profile(frequency, duration).await { - Ok(body) => Ok(( - StatusCode::OK, - [("Content-Type", "application/octet-stream")], - [( - "Content-Disposition", - "attachment; filename=\"profile.pb.gz\"", - )], - body, - ) - .into_response()), - Err(_) => Err(StatusCode::INTERNAL_SERVER_ERROR), - } -} - -#[derive(serde::Deserialize)] -pub struct ProfileParams { - /// CPU profile collecting frequency, unit: Hz - pub frequency: Option, - /// CPU profile collecting duration, unit: second - pub duration: Option, -} - -async fn generate_profile( - frequency: i32, - duration: u64, -) -> Result, Box> { - let guard = ProfilerGuardBuilder::default() - .frequency(frequency) - .blocklist(&["libc", "libgcc", "pthread", "vdso"]) - .build()?; - - sleep(Duration::from_secs(duration)).await; - - let profile = guard.report().build()?.pprof()?; - - let mut body = Vec::new(); - let mut encoder = GzEncoder::new(&mut body, Compression::default()); - - profile.write_to_writer(&mut encoder)?; - encoder.finish()?; - Ok(body) -} +use axum::{ + extract::Query, + http::StatusCode, + response::{IntoResponse, Response}, +}; +use flate2::write::GzEncoder; +use flate2::Compression; +use pprof::{protos::Message, ProfilerGuardBuilder}; +use std::time::Duration; +use tokio::time::sleep; + +pub async fn handle_get_profile( + Query(params): Query, +) -> Result { + let frequency = params.frequency.unwrap_or(3000); + let duration = params.duration.unwrap_or(30); + match generate_profile(frequency, duration).await { + Ok(body) => Ok(( + StatusCode::OK, + [("Content-Type", "application/octet-stream")], + [( + "Content-Disposition", + "attachment; filename=\"profile.pb.gz\"", + )], + body, + ) + .into_response()), + Err(_) => Err(StatusCode::INTERNAL_SERVER_ERROR), + } +} + +#[derive(serde::Deserialize)] +pub struct ProfileParams { + /// CPU profile collecting frequency, unit: Hz + pub frequency: Option, + /// CPU profile collecting duration, unit: second + pub duration: Option, +} + +async fn generate_profile( + frequency: i32, + duration: u64, +) -> Result, Box> { + let guard = ProfilerGuardBuilder::default() + .frequency(frequency) + .blocklist(&["libc", "libgcc", "pthread", "vdso"]) + .build()?; + + sleep(Duration::from_secs(duration)).await; + + let profile = guard.report().build()?.pprof()?; + + let mut body = Vec::new(); + let mut encoder = GzEncoder::new(&mut body, Compression::default()); + + profile.write_to_writer(&mut encoder)?; + encoder.finish()?; + Ok(body) +}