Skip to content

Improve ITelemetry Serialization #997

@TimothyMothra

Description

@TimothyMothra

JsonSerializer is attempting several type casts.
Because of the if statements, there are several failed casts before finding the correct matching type.

https://github.com/Microsoft/ApplicationInsights-dotnet/blob/c9e06e96cea44728feb521189b82bbc0c438d831/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs#L171-L189

Option 1
I propose to remove the serialization entirely by appending the TelemetryName and BaseType to the ITelemetry interface. This would completely eliminate any need for casting here.
This isn't viable because ITelemetry is the foundation of the Common Schema and cannot take changes.

Option 2
If we don't want to add properties to ITelemetry we can instead introduce a new interface ISerializableTelemetry. With this there would be only one type cast (ITelemetry => ISerializableTelemetry).
This has the benefit of being applied only to our AI Telemetry objects and won't affect external types.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions