@@ -183,4 +183,33 @@ describe("agent/AKSLoader", () => {
183183 ) ;
184184 assert . equal ( azureMonitorExporters . length , 1 , "Should have exactly one Azure Monitor metric exporter" ) ;
185185 } ) ;
186+
187+ it ( "constructor creates OTLP protobuf exporter when OTEL_EXPORTER_OTLP_METRICS_PROTOCOL is set to http/protobuf" , ( ) => {
188+ const env = {
189+ [ "APPLICATIONINSIGHTS_CONNECTION_STRING" ] : "InstrumentationKey=1aa11111-bbbb-1ccc-8ddd-eeeeffff3333" ,
190+ [ "OTEL_METRICS_EXPORTER" ] : "otlp" ,
191+ [ "OTEL_EXPORTER_OTLP_ENDPOINT" ] : "http://localhost:4317" ,
192+ [ "OTEL_EXPORTER_OTLP_METRICS_PROTOCOL" ] : "http/protobuf"
193+ } ;
194+ process . env = env ;
195+
196+ const agent = new AKSLoader ( ) ;
197+
198+ // Verify that metricReaders were added to the options
199+ const options = ( agent as any ) . _options ;
200+ assert . ok ( options . metricReaders , "metricReaders should be present in options" ) ;
201+ assert . equal ( options . metricReaders . length , 1 , "Should have exactly one metric reader" ) ;
202+
203+ // Verify the metric reader is a PeriodicExportingMetricReader
204+ const metricReader = options . metricReaders [ 0 ] ;
205+ assert . equal ( metricReader . constructor . name , "PeriodicExportingMetricReader" , "Should be a PeriodicExportingMetricReader" ) ;
206+
207+ // Verify the exporter is an OTLP protobuf exporter
208+ const exporter = ( metricReader as any ) . _exporter ;
209+ assert . equal ( exporter . constructor . name , "OTLPMetricExporter" , "Should be an OTLPMetricExporter" ) ;
210+
211+ // Verify that it's the protobuf version by checking if it was imported from the proto package
212+ // The protobuf exporter should have different internal structure than the HTTP exporter
213+ assert . ok ( exporter , "Protobuf exporter should exist" ) ;
214+ } ) ;
186215} ) ;
0 commit comments