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
refactor: rename preferredAggregationTemporality to temporalityPrefer…
…ence
  • Loading branch information
seemk committed Apr 26, 2022
commit eff2b39e5c8a4e5fb70d58044f1670077644665a
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ const testOTLPMetricExporter = (params: TestParams) =>
url: 'grpcs://' + address,
credentials,
metadata: params.metadata,
preferredAggregationTemporality: AggregationTemporality.CUMULATIVE
temporalityPreference: AggregationTemporality.CUMULATIVE
});

setUp();
Expand Down Expand Up @@ -182,15 +182,15 @@ const testOTLPMetricExporter = (params: TestParams) =>
headers: {
foo: 'bar',
},
preferredAggregationTemporality: AggregationTemporality.CUMULATIVE
temporalityPreference: AggregationTemporality.CUMULATIVE
});
const args = warnStub.args[0];
assert.strictEqual(args[0], 'Headers cannot be set when using grpc');
});
it('should warn about path in url', () => {
collectorExporter = new OTLPMetricExporter({
url: `http://${address}/v1/metrics`,
preferredAggregationTemporality: AggregationTemporality.CUMULATIVE
temporalityPreference: AggregationTemporality.CUMULATIVE
});
const args = warnStub.args[0];
assert.strictEqual(
Expand Down Expand Up @@ -264,7 +264,7 @@ describe('OTLPMetricExporter - node (getDefaultUrl)', () => {
const url = 'http://foo.bar.com';
const collectorExporter = new OTLPMetricExporter({
url,
preferredAggregationTemporality: AggregationTemporality.CUMULATIVE
temporalityPreference: AggregationTemporality.CUMULATIVE
});
setTimeout(() => {
assert.strictEqual(collectorExporter._otlpExporter.url, 'foo.bar.com');
Expand Down Expand Up @@ -309,7 +309,7 @@ describe('when configuring via environment', () => {
envSource.OTEL_EXPORTER_OTLP_METRICS_HEADERS = 'foo=boo';
const collectorExporter = new OTLPMetricExporter({
metadata,
preferredAggregationTemporality: AggregationTemporality.CUMULATIVE
temporalityPreference: AggregationTemporality.CUMULATIVE
});
assert.deepStrictEqual(collectorExporter._otlpExporter.metadata?.get('foo'), ['boo']);
assert.deepStrictEqual(collectorExporter._otlpExporter.metadata?.get('bar'), ['foo']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ export const DeltaTemporalitySelector: AggregationTemporalitySelector = (instrum
}
};

function chooseTemporalitySelector(preferredAggregationTemporality?: AggregationTemporality): AggregationTemporalitySelector {
if (preferredAggregationTemporality === AggregationTemporality.DELTA) {
function chooseTemporalitySelector(temporalityPreference?: AggregationTemporality): AggregationTemporalitySelector {
if (temporalityPreference === AggregationTemporality.DELTA) {
return DeltaTemporalitySelector;
}

Expand All @@ -59,7 +59,7 @@ implements PushMetricExporter {
constructor(exporter: T,
config: OTLPMetricExporterOptions = defaultOptions) {
this._otlpExporter = exporter;
this._aggregationTemporalitySelector = chooseTemporalitySelector(config.preferredAggregationTemporality);
this._aggregationTemporalitySelector = chooseTemporalitySelector(config.temporalityPreference);
}

export(metrics: ResourceMetrics, resultCallback: (result: ExportResult) => void): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { AggregationTemporality } from '@opentelemetry/sdk-metrics-base';
import { OTLPExporterConfigBase } from '@opentelemetry/otlp-exporter-base';

export interface OTLPMetricExporterOptions extends OTLPExporterConfigBase {
preferredAggregationTemporality?: AggregationTemporality
temporalityPreference?: AggregationTemporality
}
export const defaultExporterTemporality = AggregationTemporality.CUMULATIVE;
export const defaultOptions = {preferredAggregationTemporality: defaultExporterTemporality};
export const defaultOptions = {temporalityPreference: defaultExporterTemporality};
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ describe('OTLPMetricExporter - web', () => {
beforeEach(() => {
collectorExporter = new OTLPMetricExporter({
url: 'http://foo.bar.com',
preferredAggregationTemporality: AggregationTemporality.CUMULATIVE
temporalityPreference: AggregationTemporality.CUMULATIVE
});
});
it('should successfully send metrics using sendBeacon', done => {
Expand Down Expand Up @@ -202,7 +202,7 @@ describe('OTLPMetricExporter - web', () => {
(window.navigator as any).sendBeacon = false;
collectorExporter = new OTLPMetricExporter({
url: 'http://foo.bar.com',
preferredAggregationTemporality: AggregationTemporality.CUMULATIVE
temporalityPreference: AggregationTemporality.CUMULATIVE
});
// Overwrites the start time to make tests consistent
Object.defineProperty(collectorExporter, '_startTime', {
Expand Down Expand Up @@ -338,7 +338,7 @@ describe('OTLPMetricExporter - web', () => {
beforeEach(() => {
collectorExporterConfig = {
headers: customHeaders,
preferredAggregationTemporality: AggregationTemporality.CUMULATIVE
temporalityPreference: AggregationTemporality.CUMULATIVE
};
server = sinon.fakeServer.create();
});
Expand Down Expand Up @@ -430,7 +430,7 @@ describe('when configuring via environment', () => {
envSource.OTEL_EXPORTER_OTLP_HEADERS = 'foo=bar';
const collectorExporter = new OTLPMetricExporter({
headers: {},
preferredAggregationTemporality: AggregationTemporality.CUMULATIVE
temporalityPreference: AggregationTemporality.CUMULATIVE
});
assert.strictEqual(collectorExporter['_otlpExporter']['_headers'].foo, 'bar');
envSource.OTEL_EXPORTER_OTLP_HEADERS = '';
Expand All @@ -440,7 +440,7 @@ describe('when configuring via environment', () => {
envSource.OTEL_EXPORTER_OTLP_METRICS_HEADERS = 'foo=boo';
const collectorExporter = new OTLPMetricExporter({
headers: {},
preferredAggregationTemporality: AggregationTemporality.CUMULATIVE
temporalityPreference: AggregationTemporality.CUMULATIVE
});
assert.strictEqual(collectorExporter['_otlpExporter']['_headers'].foo, 'boo');
assert.strictEqual(collectorExporter['_otlpExporter']['_headers'].bar, 'foo');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ describe('OTLPMetricExporter - node with json over http', () => {
url: 'http://foo.bar.com',
keepAlive: true,
httpAgentOptions: { keepAliveMsecs: 2000 },
preferredAggregationTemporality: AggregationTemporality.CUMULATIVE
temporalityPreference: AggregationTemporality.CUMULATIVE
};

collectorExporter = new OTLPMetricExporter(collectorExporterConfig);
Expand Down Expand Up @@ -334,7 +334,7 @@ describe('OTLPMetricExporter - node with json over http', () => {
const url = 'http://foo.bar.com';
const collectorExporter = new OTLPMetricExporter({
url,
preferredAggregationTemporality: AggregationTemporality.CUMULATIVE
temporalityPreference: AggregationTemporality.CUMULATIVE
});
setTimeout(() => {
assert.strictEqual(collectorExporter._otlpExporter.url, url);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ describe('OTLPMetricExporter - node with proto over http', () => {
url: 'http://foo.bar.com',
keepAlive: true,
httpAgentOptions: { keepAliveMsecs: 2000 },
preferredAggregationTemporality: AggregationTemporality.CUMULATIVE
temporalityPreference: AggregationTemporality.CUMULATIVE
};
collectorExporter = new OTLPMetricExporter(collectorExporterConfig);
setUp();
Expand Down