public void TryGetEventPairDuration_recognizes_start_events_that_will_be_discarded() { var startEvent1 = CreateEventWrittenEventArgs(EventIdStart, DateTime.UtcNow, payload: 1L); Assert.That(_eventPairTimer.TryGetDuration(startEvent1, out var duration), Is.EqualTo(DurationResult.Start)); Assert.That(duration, Is.EqualTo(TimeSpan.Zero)); }
public void ProcessEvent(EventWrittenEventArgs e) { switch (_eventPairTimerConnections.TryGetDuration(e, out var duration1)) { case DurationResult.Start: ConnectionStart?.Invoke(Events.ConnectionStartEvent.Instance); break; case DurationResult.FinalWithDuration: ConnectionStop?.InvokeManyTimes(_samplingRate.SampleEvery, Events.ConnectionStopEvent.GetFrom(duration1)); break; default: break; } switch (_eventPairTimerRequests.TryGetDuration(e, out var duration2)) { case DurationResult.Start: ConnectionStart?.Invoke(Events.ConnectionStartEvent.Instance); break; case DurationResult.FinalWithDuration: ConnectionStop?.InvokeManyTimes(_samplingRate.SampleEvery, Events.ConnectionStopEvent.GetFrom(duration2)); break; default: break; } if (e.EventId == EventIdConnectionStart) { ConnectionStart?.Invoke(Events.ConnectionStartEvent.ParseFrom(e)); return; } if (e.EventId == EventIdConnectionStop) { ConnectionStop?.Invoke(Events.ConnectionStopEvent.ParseFrom(e)); return; } if (e.EventId == EventIdRequestStart) { RequestStart?.Invoke(Events.RequestStartEvent.ParseFrom(e)); return; } if (e.EventId == EventIdRequestStop) { RequestStop?.Invoke(Events.RequestStopEvent.ParseFrom(e)); return; } if (e.EventId == EventIdConnectionRejected) { ConnectionRejected?.Invoke(Events.ConnectionRejectedEvent.ParseFrom(e)); return; } }
public void ProcessEvent(EventWrittenEventArgs e) { if (_eventPairTimer.TryGetDuration(e, out var duration) == DurationResult.FinalWithDuration) { ContentionTotal.Inc(_samplingRate.SampleEvery); ContentionSecondsTotal.Inc(duration.TotalSeconds * _samplingRate.SampleEvery); } }
public void ProcessEvent(EventWrittenEventArgs e) { if (_eventPairTimer.TryGetDuration(e, out var duration) != DurationResult.FinalWithDuration) { return; } _metrics.Provider.Timer.Instance(DotNetRuntimeMetricsRegistry.Timers.ScheduleDelay).Record(duration.Ticks * 100, TimeUnit.Nanoseconds); }
public void ProcessEvent(EventWrittenEventArgs e) { if (_eventPairTimer.TryGetDuration(e, out var duration) == DurationResult.FinalWithDuration) { // dynamic methods are of special interest to us- only a certain number of JIT'd dynamic methods // will be cached. Frequent use of dynamic can cause methods to be evicted from the cache and re-JIT'd var methodFlags = (uint)e.Payload[5]; var dynamicLabelValue = (methodFlags & 0x1) == 0x1 ? LabelValueTrue : LabelValueFalse; MethodsJittedTotal.Labels(dynamicLabelValue).Inc(_samplingRate.SampleEvery); MethodsJittedSecondsTotal.Labels(dynamicLabelValue).Inc(duration.TotalSeconds * _samplingRate.SampleEvery); } }
public void ProcessEvent(EventWrittenEventArgs e) { switch (_eventPairTimer.TryGetDuration(e, out var duration)) { case DurationResult.Start: ContentionStart?.Invoke(Events.ContentionStartEvent.Instance); return; case DurationResult.FinalWithDuration: ContentionEnd?.InvokeManyTimes(_samplingRate.SampleEvery, Events.ContentionEndEvent.GetFrom(duration)); return; default: return; } }
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; } }
public void ProcessEvent(EventWrittenEventArgs e) { switch (_eventPairTimer.TryGetDuration(e, out var duration)) { case DurationResult.Start: ScheduledCount.Inc(); return; case DurationResult.FinalWithDuration: ScheduleDelay.Observe(duration.TotalSeconds, _samplingRate.SampleEvery); return; default: return; } }
public void ProcessEvent(EventWrittenEventArgs e) { if (e.EventId == EventIdAllocTick) { AllocationTick?.Invoke(Events.AllocationTickEvent.ParseFrom(e)); return; } if (e.EventId == EventIdHeapStats) { HeapStats?.Invoke(Events.HeapStatsEvent.ParseFrom(e)); return; } // flags representing the "Garbage Collection" + "Preparation for garbage collection" pause reasons const uint suspendGcReasons = 0x1 | 0x6; if (e.EventId == EventIdSuspendEEStart && ((uint)e.Payload[0] & suspendGcReasons) == 0) { // Execution engine is pausing for a reason other than GC, discard event. return; } if (_gcPauseEventTimer.TryGetDuration(e, out var pauseDuration) == DurationResult.FinalWithDuration) { PauseComplete?.Invoke(Events.PauseCompleteEvent.GetFrom(pauseDuration)); return; } if (e.EventId == EventIdGcStart) { CollectionStart?.Invoke(Events.CollectionStartEvent.ParseFrom(e)); } if (_gcEventTimer.TryGetDuration(e, out var gcDuration, out var gcData) == DurationResult.FinalWithDuration) { CollectionComplete?.Invoke(Events.CollectionCompleteEvent.GetFrom(gcData.Generation, gcData.Type, gcDuration)); } }
public void ProcessEvent(EventWrittenEventArgs e) { if (_eventPairTimer.TryGetDuration(e, out var duration) == DurationResult.FinalWithDuration) { // dynamic methods are of special interest to us- only a certain number of JIT'd dynamic methods // will be cached. Frequent use of dynamic can cause methods to be evicted from the cache and re-JIT'd var methodFlags = (uint)e.Payload[5]; var dynamicLabelValue = (methodFlags & 0x1) == 0x1 ? LabelValueTrue : LabelValueFalse; _metrics.Provider.Timer.Instance(DotNetRuntimeMetricsRegistry.Timers.MethodsJittedMilliSecondsTotal, new MetricTags(DynamicLabel, dynamicLabelValue)).Record(duration.Ticks * 100, TimeUnit.Nanoseconds); _metrics.Provider.Timer.Instance(DotNetRuntimeMetricsRegistry.Timers.MethodsJittedMilliSecondsTotal) .Record(duration.Ticks * 100, TimeUnit.Nanoseconds); var methodsJittedMsTotalCounter = _metrics.Provider.Timer.Instance(DotNetRuntimeMetricsRegistry.Timers.MethodsJittedMilliSecondsTotal); _jitCpuProcessTotalCpuTimer.Calculate(); _metrics.Measure.Gauge.SetValue(DotNetRuntimeMetricsRegistry.Gauges.CpuRatio, () => new RatioGauge( () => methodsJittedMsTotalCounter.GetValueOrDefault().Histogram.LastValue, () => _jitCpuProcessTotalCpuTimer.ProcessTimeUsed.Ticks * 100.0)); } }
public void TryGetEventPairDuration_ignores_events_that_its_not_configured_to_look_for() { var nonMonitoredEvent = CreateEventWrittenEventArgs(3); Assert.That(_eventPairTimer.TryGetDuration(nonMonitoredEvent, out var duration), Is.EqualTo(DurationResult.Unrecognized)); Assert.That(duration, Is.EqualTo(TimeSpan.Zero)); }