Skip to content

Commit

Permalink
Add current-dns-lookups NameResolution metric (#1312)
Browse files Browse the repository at this point in the history
  • Loading branch information
MihaZupan authored Oct 20, 2021
1 parent 7319eb3 commit 8220700
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ internal sealed class NameResolutionEventListenerService : EventListenerService<
{
protected override string EventSourceName => "System.Net.NameResolution";

#if NET6_0_OR_GREATER
protected override int NumberOfMetrics => 3;
#else
protected override int NumberOfMetrics => 2;
#endif

public NameResolutionEventListenerService(ILogger<NameResolutionEventListenerService> logger, IEnumerable<INameResolutionTelemetryConsumer> telemetryConsumers, IEnumerable<IMetricsConsumer<NameResolutionMetrics>> metricsConsumers)
: base(logger, telemetryConsumers, metricsConsumers)
Expand Down Expand Up @@ -74,6 +78,12 @@ protected override bool TrySaveMetric(NameResolutionMetrics metrics, string name
metrics.AverageLookupDuration = TimeSpan.FromMilliseconds(value);
break;

#if NET6_0_OR_GREATER
case "current-dns-lookups":
metrics.CurrentDnsLookups = (long)value;
break;
#endif

default:
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,12 @@ public sealed class NameResolutionMetrics
/// Average DNS lookup duration in the last metrics interval.
/// </summary>
public TimeSpan AverageLookupDuration { get; internal set; }

#if NET6_0_OR_GREATER
/// <summary>
/// Number of DNS lookups that have started but not yet completed or failed.
/// </summary>
public long CurrentDnsLookups { get; internal set; }
#endif
}
}

0 comments on commit 8220700

Please sign in to comment.