This adds prefixes to our error! tracing logs on the identity service
Depends on D11831
Differential D11852
[identity] Add prefixes to error logs for filtering will on May 1 2024, 8:03 PM. Authored by Tags None Referenced Files
Details
This adds prefixes to our error! tracing logs on the identity service Depends on D11831 cargo check
Diff Detail
Event TimelineComment Actions I was imagining that all the prefixes (e.g. DB Error) would be defined in a module in constants.rs and then used like this: pub const DB_ERROR_LOG_PREFIX: &str = "DB Error"; error!(DB_ERROR_LOG_PREFIX, "Encountered an unexpected error: {}", e); Comment Actions So that would look something like this on output: {"message":"Encountered an unexpected error: e","DB_ERROR_LOG_PREFIX":"DB Error"} Currently my alarms match on the message field. I think it overcomplicates the cloudwatch patterns if we're accessing each possible prefix variable name so what might be best is each error log specifies some field: error!(errorType=DB_ERROR_LOG_PREFIX, "Encountered an unexpected error: {}", e); would get us: {"message":"Encountered an unexpected error: e", "errorType":"DB Error"} I thought about how we'd be able to store the key value "errorType = DB_ERROR_LOG_PREFIX" in our const file so we wouldn't have to include errorType each time, but I don't think it's possible unless we do something really hacky with mods Another option is a new error log helper function? Comment Actions @varun's concern is valid to me. I like the errorType = ... approach. I think including errorType in each log is okay for now. If this gets too annoying, we can think about creating a custom error! macro
|