Skip to content
This repository has been archived by the owner on Oct 3, 2023. It is now read-only.

Commit

Permalink
Remove min/max from Distribution (#212)
Browse files Browse the repository at this point in the history
  • Loading branch information
mayurkale22 committed Dec 4, 2018
1 parent 8d5e708 commit 4116982
Show file tree
Hide file tree
Showing 8 changed files with 2 additions and 26 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file.
- Fix bugs related to Stackdriver Metrics Descriptor and TimeSeries.
- Add Resource API.
- Add Metrics API.
- Remove support for `min`/`max` in the stats Distribution to make it compatible with Metrics.

## 0.0.7 - 2018-11-12
**Contains API breaking changes for stats/metrics implementations**
Expand Down
11 changes: 1 addition & 10 deletions packages/opencensus-core/src/stats/recorder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,8 @@ export class Recorder {
if (bucketIndex < 0) {
bucketIndex = distributionData.buckets.length;
}

distributionData.bucketCounts[bucketIndex] += 1;

if (value > distributionData.max) {
distributionData.max = value;
}

if (value < distributionData.min) {
distributionData.min = value;
}

if (distributionData.count === 1) {
distributionData.mean = value;
}
Expand Down Expand Up @@ -94,4 +85,4 @@ export class Recorder {
lastValueData.value = value;
return lastValueData;
}
}
}
4 changes: 0 additions & 4 deletions packages/opencensus-core/src/stats/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,6 @@ export interface DistributionData extends AggregationMetadata {
count: number;
/** Sum of all recorded values in the histogram */
sum: number;
/** Max value recorded in the histogram */
max: number;
/** Min value recorded in the histogram */
min: number;
/** Get the computed mean value of all recorded values in the histogram */
mean: number;
/**
Expand Down
2 changes: 0 additions & 2 deletions packages/opencensus-core/src/stats/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,6 @@ export class BaseView implements View {
startTime: this.startTime,
count: 0,
sum: 0,
max: Number.MIN_SAFE_INTEGER,
min: Number.MAX_SAFE_INTEGER,
mean: null as number,
stdDeviation: null as number,
sumOfSquaredDeviation: null as number,
Expand Down
4 changes: 0 additions & 4 deletions packages/opencensus-core/test/test-recorder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ function assertDistributionData(
distributionData: DistributionData, values: number[]) {
const valuesSum = values.reduce((acc, cur) => acc + cur);

assert.strictEqual(distributionData.max, Math.max(...values));
assert.strictEqual(distributionData.min, Math.min(...values));
assert.strictEqual(distributionData.count, values.length);
assert.strictEqual(distributionData.sum, valuesSum);

Expand Down Expand Up @@ -157,8 +155,6 @@ describe('Recorder', () => {
startTime: Date.now(),
count: 0,
sum: 0,
max: Number.MIN_SAFE_INTEGER,
min: Number.MAX_SAFE_INTEGER,
mean: 0,
stdDeviation: 0,
sumOfSquaredDeviation: 0,
Expand Down
2 changes: 0 additions & 2 deletions packages/opencensus-core/test/test-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ function assertDistributionData(
distributionData: DistributionData, values: number[]) {
const valuesSum = values.reduce((acc, cur) => acc + cur);

assert.strictEqual(distributionData.max, Math.max(...values));
assert.strictEqual(distributionData.min, Math.min(...values));
assert.strictEqual(distributionData.count, values.length);
assert.strictEqual(distributionData.sum, valuesSum);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
<? } ?>
<td class="borderRL"><?= data.snapshot.mean ?></td>
<td class="borderRL"><?= data.snapshot.count ?></td>
<td class="borderRL"><?= data.snapshot.max ?></td>
<td class="borderRL"><?= data.snapshot.min ?></td>
<td class="borderRL"><?= data.snapshot.sumOfSquaredDeviation ?></td>
<td class="borderRL">
<table>
Expand Down
2 changes: 0 additions & 2 deletions packages/opencensus-exporter-zpages/test/test-zpages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,6 @@ describe('Zpages Exporter', () => {
assert.equal(data.tagValues[0], tagValues[0]);
assert.equal(data.tagValues[1], tagValues[1]);
assert.equal(snapshot.count, 2);
assert.equal(snapshot.max, 22);
assert.equal(snapshot.min, 11);
assert.equal(snapshot.mean, 16.5);
assert.equal(snapshot.sumOfSquaredDeviation, 60.5);
});
Expand Down

0 comments on commit 4116982

Please sign in to comment.