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

expose internal log poller #1674

Merged
merged 10 commits into from
Oct 1, 2021
12 changes: 11 additions & 1 deletion AISKU/src/Initialization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export class Initialization implements IApplicationInsights {
private properties: PropertiesPlugin;
private _sender: Sender;
private _snippetVersion: string;
private _internalLogPoller: number;

constructor(snippet: Snippet) {
let _self = this;
Expand Down Expand Up @@ -463,7 +464,16 @@ export class Initialization implements IApplicationInsights {
}

public pollInternalLogs(): void {
this.core.pollInternalLogs();
// If pollInternalLogs is called more than once, existing log poller should be stopped before starting another log poller.
if(this._internalLogPoller) {
this.stopPollingInternalLogs();
}
this._internalLogPoller = this.core.pollInternalLogs();
kryalama marked this conversation as resolved.
Show resolved Hide resolved
}

public stopPollingInternalLogs(): void {
this.core.stopPollingInternalLogs(this._internalLogPoller);
kryalama marked this conversation as resolved.
Show resolved Hide resolved
this._internalLogPoller = 0;
}

public addHousekeepingBeforeUnload(appInsightsInstance: IApplicationInsights): void {
Expand Down
13 changes: 12 additions & 1 deletion AISKULight/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { Sender } from "@microsoft/applicationinsights-channel-js";
export class ApplicationInsights {
public config: IConfiguration & IConfig;
private core: IAppInsightsCore;
private _internalLogPoller: number;

/**
* Creates an instance of ApplicationInsights.
Expand Down Expand Up @@ -91,13 +92,23 @@ export class ApplicationInsights {
}

private pollInternalLogs(): void {
this.core.pollInternalLogs()
// If pollInternalLogs is called more than once, existing log poller should be stopped before starting another log poller.
if(this._internalLogPoller) {
this.stopPollingInternalLogs();
}
this._internalLogPoller = this.core.pollInternalLogs();
}

public stopPollingInternalLogs(): void {
this.core.stopPollingInternalLogs(this._internalLogPoller);
this._internalLogPoller = 0;
}

private getSKUDefaults() {
this.config.diagnosticLogInterval =
this.config.diagnosticLogInterval && this.config.diagnosticLogInterval > 0 ? this.config.diagnosticLogInterval : 10000;
}

}

export {
Expand Down
Loading