mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-07 10:31:46 +00:00
enrich messages
This commit is contained in:
1 parent
552ec9ee9d
commit
0c783e25fb
1 file changed
+28
-4
@@ -112,12 +112,36 @@ impl PagerClient {
|
||||
labels.push(("hostname".to_string(), h.clone()));
|
||||
}
|
||||
|
||||
if let Some(method) = ¬ification.http_method {
|
||||
labels.push(("http_method".to_string(), method.clone()));
|
||||
}
|
||||
|
||||
if let Some(path) = ¬ification.endpoint_path {
|
||||
labels.push(("http_path".to_string(), path.clone()));
|
||||
}
|
||||
|
||||
let labels = if labels.is_empty() { None } else { Some(labels) };
|
||||
|
||||
// Enrich the description with hostname if both are present.
|
||||
let description = match (¬ification.description, &self.hostname) {
|
||||
(Some(desc), Some(h)) => Some(format!("{}\n\nHostname: {}", desc, h)),
|
||||
(desc, _) => desc.clone(),
|
||||
// Enrich the description with HTTP context and hostname if present.
|
||||
let description = match ¬ification.description {
|
||||
Some(desc) => {
|
||||
let mut parts = vec![desc.clone()];
|
||||
|
||||
if let Some(method) = ¬ification.http_method {
|
||||
parts.push(format!("HTTP Method: {}", method));
|
||||
}
|
||||
|
||||
if let Some(path) = ¬ification.endpoint_path {
|
||||
parts.push(format!("HTTP Path: {}", path));
|
||||
}
|
||||
|
||||
if let Some(h) = &self.hostname {
|
||||
parts.push(format!("Hostname: {}", h));
|
||||
}
|
||||
|
||||
Some(parts.join("\n\n"))
|
||||
}
|
||||
None => None,
|
||||
};
|
||||
|
||||
let result = create_alert(CreateAlertArgs {
|
||||
|
||||
Reference in new issue
Block a user