Skip to content

Commit a159d76

Browse files
Kai NawrothTimothy Mothra
andauthored
Update articles/azure-monitor/app/sampling.md
Co-authored-by: Timothy Mothra <[email protected]>
1 parent 9fb0614 commit a159d76

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

articles/azure-monitor/app/sampling.md

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -222,21 +222,32 @@ Use extension methods of `TelemetryProcessorChainBuilder` as shown below to cust
222222
### [ASP.NET Core 6 and later](#tab/net-core-new)
223223

224224
```csharp
225-
using Microsoft.ApplicationInsights.Extensibility
225+
using Microsoft.ApplicationInsights.AspNetCore.Extensions;
226+
using Microsoft.ApplicationInsights.Extensibility;
226227

227228
var builder = WebApplication.CreateBuilder(args);
228229

229-
// Using adaptive sampling
230-
configuration.DefaultTelemetrySink.TelemetryProcessorChainBuilder.UseAdaptiveSampling(maxTelemetryItemsPerSecond:5);
230+
builder.Services.Configure<TelemetryConfiguration>(telemetryConfiguration =>
231+
{
232+
var builder = telemetryConfiguration.DefaultTelemetrySink.TelemetryProcessorChainBuilder;
231233

232-
// Alternately, the following configures adaptive sampling with 5 items per second, and also excludes DependencyTelemetry from being subject to sampling:
233-
// configuration.DefaultTelemetrySink.TelemetryProcessorChainBuilder.UseAdaptiveSampling(maxTelemetryItemsPerSecond:5, excludedTypes: "Dependency");
234+
// Using adaptive sampling
235+
builder.UseAdaptiveSampling(maxTelemetryItemsPerSecond: 5);
234236

235-
// If you have other telemetry processors:
236-
Use((next) => new AnotherProcessor(next));
237+
// Alternately, the following configures adaptive sampling with 5 items per second, and also excludes DependencyTelemetry from being subject to sampling:
238+
// configuration.DefaultTelemetrySink.TelemetryProcessorChainBuilder.UseAdaptiveSampling(maxTelemetryItemsPerSecond:5, excludedTypes: "Dependency");
239+
240+
// If you have other telemetry processors:
241+
builder.Use(next => new AnotherProcessor(next));
242+
243+
});
244+
245+
builder.Services.AddApplicationInsightsTelemetry(new ApplicationInsightsServiceOptions
246+
{
247+
EnableAdaptiveSampling = false,
248+
});
237249

238250
var app = builder.Build();
239-
```
240251

241252
### [ASP.NET Core 5 and earlier](#tab/net-core-old)
242253

0 commit comments

Comments
 (0)