generated from fossapps/Micro.Starter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(measurements): add measurements
- Loading branch information
Showing
5 changed files
with
73 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace Micro.KeyStore.Api.Measurements | ||
{ | ||
public static class KeyController | ||
{ | ||
public static void Measure | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using System; | ||
using App.Metrics; | ||
|
||
namespace Micro.KeyStore.Api.Measurements | ||
{ | ||
public class WorkerMeasurements | ||
{ | ||
public static void MeasureTime(IMetrics metrics, TimeSpan duration) | ||
{ | ||
var timer = new App.Metrics.Timer.TimerOptions | ||
{ | ||
Name = "KeyArchiveSaveTime", | ||
DurationUnit = TimeUnit.Milliseconds, | ||
RateUnit = TimeUnit.Milliseconds | ||
}; | ||
metrics?.Provider?.Timer.Instance(timer).Record((long) duration.TotalMilliseconds, TimeUnit.Milliseconds); | ||
} | ||
|
||
public static void MeasureArchiveOccurrence(IMetrics metrics) | ||
{ | ||
var meter = new App.Metrics.Meter.MeterOptions | ||
{ | ||
Name = "KeyArchive", | ||
MeasurementUnit = Unit.Events, | ||
RateUnit = TimeUnit.Seconds | ||
}; | ||
metrics?.Provider?.Meter.Instance(meter).Mark(); | ||
} | ||
public static void MeasureErrorOccurrence(IMetrics metrics) | ||
{ | ||
var meter = new App.Metrics.Meter.MeterOptions | ||
{ | ||
Name = "KeyArchiveError", | ||
MeasurementUnit = Unit.Events, | ||
RateUnit = TimeUnit.Seconds | ||
}; | ||
metrics?.Provider?.Meter.Instance(meter).Mark(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters