Upgrading Microsoft.ApplicationInsights 1 to 2
Breaking1.2.3 → 2.23.0Breaking32Security3Platform1Deprecated8New71Changed101Fixed90Other8
SecurityUpgrades System.Diagnostics.PerformanceCounter to version 6.0.0 to address CVE-2021-24112.CVE-2021-24112 ↗
BreakingUpgrade verdict
32 breaking changes and a platform requirement change and 3 security fixes.
In plain terms
- ASP.NET Core apps can no longer use the old global TelemetryConfiguration.Active; configuration must be passed explicitly.
- The setting to turn off W3C correlation was removed. To turn it off, change the Activity ID format settings instead.
- If you relied on the processors and channel that were added to the config for you, they now live in a different section of the config file, so you may need to move your customizations there.
- A metrics method has a new name, so code that calls the old name will no longer compile.
Must act Top 5 of 44 that need code or config changes
Target frameworks requirement changed in 2.15.0-beta3: .NETFramework4.0, .NETFramework4.5, WindowsPhone8.0 → .NETFramework4.5.2, .NETFramework4.6, .NETStandard2.0.
Adds system.diagnostics.diagnosticsource 5.0.0.
Drops microsoft.bcl.async, microsoft.diagnostics.tracing.eventsource.redist.
What you must change
Breaking32
Removes legacy TelemetryConfiguration.Active from the ASP.NET Core SDK.
TelemetryConfiguration.ActiveRemoves TelemetryConfiguration.EnableW3CCorrelation; disable W3C format via Activity.DefaultIdFormat and Activity.ForceDefaultIdFormat instead.
TelemetryConfiguration.EnableW3CCorrelationActivity.DefaultIdFormatActivityIdFormat.HierarchicalActivity.ForceDefaultIdFormatTelemetryProcessors and ServerTelemetryChannel added automatically to the default ApplicationInsights.config are moved under the default telemetry sink.
TelemetryProcessorsTelemetryChannelServerTelemetryChannelApplicationInsights.configRenames Metrics TryTrackValue(..) to TrackValue(..).
TryTrackValueTrackValueRemoves some superfluous public constants from Metrics.
Sanitize on ITelemetry implementations no longer modifies TelemetryContext fields, though serialized JSON and ETW events still have context tags sanitized.SanitizeITelemetryTelemetryContextRemoves metric aggregation functionality because there is not enough feedback on the API surface yet.
Request.Success is no longer populated from ResponseCode and must be set explicitly.
Request.SuccessResponseCodeRemoves the metric aggregation functionality that was added in the 2.3.0-beta1 release.
TelemetryConfiguration no longer disposes user provided ITelemetryChannel instances; users must dispose channels they create.
TelemetryConfigurationITelemetryChannelRemoves the DependencyTelemetry.Async property.
DependencyTelemetry.AsyncRemoves the DependencyTelemetry.Count property.
DependencyTelemetry.CountRemoves the UserContext.AcquisitionDate property.
UserContext.AcquisitionDateRemoves the UserContext.StoreRegion property.
UserContext.StoreRegionRemoves InMemoryChannel.DataUploadIntervalInSeconds; use SendingInterval instead.
InMemoryChannel.DataUploadIntervalInSecondsSendingIntervalRemoves DeviceContext.RoleName; use DeviceContext.Cloud.RoleName instead.
DeviceContext.RoleNameDeviceContext.Cloud.RoleNameRemoves DeviceContext.RoleInstance; use DeviceContext.Cloud.RoleInstance instead.
DeviceContext.RoleInstanceDeviceContext.Cloud.RoleInstanceRemoves the TelemetryConfiguration.GetTelemetryProcessorChainBuilder extension method in favor of the TelemetryProcessorChainBuilder instance method.
TelemetryConfiguration.GetTelemetryProcessorChainBuilderTelemetryConfiguration.TelemetryProcessorChainBuilderRemoves TimestampTelemetryInitializer; Timestamp is now added automatically by TelemetryClient.
TimestampTelemetryInitializerTelemetryClientStops collecting User Agent by default by removing the User Agent telemetry initializer.
Removes support for the IContextInitializer interface and the ContextInitializers collection from TelemetryConfiguration.
IContextInitializerTelemetryConfiguration.ContextInitializersRenames the Name property of OperationContext to RootName.
OperationContext.NameOperationContext.RootNameRemoves the Id property of RequestTelemetry.
RequestTelemetry.IdRequestTelemetry Id and Context.Operation.Id are no longer initialized when creating a new RequestTelemetry.
RequestTelemetry.IdOperationContext.IdCredentialEnvelope.GetToken() now returns AuthToken instead of string, exposing the token's Expiration value.
CredentialEnvelope.GetToken()AuthTokenReverts the namespace change for SamplingPercentageEstimatorSettings and AdaptiveSamplingPercentageEvaluatedCallback.
SamplingPercentageEstimatorSettingsAdaptiveSamplingPercentageEvaluatedCallbackChanges the signature of TelemetryClient.TrackDependency.
TelemetryClient.TrackDependencyMakes the Metric class private and fixes various metrics related issues.
MetricStartOperation now starts a new System.Diagnostics.Activity and overwrites OperationTelemetry.Id set before or during initialization.
StartOperationSystem.Diagnostics.ActivityOperationTelemetry.IdLocal storage folder name changed, so telemetry saved by the old SDK is not sent after upgrading.
Requires calling ServerTelemetryChannel.Initialize() when the channel is created programmatically, or persistent storage is not initialized.
ServerTelemetryChannel.Initialize()Moves internal types from the Shared namespace to the Microsoft namespace.
SharedMicrosoftSecurity3
Upgrades System.Diagnostics.PerformanceCounter to version 6.0.0 to address CVE-2021-24112.
System.Diagnostics.PerformanceCounterAddresses a vulnerability in Newtonsoft.Json (GHSA-5crp-9r3c-p9vr) by upgrading dependencies in Microsoft.ApplicationInsights.AspNetCore.
Newtonsoft.JsonMicrosoft.ApplicationInsights.AspNetCoreAdds payload sanitization for RichPayloadEventSource.
RichPayloadEventSourcePlatform1
Ends support for .NET Framework 4.5 and 4.5.1 and adds support for .NET Framework 4.5.2.
Deprecations to plan for
Deprecated8
Marks Instrumentation Key based APIs as Obsolete.
Deprecates TelemetryConfiguration.Active on .NET Core in favor of the dependency injection pattern.
TelemetryConfiguration.ActiveAdds a distinct GlobalProperties collection on TelemetryContext and obsoletes the Properties collection on TelemetryContext.
TelemetryContext.GlobalPropertiesTelemetryContext.PropertiesMarks context properties NetworkType, ScreenResolution and Language as obsolete in favor of custom properties.
NetworkTypeScreenResolutionLanguageMarks SessionStateTelemetry as obsolete; use the IsFirst flag in SessionContext instead.
SessionStateTelemetryIsFirstSessionContextMarks PerformanceCounterTelemetry as obsolete; use MetricTelemetry instead.
PerformanceCounterTelemetryMetricTelemetryMarks RequestTelemetry.HttpMethod as obsolete; put the HTTP verb in the name and use custom properties for the dimension.
RequestTelemetry.HttpMethodMarks RequestTelemetry.StartTime as obsolete; use TimeStamp instead.
RequestTelemetry.StartTimeTimeStamp