Skip to content
Closed
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 @@ -11,6 +11,8 @@ Microsoft.ApplicationInsights.AspNetCore.Extensions.ApplicationInsightsServiceOp
Microsoft.ApplicationInsights.AspNetCore.Extensions.ApplicationInsightsServiceOptions.DependencyCollectionOptions.get -> Microsoft.ApplicationInsights.AspNetCore.Extensions.DependencyCollectionOptions
Microsoft.ApplicationInsights.AspNetCore.Extensions.ApplicationInsightsServiceOptions.EnableActiveTelemetryConfigurationSetup.get -> bool
Microsoft.ApplicationInsights.AspNetCore.Extensions.ApplicationInsightsServiceOptions.EnableActiveTelemetryConfigurationSetup.set -> void
Microsoft.ApplicationInsights.AspNetCore.Extensions.ApplicationInsightsServiceOptions.DisableOfflineStorage.get -> bool
Microsoft.ApplicationInsights.AspNetCore.Extensions.ApplicationInsightsServiceOptions.DisableOfflineStorage.set -> void
Microsoft.ApplicationInsights.AspNetCore.Extensions.ApplicationInsightsServiceOptions.EnableAdaptiveSampling.get -> bool
Microsoft.ApplicationInsights.AspNetCore.Extensions.ApplicationInsightsServiceOptions.EnableAdaptiveSampling.set -> void
Microsoft.ApplicationInsights.AspNetCore.Extensions.ApplicationInsightsServiceOptions.EnableAuthenticationTrackingJavaScript.get -> bool
Expand All @@ -19,6 +21,8 @@ Microsoft.ApplicationInsights.AspNetCore.Extensions.ApplicationInsightsServiceOp
Microsoft.ApplicationInsights.AspNetCore.Extensions.ApplicationInsightsServiceOptions.EnableDebugLogger.set -> void
Microsoft.ApplicationInsights.AspNetCore.Extensions.ApplicationInsightsServiceOptions.EnableDependencyTrackingTelemetryModule.get -> bool
Microsoft.ApplicationInsights.AspNetCore.Extensions.ApplicationInsightsServiceOptions.EnableDependencyTrackingTelemetryModule.set -> void
Microsoft.ApplicationInsights.AspNetCore.Extensions.ApplicationInsightsServiceOptions.EnableTraceBasedLogsSampler.get -> bool
Microsoft.ApplicationInsights.AspNetCore.Extensions.ApplicationInsightsServiceOptions.EnableTraceBasedLogsSampler.set -> void
Microsoft.ApplicationInsights.AspNetCore.Extensions.ApplicationInsightsServiceOptions.EnablePerformanceCounterCollectionModule.get -> bool
Microsoft.ApplicationInsights.AspNetCore.Extensions.ApplicationInsightsServiceOptions.EnablePerformanceCounterCollectionModule.set -> void
Microsoft.ApplicationInsights.AspNetCore.Extensions.ApplicationInsightsServiceOptions.EnableQuickPulseMetricStream.get -> bool
Expand All @@ -28,6 +32,10 @@ Microsoft.ApplicationInsights.AspNetCore.Extensions.ApplicationInsightsServiceOp
Microsoft.ApplicationInsights.AspNetCore.Extensions.ApplicationInsightsServiceOptions.EndpointAddress.get -> string
Microsoft.ApplicationInsights.AspNetCore.Extensions.ApplicationInsightsServiceOptions.EndpointAddress.set -> void
Microsoft.ApplicationInsights.AspNetCore.Extensions.ApplicationInsightsServiceOptions.RequestCollectionOptions.get -> Microsoft.ApplicationInsights.AspNetCore.Extensions.RequestCollectionOptions
Microsoft.ApplicationInsights.AspNetCore.Extensions.ApplicationInsightsServiceOptions.StorageDirectory.get -> string
Microsoft.ApplicationInsights.AspNetCore.Extensions.ApplicationInsightsServiceOptions.StorageDirectory.set -> void
Microsoft.ApplicationInsights.AspNetCore.Extensions.ApplicationInsightsServiceOptions.TracesPerSecond.get -> double
Microsoft.ApplicationInsights.AspNetCore.Extensions.ApplicationInsightsServiceOptions.TracesPerSecond.set -> void
Microsoft.ApplicationInsights.AspNetCore.Extensions.DependencyCollectionOptions
Microsoft.ApplicationInsights.AspNetCore.Extensions.DependencyCollectionOptions.DependencyCollectionOptions() -> void
Microsoft.ApplicationInsights.AspNetCore.Extensions.DependencyCollectionOptions.EnableLegacyCorrelationHeadersInjection.get -> bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,26 @@ Microsoft.ApplicationInsights.WorkerService.ApplicationInsightsServiceOptions.Co
Microsoft.ApplicationInsights.WorkerService.ApplicationInsightsServiceOptions.Credential.get -> Azure.Core.TokenCredential
Microsoft.ApplicationInsights.WorkerService.ApplicationInsightsServiceOptions.Credential.set -> void
Microsoft.ApplicationInsights.WorkerService.ApplicationInsightsServiceOptions.DependencyCollectionOptions.get -> Microsoft.ApplicationInsights.WorkerService.DependencyCollectionOptions
Microsoft.ApplicationInsights.WorkerService.ApplicationInsightsServiceOptions.DisableOfflineStorage.get -> bool
Microsoft.ApplicationInsights.WorkerService.ApplicationInsightsServiceOptions.DisableOfflineStorage.set -> void
Microsoft.ApplicationInsights.WorkerService.ApplicationInsightsServiceOptions.EnableAdaptiveSampling.get -> bool
Microsoft.ApplicationInsights.WorkerService.ApplicationInsightsServiceOptions.EnableAdaptiveSampling.set -> void
Microsoft.ApplicationInsights.WorkerService.ApplicationInsightsServiceOptions.EnableDebugLogger.get -> bool
Microsoft.ApplicationInsights.WorkerService.ApplicationInsightsServiceOptions.EnableDebugLogger.set -> void
Microsoft.ApplicationInsights.WorkerService.ApplicationInsightsServiceOptions.EnableDependencyTrackingTelemetryModule.get -> bool
Microsoft.ApplicationInsights.WorkerService.ApplicationInsightsServiceOptions.EnableDependencyTrackingTelemetryModule.set -> void
Microsoft.ApplicationInsights.WorkerService.ApplicationInsightsServiceOptions.EnableTraceBasedLogsSampler.get -> bool
Microsoft.ApplicationInsights.WorkerService.ApplicationInsightsServiceOptions.EnableTraceBasedLogsSampler.set -> void
Microsoft.ApplicationInsights.WorkerService.ApplicationInsightsServiceOptions.EnablePerformanceCounterCollectionModule.get -> bool
Microsoft.ApplicationInsights.WorkerService.ApplicationInsightsServiceOptions.EnablePerformanceCounterCollectionModule.set -> void
Microsoft.ApplicationInsights.WorkerService.ApplicationInsightsServiceOptions.EnableQuickPulseMetricStream.get -> bool
Microsoft.ApplicationInsights.WorkerService.ApplicationInsightsServiceOptions.EnableQuickPulseMetricStream.set -> void
Microsoft.ApplicationInsights.WorkerService.ApplicationInsightsServiceOptions.EndpointAddress.get -> string
Microsoft.ApplicationInsights.WorkerService.ApplicationInsightsServiceOptions.EndpointAddress.set -> void
Microsoft.ApplicationInsights.WorkerService.ApplicationInsightsServiceOptions.StorageDirectory.get -> string
Microsoft.ApplicationInsights.WorkerService.ApplicationInsightsServiceOptions.StorageDirectory.set -> void
Microsoft.ApplicationInsights.WorkerService.ApplicationInsightsServiceOptions.TracesPerSecond.get -> double
Microsoft.ApplicationInsights.WorkerService.ApplicationInsightsServiceOptions.TracesPerSecond.set -> void
Microsoft.ApplicationInsights.WorkerService.DependencyCollectionOptions
Microsoft.ApplicationInsights.WorkerService.DependencyCollectionOptions.DependencyCollectionOptions() -> void
Microsoft.ApplicationInsights.WorkerService.DependencyCollectionOptions.EnableLegacyCorrelationHeadersInjection.get -> bool
Expand Down
29 changes: 29 additions & 0 deletions NETCORE/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,38 @@ builder.Services.AddApplicationInsightsTelemetry(options =>
// When true, enables rate-limit based sampling in Azure Monitor Exporter
// When false, sampling is disabled (100% collection)
options.EnableAdaptiveSampling = true;

// Target number of traces per second for sampling (default: 5.0)
options.TracesPerSecond = 5.0;

// Disable offline storage for failed telemetry (default: false)
options.DisableOfflineStorage = false;

// Custom directory for offline storage
options.StorageDirectory = "C:\\AppInsightsStorage";

// Enable trace-based logs sampling (default: true)
// When true, logs are sampled based on their associated trace
options.EnableTraceBasedLogsSampler = true;
});
```

These options can also be configured via `appsettings.json`:

```json
{
"ApplicationInsights": {
"ConnectionString": "InstrumentationKey=...",
"EnableQuickPulseMetricStream": true,
"EnableAdaptiveSampling": true,
"TracesPerSecond": 5.0,
"DisableOfflineStorage": false,
"StorageDirectory": "C:\\AppInsightsStorage",
"EnableTraceBasedLogsSampler": true
}
}
```

> **Note**: In version 3.x, many properties from `ApplicationInsightsServiceOptions` in 2.x are no longer functional because they related to telemetry modules, processors, and channels that have been replaced by OpenTelemetry components. The properties shown above are the ones that are actively used in the 3.x OpenTelemetry-based implementation.

## Advanced Configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,23 @@ internal static IOpenTelemetryBuilder UseApplicationInsightsTelemetry(this IOpen
exporterOptions.SamplingRatio = 1.0F;
}

// Copy TracesPerSecond to Azure Monitor Exporter (with validation)
if (serviceOptions.TracesPerSecond > 0)
{
exporterOptions.TracesPerSecond = serviceOptions.TracesPerSecond;
}

// Copy offline storage settings to Azure Monitor Exporter
exporterOptions.DisableOfflineStorage = serviceOptions.DisableOfflineStorage;

if (!string.IsNullOrEmpty(serviceOptions.StorageDirectory))
{
exporterOptions.StorageDirectory = serviceOptions.StorageDirectory;
}

// Copy trace-based logs sampler setting to Azure Monitor Exporter
exporterOptions.EnableTraceBasedLogsSampler = serviceOptions.EnableTraceBasedLogsSampler;

if (serviceOptions.EnableQuickPulseMetricStream)
{
exporterOptions.EnableLiveMetrics = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,23 @@ internal static IOpenTelemetryBuilder UseApplicationInsightsTelemetry(this IOpen
exporterOptions.SamplingRatio = 1.0F;
}

// Copy TracesPerSecond to Azure Monitor Exporter (with validation)
if (serviceOptions.TracesPerSecond > 0)
{
exporterOptions.TracesPerSecond = serviceOptions.TracesPerSecond;
}

// Copy offline storage settings to Azure Monitor Exporter
exporterOptions.DisableOfflineStorage = serviceOptions.DisableOfflineStorage;

if (!string.IsNullOrEmpty(serviceOptions.StorageDirectory))
{
exporterOptions.StorageDirectory = serviceOptions.StorageDirectory;
}

// Copy trace-based logs sampler setting to Azure Monitor Exporter
exporterOptions.EnableTraceBasedLogsSampler = serviceOptions.EnableTraceBasedLogsSampler;

exporterOptions.EnableLiveMetrics = serviceOptions.EnableQuickPulseMetricStream;
});

Expand Down
30 changes: 30 additions & 0 deletions NETCORE/src/Shared/Extensions/ApplicationInsightsServiceOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,32 @@ public class ApplicationInsightsServiceOptions
/// </summary>
public bool EnableAdaptiveSampling { get; set; } = true;

/// <summary>
/// Gets or sets the target number of traces per second to be collected.
/// Defaults to <value>5.0</value>.
/// </summary>
public double TracesPerSecond { get; set; } = 5.0;

/// <summary>
/// Gets or sets a value indicating whether offline storage should be disabled.
/// When <value>true</value>, telemetry will not be stored locally when transmission fails.
/// Defaults to <value>false</value>.
/// </summary>
public bool DisableOfflineStorage { get; set; } = false;

/// <summary>
/// Gets or sets the directory path for storing telemetry when offline.
/// If not specified, the default storage directory will be used.
/// </summary>
public string StorageDirectory { get; set; }

/// <summary>
/// Gets or sets a value indicating whether the trace-based logs sampler is enabled.
/// When <value>true</value> (default), logs are sampled based on their associated trace.
/// Defaults to <value>true</value>.
/// </summary>
public bool EnableTraceBasedLogsSampler { get; set; } = true;

/// <summary>
/// Gets or sets the connection string for the application.
/// </summary>
Expand Down Expand Up @@ -129,6 +155,10 @@ internal void CopyPropertiesTo(ApplicationInsightsServiceOptions target)

target.ApplicationVersion = this.ApplicationVersion;
target.EnableAdaptiveSampling = this.EnableAdaptiveSampling;
target.TracesPerSecond = this.TracesPerSecond;
target.DisableOfflineStorage = this.DisableOfflineStorage;
target.StorageDirectory = this.StorageDirectory;
target.EnableTraceBasedLogsSampler = this.EnableTraceBasedLogsSampler;
target.EnableDebugLogger = this.EnableDebugLogger;
target.EnableQuickPulseMetricStream = this.EnableQuickPulseMetricStream;
target.AddAutoCollectedMetricExtractor = this.AddAutoCollectedMetricExtractor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"ApplicationInsights": {
"ConnectionString": "InstrumentationKey=11111111-2222-3333-4444-555555555555;IngestionEndpoint=http://testendpoint",
"EnableAdaptiveSampling": false,
"TracesPerSecond": 5.0,
"DisableOfflineStorage": false,
"EnableTraceBasedLogsSampler": true,
"EnableQuickPulseMetricStream": true,
"ApplicationVersion": "Version",
"RequestCollectionOptions": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
"ApplicationInsights": {
"ConnectionString": "InstrumentationKey=22222222-2222-3333-4444-555555555555",
"EnableAdaptiveSampling": false,
"TracesPerSecond": 1.0,
"DisableOfflineStorage": false,
"StorageDirectory": "C:\\TestStorage",
"EnableTraceBasedLogsSampler": false,
"EnableQuickPulseMetricStream": false,
"RequestCollectionOptions": {
"InjectResponseHeaders": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"ApplicationInsights": {
"ConnectionString": "InstrumentationKey=22222222-2222-3333-4444-555555555555",
"EnableAdaptiveSampling": true,
"TracesPerSecond": 10.0,
"DisableOfflineStorage": true,
"EnableTraceBasedLogsSampler": true,
"EnableQuickPulseMetricStream": true,
"ApplicationVersion": "1.0.0",
"RequestCollectionOptions": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"InstrumentationKey": "11111111-2222-3333-4444-555555555555",
"ConnectionString": "InstrumentationKey=11111111-2222-3333-4444-555555555555;IngestionEndpoint=http://testendpoint",
"EnableAdaptiveSampling": false,
"TracesPerSecond": 5.0,
"DisableOfflineStorage": false,
"EnableTraceBasedLogsSampler": true,
"EnablePerformanceCounterCollectionModule": true,
"EnableAzureInstanceMetadataTelemetryModule": true,
"EnableRequestTrackingTelemetryModule": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
"InstrumentationKey": "22222222-2222-3333-4444-555555555555",
"ConnectionString": "InstrumentationKey=22222222-2222-3333-4444-555555555555;IngestionEndpoint=http://testendpoint",
"EnableAdaptiveSampling": false,
"TracesPerSecond": 1.0,
"DisableOfflineStorage": false,
"StorageDirectory": "C:\\TestStorage",
"EnableTraceBasedLogsSampler": false,
"EnablePerformanceCounterCollectionModule": false,
"EnableAzureInstanceMetadataTelemetryModule": false,
"EnableRequestTrackingTelemetryModule": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"InstrumentationKey": "22222222-2222-3333-4444-555555555555",
"ConnectionString": "InstrumentationKey=22222222-2222-3333-4444-555555555555;IngestionEndpoint=http://testendpoint",
"EnableAdaptiveSampling": true,
"TracesPerSecond": 10.0,
"DisableOfflineStorage": true,
"EnableTraceBasedLogsSampler": true,
"EnablePerformanceCounterCollectionModule": true,
"EnableAzureInstanceMetadataTelemetryModule": true,
"EnableRequestTrackingTelemetryModule": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
"InstrumentationKey": "11111111-2222-3333-4444-555555555555",
"ConnectionString": "InstrumentationKey=11111111-2222-3333-4444-555555555555;IngestionEndpoint=http://testendpoint",
"EnableAdaptiveSampling": false,
"TracesPerSecond": 5.0,
"DisableOfflineStorage": false,
"EnableTraceBasedLogsSampler": true,
"EnablePerformanceCounterCollectionModule": true,
"EnableAzureInstanceMetadataTelemetryModule": true,
"EnableAzureInstanceMetadatsaTelemetryModule": true,
"EnableRequestTrackingTelemetryModule": true,
"EnableDependencyTrackingTelemetryModule": true,
"EnableAppServicesHeartbeatTelemetryModule": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
"InstrumentationKey": "22222222-2222-3333-4444-555555555555",
"ConnectionString": "InstrumentationKey=22222222-2222-3333-4444-555555555555;IngestionEndpoint=http://testendpoint",
"EnableAdaptiveSampling": false,
"TracesPerSecond": 1.0,
"DisableOfflineStorage": false,
"StorageDirectory": "C:\\TestStorage",
"EnableTraceBasedLogsSampler": false,
"EnablePerformanceCounterCollectionModule": false,
"EnableAzureInstanceMetadataTelemetryModule": false,
"EnableRequestTrackingTelemetryModule": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"InstrumentationKey": "22222222-2222-3333-4444-555555555555",
"ConnectionString": "InstrumentationKey=22222222-2222-3333-4444-555555555555;IngestionEndpoint=http://testendpoint",
"EnableAdaptiveSampling": true,
"TracesPerSecond": 10.0,
"DisableOfflineStorage": true,
"EnableTraceBasedLogsSampler": true,
"EnablePerformanceCounterCollectionModule": true,
"EnableAzureInstanceMetadataTelemetryModule": true,
"EnableRequestTrackingTelemetryModule": true,
Expand Down
Loading
Loading