Skip to content

Commit

Permalink
disable adaptive sampling
Browse files Browse the repository at this point in the history
  • Loading branch information
JhontSouth committed Sep 11, 2024
1 parent c7ab0d3 commit e83258a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ internal static void AddBotRuntimeTelemetry(this IServiceCollection services, IC
}
else
{
telemetrySettings.Options.EnableAdaptiveSampling = false;
services.AddApplicationInsightsTelemetry(telemetrySettings.Options);
services.TryAddSingleton<IBotTelemetryClient, BotTelemetryClient>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,14 @@ public static IServiceCollection AddBotApplicationInsights(this IServiceCollecti
IBotTelemetryClient telemetryClient = null;
if (appInsightService != null)
{
services.AddApplicationInsightsTelemetry(appInsightService.InstrumentationKey);
// Create Application Insights options and disable adaptive sampling
var aiOptions = new Microsoft.ApplicationInsights.AspNetCore.Extensions.ApplicationInsightsServiceOptions
{
EnableAdaptiveSampling = false,
InstrumentationKey = appInsightService.InstrumentationKey
};

services.AddApplicationInsightsTelemetry(aiOptions);
telemetryClient = new BotTelemetryClient(new TelemetryClient());
}
else
Expand Down Expand Up @@ -88,9 +95,19 @@ public static IServiceCollection AddBotApplicationInsights(this IServiceCollecti
CreateBotTelemetry(services);

IBotTelemetryClient telemetryClient = null;

if (!string.IsNullOrWhiteSpace(instrumentationKey))
{
services.AddApplicationInsightsTelemetry(instrumentationKey);
// Create Application Insights options and disable adaptive sampling
var aiOptions = new Microsoft.ApplicationInsights.AspNetCore.Extensions.ApplicationInsightsServiceOptions
{
EnableAdaptiveSampling = false,
InstrumentationKey = instrumentationKey
};

// Add Application Insights telemetry with custom options
services.AddApplicationInsightsTelemetry(aiOptions);

telemetryClient = new BotTelemetryClient(new TelemetryClient());
}
else
Expand Down Expand Up @@ -122,7 +139,14 @@ public static IServiceCollection AddBotApplicationInsights(this IServiceCollecti
// Start Application Insights
if (instrumentationKey != null)
{
services.AddApplicationInsightsTelemetry(instrumentationKey);
// Create Application Insights options and disable adaptive sampling
var aiOptions = new Microsoft.ApplicationInsights.AspNetCore.Extensions.ApplicationInsightsServiceOptions
{
EnableAdaptiveSampling = false,
InstrumentationKey = instrumentationKey
};

services.AddApplicationInsightsTelemetry(aiOptions);
}

// Register the BotTelemetryClient
Expand Down

0 comments on commit e83258a

Please sign in to comment.