Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add System.Net.NameResolution metrics #68

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

saul
Copy link

@saul saul commented May 5, 2022

Adds new metrics on .NET 5+:

  • dotnet_dns_lookups_total: The number of DNS lookups requested since the process started
  • dotnet_dns_lookup_duration_avg_seconds: The average time taken for a DNS lookup

@djluck
Copy link
Owner

djluck commented May 9, 2022

Hey, thanks for the submission! I'm on holiday from now until the end of May but I'll try and take a look at this over the next couple of weeks.

Copy link
Owner

@djluck djluck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for this quality submission. I have one blocking comment around the name and type of metric that we are using to measure average duration lookup but that's it, all other comments are just clarifications.

while (!_collector.EventListeners.All(x => x.StartedReceivingEvents))

Console.Write("Waiting for event listeners to be active.. ");
if (!SpinWait.SpinUntil(() =>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a benefit in switching from a blocking wait to a spin wait?

lastLookups = e.Mean;
};

DnsLookupDuration = metrics.CreateHistogram("dotnet_dns_lookup_duration_avg_seconds",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have some issues with taking the average and representing it as a histogram:

  1. The single sample produced from the event parser every n seconds will see invalid values set for the _count and _sum values.
  2. The name includes _avg_ which is confusing for a histogram

I would instead look at creating a gauge to capture the average lookup duration. A histogram would only be viable if we were listening to the individual DNS lookup events and we could track the individual times of each resolution.

.Where(s => allMetrics.SourceToMetrics[s].Count > 0)
.ToList();

if (nonEmptySources.Count == 0)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was my original intention to not render anything for runtime versions where no metrics could be produced. Do you find this alternative easier to understand?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants