@opentelemetry/sdk-metrics
Advanced tools
Comparing version 1.9.0 to 1.9.1
@@ -33,3 +33,3 @@ /* | ||
import { AggregatorKind, } from './types'; | ||
import { hrTime, hrTimeToMicroseconds } from '@opentelemetry/core'; | ||
import { millisToHrTime, hrTimeToMicroseconds } from '@opentelemetry/core'; | ||
import { DataPointType } from '../export/MetricData'; | ||
@@ -46,3 +46,3 @@ var LastValueAccumulation = /** @class */ (function () { | ||
this._current = value; | ||
this.sampleTime = hrTime(); | ||
this.sampleTime = millisToHrTime(Date.now()); | ||
}; | ||
@@ -49,0 +49,0 @@ LastValueAccumulation.prototype.setStartTime = function (startTime) { |
@@ -29,2 +29,3 @@ import { MetricReader } from './MetricReader'; | ||
private _runOnce; | ||
private _doRun; | ||
protected onInitialized(): void; | ||
@@ -31,0 +32,0 @@ protected onForceFlush(): Promise<void>; |
@@ -128,2 +128,26 @@ /* | ||
return __awaiter(this, void 0, void 0, function () { | ||
var err_1; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
_a.trys.push([0, 2, , 3]); | ||
return [4 /*yield*/, callWithTimeout(this._doRun(), this._exportTimeout)]; | ||
case 1: | ||
_a.sent(); | ||
return [3 /*break*/, 3]; | ||
case 2: | ||
err_1 = _a.sent(); | ||
if (err_1 instanceof TimeoutError) { | ||
api.diag.error('Export took longer than %s milliseconds and timed out.', this._exportTimeout); | ||
return [2 /*return*/]; | ||
} | ||
globalErrorHandler(err_1); | ||
return [3 /*break*/, 3]; | ||
case 3: return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}; | ||
PeriodicExportingMetricReader.prototype._doRun = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var _a, resourceMetrics, errors, result; | ||
@@ -133,3 +157,5 @@ var _b; | ||
switch (_c.label) { | ||
case 0: return [4 /*yield*/, this.collect({})]; | ||
case 0: return [4 /*yield*/, this.collect({ | ||
timeoutMillis: this._exportTimeout, | ||
})]; | ||
case 1: | ||
@@ -154,24 +180,6 @@ _a = _c.sent(), resourceMetrics = _a.resourceMetrics, errors = _a.errors; | ||
// start running the interval as soon as this reader is initialized and keep handle for shutdown. | ||
this._interval = setInterval(function () { return __awaiter(_this, void 0, void 0, function () { | ||
var err_1; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
_a.trys.push([0, 2, , 3]); | ||
return [4 /*yield*/, callWithTimeout(this._runOnce(), this._exportTimeout)]; | ||
case 1: | ||
_a.sent(); | ||
return [3 /*break*/, 3]; | ||
case 2: | ||
err_1 = _a.sent(); | ||
if (err_1 instanceof TimeoutError) { | ||
api.diag.error('Export took longer than %s milliseconds and timed out.', this._exportTimeout); | ||
return [2 /*return*/]; | ||
} | ||
globalErrorHandler(err_1); | ||
return [3 /*break*/, 3]; | ||
case 3: return [2 /*return*/]; | ||
} | ||
}); | ||
}); }, this._exportInterval); | ||
this._interval = setInterval(function () { | ||
// this._runOnce never rejects. Using void operator to suppress @typescript-eslint/no-floating-promises. | ||
void _this._runOnce(); | ||
}, this._exportInterval); | ||
unrefTimer(this._interval); | ||
@@ -183,5 +191,8 @@ }; | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this._exporter.forceFlush()]; | ||
case 0: return [4 /*yield*/, this._runOnce()]; | ||
case 1: | ||
_a.sent(); | ||
return [4 /*yield*/, this._exporter.forceFlush()]; | ||
case 2: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
@@ -188,0 +199,0 @@ } |
@@ -32,3 +32,3 @@ /* | ||
import { context as contextApi, diag, ValueType, } from '@opentelemetry/api'; | ||
import { hrTime } from '@opentelemetry/core'; | ||
import { millisToHrTime } from '@opentelemetry/core'; | ||
var SyncInstrument = /** @class */ (function () { | ||
@@ -47,3 +47,3 @@ function SyncInstrument(_writableMetricStorage, _descriptor) { | ||
} | ||
this._writableMetricStorage.record(value, attributes, context, hrTime()); | ||
this._writableMetricStorage.record(value, attributes, context, millisToHrTime(Date.now())); | ||
}; | ||
@@ -50,0 +50,0 @@ return SyncInstrument; |
@@ -52,3 +52,3 @@ /* | ||
}; | ||
import { hrTime } from '@opentelemetry/core'; | ||
import { millisToHrTime } from '@opentelemetry/core'; | ||
import { FlatMap } from '../utils'; | ||
@@ -72,3 +72,3 @@ /** | ||
case 0: | ||
collectionTime = hrTime(); | ||
collectionTime = millisToHrTime(Date.now()); | ||
meterCollectionPromises = Array.from(this._sharedState.meterSharedStates.values()).map(function (meterSharedState) { | ||
@@ -75,0 +75,0 @@ return meterSharedState.collect(_this, collectionTime, options); |
@@ -1,2 +0,2 @@ | ||
export declare const VERSION = "1.9.0"; | ||
export declare const VERSION = "1.9.1"; | ||
//# sourceMappingURL=version.d.ts.map |
@@ -17,3 +17,3 @@ /* | ||
// this is autogenerated file, see scripts/version-update.js | ||
export var VERSION = '1.9.0'; | ||
export var VERSION = '1.9.1'; | ||
//# sourceMappingURL=version.js.map |
@@ -17,3 +17,3 @@ /* | ||
import { AggregatorKind, } from './types'; | ||
import { hrTime, hrTimeToMicroseconds } from '@opentelemetry/core'; | ||
import { millisToHrTime, hrTimeToMicroseconds } from '@opentelemetry/core'; | ||
import { DataPointType } from '../export/MetricData'; | ||
@@ -28,3 +28,3 @@ export class LastValueAccumulation { | ||
this._current = value; | ||
this.sampleTime = hrTime(); | ||
this.sampleTime = millisToHrTime(Date.now()); | ||
} | ||
@@ -31,0 +31,0 @@ setStartTime(startTime) { |
@@ -29,2 +29,3 @@ import { MetricReader } from './MetricReader'; | ||
private _runOnce; | ||
private _doRun; | ||
protected onInitialized(): void; | ||
@@ -31,0 +32,0 @@ protected onForceFlush(): Promise<void>; |
@@ -49,3 +49,17 @@ /* | ||
async _runOnce() { | ||
const { resourceMetrics, errors } = await this.collect({}); | ||
try { | ||
await callWithTimeout(this._doRun(), this._exportTimeout); | ||
} | ||
catch (err) { | ||
if (err instanceof TimeoutError) { | ||
api.diag.error('Export took longer than %s milliseconds and timed out.', this._exportTimeout); | ||
return; | ||
} | ||
globalErrorHandler(err); | ||
} | ||
} | ||
async _doRun() { | ||
const { resourceMetrics, errors } = await this.collect({ | ||
timeoutMillis: this._exportTimeout, | ||
}); | ||
if (errors.length > 0) { | ||
@@ -61,13 +75,5 @@ api.diag.error('PeriodicExportingMetricReader: metrics collection errors', ...errors); | ||
// start running the interval as soon as this reader is initialized and keep handle for shutdown. | ||
this._interval = setInterval(async () => { | ||
try { | ||
await callWithTimeout(this._runOnce(), this._exportTimeout); | ||
} | ||
catch (err) { | ||
if (err instanceof TimeoutError) { | ||
api.diag.error('Export took longer than %s milliseconds and timed out.', this._exportTimeout); | ||
return; | ||
} | ||
globalErrorHandler(err); | ||
} | ||
this._interval = setInterval(() => { | ||
// this._runOnce never rejects. Using void operator to suppress @typescript-eslint/no-floating-promises. | ||
void this._runOnce(); | ||
}, this._exportInterval); | ||
@@ -77,2 +83,3 @@ unrefTimer(this._interval); | ||
async onForceFlush() { | ||
await this._runOnce(); | ||
await this._exporter.forceFlush(); | ||
@@ -79,0 +86,0 @@ } |
@@ -17,3 +17,3 @@ /* | ||
import { context as contextApi, diag, ValueType, } from '@opentelemetry/api'; | ||
import { hrTime } from '@opentelemetry/core'; | ||
import { millisToHrTime } from '@opentelemetry/core'; | ||
export class SyncInstrument { | ||
@@ -30,3 +30,3 @@ constructor(_writableMetricStorage, _descriptor) { | ||
} | ||
this._writableMetricStorage.record(value, attributes, context, hrTime()); | ||
this._writableMetricStorage.record(value, attributes, context, millisToHrTime(Date.now())); | ||
} | ||
@@ -33,0 +33,0 @@ } |
@@ -16,3 +16,3 @@ /* | ||
*/ | ||
import { hrTime } from '@opentelemetry/core'; | ||
import { millisToHrTime } from '@opentelemetry/core'; | ||
import { FlatMap } from '../utils'; | ||
@@ -30,3 +30,3 @@ /** | ||
async collect(options) { | ||
const collectionTime = hrTime(); | ||
const collectionTime = millisToHrTime(Date.now()); | ||
const meterCollectionPromises = Array.from(this._sharedState.meterSharedStates.values()).map(meterSharedState => meterSharedState.collect(this, collectionTime, options)); | ||
@@ -33,0 +33,0 @@ const result = await Promise.all(meterCollectionPromises); |
@@ -1,2 +0,2 @@ | ||
export declare const VERSION = "1.9.0"; | ||
export declare const VERSION = "1.9.1"; | ||
//# sourceMappingURL=version.d.ts.map |
@@ -17,3 +17,3 @@ /* | ||
// this is autogenerated file, see scripts/version-update.js | ||
export const VERSION = '1.9.0'; | ||
export const VERSION = '1.9.1'; | ||
//# sourceMappingURL=version.js.map |
@@ -30,3 +30,3 @@ "use strict"; | ||
this._current = value; | ||
this.sampleTime = (0, core_1.hrTime)(); | ||
this.sampleTime = (0, core_1.millisToHrTime)(Date.now()); | ||
} | ||
@@ -33,0 +33,0 @@ setStartTime(startTime) { |
@@ -29,2 +29,3 @@ import { MetricReader } from './MetricReader'; | ||
private _runOnce; | ||
private _doRun; | ||
protected onInitialized(): void; | ||
@@ -31,0 +32,0 @@ protected onForceFlush(): Promise<void>; |
@@ -52,3 +52,17 @@ "use strict"; | ||
async _runOnce() { | ||
const { resourceMetrics, errors } = await this.collect({}); | ||
try { | ||
await (0, utils_1.callWithTimeout)(this._doRun(), this._exportTimeout); | ||
} | ||
catch (err) { | ||
if (err instanceof utils_1.TimeoutError) { | ||
api.diag.error('Export took longer than %s milliseconds and timed out.', this._exportTimeout); | ||
return; | ||
} | ||
(0, core_1.globalErrorHandler)(err); | ||
} | ||
} | ||
async _doRun() { | ||
const { resourceMetrics, errors } = await this.collect({ | ||
timeoutMillis: this._exportTimeout, | ||
}); | ||
if (errors.length > 0) { | ||
@@ -64,13 +78,5 @@ api.diag.error('PeriodicExportingMetricReader: metrics collection errors', ...errors); | ||
// start running the interval as soon as this reader is initialized and keep handle for shutdown. | ||
this._interval = setInterval(async () => { | ||
try { | ||
await (0, utils_1.callWithTimeout)(this._runOnce(), this._exportTimeout); | ||
} | ||
catch (err) { | ||
if (err instanceof utils_1.TimeoutError) { | ||
api.diag.error('Export took longer than %s milliseconds and timed out.', this._exportTimeout); | ||
return; | ||
} | ||
(0, core_1.globalErrorHandler)(err); | ||
} | ||
this._interval = setInterval(() => { | ||
// this._runOnce never rejects. Using void operator to suppress @typescript-eslint/no-floating-promises. | ||
void this._runOnce(); | ||
}, this._exportInterval); | ||
@@ -80,2 +86,3 @@ (0, core_1.unrefTimer)(this._interval); | ||
async onForceFlush() { | ||
await this._runOnce(); | ||
await this._exporter.forceFlush(); | ||
@@ -82,0 +89,0 @@ } |
@@ -32,3 +32,3 @@ "use strict"; | ||
} | ||
this._writableMetricStorage.record(value, attributes, context, (0, core_1.hrTime)()); | ||
this._writableMetricStorage.record(value, attributes, context, (0, core_1.millisToHrTime)(Date.now())); | ||
} | ||
@@ -35,0 +35,0 @@ } |
@@ -32,3 +32,3 @@ "use strict"; | ||
async collect(options) { | ||
const collectionTime = (0, core_1.hrTime)(); | ||
const collectionTime = (0, core_1.millisToHrTime)(Date.now()); | ||
const meterCollectionPromises = Array.from(this._sharedState.meterSharedStates.values()).map(meterSharedState => meterSharedState.collect(this, collectionTime, options)); | ||
@@ -35,0 +35,0 @@ const result = await Promise.all(meterCollectionPromises); |
@@ -1,2 +0,2 @@ | ||
export declare const VERSION = "1.9.0"; | ||
export declare const VERSION = "1.9.1"; | ||
//# sourceMappingURL=version.d.ts.map |
@@ -20,3 +20,3 @@ "use strict"; | ||
// this is autogenerated file, see scripts/version-update.js | ||
exports.VERSION = '1.9.0'; | ||
exports.VERSION = '1.9.1'; | ||
//# sourceMappingURL=version.js.map |
{ | ||
"name": "@opentelemetry/sdk-metrics", | ||
"version": "1.9.0", | ||
"version": "1.9.1", | ||
"description": "OpenTelemetry metrics SDK", | ||
@@ -71,3 +71,3 @@ "main": "build/src/index.js", | ||
"nyc": "15.1.0", | ||
"rimraf": "3.0.2", | ||
"rimraf": "4.1.2", | ||
"sinon": "15.0.0", | ||
@@ -81,4 +81,4 @@ "ts-mocha": "10.0.0", | ||
"dependencies": { | ||
"@opentelemetry/core": "1.9.0", | ||
"@opentelemetry/resources": "1.9.0", | ||
"@opentelemetry/core": "1.9.1", | ||
"@opentelemetry/resources": "1.9.1", | ||
"lodash.merge": "4.6.2" | ||
@@ -88,3 +88,3 @@ }, | ||
"sideEffects": false, | ||
"gitHead": "08f597f3a3d71a4852b0afbba120af15ca038121" | ||
"gitHead": "279458e7ddf16f7ddca5fe60c78672e05fafce66" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1556782
543
17501
+ Added@opentelemetry/core@1.9.1(transitive)
+ Added@opentelemetry/resources@1.9.1(transitive)
+ Added@opentelemetry/semantic-conventions@1.9.1(transitive)
- Removed@opentelemetry/core@1.9.0(transitive)
- Removed@opentelemetry/resources@1.9.0(transitive)
- Removed@opentelemetry/semantic-conventions@1.9.0(transitive)
Updated@opentelemetry/core@1.9.1