Extremely Weird/Bad Metrics Consumer Behavior with Prometheus.NET and/or AppInsights #2121
-
I recently added Prometheus metrics to my YARP proxy, essentially copying the samples in this repo. The only difference is that I'm using the latest versions of the Prometheus.NET libraries ( I noticed something very odd about the metrics being produced. I saw all the For example, I'd make a single request through the proxy to a page that also requests 2 additional resources. As expected I stuck a breakpoint in
On each hit that wasn't So here's what I've now learned. The To fix the "jumping around" of the data (3-17-3), I had to disable built-in event counters tracking with a suppression at startup: Metrics.SuppressDefaultMetrics(new SuppressDefaultMetricOptions
{
SuppressEventCounters = true
}); Even with this "fix", the value of It turns out that I also have Application Insights installed. After a bunch of guess-and-check I isolated it to the on-by-default Has anyone experienced any of this before? Does it sound like there could be a bug on the YARP side? Or with Prometheus.NET, AppInsights, or all of the above? Aside: should the samples be updated to use the most recent version of Prometheus.NET and potentially call-out the above issue? Edit: I thought I had completely worked-around the issue. I had been validating the last bits without hitting a proxy route as the behavior would trigger on initial load. But I found one more issue once I actually hit a proxy route. If the AppInsights |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
This is likely related to #2102. There is a bug in EventListener that YARP's telemetry consumption implementation runs into when you listen to both |
Beta Was this translation helpful? Give feedback.
-
If the daily build fix works, the samples should probably still be updated to use the latest prometheus libraries. They're several major versions behind. As is, you're still going to get double metrics for yarp-related things (under different names) unless you either: A. opt-out of EventCounter instrumentation completely (as in my OP), or |
Beta Was this translation helpful? Give feedback.
-
Daily build worked! The socket bytes sent metrics constantly increases if I leave the App Insights Quick Pulse stream enabled, but that makes sense since it's constantly using sockets to communicate with Azure. I don't think there's any way for that to be excluded (by me, or generally). I still have an issue that I believe is a bug in prometheus.net where I'm getting the event source metrics when they shouldn't be included by default (and filtering options don't seem to work). I opened an issue with them and crossing-fingers YARP isn't somehow to blame. Regarding the fix: is it possible to get that back-ported? I'm more than happy to use preview/daily feeds to debug and validate but I can't push that into production... especially with the BCL preview package (we cannot update to net8 until at least GA). It seems like it can have a more general impact for anyone wishing to trust metrics coming out of YARP. |
Beta Was this translation helpful? Give feedback.
This is likely related to #2102. There is a bug in EventListener that YARP's telemetry consumption implementation runs into when you listen to both
HttpMetrics
andForwarderMetrics
.We've recently worked around this issue in YARP: #2104. Are you able to reproduce the issue using a daily build of YARP?