Skip to content

Commit

Permalink
only createt qps client when enabled (#613)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Wolff committed Apr 9, 2020
1 parent a34f9e2 commit 156036c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
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

0 comments on commit 156036c

Please sign in to comment.