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

First heartbeat sent after 15 minutes instead of configured interval #1298

Closed
xavierdecoster opened this issue Nov 12, 2019 · 3 comments · Fixed by #1979
Closed

First heartbeat sent after 15 minutes instead of configured interval #1298

xavierdecoster opened this issue Nov 12, 2019 · 3 comments · Fixed by #1979
Milestone

Comments

@xavierdecoster
Copy link

It appears that the very first heartbeat is sent after 15 minutes, which is the default built-in heartbeat interval, even when a different interval is configured. Every other subsequent heartbeat will respect the configured interval.

SDK version used: 2.10.0

Attached some code that reproduces the issue.

Expected behavior: heartbeats start after the very first minute (as configured)
Actual behavior: heartbeats only start after 15 minutes (default interval)

ConsoleApp1.zip

@cijothomas
Copy link
Contributor

Its a bug/limitation as setting interval does not alter the current timer, which is triggered upon initialize.
https://github.com/microsoft/ApplicationInsights-dotnet/blob/develop/BASE/src/Microsoft.ApplicationInsights/Managed/Shared/Extensibility/Implementation/Tracing/HeartbeatProvider.cs#L91

Use the following workaround:
Basically, don't use .Active, instead create DiagnosticTelemetryModule by yourself, so that you can interval before initializing it.

static void Main(string[] args)
{

        var tc = new TelemetryConfiguration("ikey");
        var diagModule = new DiagnosticsTelemetryModule();
        diagModule.HeartbeatInterval = TimeSpan.FromSeconds(30);
        diagModule.Initialize(tc);
        
        while(true)
        {

        }
    }

(Modify example as per your requirement, but this should give you the idea)

@cijothomas cijothomas added this to the Future milestone Nov 12, 2019
@xavierdecoster
Copy link
Author

@cijothomas does the call to new TelemetryConfiguration("ikey") still consider the applicationinsights.config file? Or should we rely on TelemetryConfiguration.CreateDefault() instead, and then set TelemetryConfiguration.InstrumentationKey on that instance?

@cijothomas
Copy link
Contributor

new TelemetryConfiguration("ikey") wont consider ai.config.

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

Successfully merging a pull request may close this issue.

3 participants