@opentelemetry/metrics
Advanced tools
Comparing version 0.5.1 to 0.5.2
@@ -16,8 +16,9 @@ /*! | ||
*/ | ||
import { Aggregator, Distribution, LastValue, Sum } from './types'; | ||
import { Aggregator, Point } from './types'; | ||
/** Basic aggregator which calculates a Sum from individual measurements. */ | ||
export declare class CounterSumAggregator implements Aggregator { | ||
private _current; | ||
private _lastUpdateTime; | ||
update(value: number): void; | ||
value(): Sum; | ||
toPoint(): Point; | ||
} | ||
@@ -27,4 +28,5 @@ /** Basic aggregator for Observer which keeps the last recorded value. */ | ||
private _current; | ||
private _lastUpdateTime; | ||
update(value: number): void; | ||
value(): LastValue; | ||
toPoint(): Point; | ||
} | ||
@@ -34,5 +36,6 @@ /** Basic aggregator keeping all raw values (events, sum, max and min). */ | ||
private _distribution; | ||
private _lastUpdateTime; | ||
constructor(); | ||
update(value: number): void; | ||
value(): Distribution; | ||
toPoint(): Point; | ||
} |
@@ -18,2 +18,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const core_1 = require("@opentelemetry/core"); | ||
/** Basic aggregator which calculates a Sum from individual measurements. */ | ||
@@ -23,8 +24,13 @@ class CounterSumAggregator { | ||
this._current = 0; | ||
this._lastUpdateTime = [0, 0]; | ||
} | ||
update(value) { | ||
this._current += value; | ||
this._lastUpdateTime = core_1.hrTime(); | ||
} | ||
value() { | ||
return this._current; | ||
toPoint() { | ||
return { | ||
value: this._current, | ||
timestamp: this._lastUpdateTime, | ||
}; | ||
} | ||
@@ -37,8 +43,13 @@ } | ||
this._current = 0; | ||
this._lastUpdateTime = [0, 0]; | ||
} | ||
update(value) { | ||
this._current = value; | ||
this._lastUpdateTime = core_1.hrTime(); | ||
} | ||
value() { | ||
return this._current; | ||
toPoint() { | ||
return { | ||
value: this._current, | ||
timestamp: this._lastUpdateTime, | ||
}; | ||
} | ||
@@ -50,2 +61,3 @@ } | ||
constructor() { | ||
this._lastUpdateTime = [0, 0]; | ||
this._distribution = { | ||
@@ -63,5 +75,9 @@ min: Infinity, | ||
this._distribution.max = Math.max(this._distribution.max, value); | ||
this._lastUpdateTime = core_1.hrTime(); | ||
} | ||
value() { | ||
return this._distribution; | ||
toPoint() { | ||
return { | ||
value: this._distribution, | ||
timestamp: this._lastUpdateTime, | ||
}; | ||
} | ||
@@ -68,0 +84,0 @@ } |
@@ -31,7 +31,8 @@ "use strict"; | ||
case types_1.MetricKind.COUNTER: | ||
const sum = metric.aggregator.value(); | ||
const sum = metric.aggregator.toPoint().value; | ||
console.log('value: ' + sum); | ||
break; | ||
default: | ||
const distribution = metric.aggregator.value(); | ||
const distribution = metric.aggregator.toPoint() | ||
.value; | ||
console.log('min: ' + | ||
@@ -38,0 +39,0 @@ distribution.min + |
@@ -16,3 +16,3 @@ /*! | ||
*/ | ||
import { ValueType } from '@opentelemetry/api'; | ||
import { ValueType, HrTime } from '@opentelemetry/api'; | ||
import { ExportResult } from '@opentelemetry/base'; | ||
@@ -66,4 +66,8 @@ import { LabelSet } from '../LabelSet'; | ||
update(value: number): void; | ||
/** Returns snapshot of the current value. */ | ||
value(): Sum | Distribution; | ||
/** Returns snapshot of the current point (value with timestamp). */ | ||
toPoint(): Point; | ||
} | ||
export interface Point { | ||
value: Sum | LastValue | Distribution; | ||
timestamp: HrTime; | ||
} |
@@ -16,2 +16,2 @@ /*! | ||
*/ | ||
export declare const VERSION = "0.5.1"; | ||
export declare const VERSION = "0.5.2"; |
@@ -19,3 +19,3 @@ "use strict"; | ||
// this is autogenerated file, see scripts/version-update.js | ||
exports.VERSION = '0.5.1'; | ||
exports.VERSION = '0.5.2'; | ||
//# sourceMappingURL=version.js.map |
{ | ||
"name": "@opentelemetry/metrics", | ||
"version": "0.5.1", | ||
"version": "0.5.2", | ||
"description": "OpenTelemetry metrics SDK", | ||
@@ -60,7 +60,7 @@ "main": "build/src/index.js", | ||
"dependencies": { | ||
"@opentelemetry/api": "^0.5.1", | ||
"@opentelemetry/base": "^0.5.1", | ||
"@opentelemetry/core": "^0.5.1", | ||
"@opentelemetry/resources": "^0.5.1" | ||
"@opentelemetry/api": "^0.5.2", | ||
"@opentelemetry/base": "^0.5.2", | ||
"@opentelemetry/core": "^0.5.2", | ||
"@opentelemetry/resources": "^0.5.2" | ||
} | ||
} |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
75507
1546
0
Updated@opentelemetry/api@^0.5.2
Updated@opentelemetry/base@^0.5.2
Updated@opentelemetry/core@^0.5.2