Skip to content

Commit 5e8ee08

Browse files
authored
Set temporality to delta. (#1488)
1 parent 3fbe1fd commit 5e8ee08

3 files changed

Lines changed: 20 additions & 1 deletion

File tree

src/agent/aksLoader.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { InstrumentationOptions } from '../types';
1111
import { OTLPMetricExporter as OTLPProtoMetricExporter } from "@opentelemetry/exporter-metrics-otlp-proto";
1212
import { OTLPMetricExporter as OTLPHttpMetricExporter } from "@opentelemetry/exporter-metrics-otlp-http";
1313
import { MetricReader, PeriodicExportingMetricReader } from "@opentelemetry/sdk-metrics";
14-
import { OTLP_METRIC_EXPORTER_EXPORT_INTERVAL } from './types';
14+
import { ENV_OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE, OTLP_METRIC_EXPORTER_EXPORT_INTERVAL } from './types';
1515

1616
export class AKSLoader extends AgentLoader {
1717

@@ -55,6 +55,9 @@ export class AKSLoader extends AgentLoader {
5555
)
5656
);
5757

58+
// Ensure Delta temporality is used for OTLP metrics
59+
process.env[ENV_OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE] = "Delta";
60+
5861
// Create metricReaders array and add OTLP reader if environment variables request it
5962
try {
6063
const metricReaders: MetricReader[] = [];

src/agent/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export const AZURE_APP_NAME = process.env.WEBSITE_SITE_NAME || 'unknown';
55
export const AZURE_MONITOR_AUTO_ATTACH = "AZURE_MONITOR_AUTO_ATTACH";
66

77
export const OTLP_METRIC_EXPORTER_EXPORT_INTERVAL = 60000; // in ms
8+
export const ENV_OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE = "OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE";
89

910
export interface IAgentLogger {
1011
log(message: any, ...optional: any[]): void;

test/unitTests/agent/aksLoader.tests.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,21 @@ describe("agent/AKSLoader", () => {
355355
assert.equal(exporter.constructor.name, "OTLPMetricExporter", "Should be an OTLPMetricExporter");
356356
});
357357

358+
it("constructor sets OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE to Delta", () => {
359+
const env = {
360+
["APPLICATIONINSIGHTS_CONNECTION_STRING"]: "InstrumentationKey=1aa11111-bbbb-1ccc-8ddd-eeeeffff3333",
361+
};
362+
process.env = env;
363+
364+
new AKSLoader();
365+
366+
assert.equal(
367+
process.env["OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE"],
368+
"Delta",
369+
"OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE should be set to Delta"
370+
);
371+
});
372+
358373
it("constructor creates OTLP metric reader when OTEL_METRICS_EXPORTER contains mixed case otlp with other exporters", () => {
359374
const env = {
360375
["APPLICATIONINSIGHTS_CONNECTION_STRING"]: "InstrumentationKey=1aa11111-bbbb-1ccc-8ddd-eeeeffff3333",

0 commit comments

Comments
 (0)