Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 4 additions & 1 deletion src/agent/aksLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { InstrumentationOptions } from '../types';
import { OTLPMetricExporter as OTLPProtoMetricExporter } from "@opentelemetry/exporter-metrics-otlp-proto";
import { OTLPMetricExporter as OTLPHttpMetricExporter } from "@opentelemetry/exporter-metrics-otlp-http";
import { MetricReader, PeriodicExportingMetricReader } from "@opentelemetry/sdk-metrics";
import { OTLP_METRIC_EXPORTER_EXPORT_INTERVAL } from './types';
import { ENV_OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE, OTLP_METRIC_EXPORTER_EXPORT_INTERVAL } from './types';

export class AKSLoader extends AgentLoader {

Expand Down Expand Up @@ -55,6 +55,9 @@ export class AKSLoader extends AgentLoader {
)
);

// Ensure Delta temporality is used for OTLP metrics
process.env[ENV_OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE] = "Delta";

// Create metricReaders array and add OTLP reader if environment variables request it
try {
const metricReaders: MetricReader[] = [];
Expand Down
1 change: 1 addition & 0 deletions src/agent/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export const AZURE_APP_NAME = process.env.WEBSITE_SITE_NAME || 'unknown';
export const AZURE_MONITOR_AUTO_ATTACH = "AZURE_MONITOR_AUTO_ATTACH";

export const OTLP_METRIC_EXPORTER_EXPORT_INTERVAL = 60000; // in ms
export const ENV_OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE = "OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE";

export interface IAgentLogger {
log(message: any, ...optional: any[]): void;
Expand Down
15 changes: 15 additions & 0 deletions test/unitTests/agent/aksLoader.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,21 @@ describe("agent/AKSLoader", () => {
assert.equal(exporter.constructor.name, "OTLPMetricExporter", "Should be an OTLPMetricExporter");
});

it("constructor sets OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE to Delta", () => {
const env = {
["APPLICATIONINSIGHTS_CONNECTION_STRING"]: "InstrumentationKey=1aa11111-bbbb-1ccc-8ddd-eeeeffff3333",
};
process.env = env;

new AKSLoader();

assert.equal(
process.env["OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE"],
"Delta",
"OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE should be set to Delta"
);
});

it("constructor creates OTLP metric reader when OTEL_METRICS_EXPORTER contains mixed case otlp with other exporters", () => {
const env = {
["APPLICATIONINSIGHTS_CONNECTION_STRING"]: "InstrumentationKey=1aa11111-bbbb-1ccc-8ddd-eeeeffff3333",
Expand Down
Loading