@opentelemetry/sdk-metrics
Advanced tools
Comparing version 1.9.1 to 1.10.0
@@ -42,3 +42,3 @@ import { Accumulation, AccumulationRecord, Aggregator, AggregatorKind } from './types'; | ||
/** | ||
* @param _boundaries upper bounds of recorded values. | ||
* @param _boundaries sorted upper bounds of recorded values. | ||
* @param _recordMinMax If set to true, min and max will be recorded. Otherwise, min and max will not be recorded. | ||
@@ -45,0 +45,0 @@ */ |
@@ -35,2 +35,3 @@ /* | ||
import { InstrumentType } from '../InstrumentDescriptor'; | ||
import { binarySearchLB } from '../utils'; | ||
function createNewEmptyCheckpoint(boundaries) { | ||
@@ -68,10 +69,4 @@ var counts = boundaries.map(function () { return 0; }); | ||
} | ||
for (var i = 0; i < this._boundaries.length; i++) { | ||
if (value < this._boundaries[i]) { | ||
this._current.buckets.counts[i] += 1; | ||
return; | ||
} | ||
} | ||
// value is above all observed boundaries | ||
this._current.buckets.counts[this._boundaries.length] += 1; | ||
var idx = binarySearchLB(this._boundaries, value); | ||
this._current.buckets.counts[idx + 1] += 1; | ||
}; | ||
@@ -93,3 +88,3 @@ HistogramAccumulation.prototype.setStartTime = function (startTime) { | ||
/** | ||
* @param _boundaries upper bounds of recorded values. | ||
* @param _boundaries sorted upper bounds of recorded values. | ||
* @param _recordMinMax If set to true, min and max will be recorded. Otherwise, min and max will not be recorded. | ||
@@ -96,0 +91,0 @@ */ |
import { HrTime, MetricAttributes } from '@opentelemetry/api'; | ||
import { InstrumentationScope } from '@opentelemetry/core'; | ||
import { Resource } from '@opentelemetry/resources'; | ||
import { IResource } from '@opentelemetry/resources'; | ||
import { InstrumentDescriptor } from '../InstrumentDescriptor'; | ||
@@ -47,3 +47,3 @@ import { AggregationTemporality } from './AggregationTemporality'; | ||
export interface ResourceMetrics { | ||
resource: Resource; | ||
resource: IResource; | ||
scopeMetrics: ScopeMetrics[]; | ||
@@ -50,0 +50,0 @@ } |
@@ -96,2 +96,3 @@ /* | ||
import { callWithTimeout, TimeoutError } from '../utils'; | ||
import { diag } from '@opentelemetry/api'; | ||
/** | ||
@@ -152,7 +153,9 @@ * {@link MetricReader} which collects metrics based on a user-configurable time interval, and passes the metrics to | ||
PeriodicExportingMetricReader.prototype._doRun = function () { | ||
var _a, _b; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var _a, resourceMetrics, errors, result; | ||
var _b; | ||
return __generator(this, function (_c) { | ||
switch (_c.label) { | ||
var _c, resourceMetrics, errors, doExport; | ||
var _d; | ||
var _this = this; | ||
return __generator(this, function (_e) { | ||
switch (_e.label) { | ||
case 0: return [4 /*yield*/, this.collect({ | ||
@@ -162,13 +165,30 @@ timeoutMillis: this._exportTimeout, | ||
case 1: | ||
_a = _c.sent(), resourceMetrics = _a.resourceMetrics, errors = _a.errors; | ||
_c = _e.sent(), resourceMetrics = _c.resourceMetrics, errors = _c.errors; | ||
if (errors.length > 0) { | ||
(_b = api.diag).error.apply(_b, __spreadArray(['PeriodicExportingMetricReader: metrics collection errors'], __read(errors), false)); | ||
(_d = api.diag).error.apply(_d, __spreadArray(['PeriodicExportingMetricReader: metrics collection errors'], __read(errors), false)); | ||
} | ||
return [4 /*yield*/, internal._export(this._exporter, resourceMetrics)]; | ||
case 2: | ||
result = _c.sent(); | ||
if (result.code !== ExportResultCode.SUCCESS) { | ||
throw new Error("PeriodicExportingMetricReader: metrics export failed (error " + result.error + ")"); | ||
} | ||
return [2 /*return*/]; | ||
doExport = function () { return __awaiter(_this, void 0, void 0, function () { | ||
var result; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, internal._export(this._exporter, resourceMetrics)]; | ||
case 1: | ||
result = _a.sent(); | ||
if (result.code !== ExportResultCode.SUCCESS) { | ||
throw new Error("PeriodicExportingMetricReader: metrics export failed (error " + result.error + ")"); | ||
} | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); }; | ||
if (!resourceMetrics.resource.asyncAttributesPending) return [3 /*break*/, 2]; | ||
(_b = (_a = resourceMetrics.resource).waitForAsyncAttributes) === null || _b === void 0 ? void 0 : _b.call(_a).then(doExport, function (err) { | ||
return diag.debug('Error while resolving async portion of resource: ', err); | ||
}); | ||
return [3 /*break*/, 4]; | ||
case 2: return [4 /*yield*/, doExport()]; | ||
case 3: | ||
_e.sent(); | ||
_e.label = 4; | ||
case 4: return [2 /*return*/]; | ||
} | ||
@@ -175,0 +195,0 @@ }); |
import { MeterProvider as IMeterProvider, Meter as IMeter, MeterOptions } from '@opentelemetry/api'; | ||
import { Resource } from '@opentelemetry/resources'; | ||
import { IResource } from '@opentelemetry/resources'; | ||
import { MetricReader } from './export/MetricReader'; | ||
@@ -11,3 +11,3 @@ import { ForceFlushOptions, ShutdownOptions } from './types'; | ||
/** Resource associated with metric telemetry */ | ||
resource?: Resource; | ||
resource?: IResource; | ||
views?: View[]; | ||
@@ -14,0 +14,0 @@ } |
import { InstrumentationScope } from '@opentelemetry/core'; | ||
import { Resource } from '@opentelemetry/resources'; | ||
import { IResource } from '@opentelemetry/resources'; | ||
import { Aggregation, InstrumentType } from '..'; | ||
@@ -11,7 +11,7 @@ import { ViewRegistry } from '../view/ViewRegistry'; | ||
export declare class MeterProviderSharedState { | ||
resource: Resource; | ||
resource: IResource; | ||
viewRegistry: ViewRegistry; | ||
metricCollectors: MetricCollector[]; | ||
meterSharedStates: Map<string, MeterSharedState>; | ||
constructor(resource: Resource); | ||
constructor(resource: IResource); | ||
getMeterSharedState(instrumentationScope: InstrumentationScope): MeterSharedState; | ||
@@ -18,0 +18,0 @@ selectAggregations(instrumentType: InstrumentType): [MetricCollectorHandle, Aggregation][]; |
@@ -50,2 +50,9 @@ import { MetricAttributes } from '@opentelemetry/api'; | ||
export declare function setEquals(lhs: Set<unknown>, rhs: Set<unknown>): boolean; | ||
/** | ||
* Binary search the sorted array to the find lower bound for the value. | ||
* @param arr | ||
* @param value | ||
* @returns | ||
*/ | ||
export declare function binarySearchLB(arr: number[], value: number): number; | ||
//# sourceMappingURL=utils.d.ts.map |
@@ -233,2 +233,28 @@ /* | ||
} | ||
/** | ||
* Binary search the sorted array to the find lower bound for the value. | ||
* @param arr | ||
* @param value | ||
* @returns | ||
*/ | ||
export function binarySearchLB(arr, value) { | ||
var lo = 0; | ||
var hi = arr.length - 1; | ||
while (hi - lo > 1) { | ||
var mid = Math.trunc((hi + lo) / 2); | ||
if (arr[mid] <= value) { | ||
lo = mid; | ||
} | ||
else { | ||
hi = mid - 1; | ||
} | ||
} | ||
if (arr[hi] <= value) { | ||
return hi; | ||
} | ||
else if (arr[lo] <= value) { | ||
return lo; | ||
} | ||
return -1; | ||
} | ||
//# sourceMappingURL=utils.js.map |
@@ -1,2 +0,2 @@ | ||
export declare const VERSION = "1.9.1"; | ||
export declare const VERSION = "1.10.0"; | ||
//# sourceMappingURL=version.d.ts.map |
@@ -17,3 +17,3 @@ /* | ||
// this is autogenerated file, see scripts/version-update.js | ||
export var VERSION = '1.9.1'; | ||
export var VERSION = '1.10.0'; | ||
//# sourceMappingURL=version.js.map |
@@ -6,2 +6,3 @@ import { InstrumentType } from '../InstrumentDescriptor'; | ||
type?: InstrumentType; | ||
unit?: string; | ||
} | ||
@@ -11,6 +12,8 @@ export declare class InstrumentSelector { | ||
private _type?; | ||
private _unitFilter; | ||
constructor(criteria?: InstrumentSelectorCriteria); | ||
getType(): InstrumentType | undefined; | ||
getNameFilter(): Predicate; | ||
getUnitFilter(): Predicate; | ||
} | ||
//# sourceMappingURL=InstrumentSelector.d.ts.map |
@@ -16,3 +16,3 @@ /* | ||
*/ | ||
import { PatternPredicate } from './Predicate'; | ||
import { ExactPredicate, PatternPredicate } from './Predicate'; | ||
var InstrumentSelector = /** @class */ (function () { | ||
@@ -23,2 +23,3 @@ function InstrumentSelector(criteria) { | ||
this._type = criteria === null || criteria === void 0 ? void 0 : criteria.type; | ||
this._unitFilter = new ExactPredicate(criteria === null || criteria === void 0 ? void 0 : criteria.unit); | ||
} | ||
@@ -31,2 +32,5 @@ InstrumentSelector.prototype.getType = function () { | ||
}; | ||
InstrumentSelector.prototype.getUnitFilter = function () { | ||
return this._unitFilter; | ||
}; | ||
return InstrumentSelector; | ||
@@ -33,0 +37,0 @@ }()); |
@@ -42,2 +42,3 @@ /* | ||
type: otherDescriptor.type, | ||
unit: otherDescriptor.unit, | ||
}; | ||
@@ -51,2 +52,3 @@ var selectorString = JSON.stringify(selector); | ||
type: otherDescriptor.type, | ||
unit: otherDescriptor.unit, | ||
}; | ||
@@ -53,0 +55,0 @@ var selectorString = JSON.stringify(selector); |
@@ -67,2 +67,10 @@ import { AttributesProcessor } from './AttributesProcessor'; | ||
* Instrument selection criteria: | ||
* The unit of the Instrument(s). | ||
* | ||
* @example <caption>select all instruments with unit 'ms'</caption> | ||
* instrumentUnit: 'ms' | ||
*/ | ||
instrumentUnit?: string; | ||
/** | ||
* Instrument selection criteria: | ||
* The name of the Meter. No wildcard support, name must match the meter exactly. | ||
@@ -132,2 +140,5 @@ * | ||
* The original type of the Instrument(s). | ||
* @param viewOptions.instrumentUnit | ||
* Instrument selection criteria: | ||
* The unit of the Instrument(s). | ||
* @param viewOptions.meterName | ||
@@ -134,0 +145,0 @@ * Instrument selection criteria: |
@@ -24,2 +24,3 @@ /* | ||
options.instrumentType == null && | ||
options.instrumentUnit == null && | ||
options.meterName == null && | ||
@@ -64,2 +65,5 @@ options.meterVersion == null && | ||
* The original type of the Instrument(s). | ||
* @param viewOptions.instrumentUnit | ||
* Instrument selection criteria: | ||
* The unit of the Instrument(s). | ||
* @param viewOptions.meterName | ||
@@ -110,2 +114,3 @@ * Instrument selection criteria: | ||
type: viewOptions.instrumentType, | ||
unit: viewOptions.instrumentUnit, | ||
}); | ||
@@ -112,0 +117,0 @@ this.meterSelector = new MeterSelector({ |
@@ -34,3 +34,4 @@ /* | ||
instrument.type === selector.getType()) && | ||
selector.getNameFilter().match(instrument.name)); | ||
selector.getNameFilter().match(instrument.name) && | ||
selector.getUnitFilter().match(instrument.unit)); | ||
}; | ||
@@ -37,0 +38,0 @@ ViewRegistry.prototype._matchMeter = function (selector, meter) { |
@@ -42,3 +42,3 @@ import { Accumulation, AccumulationRecord, Aggregator, AggregatorKind } from './types'; | ||
/** | ||
* @param _boundaries upper bounds of recorded values. | ||
* @param _boundaries sorted upper bounds of recorded values. | ||
* @param _recordMinMax If set to true, min and max will be recorded. Otherwise, min and max will not be recorded. | ||
@@ -45,0 +45,0 @@ */ |
@@ -19,2 +19,3 @@ /* | ||
import { InstrumentType } from '../InstrumentDescriptor'; | ||
import { binarySearchLB } from '../utils'; | ||
function createNewEmptyCheckpoint(boundaries) { | ||
@@ -50,10 +51,4 @@ const counts = boundaries.map(() => 0); | ||
} | ||
for (let i = 0; i < this._boundaries.length; i++) { | ||
if (value < this._boundaries[i]) { | ||
this._current.buckets.counts[i] += 1; | ||
return; | ||
} | ||
} | ||
// value is above all observed boundaries | ||
this._current.buckets.counts[this._boundaries.length] += 1; | ||
const idx = binarySearchLB(this._boundaries, value); | ||
this._current.buckets.counts[idx + 1] += 1; | ||
} | ||
@@ -73,3 +68,3 @@ setStartTime(startTime) { | ||
/** | ||
* @param _boundaries upper bounds of recorded values. | ||
* @param _boundaries sorted upper bounds of recorded values. | ||
* @param _recordMinMax If set to true, min and max will be recorded. Otherwise, min and max will not be recorded. | ||
@@ -76,0 +71,0 @@ */ |
import { HrTime, MetricAttributes } from '@opentelemetry/api'; | ||
import { InstrumentationScope } from '@opentelemetry/core'; | ||
import { Resource } from '@opentelemetry/resources'; | ||
import { IResource } from '@opentelemetry/resources'; | ||
import { InstrumentDescriptor } from '../InstrumentDescriptor'; | ||
@@ -47,3 +47,3 @@ import { AggregationTemporality } from './AggregationTemporality'; | ||
export interface ResourceMetrics { | ||
resource: Resource; | ||
resource: IResource; | ||
scopeMetrics: ScopeMetrics[]; | ||
@@ -50,0 +50,0 @@ } |
@@ -20,2 +20,3 @@ /* | ||
import { callWithTimeout, TimeoutError } from '../utils'; | ||
import { diag } from '@opentelemetry/api'; | ||
/** | ||
@@ -62,2 +63,3 @@ * {@link MetricReader} which collects metrics based on a user-configurable time interval, and passes the metrics to | ||
async _doRun() { | ||
var _a, _b; | ||
const { resourceMetrics, errors } = await this.collect({ | ||
@@ -69,6 +71,15 @@ timeoutMillis: this._exportTimeout, | ||
} | ||
const result = await internal._export(this._exporter, resourceMetrics); | ||
if (result.code !== ExportResultCode.SUCCESS) { | ||
throw new Error(`PeriodicExportingMetricReader: metrics export failed (error ${result.error})`); | ||
const doExport = async () => { | ||
const result = await internal._export(this._exporter, resourceMetrics); | ||
if (result.code !== ExportResultCode.SUCCESS) { | ||
throw new Error(`PeriodicExportingMetricReader: metrics export failed (error ${result.error})`); | ||
} | ||
}; | ||
// Avoid scheduling a promise to make the behavior more predictable and easier to test | ||
if (resourceMetrics.resource.asyncAttributesPending) { | ||
(_b = (_a = resourceMetrics.resource).waitForAsyncAttributes) === null || _b === void 0 ? void 0 : _b.call(_a).then(doExport, err => diag.debug('Error while resolving async portion of resource: ', err)); | ||
} | ||
else { | ||
await doExport(); | ||
} | ||
} | ||
@@ -75,0 +86,0 @@ onInitialized() { |
import { MeterProvider as IMeterProvider, Meter as IMeter, MeterOptions } from '@opentelemetry/api'; | ||
import { Resource } from '@opentelemetry/resources'; | ||
import { IResource } from '@opentelemetry/resources'; | ||
import { MetricReader } from './export/MetricReader'; | ||
@@ -11,3 +11,3 @@ import { ForceFlushOptions, ShutdownOptions } from './types'; | ||
/** Resource associated with metric telemetry */ | ||
resource?: Resource; | ||
resource?: IResource; | ||
views?: View[]; | ||
@@ -14,0 +14,0 @@ } |
import { InstrumentationScope } from '@opentelemetry/core'; | ||
import { Resource } from '@opentelemetry/resources'; | ||
import { IResource } from '@opentelemetry/resources'; | ||
import { Aggregation, InstrumentType } from '..'; | ||
@@ -11,7 +11,7 @@ import { ViewRegistry } from '../view/ViewRegistry'; | ||
export declare class MeterProviderSharedState { | ||
resource: Resource; | ||
resource: IResource; | ||
viewRegistry: ViewRegistry; | ||
metricCollectors: MetricCollector[]; | ||
meterSharedStates: Map<string, MeterSharedState>; | ||
constructor(resource: Resource); | ||
constructor(resource: IResource); | ||
getMeterSharedState(instrumentationScope: InstrumentationScope): MeterSharedState; | ||
@@ -18,0 +18,0 @@ selectAggregations(instrumentType: InstrumentType): [MetricCollectorHandle, Aggregation][]; |
@@ -50,2 +50,9 @@ import { MetricAttributes } from '@opentelemetry/api'; | ||
export declare function setEquals(lhs: Set<unknown>, rhs: Set<unknown>): boolean; | ||
/** | ||
* Binary search the sorted array to the find lower bound for the value. | ||
* @param arr | ||
* @param value | ||
* @returns | ||
*/ | ||
export declare function binarySearchLB(arr: number[], value: number): number; | ||
//# sourceMappingURL=utils.d.ts.map |
@@ -118,2 +118,28 @@ /* | ||
} | ||
/** | ||
* Binary search the sorted array to the find lower bound for the value. | ||
* @param arr | ||
* @param value | ||
* @returns | ||
*/ | ||
export function binarySearchLB(arr, value) { | ||
let lo = 0; | ||
let hi = arr.length - 1; | ||
while (hi - lo > 1) { | ||
const mid = Math.trunc((hi + lo) / 2); | ||
if (arr[mid] <= value) { | ||
lo = mid; | ||
} | ||
else { | ||
hi = mid - 1; | ||
} | ||
} | ||
if (arr[hi] <= value) { | ||
return hi; | ||
} | ||
else if (arr[lo] <= value) { | ||
return lo; | ||
} | ||
return -1; | ||
} | ||
//# sourceMappingURL=utils.js.map |
@@ -1,2 +0,2 @@ | ||
export declare const VERSION = "1.9.1"; | ||
export declare const VERSION = "1.10.0"; | ||
//# sourceMappingURL=version.d.ts.map |
@@ -17,3 +17,3 @@ /* | ||
// this is autogenerated file, see scripts/version-update.js | ||
export const VERSION = '1.9.1'; | ||
export const VERSION = '1.10.0'; | ||
//# sourceMappingURL=version.js.map |
@@ -6,2 +6,3 @@ import { InstrumentType } from '../InstrumentDescriptor'; | ||
type?: InstrumentType; | ||
unit?: string; | ||
} | ||
@@ -11,6 +12,8 @@ export declare class InstrumentSelector { | ||
private _type?; | ||
private _unitFilter; | ||
constructor(criteria?: InstrumentSelectorCriteria); | ||
getType(): InstrumentType | undefined; | ||
getNameFilter(): Predicate; | ||
getUnitFilter(): Predicate; | ||
} | ||
//# sourceMappingURL=InstrumentSelector.d.ts.map |
@@ -16,3 +16,3 @@ /* | ||
*/ | ||
import { PatternPredicate } from './Predicate'; | ||
import { ExactPredicate, PatternPredicate } from './Predicate'; | ||
export class InstrumentSelector { | ||
@@ -23,2 +23,3 @@ constructor(criteria) { | ||
this._type = criteria === null || criteria === void 0 ? void 0 : criteria.type; | ||
this._unitFilter = new ExactPredicate(criteria === null || criteria === void 0 ? void 0 : criteria.unit); | ||
} | ||
@@ -31,3 +32,6 @@ getType() { | ||
} | ||
getUnitFilter() { | ||
return this._unitFilter; | ||
} | ||
} | ||
//# sourceMappingURL=InstrumentSelector.js.map |
@@ -42,2 +42,3 @@ /* | ||
type: otherDescriptor.type, | ||
unit: otherDescriptor.unit, | ||
}; | ||
@@ -51,2 +52,3 @@ const selectorString = JSON.stringify(selector); | ||
type: otherDescriptor.type, | ||
unit: otherDescriptor.unit, | ||
}; | ||
@@ -53,0 +55,0 @@ const selectorString = JSON.stringify(selector); |
@@ -67,2 +67,10 @@ import { AttributesProcessor } from './AttributesProcessor'; | ||
* Instrument selection criteria: | ||
* The unit of the Instrument(s). | ||
* | ||
* @example <caption>select all instruments with unit 'ms'</caption> | ||
* instrumentUnit: 'ms' | ||
*/ | ||
instrumentUnit?: string; | ||
/** | ||
* Instrument selection criteria: | ||
* The name of the Meter. No wildcard support, name must match the meter exactly. | ||
@@ -132,2 +140,5 @@ * | ||
* The original type of the Instrument(s). | ||
* @param viewOptions.instrumentUnit | ||
* Instrument selection criteria: | ||
* The unit of the Instrument(s). | ||
* @param viewOptions.meterName | ||
@@ -134,0 +145,0 @@ * Instrument selection criteria: |
@@ -24,2 +24,3 @@ /* | ||
options.instrumentType == null && | ||
options.instrumentUnit == null && | ||
options.meterName == null && | ||
@@ -64,2 +65,5 @@ options.meterVersion == null && | ||
* The original type of the Instrument(s). | ||
* @param viewOptions.instrumentUnit | ||
* Instrument selection criteria: | ||
* The unit of the Instrument(s). | ||
* @param viewOptions.meterName | ||
@@ -110,2 +114,3 @@ * Instrument selection criteria: | ||
type: viewOptions.instrumentType, | ||
unit: viewOptions.instrumentUnit, | ||
}); | ||
@@ -112,0 +117,0 @@ this.meterSelector = new MeterSelector({ |
@@ -33,3 +33,4 @@ /* | ||
instrument.type === selector.getType()) && | ||
selector.getNameFilter().match(instrument.name)); | ||
selector.getNameFilter().match(instrument.name) && | ||
selector.getUnitFilter().match(instrument.unit)); | ||
} | ||
@@ -36,0 +37,0 @@ _matchMeter(selector, meter) { |
@@ -42,3 +42,3 @@ import { Accumulation, AccumulationRecord, Aggregator, AggregatorKind } from './types'; | ||
/** | ||
* @param _boundaries upper bounds of recorded values. | ||
* @param _boundaries sorted upper bounds of recorded values. | ||
* @param _recordMinMax If set to true, min and max will be recorded. Otherwise, min and max will not be recorded. | ||
@@ -45,0 +45,0 @@ */ |
@@ -22,2 +22,3 @@ "use strict"; | ||
const InstrumentDescriptor_1 = require("../InstrumentDescriptor"); | ||
const utils_1 = require("../utils"); | ||
function createNewEmptyCheckpoint(boundaries) { | ||
@@ -53,10 +54,4 @@ const counts = boundaries.map(() => 0); | ||
} | ||
for (let i = 0; i < this._boundaries.length; i++) { | ||
if (value < this._boundaries[i]) { | ||
this._current.buckets.counts[i] += 1; | ||
return; | ||
} | ||
} | ||
// value is above all observed boundaries | ||
this._current.buckets.counts[this._boundaries.length] += 1; | ||
const idx = (0, utils_1.binarySearchLB)(this._boundaries, value); | ||
this._current.buckets.counts[idx + 1] += 1; | ||
} | ||
@@ -77,3 +72,3 @@ setStartTime(startTime) { | ||
/** | ||
* @param _boundaries upper bounds of recorded values. | ||
* @param _boundaries sorted upper bounds of recorded values. | ||
* @param _recordMinMax If set to true, min and max will be recorded. Otherwise, min and max will not be recorded. | ||
@@ -80,0 +75,0 @@ */ |
import { HrTime, MetricAttributes } from '@opentelemetry/api'; | ||
import { InstrumentationScope } from '@opentelemetry/core'; | ||
import { Resource } from '@opentelemetry/resources'; | ||
import { IResource } from '@opentelemetry/resources'; | ||
import { InstrumentDescriptor } from '../InstrumentDescriptor'; | ||
@@ -47,3 +47,3 @@ import { AggregationTemporality } from './AggregationTemporality'; | ||
export interface ResourceMetrics { | ||
resource: Resource; | ||
resource: IResource; | ||
scopeMetrics: ScopeMetrics[]; | ||
@@ -50,0 +50,0 @@ } |
@@ -23,2 +23,3 @@ "use strict"; | ||
const utils_1 = require("../utils"); | ||
const api_1 = require("@opentelemetry/api"); | ||
/** | ||
@@ -65,2 +66,3 @@ * {@link MetricReader} which collects metrics based on a user-configurable time interval, and passes the metrics to | ||
async _doRun() { | ||
var _a, _b; | ||
const { resourceMetrics, errors } = await this.collect({ | ||
@@ -72,6 +74,15 @@ timeoutMillis: this._exportTimeout, | ||
} | ||
const result = await core_1.internal._export(this._exporter, resourceMetrics); | ||
if (result.code !== core_1.ExportResultCode.SUCCESS) { | ||
throw new Error(`PeriodicExportingMetricReader: metrics export failed (error ${result.error})`); | ||
const doExport = async () => { | ||
const result = await core_1.internal._export(this._exporter, resourceMetrics); | ||
if (result.code !== core_1.ExportResultCode.SUCCESS) { | ||
throw new Error(`PeriodicExportingMetricReader: metrics export failed (error ${result.error})`); | ||
} | ||
}; | ||
// Avoid scheduling a promise to make the behavior more predictable and easier to test | ||
if (resourceMetrics.resource.asyncAttributesPending) { | ||
(_b = (_a = resourceMetrics.resource).waitForAsyncAttributes) === null || _b === void 0 ? void 0 : _b.call(_a).then(doExport, err => api_1.diag.debug('Error while resolving async portion of resource: ', err)); | ||
} | ||
else { | ||
await doExport(); | ||
} | ||
} | ||
@@ -78,0 +89,0 @@ onInitialized() { |
import { MeterProvider as IMeterProvider, Meter as IMeter, MeterOptions } from '@opentelemetry/api'; | ||
import { Resource } from '@opentelemetry/resources'; | ||
import { IResource } from '@opentelemetry/resources'; | ||
import { MetricReader } from './export/MetricReader'; | ||
@@ -11,3 +11,3 @@ import { ForceFlushOptions, ShutdownOptions } from './types'; | ||
/** Resource associated with metric telemetry */ | ||
resource?: Resource; | ||
resource?: IResource; | ||
views?: View[]; | ||
@@ -14,0 +14,0 @@ } |
import { InstrumentationScope } from '@opentelemetry/core'; | ||
import { Resource } from '@opentelemetry/resources'; | ||
import { IResource } from '@opentelemetry/resources'; | ||
import { Aggregation, InstrumentType } from '..'; | ||
@@ -11,7 +11,7 @@ import { ViewRegistry } from '../view/ViewRegistry'; | ||
export declare class MeterProviderSharedState { | ||
resource: Resource; | ||
resource: IResource; | ||
viewRegistry: ViewRegistry; | ||
metricCollectors: MetricCollector[]; | ||
meterSharedStates: Map<string, MeterSharedState>; | ||
constructor(resource: Resource); | ||
constructor(resource: IResource); | ||
getMeterSharedState(instrumentationScope: InstrumentationScope): MeterSharedState; | ||
@@ -18,0 +18,0 @@ selectAggregations(instrumentType: InstrumentType): [MetricCollectorHandle, Aggregation][]; |
@@ -50,2 +50,9 @@ import { MetricAttributes } from '@opentelemetry/api'; | ||
export declare function setEquals(lhs: Set<unknown>, rhs: Set<unknown>): boolean; | ||
/** | ||
* Binary search the sorted array to the find lower bound for the value. | ||
* @param arr | ||
* @param value | ||
* @returns | ||
*/ | ||
export declare function binarySearchLB(arr: number[], value: number): number; | ||
//# sourceMappingURL=utils.d.ts.map |
@@ -18,3 +18,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.setEquals = exports.FlatMap = exports.isPromiseAllSettledRejectionResult = exports.PromiseAllSettled = exports.callWithTimeout = exports.TimeoutError = exports.instrumentationScopeId = exports.hashAttributes = exports.isNotNullish = void 0; | ||
exports.binarySearchLB = exports.setEquals = exports.FlatMap = exports.isPromiseAllSettledRejectionResult = exports.PromiseAllSettled = exports.callWithTimeout = exports.TimeoutError = exports.instrumentationScopeId = exports.hashAttributes = exports.isNotNullish = void 0; | ||
function isNotNullish(item) { | ||
@@ -131,2 +131,29 @@ return item !== undefined && item !== null; | ||
exports.setEquals = setEquals; | ||
/** | ||
* Binary search the sorted array to the find lower bound for the value. | ||
* @param arr | ||
* @param value | ||
* @returns | ||
*/ | ||
function binarySearchLB(arr, value) { | ||
let lo = 0; | ||
let hi = arr.length - 1; | ||
while (hi - lo > 1) { | ||
const mid = Math.trunc((hi + lo) / 2); | ||
if (arr[mid] <= value) { | ||
lo = mid; | ||
} | ||
else { | ||
hi = mid - 1; | ||
} | ||
} | ||
if (arr[hi] <= value) { | ||
return hi; | ||
} | ||
else if (arr[lo] <= value) { | ||
return lo; | ||
} | ||
return -1; | ||
} | ||
exports.binarySearchLB = binarySearchLB; | ||
//# sourceMappingURL=utils.js.map |
@@ -1,2 +0,2 @@ | ||
export declare const VERSION = "1.9.1"; | ||
export declare const VERSION = "1.10.0"; | ||
//# sourceMappingURL=version.d.ts.map |
@@ -20,3 +20,3 @@ "use strict"; | ||
// this is autogenerated file, see scripts/version-update.js | ||
exports.VERSION = '1.9.1'; | ||
exports.VERSION = '1.10.0'; | ||
//# sourceMappingURL=version.js.map |
@@ -6,2 +6,3 @@ import { InstrumentType } from '../InstrumentDescriptor'; | ||
type?: InstrumentType; | ||
unit?: string; | ||
} | ||
@@ -11,6 +12,8 @@ export declare class InstrumentSelector { | ||
private _type?; | ||
private _unitFilter; | ||
constructor(criteria?: InstrumentSelectorCriteria); | ||
getType(): InstrumentType | undefined; | ||
getNameFilter(): Predicate; | ||
getUnitFilter(): Predicate; | ||
} | ||
//# sourceMappingURL=InstrumentSelector.d.ts.map |
@@ -25,2 +25,3 @@ "use strict"; | ||
this._type = criteria === null || criteria === void 0 ? void 0 : criteria.type; | ||
this._unitFilter = new Predicate_1.ExactPredicate(criteria === null || criteria === void 0 ? void 0 : criteria.unit); | ||
} | ||
@@ -33,4 +34,7 @@ getType() { | ||
} | ||
getUnitFilter() { | ||
return this._unitFilter; | ||
} | ||
} | ||
exports.InstrumentSelector = InstrumentSelector; | ||
//# sourceMappingURL=InstrumentSelector.js.map |
@@ -48,2 +48,3 @@ "use strict"; | ||
type: otherDescriptor.type, | ||
unit: otherDescriptor.unit, | ||
}; | ||
@@ -58,2 +59,3 @@ const selectorString = JSON.stringify(selector); | ||
type: otherDescriptor.type, | ||
unit: otherDescriptor.unit, | ||
}; | ||
@@ -60,0 +62,0 @@ const selectorString = JSON.stringify(selector); |
@@ -67,2 +67,10 @@ import { AttributesProcessor } from './AttributesProcessor'; | ||
* Instrument selection criteria: | ||
* The unit of the Instrument(s). | ||
* | ||
* @example <caption>select all instruments with unit 'ms'</caption> | ||
* instrumentUnit: 'ms' | ||
*/ | ||
instrumentUnit?: string; | ||
/** | ||
* Instrument selection criteria: | ||
* The name of the Meter. No wildcard support, name must match the meter exactly. | ||
@@ -132,2 +140,5 @@ * | ||
* The original type of the Instrument(s). | ||
* @param viewOptions.instrumentUnit | ||
* Instrument selection criteria: | ||
* The unit of the Instrument(s). | ||
* @param viewOptions.meterName | ||
@@ -134,0 +145,0 @@ * Instrument selection criteria: |
@@ -27,2 +27,3 @@ "use strict"; | ||
options.instrumentType == null && | ||
options.instrumentUnit == null && | ||
options.meterName == null && | ||
@@ -67,2 +68,5 @@ options.meterVersion == null && | ||
* The original type of the Instrument(s). | ||
* @param viewOptions.instrumentUnit | ||
* Instrument selection criteria: | ||
* The unit of the Instrument(s). | ||
* @param viewOptions.meterName | ||
@@ -113,2 +117,3 @@ * Instrument selection criteria: | ||
type: viewOptions.instrumentType, | ||
unit: viewOptions.instrumentUnit, | ||
}); | ||
@@ -115,0 +120,0 @@ this.meterSelector = new MeterSelector_1.MeterSelector({ |
@@ -36,3 +36,4 @@ "use strict"; | ||
instrument.type === selector.getType()) && | ||
selector.getNameFilter().match(instrument.name)); | ||
selector.getNameFilter().match(instrument.name) && | ||
selector.getUnitFilter().match(instrument.unit)); | ||
} | ||
@@ -39,0 +40,0 @@ _matchMeter(selector, meter) { |
{ | ||
"name": "@opentelemetry/sdk-metrics", | ||
"version": "1.9.1", | ||
"version": "1.10.0", | ||
"description": "OpenTelemetry metrics SDK", | ||
@@ -80,4 +80,4 @@ "main": "build/src/index.js", | ||
"dependencies": { | ||
"@opentelemetry/core": "1.9.1", | ||
"@opentelemetry/resources": "1.9.1", | ||
"@opentelemetry/core": "1.10.0", | ||
"@opentelemetry/resources": "1.10.0", | ||
"lodash.merge": "4.6.2" | ||
@@ -87,3 +87,3 @@ }, | ||
"sideEffects": false, | ||
"gitHead": "279458e7ddf16f7ddca5fe60c78672e05fafce66" | ||
"gitHead": "56e6b1bb890f844b8963a146780d0b9cfa8abd0d" | ||
} |
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
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
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1571910
17706
1
80
+ Added@opentelemetry/core@1.10.0(transitive)
+ Added@opentelemetry/resources@1.10.0(transitive)
+ Added@opentelemetry/semantic-conventions@1.10.0(transitive)
- Removed@opentelemetry/core@1.9.1(transitive)
- Removed@opentelemetry/resources@1.9.1(transitive)
- Removed@opentelemetry/semantic-conventions@1.9.1(transitive)
Updated@opentelemetry/core@1.10.0