@@ -10,7 +10,7 @@ use std::{
1010} ;
1111
1212use crate :: {
13- backend:: { void_backend, BackendReady , BackendUninitialized , Rule , Tag , VoidConfig } ,
13+ backend:: { void_backend, BackendReady , BackendUninitialized , Report , Rule , Tag , VoidConfig } ,
1414 error:: Result ,
1515 session:: { Session , SessionManager , SessionSignal } ,
1616 timer:: { Timer , TimerSignal } ,
@@ -45,6 +45,8 @@ pub struct PyroscopeConfig {
4545 pub auth_token : Option < String > ,
4646 /// Regex to apply
4747 pub regex : Option < Regex > ,
48+ /// Function to apply
49+ pub func : Option < fn ( Report ) -> Report > ,
4850}
4951
5052impl Default for PyroscopeConfig {
@@ -60,6 +62,7 @@ impl Default for PyroscopeConfig {
6062 spy_name : "undefined" . to_string ( ) ,
6163 auth_token : None ,
6264 regex : None ,
65+ func : None ,
6366 }
6467 }
6568}
@@ -81,6 +84,7 @@ impl PyroscopeConfig {
8184 spy_name : String :: from ( "undefined" ) , // Spy Name should be set by the backend
8285 auth_token : None , // No authentication token
8386 regex : None , // No regex
87+ func : None , // No function
8488 }
8589 }
8690
@@ -129,6 +133,14 @@ impl PyroscopeConfig {
129133 }
130134 }
131135
136+ /// Set the Function.
137+ pub fn func ( self , func : fn ( Report ) -> Report ) -> Self {
138+ Self {
139+ func : Some ( func) ,
140+ ..self
141+ }
142+ }
143+
132144 /// Set the tags.
133145 ///
134146 /// # Example
@@ -272,6 +284,24 @@ impl PyroscopeAgentBuilder {
272284 }
273285 }
274286
287+ /// Set the Function.
288+ /// This is optional. If not set, the agent will not apply any function.
289+ /// #Example
290+ /// ```ignore
291+ /// let builder = PyroscopeAgentBuilder::new("http://localhost:8080", "my-app")
292+ /// .func(|report| {
293+ /// report
294+ /// })
295+ /// .build()
296+ /// ?;
297+ /// ```
298+ pub fn func ( self , func : fn ( Report ) -> Report ) -> Self {
299+ Self {
300+ config : self . config . func ( func) ,
301+ ..self
302+ }
303+ }
304+
275305 /// Set tags. Default is empty.
276306 ///
277307 /// # Example
0 commit comments