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

Commit 0da334a

Browse files
eduardoemerykjin
authored andcommitted
refactor(fix): changes to address review comments
1 parent 88aa832 commit 0da334a

File tree

12 files changed

+135
-297
lines changed

12 files changed

+135
-297
lines changed
-248 KB
Binary file not shown.
-161 KB
Binary file not shown.

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {Measurement, View} from '../stats/types';
1818
import * as configTypes from '../trace/config/types';
1919
import * as modelTypes from '../trace/model/types';
2020

21-
/** Defines an exporter interface. */
21+
/** Defines a trace exporter interface. */
2222
export interface Exporter extends modelTypes.SpanEventListener {
2323
/**
2424
* Sends a list of root spans to the service.
@@ -27,9 +27,21 @@ export interface Exporter extends modelTypes.SpanEventListener {
2727
publish(rootSpans: modelTypes.RootSpan[]): Promise<number|string|void>;
2828
}
2929

30-
/** Defines a StatsEventListener interface */
30+
/**
31+
* An interface that describes the possible events that will be emitted from a
32+
* Stats instance. Stats exporters should implement this interface.
33+
*/
3134
export interface StatsEventListener {
35+
/**
36+
* Is called whenever a new view is registered
37+
* @param view The registered view
38+
*/
3239
onRegisterView(view: View): void;
40+
/**
41+
* Is called whenever a new measurement is recorded.
42+
* @param view The view related to the measurement
43+
* @param measurement The recorded measurement
44+
*/
3345
onRecord(view: View, measurement: Measurement): void;
3446
}
3547

packages/opencensus-core/src/index.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,9 @@ export * from './exporters/console-exporter';
4545
// classes
4646
export * from './stats/stats';
4747
export * from './stats/view';
48-
export * from './stats/aggregation/count-aggregation';
49-
export * from './stats/aggregation/sum-aggregation';
50-
export * from './stats/aggregation/last-value-aggregation';
51-
export * from './stats/aggregation/distribution-aggregation';
48+
export * from './stats/recorder';
5249

5350
// interfaces
54-
export * from './stats/aggregation/types';
5551
export * from './stats/types';
5652

5753
// logger

packages/opencensus-core/src/stats/aggregation/count-aggregation.ts

Lines changed: 0 additions & 36 deletions
This file was deleted.

packages/opencensus-core/src/stats/aggregation/distribution-aggregation.ts

Lines changed: 0 additions & 60 deletions
This file was deleted.

packages/opencensus-core/src/stats/aggregation/last-value-aggregation.ts

Lines changed: 0 additions & 36 deletions
This file was deleted.

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

Lines changed: 0 additions & 108 deletions
This file was deleted.

packages/opencensus-core/src/stats/aggregation/sum-aggregation.ts renamed to packages/opencensus-core/src/stats/recorder.ts

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,12 @@
1414
* limitations under the License.
1515
*/
1616

17-
import {Measurement, Tags} from '../types';
17+
import {AggregationData, Measurement} from './types';
1818

19-
import {AggregationType, SumData} from './types';
20-
21-
export class SumAggregation implements SumData {
22-
/** The aggregation type of the aggregation data */
23-
readonly type: AggregationType;
24-
/** The tags/labels that this AggregationData collects and aggregates */
25-
readonly tags: Tags;
26-
/** The latest timestamp a new data point was recorded */
27-
timestamp: number;
28-
/** The current accumulated value */
29-
value: number;
30-
31-
constructor() {}
32-
33-
addMeasurement(measurement: Measurement): void {
34-
// TODO: To be implemented
19+
export class Recorder {
20+
static addMeasurement(
21+
aggregationData: AggregationData,
22+
measurement: Measurement): AggregationData {
23+
throw new Error('Not Implemented');
3524
}
3625
}

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

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616

1717
import {StatsEventListener} from '../exporters/types';
1818

19-
import {AggregationType} from './aggregation/types';
20-
import {Measure, Measurement, MeasureUnit, View} from './types';
19+
import {AggregationType, Measure, Measurement, MeasureUnit, View} from './types';
2120

2221
export class Stats {
2322
/** A list of Stats exporters */
@@ -33,7 +32,7 @@ export class Stats {
3332
* @param view The view to be registered
3433
*/
3534
registerView(view: View) {
36-
// TODO: To be implemented
35+
throw new Error('Not Implemented');
3736
}
3837

3938
/**
@@ -47,16 +46,15 @@ export class Stats {
4746
createView(
4847
name: string, measure: Measure, aggregation: AggregationType,
4948
tagKeys: string[], description?: string): View {
50-
// TODO: To be implemented
51-
return null;
49+
throw new Error('Not Implemented');
5250
}
5351

5452
/**
5553
* Registers an exporter to send stats data to a service.
5654
* @param exporter An stats exporter
5755
*/
5856
registerExporter(exporter: StatsEventListener) {
59-
// TODO: To be implemented
57+
throw new Error('Not Implemented');
6058
}
6159

6260
/**
@@ -67,27 +65,26 @@ export class Stats {
6765
*/
6866
createMeasureDouble(name: string, unit: MeasureUnit, description?: string):
6967
Measure {
70-
// TODO: To be implemented
71-
return null;
68+
throw new Error('Not Implemented');
7269
}
7370

7471
/**
75-
* Creates a measure of type Int64.
72+
* Creates a measure of type Int64. Values must be integers up to
73+
* Number.MAX_SAFE_INTERGER.
7674
* @param name The measure name
7775
* @param unit The measure unit
7876
* @param description The measure description
7977
*/
80-
createMeasureInt(name: string, unit: MeasureUnit, description?: string):
78+
createMeasureInt64(name: string, unit: MeasureUnit, description?: string):
8179
Measure {
82-
// TODO: To be implemented
83-
return null;
80+
throw new Error('Not Implemented');
8481
}
8582

8683
/**
8784
* Updates all views with the new measurements.
8885
* @param measurements A list of measurements to record
8986
*/
9087
record(measurements: Measurement[]) {
91-
// TODO: To be implemented
88+
throw new Error('Not Implemented');
9289
}
93-
}
90+
}

0 commit comments

Comments
 (0)