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

Node process exits very late when sending telemetry #495

Closed
shudv opened this issue Mar 15, 2019 · 6 comments
Closed

Node process exits very late when sending telemetry #495

shudv opened this issue Mar 15, 2019 · 6 comments

Comments

@shudv
Copy link

shudv commented Mar 15, 2019

Whenever I try sending telemetry there is an unusual delay (>60 seconds) before the node process exits. The telemetry does get sent timely so I believe this is an issue with the library.

I am using webpack 4.27.1 and node 10.15.3. Here is the sample code that I used to repro this
import { ApplicationInsightsLogger } from "../../components/TelemetryLogger";
const Telemetry = new ApplicationInsightsLogger("{{InstrumentationKey}}");
const start = new Date().getTime();
console.log("Sending telemetry");
Telemetry.Event("Test");
process.on("exit", () =>
{
console.log("Finished in " + ((new Date().getTime()) - start) + "ms");
});

The time it takes when I send telemetry is more than 60 seconds which should not be the case. I am using the following config for the logger-
ApplicationInsights
.setup(key)
.setAutoCollectConsole(false)
.setAutoCollectDependencies(false)
.setAutoCollectPerformance(false)
.setAutoCollectRequests(false)
.setAutoDependencyCorrelation(false)
.setInternalLogging(false, true)
.setUseDiskRetryCaching(true)
.setAutoCollectExceptions(true)
.start();

Please help point out if I am doing something wrong here. If it's a bug then is there a temporary workaround for this? I really want to use application insights for my project but if this issue remains I will be forced to switch to something else. :(

@OsvaldoRosado
Copy link
Member

OsvaldoRosado commented Mar 15, 2019

Can you share what ApplicationInsightsLogger is? It's possible any problems are in that wrapper.

Can you also share which version of the applicationinsights package you're using? Version 1.1.0 contained fixes for some delays with Node exits.

As general advice, if you want to make sure telemetry is sent right away, you should use client.flush() to immediately clear the telemetry buffer. By default, telemetry is only sent every 15 sec or after 250 telemetry items are collected - whichever comes first.

@shudv
Copy link
Author

shudv commented Mar 15, 2019

Thanks for the response! :)

Library version - 1.0.8
The wrapper is very thin. I already shared the logger configuration. Sharing the Event method implementation as well

public Event(name: string, properties?: any)
{
this.client.trackEvent({ name, properties });
this.client.flush();
}

@OsvaldoRosado
Copy link
Member

Thanks!

It's possible you're running into problems with the timers used by setUseDiskRetryCaching keeping your process running. You can update to 1.1.0 to get the bugfix, or disable disk retry caching to avoid the bug without upgrading.

@shudv
Copy link
Author

shudv commented Mar 15, 2019

Awesome! I will give that a try.

@shudv
Copy link
Author

shudv commented Mar 15, 2019

Yay! That did it. Thanks for the super quick help Osvaldo. I really appreciate it :).

@OsvaldoRosado
Copy link
Member

Glad to help!

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

No branches or pull requests

2 participants