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

only create qps client when live metrics is enabled #613

Merged
merged 1 commit into from Apr 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions Tests/applicationInsights.tests.ts
Expand Up @@ -85,6 +85,11 @@ describe("ApplicationInsights", () => {
AppInsights.setup("key").start();
assert.equal(AppInsights.liveMetricsClient, undefined, "live metrics client is not defined");
});

it("should not start live metrics", () => {
AppInsights.setup("key").setSendLiveMetrics(false).start();
assert.equal(AppInsights.liveMetricsClient, undefined, "live metrics client is not defined");
});
});

describe("#setDistributedTracingMode", () => {
Expand Down
4 changes: 2 additions & 2 deletions applicationinsights.ts
Expand Up @@ -311,13 +311,13 @@ export class Configuration {
return Configuration;
}

if (!liveMetricsClient) {
if (!liveMetricsClient && enable) {
// No qps client exists. Create one and prepare it to be enabled at .start()
liveMetricsClient = new QuickPulseClient(defaultClient.config.instrumentationKey);
_performanceLiveMetrics = new AutoCollectPerformance(liveMetricsClient as any, 1000, true);
liveMetricsClient.addCollector(_performanceLiveMetrics);
defaultClient.quickPulseClient = liveMetricsClient; // Need this so we can forward all manual tracks to live metrics via PerformanceMetricsTelemetryProcessor
} else {
} else if (liveMetricsClient) {
// qps client already exists; enable/disable it
liveMetricsClient.enable(enable);
}
Expand Down