diff --git a/Library/TelemetryClient.ts b/Library/TelemetryClient.ts index 214297f4..cfc9cbaf 100644 --- a/Library/TelemetryClient.ts +++ b/Library/TelemetryClient.ts @@ -150,9 +150,9 @@ class TelemetryClient { // Ideally we would have a central place for "internal" telemetry processors and users can configure which ones are in use. // This will do for now. Otherwise clearTelemetryProcessors() would be problematic. accepted = accepted && TelemetryProcessors.samplingTelemetryProcessor(envelope, { correlationContext: CorrelationContextManager.getCurrentContext() }); - TelemetryProcessors.performanceMetricsTelemetryProcessor(envelope, this.quickPulseClient) if (accepted) { + TelemetryProcessors.performanceMetricsTelemetryProcessor(envelope, this.quickPulseClient); this.channel.send(envelope); } } diff --git a/Tests/EndToEnd.tests.ts b/Tests/EndToEnd.tests.ts index ba8c6725..1c5690e6 100644 --- a/Tests/EndToEnd.tests.ts +++ b/Tests/EndToEnd.tests.ts @@ -166,18 +166,18 @@ describe("EndToEnd", () => { }); it("should send telemetry", (done) => { - const expectedTelemetryData: AppInsights.Contracts.AvailabilityTelemetry = { - duration: 100, id: "id1", message: "message1",success : true, name: "name1", runLocation: "east us" + const expectedTelemetryData: AppInsights.Contracts.AvailabilityTelemetry = { + duration: 100, id: "id1", message: "message1",success : true, name: "name1", runLocation: "east us" }; var client = new AppInsights.TelemetryClient("iKey"); - + client.trackEvent({ name: "test event" }); client.trackException({ exception: new Error("test error") }); client.trackMetric({ name: "test metric", value: 3 }); client.trackTrace({ message: "test trace" }); client.trackAvailability(expectedTelemetryData); - + client.flush({ callback: (response) => { assert.ok(response, "response should not be empty"); @@ -447,14 +447,16 @@ describe("EndToEnd", () => { this.request.returns(req); - client.flush({ - callback: (response: any) => { - // yield for the caching behavior - setImmediate(() => { - assert(writeFile.callCount === 0); - done(); - }); - } + setImmediate(() => { + client.flush({ + callback: (response: any) => { + // yield for the caching behavior + setImmediate(() => { + assert(writeFile.callCount === 0); + done(); + }); + } + }); }); }); @@ -468,16 +470,18 @@ describe("EndToEnd", () => { this.request.returns(req); - client.flush({ - callback: (response: any) => { - // yield for the caching behavior - setImmediate(() => { - assert.equal(writeFile.callCount, 1); - assert.equal(spawn.callCount, os.type() === "Windows_NT" ? 2 : 0); - done(); - }); - } - }); + setImmediate(() => { + client.flush({ + callback: (response: any) => { + // yield for the caching behavior + setImmediate(() => { + assert.equal(writeFile.callCount, 1); + assert.equal(spawn.callCount, os.type() === "Windows_NT" ? 2 : 0); + done(); + }); + } + }); + }) }); it("stores data to disk when enabled", (done) => {