microsoft / ApplicationInsights-node.js

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

[Question] Too much traces `/track` being sent #1339

Open lapa182 opened 3 weeks ago

lapa182 commented 3 weeks ago

Hello! We recently noticed a spike in our Next.js application of traces coming from /track. I was googling about it and saw this Github issue in another SDK (https://github.com/microsoft/ApplicationInsights-Python/issues/317).

Do you know how I could achieve the same in the Node SDK?

JacksonWeber commented 3 weeks ago

@lapa182 Can you provide some further details here? Are you seeing duplicated traces? Or do you just want to see fewer traces in general based on some kind of criteria? Also, what version of the SDK are you using/did you recently upgrade before seeing this spike?

lapa182 commented 3 weeks ago

Hi @JacksonWeber, sorry for the delay was trying to get some information as we had to disable AppInsights in our instance because our logging was ramping up our costs.

I got a screenshot of the "issue":

8594110e-84b2-48a3-a687-758546481593

This is a dev instance and you can see that every minute (sometimes less than a minute) we had one track event from v2/track endpoint.

For context, we are using Next.js 14 and we are loading the instrumentation with this code:

    appInsights
        .setup(connectionString)
        .setAutoCollectRequests(true)
        .setAutoCollectPerformance(true, true)
        .setAutoCollectExceptions(true)
        .setAutoCollectDependencies(true)
        .setAutoCollectConsole(true, true)
        .setAutoCollectPreAggregatedMetrics(true)
        .setSendLiveMetrics(false)
        .setInternalLogging(false, true)
        .enableWebInstrumentation(false)
        .start();

We were using this implementation before https://github.com/CMeeg/nextjs-aca/blob/main/src/lib/instrumentation/azure-monitor.ts, which was still in beta and when the SDK came out of beta we decided to update the code (we are on 3.1.0 now). Is there a way to disable capturing v2/track or do you have any other suggestions we could do?

Not sure if it's related as well, but we are using Log Analytics in App Insights.