Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: metric aggregation temporality controls #2902

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge remote-tracking branch 'upstream/main' into instrument-aggregat…
…ion-temporality
  • Loading branch information
seemk committed Apr 26, 2022
commit 8b0551edb08fe660c96ee2c817bf51677487d1d7
Original file line number Diff line number Diff line change
Expand Up @@ -54,28 +54,26 @@ describe('transformMetrics', () => {
counter.add(1);
const metrics = (await collect());

const metric = metrics.instrumentationLibraryMetrics[0].metrics[0];
ensureCounterIsCorrect(
transform.toCollectorMetric(metric),
hrTimeToNanoseconds(metric.dataPoints[0].endTime),
hrTimeToNanoseconds(metric.dataPoints[0].startTime)
);
}
);
const metric = metrics.instrumentationLibraryMetrics[0].metrics[0];
ensureCounterIsCorrect(
transform.toCollectorMetric(metric),
hrTimeToNanoseconds(metric.dataPoints[0].endTime),
hrTimeToNanoseconds(metric.dataPoints[0].startTime)
);
});

it('should convert double counter', async () => {
const doubleCounter = mockDoubleCounter();
doubleCounter.add(8);
const metrics = (await collect());

const metric = metrics.instrumentationLibraryMetrics[0].metrics[0];
ensureDoubleCounterIsCorrect(
transform.toCollectorMetric(metric),
hrTimeToNanoseconds(metric.dataPoints[0].endTime),
hrTimeToNanoseconds(metric.dataPoints[0].startTime),
);
}
);
const metric = metrics.instrumentationLibraryMetrics[0].metrics[0];
ensureDoubleCounterIsCorrect(
transform.toCollectorMetric(metric),
hrTimeToNanoseconds(metric.dataPoints[0].endTime),
hrTimeToNanoseconds(metric.dataPoints[0].startTime),
);
});

it('should convert observable gauge', async () => {
let count = 0;
Expand All @@ -89,16 +87,14 @@ describe('transformMetrics', () => {
await collect();
const metrics = (await collect());

const metric = metrics.instrumentationLibraryMetrics[0].metrics[0];
ensureObservableGaugeIsCorrect(
transform.toCollectorMetric(metric),
hrTimeToNanoseconds(metric.dataPoints[0].endTime),
hrTimeToNanoseconds(metric.dataPoints[0].startTime),
-1,
);
}
);

const metric = metrics.instrumentationLibraryMetrics[0].metrics[0];
ensureObservableGaugeIsCorrect(
transform.toCollectorMetric(metric),
hrTimeToNanoseconds(metric.dataPoints[0].endTime),
hrTimeToNanoseconds(metric.dataPoints[0].startTime),
-1,
);
});

it('should convert observable counter', async () => {
mockObservableCounter(observableResult => {
Expand All @@ -111,15 +107,14 @@ describe('transformMetrics', () => {
const metrics = (await collect());
// TODO: Collect seems to not deliver the last observation -> why?

const metric = metrics.instrumentationLibraryMetrics[0].metrics[0];
ensureObservableCounterIsCorrect(
transform.toCollectorMetric(metric),
hrTimeToNanoseconds(metric.dataPoints[0].endTime),
hrTimeToNanoseconds(metric.dataPoints[0].startTime),
2,
);
}
);
const metric = metrics.instrumentationLibraryMetrics[0].metrics[0];
ensureObservableCounterIsCorrect(
transform.toCollectorMetric(metric),
hrTimeToNanoseconds(metric.dataPoints[0].endTime),
hrTimeToNanoseconds(metric.dataPoints[0].startTime),
2,
);
});

it('should convert observable up-down counter', async () => {
mockObservableUpDownCounter(observableResult => {
Expand All @@ -132,15 +127,14 @@ describe('transformMetrics', () => {
const metrics = (await collect());
// TODO: Collect seems to not deliver the last observation -> why?

const metric = metrics.instrumentationLibraryMetrics[0].metrics[0];
ensureObservableUpDownCounterIsCorrect(
transform.toCollectorMetric(metric),
hrTimeToNanoseconds(metric.dataPoints[0].endTime),
hrTimeToNanoseconds(metric.dataPoints[0].startTime),
2,
);
}
);
const metric = metrics.instrumentationLibraryMetrics[0].metrics[0];
ensureObservableUpDownCounterIsCorrect(
transform.toCollectorMetric(metric),
hrTimeToNanoseconds(metric.dataPoints[0].endTime),
hrTimeToNanoseconds(metric.dataPoints[0].startTime),
2,
);
});

it('should convert observable histogram', async () => {
const histogram = mockHistogram();
Expand All @@ -149,16 +143,15 @@ describe('transformMetrics', () => {

const metrics = (await collect());

const metric = metrics.instrumentationLibraryMetrics[0].metrics[0];
ensureHistogramIsCorrect(
transform.toCollectorMetric(metric),
hrTimeToNanoseconds(metric.dataPoints[0].endTime),
hrTimeToNanoseconds(metric.dataPoints[0].startTime),
[0, 100],
[0, 2, 0]
);
}
);
const metric = metrics.instrumentationLibraryMetrics[0].metrics[0];
ensureHistogramIsCorrect(
transform.toCollectorMetric(metric),
hrTimeToNanoseconds(metric.dataPoints[0].endTime),
hrTimeToNanoseconds(metric.dataPoints[0].startTime),
[0, 100],
[0, 2, 0]
);
});

it('should convert metric attributes value to string', () => {
const metric = transform.toCollectorMetric(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,10 @@ describe('PeriodicExportingMetricReader', () => {
it('should construct PeriodicExportingMetricReader without exceptions', () => {
const exporter = new TestDeltaMetricExporter();
assert.doesNotThrow(() => new PeriodicExportingMetricReader({
exporter,
exportIntervalMillis: 4000,
exportTimeoutMillis: 3000
}
));
exporter,
exportIntervalMillis: 4000,
exportTimeoutMillis: 3000
}));
});

it('should throw when interval less or equal to 0', () => {
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.