Skip to content

Upgrading Microsoft.ApplicationInsights 1 to 2

Breaking1.2.3 → 2.23.0Breaking32Security3Platform1Deprecated8New71Changed101Fixed90Other8

BreakingUpgrade verdict

32 breaking changes and a platform requirement change and 3 security fixes.

  • 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.
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.

Breaking32
Removes legacy TelemetryConfiguration.Active from the ASP.NET Core SDK.
TelemetryConfiguration.Active
Removes TelemetryConfiguration.EnableW3CCorrelation; disable W3C format via Activity.DefaultIdFormat and Activity.ForceDefaultIdFormat instead.
TelemetryConfiguration.EnableW3CCorrelationActivity.DefaultIdFormatActivityIdFormat.HierarchicalActivity.ForceDefaultIdFormat
TelemetryProcessors and ServerTelemetryChannel added automatically to the default ApplicationInsights.config are moved under the default telemetry sink.
TelemetryProcessorsTelemetryChannelServerTelemetryChannelApplicationInsights.config
Renames Metrics TryTrackValue(..) to TrackValue(..).
TryTrackValueTrackValue
Removes 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.
SanitizeITelemetryTelemetryContext
Removes 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.SuccessResponseCode
Removes 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.
TelemetryConfigurationITelemetryChannel
Removes the DependencyTelemetry.Async property.
DependencyTelemetry.Async
Removes the DependencyTelemetry.Count property.
DependencyTelemetry.Count
Removes the UserContext.AcquisitionDate property.
UserContext.AcquisitionDate
Removes the UserContext.StoreRegion property.
UserContext.StoreRegion
Removes InMemoryChannel.DataUploadIntervalInSeconds; use SendingInterval instead.
InMemoryChannel.DataUploadIntervalInSecondsSendingInterval
Removes DeviceContext.RoleName; use DeviceContext.Cloud.RoleName instead.
DeviceContext.RoleNameDeviceContext.Cloud.RoleName
Removes DeviceContext.RoleInstance; use DeviceContext.Cloud.RoleInstance instead.
DeviceContext.RoleInstanceDeviceContext.Cloud.RoleInstance
Removes the TelemetryConfiguration.GetTelemetryProcessorChainBuilder extension method in favor of the TelemetryProcessorChainBuilder instance method.
TelemetryConfiguration.GetTelemetryProcessorChainBuilderTelemetryConfiguration.TelemetryProcessorChainBuilder
Removes TimestampTelemetryInitializer; Timestamp is now added automatically by TelemetryClient.
TimestampTelemetryInitializerTelemetryClient
Stops 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.ContextInitializers
Renames the Name property of OperationContext to RootName.
OperationContext.NameOperationContext.RootName
Removes the Id property of RequestTelemetry.
RequestTelemetry.Id
RequestTelemetry Id and Context.Operation.Id are no longer initialized when creating a new RequestTelemetry.
RequestTelemetry.IdOperationContext.Id
CredentialEnvelope.GetToken() now returns AuthToken instead of string, exposing the token's Expiration value.
CredentialEnvelope.GetToken()AuthToken
Reverts the namespace change for SamplingPercentageEstimatorSettings and AdaptiveSamplingPercentageEvaluatedCallback.
SamplingPercentageEstimatorSettingsAdaptiveSamplingPercentageEvaluatedCallback
Changes the signature of TelemetryClient.TrackDependency.
TelemetryClient.TrackDependency
Makes the Metric class private and fixes various metrics related issues.
Metric
StartOperation now starts a new System.Diagnostics.Activity and overwrites OperationTelemetry.Id set before or during initialization.
StartOperationSystem.Diagnostics.ActivityOperationTelemetry.Id
Local 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.
SharedMicrosoft
Security3
Upgrades System.Diagnostics.PerformanceCounter to version 6.0.0 to address CVE-2021-24112.
System.Diagnostics.PerformanceCounter
Addresses a vulnerability in Newtonsoft.Json (GHSA-5crp-9r3c-p9vr) by upgrading dependencies in Microsoft.ApplicationInsights.AspNetCore.
Newtonsoft.JsonMicrosoft.ApplicationInsights.AspNetCore
Adds payload sanitization for RichPayloadEventSource.
RichPayloadEventSource
Platform1
Ends support for .NET Framework 4.5 and 4.5.1 and adds support for .NET Framework 4.5.2.
Deprecated8
Marks Instrumentation Key based APIs as Obsolete.
Deprecates TelemetryConfiguration.Active on .NET Core in favor of the dependency injection pattern.
TelemetryConfiguration.Active
Adds a distinct GlobalProperties collection on TelemetryContext and obsoletes the Properties collection on TelemetryContext.
TelemetryContext.GlobalPropertiesTelemetryContext.Properties
Marks context properties NetworkType, ScreenResolution and Language as obsolete in favor of custom properties.
NetworkTypeScreenResolutionLanguage
Marks SessionStateTelemetry as obsolete; use the IsFirst flag in SessionContext instead.
SessionStateTelemetryIsFirstSessionContext
Marks PerformanceCounterTelemetry as obsolete; use MetricTelemetry instead.
PerformanceCounterTelemetryMetricTelemetry
Marks RequestTelemetry.HttpMethod as obsolete; put the HTTP verb in the name and use custom properties for the dimension.
RequestTelemetry.HttpMethod
Marks RequestTelemetry.StartTime as obsolete; use TimeStamp instead.
RequestTelemetry.StartTimeTimeStamp