nblumhardt / serilog-timings

Extends Serilog with support for timed operations
Apache License 2.0
218 stars 22 forks source link

Feature: Checkpoints and ExceedanceReports #52

Closed sandreas closed 2 years ago

sandreas commented 2 years ago

What do you think about adding

Explanation (in Code):

var exceedTime = TimeSpan.FromSeconds(5)
using (var op = Operation.ExceedanceReport(LogEventLevel.Warn, exceedTime).Time("Creating zip archive")) {
    CopyFilesToTemp();
    op.CheckPoint("files copied to temp");
    CleanUpUnwantedFiles();
    op.CheckPoint("unwanted files deleted");
    ZipFiles();
    op.Complete("zip archive created");
}

Now, if the operation takes less than 5 seconds, NOTHING is logged, because of the second parameter in Operation.ExceedanceReport. This config produces a Warning, ONLY if the whole process takes more than 5 seconds.

The checkpoints result in log entries similar to the existing ones via using ..., but make out a series of timed events:

[WRN] files copied to temp completed in 3200 ms
[WRN] unwanted files deleted in 121 ms (3321 ms)
[WRN] zip archive created in 8433 ms (11.754 ms)
[WRN] Creating zip archive exceeded its time limit of 5.000ms by 6.754ms with a total of 11.754 ms

Advantages:

What do you think?

nblumhardt commented 2 years ago

Hi @sandreas! I think this would be really cool; I'm not really intending to expand this library though - the goal currently is to keep it ultra-simple.

I'd be really happy to see a new library (built out of a fork of this one, if you would like to), that reimagined timings for Serilog as a more sophisticated system for these kinds of operations.

If you're keen to give it a go, I'd also be happy to link it from here. Let me know if so :-)

sandreas commented 2 years ago

Thank you for the quick feedback.

I'm not really intending to expand this library though - the goal currently is to keep it ultra-simple.

Perfectly fine.

I'd be really happy to see a new library (built out of a fork of this one, if you would like to), that reimagined timings for Serilog as a more sophisticated system for these kinds of operations.

Me, too.

If you're keen to give it a go, I'd also be happy to link it from here. Let me know if so :-)

I would love to, but unfortunately there is no time left :-) I thought that these two extensions would be low hangng fruits, since they would only be a little addition to op.Complete, but if this is not the case, I'll accept that.

Since this will not be implemented, should I close this issue?

nblumhardt commented 2 years ago

Thanks @sandreas 👍