public void ProcessEvent(EventWrittenEventArgs e)
 {
     if (_eventPairTimer.TryGetEventPairDuration(e, out var duration))
     {
         ContentionTotal.TrackValue(1);
         ContentionSecondsTotal.TrackValue(duration.TotalSeconds);
     }
 }
 public void ProcessEvent(EventWrittenEventArgs e)
 {
     if (_eventPairTimer.TryGetDuration(e, out var duration) == DurationResult.FinalWithDuration)
     {
         ContentionTotal.Inc(_samplingRate.SampleEvery);
         ContentionSecondsTotal.Inc(duration.TotalSeconds * _samplingRate.SampleEvery);
     }
 }
 protected override void ProcessEvent(EventWrittenEventArgs e)
 {
     if (e.EventId == EventIdContentionStop)
     {
         ContentionTotal.Inc();
         ContentionSecondsTotal.Set(e.GetVal <double>(DurationNanoSecondsFieldName) / 1000000000);
     }
 }
        public void RegisterMetrics(MetricFactory metrics)
        {
            if (!_contentionInfo.Enabled && !_runtimeCounters.Enabled)
            {
                return;
            }

            ContentionTotal = metrics.CreateCounter("dotnet_contention_total", "The number of locks contended");
            _runtimeCounters.Events.MonitorLockContentionCount += e => ContentionTotal.Inc(e.IncrementedBy);

            if (_contentionInfo.Enabled)
            {
                ContentionSecondsTotal = metrics.CreateCounter("dotnet_contention_seconds_total", "The total amount of time spent contending locks");
                _contentionInfo.Events.ContentionEnd += e => ContentionSecondsTotal.Inc(e.ContentionDuration.TotalSeconds);
            }
        }
        public void ProcessEvent(EventWrittenEventArgs e)
        {
            switch (_eventPairTimer.TryGetDuration(e, out var duration))
            {
            case DurationResult.Start:
                ContentionTotal.Inc();
                return;

            case DurationResult.FinalWithDuration:
                ContentionSecondsTotal.Inc(duration.TotalSeconds * _samplingRate.SampleEvery);
                return;

            default:
                return;
            }
        }