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

allow filtering of live metrics #626

Merged
merged 2 commits into from May 19, 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
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