File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ import { InstrumentationOptions } from '../types';
1111import { OTLPMetricExporter as OTLPProtoMetricExporter } from "@opentelemetry/exporter-metrics-otlp-proto" ;
1212import { OTLPMetricExporter as OTLPHttpMetricExporter } from "@opentelemetry/exporter-metrics-otlp-http" ;
1313import { 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
1616export 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 [ ] = [ ] ;
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ export const AZURE_APP_NAME = process.env.WEBSITE_SITE_NAME || 'unknown';
55export const AZURE_MONITOR_AUTO_ATTACH = "AZURE_MONITOR_AUTO_ATTACH" ;
66
77export 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
910export interface IAgentLogger {
1011 log ( message : any , ...optional : any [ ] ) : void ;
Original file line number Diff line number Diff 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" ,
You can’t perform that action at this time.
0 commit comments