Skip to content

Commit

Permalink
allow filtering of live metrics (#626)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Wolff committed May 19, 2020
1 parent 44a0e7f commit 320ffc4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Library/TelemetryClient.ts
Expand Up @@ -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);
}
}
Expand Down
48 changes: 26 additions & 22 deletions Tests/EndToEnd.tests.ts
Expand Up @@ -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");
Expand Down Expand Up @@ -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();
});
}
});
});
});

Expand All @@ -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) => {
Expand Down

0 comments on commit 320ffc4

Please sign in to comment.