pub struct Task(_);
Implementations
sourceimpl Task
impl Task
pub fn create_new(name: &str) -> Self
pub fn create(&self, name: &str) -> Self
sourcepub async fn spawn_new<F, FT, T>(name: &str, f: F) -> Result<T>where
F: FnOnce(Task) -> FT,
FT: Future<Output = Result<T>> + Send,
T: Send,
pub async fn spawn_new<F, FT, T>(name: &str, f: F) -> Result<T>where
F: FnOnce(Task) -> FT,
FT: Future<Output = Result<T>> + Send,
T: Send,
Spawn a new top level task, with no parent. This should usually be done in the very beginning of the process/application.
pub async fn spawn<F, FT, T, S: Into<String>>(&self, name: S, f: F) -> Result<T>where
F: FnOnce(Task) -> FT,
FT: Future<Output = Result<T>> + Send,
T: Send,
pub fn spawn_sync<F, T, S: Into<String>>(&self, name: S, f: F) -> Result<T>where
F: FnOnce(Task) -> Result<T>,
T: Send,
pub fn data<D: Into<DataValue>>(&self, name: &str, data: D)
sourcepub fn get_data(&self, name: &str) -> Option<DataValue>
pub fn get_data(&self, name: &str) -> Option<DataValue>
Get a piece of previously set data or transitive data. This can be
useful if session/request tracking IDs need to be past to other loggers,
e.g. when shelling out to another process that needs to set the same
session_id
inside so we can group the events together.
pub fn data_transitive<D: Into<DataValue>>(&self, name: &str, data: D)
pub fn progress(&self, done: i64, total: i64)
sourcepub fn hide_error_msg(&self, msg: Option<String>)
pub fn hide_error_msg(&self, msg: Option<String>)
Reporters can use this flag to choose to not report errors. This is useful for cases where there’s a large task chain and every single task reports a partial errors (that gets built up with each task) It would make sense to report it only once at the top level (thrift request, cli call, etc) and only mark other tasks. If set to Some, the message inside is what would be reported by default instead of reporting errors to avoid confusion (e.g. “error was hidden, see …”) see hide_errors_default_msg()
sourcepub fn attach_transitive_data_to_errors(&self, val: bool)
pub fn attach_transitive_data_to_errors(&self, val: bool)
When errors occur, we attach task data to it in the description. If set to false, only task direct data will be attached and not transitive data. This is useful sometimes to remove the noise of transitive data appearing in every error in the chain (e.g. hostname) see attach_transitive_data_to_errors_default()