Event Metric - GitAtSmsPortal/Metrics.NET GitHub Wiki

An Event is used to record the occurrence of something taking place.

An event can be registered like any other metric type, although it does not accept a unit parameter.

var evnt = Metric.Event("name");
var evnt = Metric.Event("name", new Dictionary<string,string> { {"tagKey","tagValue"} });

The parameters for recording an event are optional fields and timestamp.

The default timestamp if one is not specified will be a UTC timestamp taken at the moment of recording. The default field if none are specified will be the default or specified timestamp.

evnt.Record(); // uses default timestamp and field.
evnt.Record(DateTime.UtcNow); // uses default field.
var fields = new Dictionary<string, object>
{
    { "fieldName", "fieldValue" }
};
evnt.Record(fields); // uses default timestamp
evnt.Record(fields, DateTime.UtcNow);

To keep the memory usage low, there is an event metric cleaner that removes events once they have been reported (if there are reporters) otherwise will clear all events after some interval.

Recording of events are thread safe.