microsoft / ApplicationInsights-node.js

Microsoft Application Insights SDK for Node.js
MIT License
321 stars 138 forks source link

customMetrics problems #1323

Open skhilliard opened 1 month ago

skhilliard commented 1 month ago

When upgrading from 2.x to 3.0.1, we are seeing a lot of warnings like this...

The first 6 of these aren't generated by any metrics we are doing, which is odd. The last one is one that we are using. It seems like the code doesn't like the fact that we have spaces in the metric name, which was allowed before. I do still see these appearing in metrics though, so it seems like a false warning.

Also, it looks like different instances of these sometimes get aggregated with 3.x, which isn't good for metrics...for example:

image

vs. 2.x

image

JacksonWeber commented 1 month ago

@skhilliard Those first 6 warnings are performance counters. You can disable them via configuration options in Application Insights if you don't need them and want to remove the warnings. A fix will be applied to the Azure Monitor Exporter that will remove these warnings.

Your last metric "Redis Health Check" is invalid because of added spaces. This is another effect of moving to OpenTelemetry under the hood in 3.X and something I believe is worth updating in the migration guide. Thank you for your input there!

If you want fine grain control of how metrics are collected, I'd suggest following the migration guide above and moving to the Azure Monitor OpenTelemetry. Application Insights version 3.X is intended to be an easy upgrade path for those who have basic instrumentations with 2.X, while if you want more control and the advantages of OpenTelemetry, it's best to take advantage of the Azure Monitor OpenTelemetry.

skhilliard commented 1 month ago

@JacksonWeber Did you see my question regarding the metrics being "merged" into one value? E.g. instead of 4 Redis Health Check items with value of one, they are combined into one with a value of 4?

JacksonWeber commented 1 month ago

@skhilliard Apologies for the missed answer there. Regarding the aggregated metric, you have two options with the 3.X SDK.

  1. You could change to using a custom event here if you just need to record that the health check was reported at a timestamp. This will save money on reporting fields you don't appear to use like valueMin, valueMax, etc.

  2. If you're using the metrics reported values or just need this health check to be reported in the custom metrics table, you could use the Azure Monitor OpenTelemetry package and apply an Observable Gauge to capture these custom metrics instead of this package.

Please let me know if you have questions about either of these approaches. Thanks!