Skip to content

Commit

Permalink
feat(pprof): addres comments
Browse files Browse the repository at this point in the history
  • Loading branch information
evenyag committed Jun 6, 2023
1 parent 8f2d769 commit 5d46b9c
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/common/pprof/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ license.workspace = true

[dependencies]
common-error = { path = "../error" }
pprof = { version = "0.11.1", features = [
pprof = { version = "0.11", features = [
"flamegraph",
"prost-codec",
"protobuf",
Expand Down
48 changes: 36 additions & 12 deletions src/common/pprof/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,45 @@ use std::time::Duration;

use common_error::prelude::{ErrorExt, StatusCode};
use prost::Message;
use snafu::{ResultExt, Snafu};
use snafu::{Location, ResultExt, Snafu};

#[derive(Debug, Snafu)]
pub enum Error {
#[snafu(display("Failed to create profiler guard, source: {}", source))]
CreateGuard { source: pprof::Error },

#[snafu(display("Failed to create report, source: {}", source))]
CreateReport { source: pprof::Error },

#[snafu(display("Failed to create flamegraph, source: {}", source))]
CreateFlamegraph { source: pprof::Error },

#[snafu(display("Failed to create pprof report, source: {}", source))]
ReportPprof { source: pprof::Error },
#[snafu(display(
"Failed to create profiler guard, source: {}, location: {}",
source,
location
))]
CreateGuard {
source: pprof::Error,
location: Location,
},

#[snafu(display("Failed to create report, source: {}, location: {}", source, location))]
CreateReport {
source: pprof::Error,
location: Location,
},

#[snafu(display(
"Failed to create flamegraph, source: {}, location: {}",
source,
location
))]
CreateFlamegraph {
source: pprof::Error,
location: Location,
},

#[snafu(display(
"Failed to create pprof report, source: {}, location: {}",
source,
location
))]
ReportPprof {
source: pprof::Error,
location: Location,
},
}

pub type Result<T> = std::result::Result<T, Error>;
Expand Down

0 comments on commit 5d46b9c

Please sign in to comment.