Module airbag::middleware
source · Expand description
Airbag supports installing Middleware implementors on backends to allow processing alerts before they are being sent.
Installing a middleware is done using the [install] method.
For example: this will install a PagerDuty backend that will prefix all alert titles with "Prefix: "
:
use airbag::prelude::*;
airbag::configure(
airbag::backends::PagerDuty::builder().token("PD token").build()
).with_middleware(airbag::middleware::TitlePrefix::new("Prefix: "));
Most use cases should probably opt for the [Backend::map] method, which allows wrapping backends in middleware that processes alerts via callbacks. For example, here is a use case that adds a constant field to all alerts
use airbag::prelude::*;
airbag::configure(
airbag::backends::PagerDuty::builder().token("PD token").build()
).map(
|alert| alert.with_field_if_missing("my_label", "some_value")
);
Structs§
- Prefixes dedup keys with a specific string. This is useful in case you have multiple instances of a specific app and you want the dedup keys from one instance to not interfere with dedup keys of another
- Prefixes alert titles with a specific string. This is useful in cases where you want alert titles to easily convey instance or context information