refactor: change metrics export data model to match OTLP protos (#2809)
* refactor: match metrics export model with proto * refactor: get rid of MetricsData * fix: don't filter empty instrumentation library metrics
This commit is contained in:
parent
82192b54e6
commit
c6dab2a6e7
|
|
@ -21,7 +21,7 @@ import { Counter, Histogram, UpDownCounter } from './Instruments';
|
|||
import { MeterProviderSharedState } from './state/MeterProviderSharedState';
|
||||
import { MultiMetricStorage } from './state/MultiWritableMetricStorage';
|
||||
import { SyncMetricStorage } from './state/SyncMetricStorage';
|
||||
import { MetricData } from './export/MetricData';
|
||||
import { InstrumentationLibraryMetrics } from './export/MetricData';
|
||||
import { isNotNullish } from './utils';
|
||||
import { MetricCollectorHandle } from './state/MetricCollector';
|
||||
import { HrTime } from '@opentelemetry/api';
|
||||
|
|
@ -128,16 +128,18 @@ export class Meter implements metrics.Meter {
|
|||
* @param collectionTime the HrTime at which the collection was initiated.
|
||||
* @returns the list of {@link MetricData} collected.
|
||||
*/
|
||||
async collect(collector: MetricCollectorHandle, collectionTime: HrTime): Promise<MetricData[]> {
|
||||
const result = await Promise.all(this._metricStorageRegistry.getStorages().map(metricStorage => {
|
||||
async collect(collector: MetricCollectorHandle, collectionTime: HrTime): Promise<InstrumentationLibraryMetrics> {
|
||||
const metricData = await Promise.all(this._metricStorageRegistry.getStorages().map(metricStorage => {
|
||||
return metricStorage.collect(
|
||||
collector,
|
||||
this._meterProviderSharedState.metricCollectors,
|
||||
this._meterProviderSharedState.resource,
|
||||
this._instrumentationLibrary,
|
||||
this._meterProviderSharedState.sdkStartTime,
|
||||
collectionTime);
|
||||
}));
|
||||
return result.filter(isNotNullish);
|
||||
|
||||
return {
|
||||
instrumentationLibrary: this._instrumentationLibrary,
|
||||
metrics: metricData.filter(isNotNullish),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,8 +15,6 @@
|
|||
*/
|
||||
|
||||
import { HrTime } from '@opentelemetry/api';
|
||||
import { InstrumentationLibrary } from '@opentelemetry/core';
|
||||
import { Resource } from '@opentelemetry/resources';
|
||||
import { MetricData } from '../export/MetricData';
|
||||
import { InstrumentDescriptor } from '../InstrumentDescriptor';
|
||||
import { Maybe } from '../utils';
|
||||
|
|
@ -43,8 +41,6 @@ export class DropAggregator implements Aggregator<undefined> {
|
|||
}
|
||||
|
||||
toMetricData(
|
||||
_resource: Resource,
|
||||
_instrumentationLibrary: InstrumentationLibrary,
|
||||
_instrumentDescriptor: InstrumentDescriptor,
|
||||
_accumulationByAttributes: AccumulationRecord<undefined>[],
|
||||
_startTime: HrTime,
|
||||
|
|
|
|||
|
|
@ -22,8 +22,6 @@ import {
|
|||
Histogram,
|
||||
} from './types';
|
||||
import { HistogramMetricData, PointDataType } from '../export/MetricData';
|
||||
import { Resource } from '@opentelemetry/resources';
|
||||
import { InstrumentationLibrary } from '@opentelemetry/core';
|
||||
import { HrTime } from '@opentelemetry/api';
|
||||
import { InstrumentDescriptor } from '../InstrumentDescriptor';
|
||||
import { Maybe } from '../utils';
|
||||
|
|
@ -138,15 +136,11 @@ export class HistogramAggregator implements Aggregator<HistogramAccumulation> {
|
|||
}
|
||||
|
||||
toMetricData(
|
||||
resource: Resource,
|
||||
instrumentationLibrary: InstrumentationLibrary,
|
||||
metricDescriptor: InstrumentDescriptor,
|
||||
accumulationByAttributes: AccumulationRecord<HistogramAccumulation>[],
|
||||
startTime: HrTime,
|
||||
endTime: HrTime): Maybe<HistogramMetricData> {
|
||||
return {
|
||||
resource,
|
||||
instrumentationLibrary,
|
||||
instrumentDescriptor: metricDescriptor,
|
||||
pointDataType: PointDataType.HISTOGRAM,
|
||||
pointData: accumulationByAttributes.map(([attributes, accumulation]) => {
|
||||
|
|
|
|||
|
|
@ -16,8 +16,7 @@
|
|||
|
||||
import { LastValue, AggregatorKind, Aggregator, Accumulation, AccumulationRecord } from './types';
|
||||
import { HrTime } from '@opentelemetry/api';
|
||||
import { hrTime, hrTimeToMicroseconds, InstrumentationLibrary } from '@opentelemetry/core';
|
||||
import { Resource } from '@opentelemetry/resources';
|
||||
import { hrTime, hrTimeToMicroseconds } from '@opentelemetry/core';
|
||||
import { PointDataType, SingularMetricData } from '../export/MetricData';
|
||||
import { InstrumentDescriptor } from '../InstrumentDescriptor';
|
||||
import { Maybe } from '../utils';
|
||||
|
|
@ -67,15 +66,11 @@ export class LastValueAggregator implements Aggregator<LastValueAccumulation> {
|
|||
}
|
||||
|
||||
toMetricData(
|
||||
resource: Resource,
|
||||
instrumentationLibrary: InstrumentationLibrary,
|
||||
instrumentDescriptor: InstrumentDescriptor,
|
||||
accumulationByAttributes: AccumulationRecord<LastValueAccumulation>[],
|
||||
startTime: HrTime,
|
||||
endTime: HrTime): Maybe<SingularMetricData> {
|
||||
return {
|
||||
resource,
|
||||
instrumentationLibrary,
|
||||
instrumentDescriptor,
|
||||
pointDataType: PointDataType.SINGULAR,
|
||||
pointData: accumulationByAttributes.map(([attributes, accumulation]) => {
|
||||
|
|
|
|||
|
|
@ -16,8 +16,6 @@
|
|||
|
||||
import { Sum, AggregatorKind, Aggregator, Accumulation, AccumulationRecord } from './types';
|
||||
import { HrTime } from '@opentelemetry/api';
|
||||
import { InstrumentationLibrary } from '@opentelemetry/core';
|
||||
import { Resource } from '@opentelemetry/resources';
|
||||
import { PointDataType, SingularMetricData } from '../export/MetricData';
|
||||
import { InstrumentDescriptor } from '../InstrumentDescriptor';
|
||||
import { Maybe } from '../utils';
|
||||
|
|
@ -57,15 +55,11 @@ export class SumAggregator implements Aggregator<SumAccumulation> {
|
|||
}
|
||||
|
||||
toMetricData(
|
||||
resource: Resource,
|
||||
instrumentationLibrary: InstrumentationLibrary,
|
||||
instrumentDescriptor: InstrumentDescriptor,
|
||||
accumulationByAttributes: AccumulationRecord<SumAccumulation>[],
|
||||
startTime: HrTime,
|
||||
endTime: HrTime): Maybe<SingularMetricData> {
|
||||
return {
|
||||
resource,
|
||||
instrumentationLibrary,
|
||||
instrumentDescriptor,
|
||||
pointDataType: PointDataType.SINGULAR,
|
||||
pointData: accumulationByAttributes.map(([attributes, accumulation]) => {
|
||||
|
|
|
|||
|
|
@ -16,8 +16,6 @@
|
|||
|
||||
import { HrTime } from '@opentelemetry/api';
|
||||
import { Attributes } from '@opentelemetry/api-metrics';
|
||||
import { InstrumentationLibrary } from '@opentelemetry/core';
|
||||
import { Resource } from '@opentelemetry/resources';
|
||||
import { MetricData } from '../export/MetricData';
|
||||
import { InstrumentDescriptor } from '../InstrumentDescriptor';
|
||||
import { Maybe } from '../utils';
|
||||
|
|
@ -116,9 +114,7 @@ export interface Aggregator<T> {
|
|||
* @param endTime the end time of the metric data.
|
||||
* @return the {@link MetricData} that this {@link Aggregator} will produce.
|
||||
*/
|
||||
toMetricData(resource: Resource,
|
||||
instrumentationLibrary: InstrumentationLibrary,
|
||||
instrumentDescriptor: InstrumentDescriptor,
|
||||
toMetricData(instrumentDescriptor: InstrumentDescriptor,
|
||||
accumulationByAttributes: AccumulationRecord<T>[],
|
||||
startTime: HrTime,
|
||||
endTime: HrTime): Maybe<MetricData>;
|
||||
|
|
|
|||
|
|
@ -25,22 +25,11 @@ import { Histogram } from '../aggregator/types';
|
|||
* Basic metric data fields.
|
||||
*/
|
||||
export interface BaseMetricData {
|
||||
/**
|
||||
* Resource associated with metric telemetry.
|
||||
*/
|
||||
readonly resource: Resource;
|
||||
/**
|
||||
* InstrumentationLibrary which created the metric instrument.
|
||||
*/
|
||||
readonly instrumentationLibrary: InstrumentationLibrary;
|
||||
/**
|
||||
* InstrumentDescriptor which describes the metric instrument.
|
||||
*/
|
||||
readonly instrumentDescriptor: InstrumentDescriptor;
|
||||
/**
|
||||
* PointDataType of the metric instrument.
|
||||
*/
|
||||
readonly pointDataType: PointDataType,
|
||||
readonly pointDataType: PointDataType;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -48,16 +37,16 @@ export interface BaseMetricData {
|
|||
* SumAggregation.
|
||||
*/
|
||||
export interface SingularMetricData extends BaseMetricData {
|
||||
readonly pointDataType: PointDataType.SINGULAR,
|
||||
readonly pointData: PointData<number>[],
|
||||
readonly pointDataType: PointDataType.SINGULAR;
|
||||
readonly pointData: PointData<number>[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a metric data aggregated by a HistogramAggregation.
|
||||
*/
|
||||
export interface HistogramMetricData extends BaseMetricData {
|
||||
readonly pointDataType: PointDataType.HISTOGRAM,
|
||||
readonly pointData: PointData<Histogram>[],
|
||||
readonly pointDataType: PointDataType.HISTOGRAM;
|
||||
readonly pointData: PointData<Histogram>[];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -65,6 +54,16 @@ export interface HistogramMetricData extends BaseMetricData {
|
|||
*/
|
||||
export type MetricData = SingularMetricData | HistogramMetricData;
|
||||
|
||||
export interface InstrumentationLibraryMetrics {
|
||||
instrumentationLibrary: InstrumentationLibrary;
|
||||
metrics: MetricData[];
|
||||
}
|
||||
|
||||
export interface ResourceMetrics {
|
||||
resource: Resource;
|
||||
instrumentationLibraryMetrics: InstrumentationLibraryMetrics[];
|
||||
}
|
||||
|
||||
/**
|
||||
* The aggregated point data type.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
|
||||
import { AggregationTemporality } from './AggregationTemporality';
|
||||
import { MetricData } from './MetricData';
|
||||
import { ResourceMetrics } from './MetricData';
|
||||
import {
|
||||
ExportResult,
|
||||
ExportResultCode,
|
||||
|
|
@ -26,7 +26,7 @@ import {
|
|||
|
||||
export interface PushMetricExporter {
|
||||
|
||||
export(batch: MetricData[], resultCallback: (result: ExportResult) => void): void;
|
||||
export(metrics: ResourceMetrics, resultCallback: (result: ExportResult) => void): void;
|
||||
|
||||
forceFlush(): Promise<void>;
|
||||
|
||||
|
|
@ -39,7 +39,7 @@ export interface PushMetricExporter {
|
|||
export class ConsoleMetricExporter implements PushMetricExporter {
|
||||
protected _shutdown = true;
|
||||
|
||||
export(_batch: MetricData[], resultCallback: (result: ExportResult) => void) {
|
||||
export(metrics: ResourceMetrics, resultCallback: (result: ExportResult) => void) {
|
||||
return resultCallback({
|
||||
code: ExportResultCode.FAILED,
|
||||
error: new Error('Method not implemented')
|
||||
|
|
|
|||
|
|
@ -14,11 +14,11 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { MetricData } from './MetricData';
|
||||
import { ResourceMetrics } from './MetricData';
|
||||
|
||||
/**
|
||||
* This is a public interface that represent an export state of a MetricReader.
|
||||
*/
|
||||
export interface MetricProducer {
|
||||
collect(): Promise<MetricData[]>;
|
||||
collect(): Promise<ResourceMetrics>;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,8 +17,9 @@
|
|||
import * as api from '@opentelemetry/api';
|
||||
import { AggregationTemporality } from './AggregationTemporality';
|
||||
import { MetricProducer } from './MetricProducer';
|
||||
import { MetricData } from './MetricData';
|
||||
import { callWithTimeout } from '../utils';
|
||||
import { ResourceMetrics } from './MetricData';
|
||||
import { callWithTimeout, Maybe } from '../utils';
|
||||
|
||||
|
||||
export type ReaderOptions = {
|
||||
timeoutMillis?: number
|
||||
|
|
@ -91,7 +92,7 @@ export abstract class MetricReader {
|
|||
/**
|
||||
* Collect all metrics from the associated {@link MetricProducer}
|
||||
*/
|
||||
async collect(options?: ReaderCollectionOptions): Promise<MetricData[]> {
|
||||
async collect(options?: ReaderCollectionOptions): Promise<Maybe<ResourceMetrics>> {
|
||||
if (this._metricProducer === undefined) {
|
||||
throw new Error('MetricReader is not bound to a MetricProducer');
|
||||
}
|
||||
|
|
@ -99,7 +100,7 @@ export abstract class MetricReader {
|
|||
// Subsequent invocations to collect are not allowed. SDKs SHOULD return some failure for these calls.
|
||||
if (this._shutdown) {
|
||||
api.diag.warn('Collection is not allowed after shutdown');
|
||||
return [];
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// No timeout if timeoutMillis is undefined or null.
|
||||
|
|
|
|||
|
|
@ -63,6 +63,11 @@ export class PeriodicExportingMetricReader extends MetricReader {
|
|||
|
||||
private async _runOnce(): Promise<void> {
|
||||
const metrics = await this.collect({});
|
||||
|
||||
if (metrics === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
this._exporter.export(metrics, result => {
|
||||
if (result.code !== ExportResultCode.SUCCESS) {
|
||||
|
|
|
|||
|
|
@ -24,8 +24,6 @@ import {
|
|||
} from '../InstrumentDescriptor';
|
||||
import { AttributesProcessor } from '../view/AttributesProcessor';
|
||||
import { MetricStorage } from './MetricStorage';
|
||||
import { InstrumentationLibrary } from '@opentelemetry/core';
|
||||
import { Resource } from '@opentelemetry/resources';
|
||||
import { MetricData } from '../export/MetricData';
|
||||
import { DeltaMetricProcessor } from './DeltaMetricProcessor';
|
||||
import { TemporalMetricProcessor } from './TemporalMetricProcessor';
|
||||
|
|
@ -72,8 +70,6 @@ export class AsyncMetricStorage<T extends Maybe<Accumulation>> extends MetricSto
|
|||
async collect(
|
||||
collector: MetricCollectorHandle,
|
||||
collectors: MetricCollectorHandle[],
|
||||
resource: Resource,
|
||||
instrumentationLibrary: InstrumentationLibrary,
|
||||
sdkStartTime: HrTime,
|
||||
collectionTime: HrTime,
|
||||
): Promise<Maybe<MetricData>> {
|
||||
|
|
@ -87,8 +83,6 @@ export class AsyncMetricStorage<T extends Maybe<Accumulation>> extends MetricSto
|
|||
return this._temporalMetricStorage.buildMetrics(
|
||||
collector,
|
||||
collectors,
|
||||
resource,
|
||||
instrumentationLibrary,
|
||||
this._instrumentDescriptor,
|
||||
accumulations,
|
||||
sdkStartTime,
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
import { hrTime } from '@opentelemetry/core';
|
||||
import { AggregationTemporality } from '../export/AggregationTemporality';
|
||||
import { MetricData } from '../export/MetricData';
|
||||
import { ResourceMetrics } from '../export/MetricData';
|
||||
import { MetricProducer } from '../export/MetricProducer';
|
||||
import { MetricReader } from '../export/MetricReader';
|
||||
import { MeterProviderSharedState } from './MeterProviderSharedState';
|
||||
|
|
@ -32,12 +32,15 @@ export class MetricCollector implements MetricProducer {
|
|||
this.aggregatorTemporality = this._metricReader.getPreferredAggregationTemporality();
|
||||
}
|
||||
|
||||
async collect(): Promise<MetricData[]> {
|
||||
async collect(): Promise<ResourceMetrics> {
|
||||
const collectionTime = hrTime();
|
||||
const results = await Promise.all(this._sharedState.meters
|
||||
.map(meter => meter.collect(this, collectionTime)));
|
||||
const instrumentationLibraryMetrics = (await Promise.all(this._sharedState.meters
|
||||
.map(meter => meter.collect(this, collectionTime))));
|
||||
|
||||
return results.reduce((cumulation, current) => cumulation.concat(current), []);
|
||||
return {
|
||||
resource: this._sharedState.resource,
|
||||
instrumentationLibraryMetrics,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -15,8 +15,6 @@
|
|||
*/
|
||||
|
||||
import { HrTime } from '@opentelemetry/api';
|
||||
import { InstrumentationLibrary } from '@opentelemetry/core';
|
||||
import { Resource } from '@opentelemetry/resources';
|
||||
import { MetricData } from '../export/MetricData';
|
||||
import { Maybe } from '../utils';
|
||||
import { MetricCollectorHandle } from './MetricCollector';
|
||||
|
|
@ -40,8 +38,6 @@ export abstract class MetricStorage {
|
|||
abstract collect(
|
||||
collector: MetricCollectorHandle,
|
||||
collectors: MetricCollectorHandle[],
|
||||
resource: Resource,
|
||||
instrumentationLibrary: InstrumentationLibrary,
|
||||
sdkStartTime: HrTime,
|
||||
collectionTime: HrTime,
|
||||
): Promise<Maybe<MetricData>>;
|
||||
|
|
|
|||
|
|
@ -25,8 +25,6 @@ import {
|
|||
} from '../InstrumentDescriptor';
|
||||
import { AttributesProcessor } from '../view/AttributesProcessor';
|
||||
import { MetricStorage } from './MetricStorage';
|
||||
import { InstrumentationLibrary } from '@opentelemetry/core';
|
||||
import { Resource } from '@opentelemetry/resources';
|
||||
import { MetricData } from '../export/MetricData';
|
||||
import { DeltaMetricProcessor } from './DeltaMetricProcessor';
|
||||
import { TemporalMetricProcessor } from './TemporalMetricProcessor';
|
||||
|
|
@ -66,8 +64,6 @@ export class SyncMetricStorage<T extends Maybe<Accumulation>> extends MetricStor
|
|||
async collect(
|
||||
collector: MetricCollectorHandle,
|
||||
collectors: MetricCollectorHandle[],
|
||||
resource: Resource,
|
||||
instrumentationLibrary: InstrumentationLibrary,
|
||||
sdkStartTime: HrTime,
|
||||
collectionTime: HrTime,
|
||||
): Promise<Maybe<MetricData>> {
|
||||
|
|
@ -76,8 +72,6 @@ export class SyncMetricStorage<T extends Maybe<Accumulation>> extends MetricStor
|
|||
return this._temporalMetricStorage.buildMetrics(
|
||||
collector,
|
||||
collectors,
|
||||
resource,
|
||||
instrumentationLibrary,
|
||||
this._instrumentDescriptor,
|
||||
accumulations,
|
||||
sdkStartTime,
|
||||
|
|
|
|||
|
|
@ -17,8 +17,6 @@
|
|||
import { HrTime } from '@opentelemetry/api';
|
||||
import { AccumulationRecord, Aggregator } from '../aggregator/types';
|
||||
import { MetricData } from '../export/MetricData';
|
||||
import { Resource } from '@opentelemetry/resources';
|
||||
import { InstrumentationLibrary } from '@opentelemetry/core';
|
||||
import { InstrumentDescriptor } from '../InstrumentDescriptor';
|
||||
import { AggregationTemporality } from '../export/AggregationTemporality';
|
||||
import { Maybe } from '../utils';
|
||||
|
|
@ -66,8 +64,6 @@ export class TemporalMetricProcessor<T> {
|
|||
buildMetrics(
|
||||
collector: MetricCollectorHandle,
|
||||
collectors: MetricCollectorHandle[],
|
||||
resource: Resource,
|
||||
instrumentationLibrary: InstrumentationLibrary,
|
||||
instrumentDescriptor: InstrumentDescriptor,
|
||||
currentAccumulations: AttributeHashMap<T>,
|
||||
sdkStartTime: HrTime,
|
||||
|
|
@ -111,8 +107,6 @@ export class TemporalMetricProcessor<T> {
|
|||
// 1. Cumulative Aggregation time span: (sdkStartTime, collectionTime]
|
||||
// 2. Delta Aggregation time span: (lastCollectionTime, collectionTime]
|
||||
return this._aggregator.toMetricData(
|
||||
resource,
|
||||
instrumentationLibrary,
|
||||
instrumentDescriptor,
|
||||
AttributesMapToAccumulationRecords(result),
|
||||
/* startTime */ aggregationTemporality === AggregationTemporality.CUMULATIVE ? sdkStartTime : lastCollectionTime,
|
||||
|
|
|
|||
|
|
@ -543,15 +543,23 @@ interface ValidateMetricData {
|
|||
}
|
||||
|
||||
async function validateExport(reader: MetricReader, expected: ValidateMetricData) {
|
||||
const metricData = await reader.collect();
|
||||
const metric = metricData[0];
|
||||
const resourceMetrics = await reader.collect();
|
||||
|
||||
assert.notStrictEqual(resourceMetrics, undefined);
|
||||
|
||||
const { resource, instrumentationLibraryMetrics } = resourceMetrics!;
|
||||
|
||||
const { instrumentationLibrary, metrics } = instrumentationLibraryMetrics[0];
|
||||
|
||||
assert.deepStrictEqual(resource, defaultResource);
|
||||
assert.deepStrictEqual(instrumentationLibrary, defaultInstrumentationLibrary);
|
||||
|
||||
const metric = metrics[0];
|
||||
|
||||
assertMetricData(
|
||||
metric,
|
||||
expected.pointDataType,
|
||||
expected.instrumentDescriptor ?? null,
|
||||
expected.instrumentationLibrary,
|
||||
expected.resource
|
||||
);
|
||||
|
||||
if (expected.pointData == null) {
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
import { HrTime } from '@opentelemetry/api';
|
||||
import * as assert from 'assert';
|
||||
import { DropAggregator } from '../../src/aggregator';
|
||||
import { defaultInstrumentationLibrary, defaultInstrumentDescriptor, defaultResource } from '../util';
|
||||
import { defaultInstrumentDescriptor } from '../util';
|
||||
|
||||
describe('DropAggregator', () => {
|
||||
describe('createAccumulation', () => {
|
||||
|
|
@ -54,8 +54,6 @@ describe('DropAggregator', () => {
|
|||
const endTime: HrTime = [1, 1];
|
||||
|
||||
assert.strictEqual(aggregator.toMetricData(
|
||||
defaultResource,
|
||||
defaultInstrumentationLibrary,
|
||||
defaultInstrumentDescriptor,
|
||||
[[{}, undefined]],
|
||||
startTime,
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import { HrTime } from '@opentelemetry/api';
|
|||
import * as assert from 'assert';
|
||||
import { HistogramAccumulation, HistogramAggregator } from '../../src/aggregator';
|
||||
import { MetricData, PointDataType } from '../../src/export/MetricData';
|
||||
import { commonValues, defaultInstrumentationLibrary, defaultInstrumentDescriptor, defaultResource } from '../util';
|
||||
import { commonValues, defaultInstrumentDescriptor } from '../util';
|
||||
|
||||
describe('HistogramAggregator', () => {
|
||||
describe('createAccumulation', () => {
|
||||
|
|
@ -92,8 +92,6 @@ describe('HistogramAggregator', () => {
|
|||
const endTime: HrTime = [1, 1];
|
||||
|
||||
const expected: MetricData = {
|
||||
resource: defaultResource,
|
||||
instrumentationLibrary: defaultInstrumentationLibrary,
|
||||
instrumentDescriptor: defaultInstrumentDescriptor,
|
||||
pointDataType: PointDataType.HISTOGRAM,
|
||||
pointData: [
|
||||
|
|
@ -113,8 +111,6 @@ describe('HistogramAggregator', () => {
|
|||
],
|
||||
};
|
||||
assert.deepStrictEqual(aggregator.toMetricData(
|
||||
defaultResource,
|
||||
defaultInstrumentationLibrary,
|
||||
defaultInstrumentDescriptor,
|
||||
[[{}, accumulation]],
|
||||
startTime,
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import { HrTime } from '@opentelemetry/api';
|
|||
import * as assert from 'assert';
|
||||
import { LastValueAccumulation, LastValueAggregator } from '../../src/aggregator';
|
||||
import { MetricData, PointDataType } from '../../src/export/MetricData';
|
||||
import { commonValues, defaultInstrumentationLibrary, defaultInstrumentDescriptor, defaultResource, sleep } from '../util';
|
||||
import { commonValues, defaultInstrumentDescriptor, sleep } from '../util';
|
||||
|
||||
describe('LastValueAggregator', () => {
|
||||
describe('createAccumulation', () => {
|
||||
|
|
@ -100,8 +100,6 @@ describe('LastValueAggregator', () => {
|
|||
const endTime: HrTime = [1, 1];
|
||||
|
||||
const expected: MetricData = {
|
||||
resource: defaultResource,
|
||||
instrumentationLibrary: defaultInstrumentationLibrary,
|
||||
instrumentDescriptor: defaultInstrumentDescriptor,
|
||||
pointDataType: PointDataType.SINGULAR,
|
||||
pointData: [
|
||||
|
|
@ -114,8 +112,6 @@ describe('LastValueAggregator', () => {
|
|||
],
|
||||
};
|
||||
assert.deepStrictEqual(aggregator.toMetricData(
|
||||
defaultResource,
|
||||
defaultInstrumentationLibrary,
|
||||
defaultInstrumentDescriptor,
|
||||
[[{}, accumulation]],
|
||||
startTime,
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import { HrTime } from '@opentelemetry/api';
|
|||
import * as assert from 'assert';
|
||||
import { SumAccumulation, SumAggregator } from '../../src/aggregator';
|
||||
import { MetricData, PointDataType } from '../../src/export/MetricData';
|
||||
import { commonValues, defaultInstrumentationLibrary, defaultInstrumentDescriptor, defaultResource } from '../util';
|
||||
import { commonValues, defaultInstrumentDescriptor } from '../util';
|
||||
|
||||
describe('SumAggregator', () => {
|
||||
describe('createAccumulation', () => {
|
||||
|
|
@ -78,8 +78,6 @@ describe('SumAggregator', () => {
|
|||
const endTime: HrTime = [1, 1];
|
||||
|
||||
const expected: MetricData = {
|
||||
resource: defaultResource,
|
||||
instrumentationLibrary: defaultInstrumentationLibrary,
|
||||
instrumentDescriptor: defaultInstrumentDescriptor,
|
||||
pointDataType: PointDataType.SINGULAR,
|
||||
pointData: [
|
||||
|
|
@ -92,8 +90,6 @@ describe('SumAggregator', () => {
|
|||
],
|
||||
};
|
||||
assert.deepStrictEqual(aggregator.toMetricData(
|
||||
defaultResource,
|
||||
defaultInstrumentationLibrary,
|
||||
defaultInstrumentDescriptor,
|
||||
[[{}, accumulation]],
|
||||
startTime,
|
||||
|
|
|
|||
|
|
@ -17,13 +17,14 @@
|
|||
import { PeriodicExportingMetricReader } from '../../src/export/PeriodicExportingMetricReader';
|
||||
import { AggregationTemporality } from '../../src/export/AggregationTemporality';
|
||||
import { PushMetricExporter } from '../../src';
|
||||
import { MetricData } from '../../src/export/MetricData';
|
||||
import { ResourceMetrics } from '../../src/export/MetricData';
|
||||
import * as assert from 'assert';
|
||||
import * as sinon from 'sinon';
|
||||
import { MetricProducer } from '../../src/export/MetricProducer';
|
||||
import { TimeoutError } from '../../src/utils';
|
||||
import { ExportResult, ExportResultCode } from '@opentelemetry/core';
|
||||
import { assertRejects } from '../test-utils';
|
||||
import { defaultResource } from '../util';
|
||||
|
||||
const MAX_32_BIT_INT = 2 ** 31 - 1;
|
||||
|
||||
|
|
@ -32,11 +33,11 @@ class TestMetricExporter implements PushMetricExporter {
|
|||
public forceFlushTime = 0;
|
||||
public throwException = false;
|
||||
public failureResult = false;
|
||||
private _batches: MetricData[][] = [];
|
||||
private _batches: ResourceMetrics[] = [];
|
||||
private _shutdown: boolean = false;
|
||||
|
||||
export(batch: MetricData[], resultCallback: (result: ExportResult) => void): void {
|
||||
this._batches.push(batch);
|
||||
export(metrics: ResourceMetrics, resultCallback: (result: ExportResult) => void): void {
|
||||
this._batches.push(metrics);
|
||||
|
||||
if (this.throwException) {
|
||||
throw new Error('Error during export');
|
||||
|
|
@ -65,7 +66,7 @@ class TestMetricExporter implements PushMetricExporter {
|
|||
await new Promise(resolve => setTimeout(resolve, this.forceFlushTime));
|
||||
}
|
||||
|
||||
async waitForNumberOfExports(numberOfExports: number): Promise<MetricData[][]> {
|
||||
async waitForNumberOfExports(numberOfExports: number): Promise<ResourceMetrics[]> {
|
||||
if (numberOfExports <= 0) {
|
||||
throw new Error('numberOfExports must be greater than or equal to 0');
|
||||
}
|
||||
|
|
@ -87,12 +88,14 @@ class TestDeltaMetricExporter extends TestMetricExporter {
|
|||
}
|
||||
}
|
||||
|
||||
const emptyResourceMetrics = { resource: defaultResource, instrumentationLibraryMetrics: [] };
|
||||
|
||||
class TestMetricProducer implements MetricProducer {
|
||||
public collectionTime = 0;
|
||||
|
||||
async collect(): Promise<MetricData[]> {
|
||||
async collect(): Promise<ResourceMetrics> {
|
||||
await new Promise(resolve => setTimeout(resolve, this.collectionTime));
|
||||
return [];
|
||||
return { resource: defaultResource, instrumentationLibraryMetrics: [] };
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -168,7 +171,7 @@ describe('PeriodicExportingMetricReader', () => {
|
|||
reader.setMetricProducer(new TestMetricProducer());
|
||||
const result = await exporter.waitForNumberOfExports(2);
|
||||
|
||||
assert.deepStrictEqual(result, [[], []]);
|
||||
assert.deepStrictEqual(result, [emptyResourceMetrics, emptyResourceMetrics]);
|
||||
await reader.shutdown();
|
||||
});
|
||||
});
|
||||
|
|
@ -186,7 +189,7 @@ describe('PeriodicExportingMetricReader', () => {
|
|||
reader.setMetricProducer(new TestMetricProducer());
|
||||
|
||||
const result = await exporter.waitForNumberOfExports(2);
|
||||
assert.deepStrictEqual(result, [[], []]);
|
||||
assert.deepStrictEqual(result, [emptyResourceMetrics, emptyResourceMetrics]);
|
||||
|
||||
exporter.throwException = false;
|
||||
await reader.shutdown();
|
||||
|
|
@ -204,7 +207,7 @@ describe('PeriodicExportingMetricReader', () => {
|
|||
reader.setMetricProducer(new TestMetricProducer());
|
||||
|
||||
const result = await exporter.waitForNumberOfExports(2);
|
||||
assert.deepStrictEqual(result, [[], []]);
|
||||
assert.deepStrictEqual(result, [emptyResourceMetrics, emptyResourceMetrics]);
|
||||
|
||||
exporter.failureResult = false;
|
||||
await reader.shutdown();
|
||||
|
|
@ -223,7 +226,7 @@ describe('PeriodicExportingMetricReader', () => {
|
|||
reader.setMetricProducer(new TestMetricProducer());
|
||||
|
||||
const result = await exporter.waitForNumberOfExports(2);
|
||||
assert.deepStrictEqual(result, [[], []]);
|
||||
assert.deepStrictEqual(result, [emptyResourceMetrics, emptyResourceMetrics]);
|
||||
|
||||
exporter.throwException = false;
|
||||
await reader.shutdown();
|
||||
|
|
@ -389,7 +392,7 @@ describe('PeriodicExportingMetricReader', () => {
|
|||
reader.setMetricProducer(new TestMetricProducer());
|
||||
|
||||
await reader.shutdown();
|
||||
assert.deepStrictEqual([], await reader.collect());
|
||||
assert.deepStrictEqual(await reader.collect(), undefined);
|
||||
});
|
||||
|
||||
it('should time out when timeoutMillis is set', async () => {
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import { PointDataType } from '../../src/export/MetricData';
|
|||
import { MetricCollectorHandle } from '../../src/state/MetricCollector';
|
||||
import { AsyncMetricStorage } from '../../src/state/AsyncMetricStorage';
|
||||
import { NoopAttributesProcessor } from '../../src/view/AttributesProcessor';
|
||||
import { assertMetricData, assertPointData, defaultInstrumentationLibrary, defaultInstrumentDescriptor, defaultResource } from '../util';
|
||||
import { assertMetricData, assertPointData, defaultInstrumentDescriptor } from '../util';
|
||||
import { ObservableCallback } from '@opentelemetry/api-metrics-wip';
|
||||
|
||||
const deltaCollector: MetricCollectorHandle = {
|
||||
|
|
@ -71,8 +71,6 @@ describe('AsyncMetricStorage', () => {
|
|||
const metric = await metricStorage.collect(
|
||||
deltaCollector,
|
||||
collectors,
|
||||
defaultResource,
|
||||
defaultInstrumentationLibrary,
|
||||
sdkStartTime,
|
||||
hrTime());
|
||||
|
||||
|
|
@ -89,8 +87,6 @@ describe('AsyncMetricStorage', () => {
|
|||
const metric = await metricStorage.collect(
|
||||
deltaCollector,
|
||||
collectors,
|
||||
defaultResource,
|
||||
defaultInstrumentationLibrary,
|
||||
sdkStartTime,
|
||||
hrTime());
|
||||
|
||||
|
|
@ -107,8 +103,6 @@ describe('AsyncMetricStorage', () => {
|
|||
const metric = await metricStorage.collect(
|
||||
deltaCollector,
|
||||
[deltaCollector],
|
||||
defaultResource,
|
||||
defaultInstrumentationLibrary,
|
||||
sdkStartTime,
|
||||
hrTime());
|
||||
|
||||
|
|
@ -142,8 +136,6 @@ describe('AsyncMetricStorage', () => {
|
|||
const metric = await metricStorage.collect(
|
||||
cumulativeCollector,
|
||||
collectors,
|
||||
defaultResource,
|
||||
defaultInstrumentationLibrary,
|
||||
sdkStartTime,
|
||||
hrTime());
|
||||
|
||||
|
|
@ -160,8 +152,6 @@ describe('AsyncMetricStorage', () => {
|
|||
const metric = await metricStorage.collect(
|
||||
cumulativeCollector,
|
||||
collectors,
|
||||
defaultResource,
|
||||
defaultInstrumentationLibrary,
|
||||
sdkStartTime,
|
||||
hrTime());
|
||||
|
||||
|
|
@ -181,8 +171,6 @@ describe('AsyncMetricStorage', () => {
|
|||
const metric = await metricStorage.collect(
|
||||
cumulativeCollector,
|
||||
collectors,
|
||||
defaultResource,
|
||||
defaultInstrumentationLibrary,
|
||||
sdkStartTime,
|
||||
hrTime());
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import * as assert from 'assert';
|
|||
import * as sinon from 'sinon';
|
||||
import { MeterProvider } from '../../src';
|
||||
import { AggregationTemporality } from '../../src/export/AggregationTemporality';
|
||||
import { MetricData, PointDataType } from '../../src/export/MetricData';
|
||||
import { PointDataType, ResourceMetrics } from '../../src/export/MetricData';
|
||||
import { PushMetricExporter } from '../../src/export/MetricExporter';
|
||||
import { MeterProviderSharedState } from '../../src/state/MeterProviderSharedState';
|
||||
import { MetricCollector } from '../../src/state/MetricCollector';
|
||||
|
|
@ -27,9 +27,7 @@ import { TestMetricReader } from '../export/TestMetricReader';
|
|||
import { ExportResult, ExportResultCode } from '@opentelemetry/core';
|
||||
|
||||
class TestMetricExporter implements PushMetricExporter {
|
||||
metricDataList: MetricData[] = [];
|
||||
async export(batch: MetricData[], resultCallback: (result: ExportResult) => void): Promise<void> {
|
||||
this.metricDataList.push(...batch);
|
||||
async export(metrics: ResourceMetrics, resultCallback: (result: ExportResult) => void): Promise<void> {
|
||||
resultCallback({code: ExportResultCode.SUCCESS});
|
||||
}
|
||||
|
||||
|
|
@ -96,24 +94,24 @@ describe('MetricCollector', () => {
|
|||
counter2.add(3);
|
||||
|
||||
/** collect metrics */
|
||||
const batch = await metricCollector.collect();
|
||||
assert(Array.isArray(batch));
|
||||
assert.strictEqual(batch.length, 2);
|
||||
const { instrumentationLibraryMetrics } = await metricCollector.collect();
|
||||
const { metrics } = instrumentationLibraryMetrics[0];
|
||||
assert.strictEqual(metrics.length, 2);
|
||||
|
||||
/** checking batch[0] */
|
||||
const metricData1 = batch[0];
|
||||
const metricData1 = metrics[0];
|
||||
assertMetricData(metricData1, PointDataType.SINGULAR, {
|
||||
name: 'counter1'
|
||||
}, defaultInstrumentationLibrary);
|
||||
});
|
||||
assert.strictEqual(metricData1.pointData.length, 2);
|
||||
assertPointData(metricData1.pointData[0], {}, 1);
|
||||
assertPointData(metricData1.pointData[1], { foo: 'bar' }, 2);
|
||||
|
||||
/** checking batch[1] */
|
||||
const metricData2 = batch[1];
|
||||
const metricData2 = metrics[1];
|
||||
assertMetricData(metricData2, PointDataType.SINGULAR, {
|
||||
name: 'counter2'
|
||||
}, defaultInstrumentationLibrary);
|
||||
});
|
||||
assert.strictEqual(metricData2.pointData.length, 1);
|
||||
assertPointData(metricData2.pointData[0], {}, 3);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -18,8 +18,6 @@ import { MetricStorageRegistry } from '../../src/state/MetricStorageRegistry';
|
|||
import { ValueType } from '@opentelemetry/api-metrics-wip';
|
||||
import { MetricStorage } from '../../src/state/MetricStorage';
|
||||
import { HrTime } from '@opentelemetry/api';
|
||||
import { InstrumentationLibrary } from '@opentelemetry/core';
|
||||
import { Resource } from '@opentelemetry/resources';
|
||||
import { MetricCollectorHandle } from '../../src/state/MetricCollector';
|
||||
import { MetricData, InstrumentDescriptor, InstrumentType } from '../../src';
|
||||
import { Maybe } from '../../src/utils';
|
||||
|
|
@ -35,8 +33,6 @@ import {
|
|||
class TestMetricStorage extends MetricStorage {
|
||||
collect(collector: MetricCollectorHandle,
|
||||
collectors: MetricCollectorHandle[],
|
||||
resource: Resource,
|
||||
instrumentationLibrary: InstrumentationLibrary,
|
||||
sdkStartTime: HrTime,
|
||||
collectionTime: HrTime,
|
||||
): Promise<Maybe<MetricData>> {
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import { PointDataType } from '../../src/export/MetricData';
|
|||
import { MetricCollectorHandle } from '../../src/state/MetricCollector';
|
||||
import { SyncMetricStorage } from '../../src/state/SyncMetricStorage';
|
||||
import { NoopAttributesProcessor } from '../../src/view/AttributesProcessor';
|
||||
import { assertMetricData, assertPointData, commonAttributes, commonValues, defaultInstrumentationLibrary, defaultInstrumentDescriptor, defaultResource } from '../util';
|
||||
import { assertMetricData, assertPointData, commonAttributes, commonValues, defaultInstrumentDescriptor } from '../util';
|
||||
|
||||
const deltaCollector: MetricCollectorHandle = {
|
||||
aggregatorTemporality: AggregationTemporality.DELTA,
|
||||
|
|
@ -61,8 +61,6 @@ describe('SyncMetricStorage', () => {
|
|||
const metric = await metricStorage.collect(
|
||||
deltaCollector,
|
||||
collectors,
|
||||
defaultResource,
|
||||
defaultInstrumentationLibrary,
|
||||
sdkStartTime,
|
||||
hrTime());
|
||||
|
||||
|
|
@ -76,8 +74,6 @@ describe('SyncMetricStorage', () => {
|
|||
const metric = await metricStorage.collect(
|
||||
deltaCollector,
|
||||
collectors,
|
||||
defaultResource,
|
||||
defaultInstrumentationLibrary,
|
||||
sdkStartTime,
|
||||
hrTime());
|
||||
|
||||
|
|
@ -90,8 +86,6 @@ describe('SyncMetricStorage', () => {
|
|||
const metric = await metricStorage.collect(
|
||||
deltaCollector,
|
||||
[deltaCollector],
|
||||
defaultResource,
|
||||
defaultInstrumentationLibrary,
|
||||
sdkStartTime,
|
||||
hrTime());
|
||||
|
||||
|
|
@ -113,8 +107,6 @@ describe('SyncMetricStorage', () => {
|
|||
const metric = await metricStorage.collect(
|
||||
cumulativeCollector,
|
||||
collectors,
|
||||
defaultResource,
|
||||
defaultInstrumentationLibrary,
|
||||
sdkStartTime,
|
||||
hrTime());
|
||||
|
||||
|
|
@ -128,8 +120,6 @@ describe('SyncMetricStorage', () => {
|
|||
const metric = await metricStorage.collect(
|
||||
cumulativeCollector,
|
||||
collectors,
|
||||
defaultResource,
|
||||
defaultInstrumentationLibrary,
|
||||
sdkStartTime,
|
||||
hrTime());
|
||||
|
||||
|
|
@ -143,8 +133,6 @@ describe('SyncMetricStorage', () => {
|
|||
const metric = await metricStorage.collect(
|
||||
cumulativeCollector,
|
||||
collectors,
|
||||
defaultResource,
|
||||
defaultInstrumentationLibrary,
|
||||
sdkStartTime,
|
||||
hrTime());
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import { PointDataType } from '../../src/export/MetricData';
|
|||
import { DeltaMetricProcessor } from '../../src/state/DeltaMetricProcessor';
|
||||
import { MetricCollectorHandle } from '../../src/state/MetricCollector';
|
||||
import { TemporalMetricProcessor } from '../../src/state/TemporalMetricProcessor';
|
||||
import { assertMetricData, assertPointData, defaultInstrumentationLibrary, defaultInstrumentDescriptor, defaultResource } from '../util';
|
||||
import { assertMetricData, assertPointData, defaultInstrumentDescriptor } from '../util';
|
||||
|
||||
const deltaCollector1: MetricCollectorHandle = {
|
||||
aggregatorTemporality: AggregationTemporality.DELTA,
|
||||
|
|
@ -54,8 +54,6 @@ describe('TemporalMetricProcessor', () => {
|
|||
const metric = temporalMetricStorage.buildMetrics(
|
||||
deltaCollector1,
|
||||
collectors,
|
||||
defaultResource,
|
||||
defaultInstrumentationLibrary,
|
||||
defaultInstrumentDescriptor,
|
||||
deltaMetricStorage.collect(),
|
||||
sdkStartTime,
|
||||
|
|
@ -71,8 +69,6 @@ describe('TemporalMetricProcessor', () => {
|
|||
const metric = temporalMetricStorage.buildMetrics(
|
||||
deltaCollector1,
|
||||
collectors,
|
||||
defaultResource,
|
||||
defaultInstrumentationLibrary,
|
||||
defaultInstrumentDescriptor,
|
||||
deltaMetricStorage.collect(),
|
||||
sdkStartTime,
|
||||
|
|
@ -87,8 +83,6 @@ describe('TemporalMetricProcessor', () => {
|
|||
const metric = temporalMetricStorage.buildMetrics(
|
||||
deltaCollector1,
|
||||
collectors,
|
||||
defaultResource,
|
||||
defaultInstrumentationLibrary,
|
||||
defaultInstrumentDescriptor,
|
||||
deltaMetricStorage.collect(),
|
||||
sdkStartTime,
|
||||
|
|
@ -113,8 +107,6 @@ describe('TemporalMetricProcessor', () => {
|
|||
const metric = temporalMetricStorage.buildMetrics(
|
||||
deltaCollector1,
|
||||
collectors,
|
||||
defaultResource,
|
||||
defaultInstrumentationLibrary,
|
||||
defaultInstrumentDescriptor,
|
||||
deltaMetricStorage.collect(),
|
||||
sdkStartTime,
|
||||
|
|
@ -129,8 +121,6 @@ describe('TemporalMetricProcessor', () => {
|
|||
const metric = temporalMetricStorage.buildMetrics(
|
||||
deltaCollector2,
|
||||
collectors,
|
||||
defaultResource,
|
||||
defaultInstrumentationLibrary,
|
||||
defaultInstrumentDescriptor,
|
||||
deltaMetricStorage.collect(),
|
||||
sdkStartTime,
|
||||
|
|
@ -155,8 +145,6 @@ describe('TemporalMetricProcessor', () => {
|
|||
const metric = temporalMetricStorage.buildMetrics(
|
||||
cumulativeCollector1,
|
||||
collectors,
|
||||
defaultResource,
|
||||
defaultInstrumentationLibrary,
|
||||
defaultInstrumentDescriptor,
|
||||
deltaMetricStorage.collect(),
|
||||
sdkStartTime,
|
||||
|
|
@ -172,8 +160,6 @@ describe('TemporalMetricProcessor', () => {
|
|||
const metric = temporalMetricStorage.buildMetrics(
|
||||
cumulativeCollector1,
|
||||
collectors,
|
||||
defaultResource,
|
||||
defaultInstrumentationLibrary,
|
||||
defaultInstrumentDescriptor,
|
||||
deltaMetricStorage.collect(),
|
||||
sdkStartTime,
|
||||
|
|
@ -198,8 +184,6 @@ describe('TemporalMetricProcessor', () => {
|
|||
const metric = temporalMetricStorage.buildMetrics(
|
||||
cumulativeCollector1,
|
||||
collectors,
|
||||
defaultResource,
|
||||
defaultInstrumentationLibrary,
|
||||
defaultInstrumentDescriptor,
|
||||
deltaMetricStorage.collect(),
|
||||
sdkStartTime,
|
||||
|
|
@ -215,8 +199,6 @@ describe('TemporalMetricProcessor', () => {
|
|||
const metric = temporalMetricStorage.buildMetrics(
|
||||
deltaCollector1,
|
||||
collectors,
|
||||
defaultResource,
|
||||
defaultInstrumentationLibrary,
|
||||
defaultInstrumentDescriptor,
|
||||
deltaMetricStorage.collect(),
|
||||
sdkStartTime,
|
||||
|
|
@ -230,8 +212,6 @@ describe('TemporalMetricProcessor', () => {
|
|||
const metric = temporalMetricStorage.buildMetrics(
|
||||
cumulativeCollector1,
|
||||
collectors,
|
||||
defaultResource,
|
||||
defaultInstrumentationLibrary,
|
||||
defaultInstrumentDescriptor,
|
||||
deltaMetricStorage.collect(),
|
||||
sdkStartTime,
|
||||
|
|
|
|||
|
|
@ -57,19 +57,11 @@ export function assertMetricData(
|
|||
actual: unknown,
|
||||
pointDataType?: PointDataType,
|
||||
instrumentDescriptor: Partial<InstrumentDescriptor> | null = defaultInstrumentDescriptor,
|
||||
instrumentationLibrary: Partial<InstrumentationLibrary> | null = defaultInstrumentationLibrary,
|
||||
resource: Resource | null = defaultResource,
|
||||
): asserts actual is MetricData {
|
||||
const it = actual as MetricData;
|
||||
if (resource != null) {
|
||||
assert.deepStrictEqual(it.resource, resource);
|
||||
}
|
||||
if (instrumentDescriptor != null) {
|
||||
assertPartialDeepStrictEqual(it.instrumentDescriptor, instrumentDescriptor);
|
||||
}
|
||||
if (instrumentationLibrary != null) {
|
||||
assertPartialDeepStrictEqual(it.instrumentationLibrary, instrumentationLibrary);
|
||||
}
|
||||
if (isNotNullish(pointDataType)) {
|
||||
assert.strictEqual(it.pointDataType, pointDataType);
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in New Issue