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

Commit 4116982

Browse files
authored
Remove min/max from Distribution (#212)
1 parent 8d5e708 commit 4116982

File tree

8 files changed

+2
-26
lines changed

8 files changed

+2
-26
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file.
77
- Fix bugs related to Stackdriver Metrics Descriptor and TimeSeries.
88
- Add Resource API.
99
- Add Metrics API.
10+
- Remove support for `min`/`max` in the stats Distribution to make it compatible with Metrics.
1011

1112
## 0.0.7 - 2018-11-12
1213
**Contains API breaking changes for stats/metrics implementations**

packages/opencensus-core/src/stats/recorder.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,8 @@ export class Recorder {
5050
if (bucketIndex < 0) {
5151
bucketIndex = distributionData.buckets.length;
5252
}
53-
5453
distributionData.bucketCounts[bucketIndex] += 1;
5554

56-
if (value > distributionData.max) {
57-
distributionData.max = value;
58-
}
59-
60-
if (value < distributionData.min) {
61-
distributionData.min = value;
62-
}
63-
6455
if (distributionData.count === 1) {
6556
distributionData.mean = value;
6657
}
@@ -94,4 +85,4 @@ export class Recorder {
9485
lastValueData.value = value;
9586
return lastValueData;
9687
}
97-
}
88+
}

packages/opencensus-core/src/stats/types.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,6 @@ export interface DistributionData extends AggregationMetadata {
174174
count: number;
175175
/** Sum of all recorded values in the histogram */
176176
sum: number;
177-
/** Max value recorded in the histogram */
178-
max: number;
179-
/** Min value recorded in the histogram */
180-
min: number;
181177
/** Get the computed mean value of all recorded values in the histogram */
182178
mean: number;
183179
/**

packages/opencensus-core/src/stats/view.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,6 @@ export class BaseView implements View {
166166
startTime: this.startTime,
167167
count: 0,
168168
sum: 0,
169-
max: Number.MIN_SAFE_INTEGER,
170-
min: Number.MAX_SAFE_INTEGER,
171169
mean: null as number,
172170
stdDeviation: null as number,
173171
sumOfSquaredDeviation: null as number,

packages/opencensus-core/test/test-recorder.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ function assertDistributionData(
3535
distributionData: DistributionData, values: number[]) {
3636
const valuesSum = values.reduce((acc, cur) => acc + cur);
3737

38-
assert.strictEqual(distributionData.max, Math.max(...values));
39-
assert.strictEqual(distributionData.min, Math.min(...values));
4038
assert.strictEqual(distributionData.count, values.length);
4139
assert.strictEqual(distributionData.sum, valuesSum);
4240

@@ -157,8 +155,6 @@ describe('Recorder', () => {
157155
startTime: Date.now(),
158156
count: 0,
159157
sum: 0,
160-
max: Number.MIN_SAFE_INTEGER,
161-
min: Number.MAX_SAFE_INTEGER,
162158
mean: 0,
163159
stdDeviation: 0,
164160
sumOfSquaredDeviation: 0,

packages/opencensus-core/test/test-view.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ function assertDistributionData(
3636
distributionData: DistributionData, values: number[]) {
3737
const valuesSum = values.reduce((acc, cur) => acc + cur);
3838

39-
assert.strictEqual(distributionData.max, Math.max(...values));
40-
assert.strictEqual(distributionData.min, Math.min(...values));
4139
assert.strictEqual(distributionData.count, values.length);
4240
assert.strictEqual(distributionData.sum, valuesSum);
4341

packages/opencensus-exporter-zpages/templates/statsz-view-distribution.ejs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
<? } ?>
2222
<td class="borderRL"><?= data.snapshot.mean ?></td>
2323
<td class="borderRL"><?= data.snapshot.count ?></td>
24-
<td class="borderRL"><?= data.snapshot.max ?></td>
25-
<td class="borderRL"><?= data.snapshot.min ?></td>
2624
<td class="borderRL"><?= data.snapshot.sumOfSquaredDeviation ?></td>
2725
<td class="borderRL">
2826
<table>

packages/opencensus-exporter-zpages/test/test-zpages.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,8 +406,6 @@ describe('Zpages Exporter', () => {
406406
assert.equal(data.tagValues[0], tagValues[0]);
407407
assert.equal(data.tagValues[1], tagValues[1]);
408408
assert.equal(snapshot.count, 2);
409-
assert.equal(snapshot.max, 22);
410-
assert.equal(snapshot.min, 11);
411409
assert.equal(snapshot.mean, 16.5);
412410
assert.equal(snapshot.sumOfSquaredDeviation, 60.5);
413411
});

0 commit comments

Comments
 (0)