Skip to content

Add comprehensive applicationinsights.config support#3069

Merged
rajkumar-rangaraj merged 3 commits intomainfrom
rajrang/classicaspnetconfig
Jan 7, 2026
Merged

Add comprehensive applicationinsights.config support#3069
rajkumar-rangaraj merged 3 commits intomainfrom
rajrang/classicaspnetconfig

Conversation

@rajkumar-rangaraj
Copy link
Copy Markdown
Member

Summary

Expands applicationinsights.config from ConnectionString-only to support 12 configurable properties for WEB SDK 3.x, enabling users to configure telemetry behavior, sampling, storage, and feature flags through XML configuration.

Changes

Core Implementation

  • ApplicationInsightsConfigOptions: Internal class holding 12 configuration properties
  • ApplicationInsightsConfigurationReader: XML parser with culture-invariant type conversion, automatic comment handling, and exception safety
  • ApplicationInsightsHttpModule: Enhanced to read config on initialization and apply settings to TelemetryConfiguration

Configuration Properties Added

  1. Core: ConnectionString, DisableTelemetry, ApplicationVersion
  2. Sampling & Rate Limiting: SamplingRatio, TracesPerSecond, EnableTraceBasedLogsSampler
  3. Storage: StorageDirectory, DisableOfflineStorage
  4. Feature Flags: EnableQuickPulseMetricStream, EnablePerformanceCounterCollectionModule, AddAutoCollectedMetricExtractor, EnableDependencyTrackingTelemetryModule

OpenTelemetry Integration

  • Uses TelemetryConfiguration.ConfigureOpenTelemetryBuilder() for OpenTelemetry-specific configuration
  • Reflection-based configuration for internal AzureMonitorExporterOptions properties (EnablePerfCounters, EnableStandardMetrics) with forward compatibility
  • ActivityFilterProcessor support via linked file from NETCORE with AI_CLASSIC_WEB conditional compilation
  • Resource attributes mapping (ApplicationVersion → service.version)

NuGet Package Support

  • install.xdt: InsertIfMissing transformation with 8 properties (1 required, 7 optional with defaults)
  • uninstall.xdt: Remove directives for all properties

Documentation & Examples

  • applicationinsights.config.sample: Comprehensive template with detailed comments, organized sections, and usage guidance
  • ClassicAspNetWebApp: Updated example config with all properties enabled for testing

Testing

  • ApplicationInsightsConfigurationReaderTests (14 tests): XML parsing, type conversion, culture-invariant parsing, error handling
  • ApplicationInsightsHttpModuleTests (10 tests): Module initialization, config application, singleton pattern validation
  • SampleConfigValidationTests (5 tests): Sample config validation, property completeness verification
  • All 125 WEB tests passing

Copilot AI review requested due to automatic review settings January 7, 2026 00:57
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR significantly expands the applicationinsights.config XML configuration support for classic ASP.NET applications, moving from a simple connection string-only configuration to a comprehensive 12-property system that enables control over telemetry behavior, sampling strategies, storage options, and feature toggles.

Key Changes:

  • Introduced ApplicationInsightsConfigOptions to encapsulate 12 configuration properties (connection string, telemetry control, sampling, storage, and feature flags)
  • Implemented ApplicationInsightsConfigurationReader with culture-invariant XML parsing and type conversion
  • Enhanced ApplicationInsightsHttpModule to read and apply all configuration settings via OpenTelemetry integration using reflection for internal properties

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 15 comments.

Show a summary per file
File Description
examples/ClassicAspNetWebApp/applicationinsights.config Updated example configuration with all 12 properties enabled for testing purposes
WEB/Src/Web/Web/net462/ApplicationInsights.config.install.xdt Added XDT transformations to install 8 properties (connection string, sampling settings, and feature flags) with detailed comments
WEB/Src/Web/Web/net462/ApplicationInsights.config.uninstall.xdt Added removal directives for all installed properties plus legacy properties for backward compatibility
WEB/Src/Web/Web/applicationinsights.config.sample Comprehensive sample configuration with detailed documentation, organized sections, and default values
WEB/Src/Web/Web/Implementation/ApplicationInsightsConfigOptions.cs New internal class defining 12 configuration properties with XML documentation
WEB/Src/Web/Web/Implementation/ApplicationInsightsConfigurationReader.cs Enhanced reader supporting all configuration properties with culture-invariant parsing and graceful error handling
WEB/Src/Web/Web/ApplicationInsightsHttpModule.cs Enhanced initialization to read full configuration, apply settings to TelemetryConfiguration, and configure OpenTelemetry with reflection-based internal property access
WEB/Src/Web/Web/Web.csproj Added AI_CLASSIC_WEB compilation constant and linked ActivityFilterProcessor for activity filtering support
NETCORE/src/Shared/ActivityFilterProcessor.cs Extended with AI_CLASSIC_WEB conditional compilation to support classic ASP.NET with constructor accepting boolean parameters
WEB/Src/Web/Web.Tests/ApplicationInsightsConfigurationReaderTests.cs 14 comprehensive tests covering XML parsing, type conversion, culture-invariant parsing, and error handling
WEB/Src/Web/Web.Tests/ApplicationInsightsHttpModuleTests.cs 10 tests validating module initialization, configuration application, and singleton pattern
WEB/Src/Web/Web.Tests/SampleConfigValidationTests.cs 5 tests ensuring sample configuration validity, parsing correctness, and property completeness

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread WEB/Src/Web/Web/applicationinsights.config.sample
Comment thread WEB/Src/Web/Web/Implementation/ApplicationInsightsConfigurationReader.cs Outdated
Comment thread WEB/Src/Web/Web/ApplicationInsightsHttpModule.cs
Comment thread WEB/Src/Web/Web/Implementation/ApplicationInsightsConfigurationReader.cs Outdated
Comment thread WEB/Src/Web/Web/applicationinsights.config.sample Outdated
Comment thread examples/ClassicAspNetWebApp/applicationinsights.config
Comment thread WEB/Src/Web/Web.Tests/SampleConfigValidationTests.cs
Comment thread WEB/Src/Web/Web/ApplicationInsightsHttpModule.cs
Comment thread WEB/Src/Web/Web/Implementation/ApplicationInsightsConfigOptions.cs
Comment thread WEB/Src/Web/Web/applicationinsights.config.sample
Comment thread WEB/Src/Web/Web/applicationinsights.config.sample Outdated
@rajkumar-rangaraj rajkumar-rangaraj merged commit 0b7d098 into main Jan 7, 2026
22 checks passed
@rajkumar-rangaraj rajkumar-rangaraj deleted the rajrang/classicaspnetconfig branch January 7, 2026 23:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants