Skip to content

Commit

Permalink
[BUG] trackMetric does not track stdDev nor sum #1680 (#1701)
Browse files Browse the repository at this point in the history
- add (missing) stdDev sending for metrics
  • Loading branch information
MSNev authored Oct 29, 2021
1 parent 1ec8004 commit 5101bdf
Show file tree
Hide file tree
Showing 5 changed files with 309 additions and 154 deletions.
5 changes: 5 additions & 0 deletions AISKU/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ Parameter | Type | Description
`sampleCount?` | number | **Optional**<br>Count of measurements represented by the average. Defaults to 1. Should be >=1.
`min?` | number | **Optional**<br>The smallest measurement in the sample. Defaults to the average. Should be >= 0.
`max?` | number | **Optional**<br>The largest measurement in the sample. Defaults to the average. Should be >= 0.
`stdDev?` | number | **Optional**<br>The standard deviation for the sample. Defaults to undefined which is reported as zero (0).

```typescript
appInsights.trackMetric({ name: "my_custom_metric", average: 1.5, sampleCount: 2, min: 1, max: 2, stdDev: 1.0 });
```

### trackException

Expand Down
17 changes: 16 additions & 1 deletion AISKU/Tests/applicationinsights.e2e.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -426,13 +426,28 @@ export class ApplicationInsightsTests extends TestClass {
() => {
console.log("* calling trackMetric " + new Date().toISOString());
for (let i = 0; i < 100; i++) {
this._ai.trackMetric({ name: "test" + i, average: Math.round(100 * Math.random()) });
this._ai.trackMetric({ name: "test" + i, average: Math.round(100 * Math.random()), min: 1, max: i+1, stdDev: 10.0 * Math.random() });
}
console.log("* done calling trackMetric " + new Date().toISOString());
}
].concat(this.asserts(100))
});

this.testCaseAsync({
name: "TelemetryContext: track custom metric",
stepDelay: 1,
steps: [
() => {
console.log("* calling trackMetric " + new Date().toISOString());
this._ai.trackMetric({ name: "my_custom_metric_0", average: 2 });
this._ai.trackMetric({ name: "my_custom_metric_1", average: 1.1, sampleCount: 1, min: 1, max: 1, stdDev: 1.12 });
this._ai.trackMetric({ name: "my_custom_metric_2", average: 1.2, sampleCount: 2, min: 1, max: 2, stdDev: 1.23 });
this._ai.trackMetric({ name: "my_custom_metric_3", average: 1.3, sampleCount: 3, min: 1, max: 2.5, stdDev: 1.35 });
console.log("* done calling trackMetric " + new Date().toISOString());
}
].concat(this.asserts(4))
});

this.testCaseAsync({
name: `TelemetryContext: track page view ${window.location.pathname}`,
stepDelay: 500,
Expand Down
Loading

0 comments on commit 5101bdf

Please sign in to comment.