Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Disable telemetry adaptive sampling #6849

Merged
merged 2 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -5,6 +5,7 @@
using System;
using System.Linq;
using Microsoft.ApplicationInsights;
using Microsoft.ApplicationInsights.AspNetCore.Extensions;
using Microsoft.ApplicationInsights.Extensibility;
using Microsoft.Bot.Builder.ApplicationInsights;
using Microsoft.Bot.Configuration;
Expand Down Expand Up @@ -57,7 +58,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 ApplicationInsightsServiceOptions
{
EnableAdaptiveSampling = false,
InstrumentationKey = appInsightService.InstrumentationKey
};

services.AddApplicationInsightsTelemetry(aiOptions);
telemetryClient = new BotTelemetryClient(new TelemetryClient());
}
else
Expand Down Expand Up @@ -88,9 +96,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 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 +140,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 ApplicationInsightsServiceOptions
{
EnableAdaptiveSampling = false,
InstrumentationKey = instrumentationKey
};

services.AddApplicationInsightsTelemetry(aiOptions);
}

// Register the BotTelemetryClient
Expand Down
Loading