smarkets / marge-bot

A merge-bot for GitLab
BSD 3-Clause "New" or "Revised" License
701 stars 136 forks source link

Log the MR(s) in each log line #315

Open sir4ur0n opened 3 years ago

sir4ur0n commented 3 years ago

Current Marge Bot logs do not always tell which MR Marge is working on, which can make debugging unnecessarily tedious, as one needs to read previous log lines to find an MR number or branch name, and hope the current log line is related.

Examples of logging with not enough info in itself:

2021-06-21 06:29:50,578 WARNING Suspicious CI status: None
2021-06-21 06:29:14,476 WARNING git returned 128
2021-06-21 06:29:13,783 INFO Running git -C /tmp/tmp_izdcf04/tmpcs1u03ih config user.name 'Marge Bot'

It would be great if the MR (or MRs, in case of batching? We don't use batching on my project so I don't know) - if any - that triggers a log line was (optionally? a configuration flag?) part of the log line.

I reckon not all log lines would be eligible, e.g. such logs are - I guess - meta and not directly linked to an MR:


2021-06-21 07:09:41,561 INFO Got 1 requests to merge;
2021-06-21 07:09:41,562 INFO Attempting to merge the oldest MR...

That way, one could easily search all logs related to an MR in case it fails and Marge greets us with the famous "I am broken inside" :grin:

Note: Such info should probably be easily parseable to be digested into a log system, e.g. ELK or Prometheus/Grafana

What do you think about this idea?

Thank you for this tool!

snim2 commented 3 years ago

This is a great idea, but many of us use marge-bot with groups of projects, so we really need to prepend group/project!MR to each log line. So,

2021-06-21 06:29:14,476 WARNING git returned 128

would become:

2021-06-21 06:29:14,476 WARNING group/project/!123 git returned 128