@@ -225,6 +225,7 @@ public void DependencyInjectionConfiguration_ConfiguresSampling()
225
225
o . SamplingSettings = samplingSettings ;
226
226
o . SamplingExcludedTypes = samplingExcludedTypes ;
227
227
o . SamplingIncludedTypes = samplingIncludedTypes ;
228
+ o . EnableAdaptiveSamplingDelay = false ;
228
229
} ) ;
229
230
} )
230
231
. Build ( ) )
@@ -242,7 +243,43 @@ public void DependencyInjectionConfiguration_ConfiguresSampling()
242
243
}
243
244
}
244
245
245
-
246
+ [ Fact ]
247
+ public void DependencyInjectionConfiguration_ConfiguresDelayedSampling ( )
248
+ {
249
+ var samplingSettings = new SamplingPercentageEstimatorSettings { MaxTelemetryItemsPerSecond = 1 } ;
250
+ var samplingExcludedTypes = "PageView;Request" ;
251
+ var samplingIncludedTypes = "Trace" ;
252
+ using ( var host = new HostBuilder ( )
253
+ . ConfigureLogging ( b =>
254
+ {
255
+ b . AddApplicationInsightsWebJobs ( o =>
256
+ {
257
+ o . InstrumentationKey = "some key" ;
258
+ o . SamplingSettings = samplingSettings ;
259
+ o . SamplingExcludedTypes = samplingExcludedTypes ;
260
+ o . SamplingIncludedTypes = samplingIncludedTypes ;
261
+ } ) ;
262
+ } )
263
+ . Build ( ) )
264
+ {
265
+ var config = host . Services . GetService < TelemetryConfiguration > ( ) ;
266
+ Assert . Equal ( 5 , config . TelemetryProcessors . Count ) ;
267
+ Assert . IsType < OperationFilteringTelemetryProcessor > ( config . TelemetryProcessors [ 0 ] ) ;
268
+ Assert . IsType < QuickPulseTelemetryProcessor > ( config . TelemetryProcessors [ 1 ] ) ;
269
+ Assert . IsType < FilteringTelemetryProcessor > ( config . TelemetryProcessors [ 2 ] ) ;
270
+ Assert . IsType < DelayedSamplingProcessor > ( config . TelemetryProcessors [ 3 ] ) ;
271
+
272
+ // Use reflection to access the private field "_samplingProcessor"
273
+ var samplingProcessorField = typeof ( DelayedSamplingProcessor )
274
+ . GetField ( "_samplingProcessor" , BindingFlags . NonPublic | BindingFlags . Instance ) ;
275
+ var samplingProcessorInstance = ( AdaptiveSamplingTelemetryProcessor ) samplingProcessorField . GetValue ( config . TelemetryProcessors [ 3 ] ) ;
276
+
277
+ Assert . Equal ( samplingSettings . MaxTelemetryItemsPerSecond , samplingProcessorInstance . MaxTelemetryItemsPerSecond ) ;
278
+ Assert . Equal ( samplingExcludedTypes , samplingProcessorInstance . ExcludedTypes ) ;
279
+ Assert . Equal ( samplingIncludedTypes , samplingProcessorInstance . IncludedTypes ) ;
280
+ }
281
+ }
282
+
246
283
[ Fact ]
247
284
public void DependencyInjectionConfiguration_EnableLiveMetricsFilters ( )
248
285
{
@@ -589,6 +626,7 @@ public void DependencyInjectionConfiguration_NoFilterConfiguresSampling()
589
626
{
590
627
o . InstrumentationKey = "some key" ;
591
628
o . SamplingSettings = samplingSettings ;
629
+ o . EnableAdaptiveSamplingDelay = false ;
592
630
} ) ;
593
631
} ) . Build ( ) )
594
632
{
0 commit comments