From 6ff35f32332f8cbf697cf303027d8909cdb08727 Mon Sep 17 00:00:00 2001 From: Sergey Kanzhelev Date: Wed, 6 Dec 2017 23:17:19 -0800 Subject: [PATCH 01/74] add page view performance telemetry --- .../net45/PublicAPI.Unshipped.txt | 27 +++ .../net46/PublicAPI.Unshipped.txt | 27 +++ .../netstandard1.3/PublicAPI.Unshipped.txt | 27 +++ .../PageViewPerformanceTelemetry.cs | 210 ++++++++++++++++++ .../External/PageViewPerfData.cs | 28 ++- .../Implementation/JsonSerializer.cs | 43 +++- .../RichPayloadEventSource.Keywords.cs | 5 + ...RichPayloadEventSource.TelemetryHandler.cs | 61 +++++ .../Implementation/RichPayloadEventSource.cs | 16 ++ 9 files changed, 438 insertions(+), 6 deletions(-) create mode 100644 src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs diff --git a/PublicAPI/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Unshipped.txt b/PublicAPI/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Unshipped.txt index 86ff2ddb5f..9152a94451 100644 --- a/PublicAPI/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Unshipped.txt +++ b/PublicAPI/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Unshipped.txt @@ -1,3 +1,30 @@ +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Context.get -> Microsoft.ApplicationInsights.DataContracts.TelemetryContext +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.DeepClone() -> Microsoft.ApplicationInsights.Channel.ITelemetry +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.DomProcessing.get -> System.TimeSpan +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.DomProcessing.set -> void +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Duration.get -> System.TimeSpan +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Duration.set -> void +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Metrics.get -> System.Collections.Generic.IDictionary +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Name.get -> string +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Name.set -> void +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.NetworkConnect.get -> System.TimeSpan +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.NetworkConnect.set -> void +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.PageViewPerformanceTelemetry() -> void +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.PageViewPerformanceTelemetry(string pageName) -> void +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.PerfTotal.get -> System.TimeSpan +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.PerfTotal.set -> void +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Properties.get -> System.Collections.Generic.IDictionary +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.ReceivedResponse.get -> System.TimeSpan +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.ReceivedResponse.set -> void +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.SentRequest.get -> System.TimeSpan +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.SentRequest.set -> void +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Sequence.get -> string +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Sequence.set -> void +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Timestamp.get -> System.DateTimeOffset +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Timestamp.set -> void +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Url.get -> System.Uri +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Url.set -> void Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.DiagnosticsTelemetryModule.AddHeartbeatProperty(string propertyName, string propertyValue, bool isHealthy) -> bool Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.DiagnosticsTelemetryModule.ExcludedHeartbeatProperties.get -> System.Collections.Generic.IList Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.DiagnosticsTelemetryModule.HeartbeatInterval.get -> System.TimeSpan diff --git a/PublicAPI/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Unshipped.txt b/PublicAPI/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Unshipped.txt index 86ff2ddb5f..9152a94451 100644 --- a/PublicAPI/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Unshipped.txt +++ b/PublicAPI/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Unshipped.txt @@ -1,3 +1,30 @@ +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Context.get -> Microsoft.ApplicationInsights.DataContracts.TelemetryContext +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.DeepClone() -> Microsoft.ApplicationInsights.Channel.ITelemetry +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.DomProcessing.get -> System.TimeSpan +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.DomProcessing.set -> void +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Duration.get -> System.TimeSpan +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Duration.set -> void +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Metrics.get -> System.Collections.Generic.IDictionary +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Name.get -> string +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Name.set -> void +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.NetworkConnect.get -> System.TimeSpan +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.NetworkConnect.set -> void +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.PageViewPerformanceTelemetry() -> void +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.PageViewPerformanceTelemetry(string pageName) -> void +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.PerfTotal.get -> System.TimeSpan +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.PerfTotal.set -> void +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Properties.get -> System.Collections.Generic.IDictionary +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.ReceivedResponse.get -> System.TimeSpan +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.ReceivedResponse.set -> void +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.SentRequest.get -> System.TimeSpan +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.SentRequest.set -> void +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Sequence.get -> string +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Sequence.set -> void +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Timestamp.get -> System.DateTimeOffset +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Timestamp.set -> void +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Url.get -> System.Uri +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Url.set -> void Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.DiagnosticsTelemetryModule.AddHeartbeatProperty(string propertyName, string propertyValue, bool isHealthy) -> bool Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.DiagnosticsTelemetryModule.ExcludedHeartbeatProperties.get -> System.Collections.Generic.IList Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.DiagnosticsTelemetryModule.HeartbeatInterval.get -> System.TimeSpan diff --git a/PublicAPI/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Unshipped.txt b/PublicAPI/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Unshipped.txt index 86ff2ddb5f..9152a94451 100644 --- a/PublicAPI/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Unshipped.txt +++ b/PublicAPI/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Unshipped.txt @@ -1,3 +1,30 @@ +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Context.get -> Microsoft.ApplicationInsights.DataContracts.TelemetryContext +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.DeepClone() -> Microsoft.ApplicationInsights.Channel.ITelemetry +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.DomProcessing.get -> System.TimeSpan +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.DomProcessing.set -> void +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Duration.get -> System.TimeSpan +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Duration.set -> void +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Metrics.get -> System.Collections.Generic.IDictionary +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Name.get -> string +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Name.set -> void +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.NetworkConnect.get -> System.TimeSpan +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.NetworkConnect.set -> void +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.PageViewPerformanceTelemetry() -> void +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.PageViewPerformanceTelemetry(string pageName) -> void +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.PerfTotal.get -> System.TimeSpan +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.PerfTotal.set -> void +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Properties.get -> System.Collections.Generic.IDictionary +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.ReceivedResponse.get -> System.TimeSpan +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.ReceivedResponse.set -> void +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.SentRequest.get -> System.TimeSpan +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.SentRequest.set -> void +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Sequence.get -> string +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Sequence.set -> void +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Timestamp.get -> System.DateTimeOffset +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Timestamp.set -> void +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Url.get -> System.Uri +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Url.set -> void Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.DiagnosticsTelemetryModule.AddHeartbeatProperty(string propertyName, string propertyValue, bool isHealthy) -> bool Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.DiagnosticsTelemetryModule.ExcludedHeartbeatProperties.get -> System.Collections.Generic.IList Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.DiagnosticsTelemetryModule.HeartbeatInterval.get -> System.TimeSpan diff --git a/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs new file mode 100644 index 0000000000..6d22ef39c8 --- /dev/null +++ b/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs @@ -0,0 +1,210 @@ +namespace Microsoft.ApplicationInsights.DataContracts +{ + using System; + using System.Collections.Generic; + using Microsoft.ApplicationInsights.Channel; + using Microsoft.ApplicationInsights.Extensibility.Implementation; + using Microsoft.ApplicationInsights.Extensibility.Implementation.External; + + /// + /// Telemetry type used to track page load performance. + /// + public sealed class PageViewPerformanceTelemetry : ITelemetry, ISupportProperties, ISupportSampling + { + internal const string TelemetryName = "PageView"; + + internal readonly string BaseType = typeof(PageViewPerformanceTelemetry).Name; + + internal readonly PageViewPerfData Data; + private readonly TelemetryContext context; + + private double? samplingPercentage; + + /// + /// Initializes a new instance of the class. + /// + public PageViewPerformanceTelemetry() + { + this.Data = new PageViewPerfData(); + this.context = new TelemetryContext(this.Data.properties); + } + + /// + /// Initializes a new instance of the class with the + /// specified . + /// + /// The is null or empty string. + public PageViewPerformanceTelemetry(string pageName) : this() + { + this.Name = pageName; + } + + /// + /// Initializes a new instance of the class by cloning an existing instance. + /// + /// Source instance of to clone from. + private PageViewPerformanceTelemetry(PageViewPerformanceTelemetry source) + { + this.Data = source.Data.DeepClone(); + this.context = source.context.DeepClone(this.Data.properties); + } + + /// + /// Gets or sets date and time when event was recorded. + /// + public DateTimeOffset Timestamp { get; set; } + + /// + /// Gets or sets the value that defines absolute order of the telemetry item. + /// + public string Sequence { get; set; } + + /// + /// Gets the context associated with the current telemetry item. + /// + public TelemetryContext Context + { + get { return this.context; } + } + + /// + /// Gets or sets the name of the page. + /// + public string Name + { + get { return this.Data.name; } + set { this.Data.name = value; } + } + + /// + /// Gets or sets the page view Uri. + /// + public Uri Url + { + get + { + if (this.Data.url.IsNullOrWhiteSpace()) + { + return null; + } + + return new Uri(this.Data.url, UriKind.RelativeOrAbsolute); + } + + set + { + if (value == null) + { + this.Data.url = null; + } + else + { + this.Data.url = value.ToString(); + } + } + } + + /// + /// Gets or sets the page view duration. + /// + public TimeSpan Duration + { + get { return Utils.ValidateDuration(this.Data.duration); } + set { this.Data.duration = value.ToString(); } + } + + /// + /// Gets or sets the page DOM processing time. + /// + public TimeSpan DomProcessing + { + get { return Utils.ValidateDuration(this.Data.domProcessing); } + set { this.Data.domProcessing = value.ToString(); } + } + + /// + /// Gets or sets the page loading total time. + /// + public TimeSpan PerfTotal + { + get { return Utils.ValidateDuration(this.Data.perfTotal); } + set { this.Data.perfTotal = value.ToString(); } + } + + /// + /// Gets or sets the page load network time. + /// + public TimeSpan NetworkConnect + { + get { return Utils.ValidateDuration(this.Data.networkConnect); } + set { this.Data.networkConnect = value.ToString(); } + } + + /// + /// Gets or sets the page load send request time. + /// + public TimeSpan SentRequest + { + get { return Utils.ValidateDuration(this.Data.sentRequest); } + set { this.Data.sentRequest = value.ToString(); } + } + + /// + /// Gets or sets the page load recieve response duration. + /// + public TimeSpan ReceivedResponse + { + get { return Utils.ValidateDuration(this.Data.receivedResponse); } + set { this.Data.receivedResponse = value.ToString(); } + } + + /// + /// Gets a dictionary of custom defined metrics. + /// Learn more + /// + public IDictionary Metrics + { + get { return this.Data.measurements; } + } + + /// + /// Gets a dictionary of application-defined property names and values providing additional information about this page view. + /// Learn more + /// + public IDictionary Properties + { + get { return this.Data.properties; } + } + + /// + /// Gets or sets data sampling percentage (between 0 and 100). + /// Should be 100/n where n is an integer. Learn more + /// + double? ISupportSampling.SamplingPercentage + { + get { return this.samplingPercentage; } + set { this.samplingPercentage = value; } + } + + /// + /// Deeply clones a object. + /// + /// A cloned instance. + public ITelemetry DeepClone() + { + return new PageViewPerformanceTelemetry(this); + } + + /// + /// Sanitizes the properties based on constraints. + /// + void ITelemetry.Sanitize() + { + this.Name = this.Name.SanitizeName(); + this.Name = Utils.PopulateRequiredStringValue(this.Name, "name", typeof(PageViewTelemetry).FullName); + this.Properties.SanitizeProperties(); + this.Metrics.SanitizeMeasurements(); + this.Url = this.Url.SanitizeUri(); + } + } +} diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/PageViewPerfData.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/PageViewPerfData.cs index b9a2259138..14fbec9eb0 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/PageViewPerfData.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/PageViewPerfData.cs @@ -1,14 +1,34 @@ namespace Microsoft.ApplicationInsights.Extensibility.Implementation.External { -#if NET45 - // .Net 4.5 has a custom implementation of RichPayloadEventSource -#else /// /// Partial class to add the EventData attribute and any additional customizations to the generated type. /// +#if NET45 + // .Net 4.5 has a custom implementation of RichPayloadEventSource +#else [System.Diagnostics.Tracing.EventData(Name = "PartB_PageViewPerfData")] +#endif internal partial class PageViewPerfData { + public new PageViewPerfData DeepClone() + { + var other = new PageViewPerfData(); + this.ApplyProperties(other); + return other; + } + + protected override void ApplyProperties(EventData other) + { + base.ApplyProperties(other); + PageViewPerfData otherPageViewPerf = other as PageViewPerfData; + if (otherPageViewPerf != null) + { + otherPageViewPerf.domProcessing = this.domProcessing; + otherPageViewPerf.perfTotal = this.perfTotal; + otherPageViewPerf.networkConnect = this.networkConnect; + otherPageViewPerf.sentRequest = this.sentRequest; + otherPageViewPerf.receivedResponse = this.receivedResponse; + } + } } -#endif } \ No newline at end of file diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs index e48eea9160..82cd7071ad 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs @@ -257,6 +257,11 @@ private static void SerializeTelemetryItem(ITelemetry telemetryItem, JsonWriter PageViewTelemetry pageViewTelemetry = telemetryItem as PageViewTelemetry; SerializePageViewTelemetry(pageViewTelemetry, jsonWriter); } + else if (telemetryItem is PageViewPerformanceTelemetry) + { + PageViewPerformanceTelemetry pageViewPerfTelemetry = telemetryItem as PageViewPerformanceTelemetry; + SerializePageViewPerformanceTelemetry(pageViewPerfTelemetry, jsonWriter); + } else if (telemetryItem is DependencyTelemetry) { DependencyTelemetry remoteDependencyTelemetry = telemetryItem as DependencyTelemetry; @@ -443,7 +448,6 @@ private static void SerializePageViewTelemetry(PageViewTelemetry pageViewTelemet { writer.WriteStartObject(); - // TODO: MetricTelemetry should write type as this.data.baseType once Common Schema 2.0 compliant. writer.WriteProperty("baseType", pageViewTelemetry.BaseType); writer.WritePropertyName("baseData"); { @@ -465,6 +469,42 @@ private static void SerializePageViewTelemetry(PageViewTelemetry pageViewTelemet writer.WriteEndObject(); } + private static void SerializePageViewPerformanceTelemetry(PageViewPerformanceTelemetry pageViewPerfTelemetry, JsonWriter writer) + { + writer.WriteStartObject(); + + pageViewPerfTelemetry.WriteTelemetryName(writer, PageViewTelemetry.TelemetryName); + pageViewPerfTelemetry.WriteEnvelopeProperties(writer); + writer.WritePropertyName("data"); + { + writer.WriteStartObject(); + + writer.WriteProperty("baseType", pageViewPerfTelemetry.BaseType); + writer.WritePropertyName("baseData"); + { + writer.WriteStartObject(); + + writer.WriteProperty("ver", pageViewPerfTelemetry.Data.ver); + writer.WriteProperty("name", pageViewPerfTelemetry.Data.name); + writer.WriteProperty("url", pageViewPerfTelemetry.Data.url); + writer.WriteProperty("duration", pageViewPerfTelemetry.Data.duration); + writer.WriteProperty("domProcessing", pageViewPerfTelemetry.Data.domProcessing); + writer.WriteProperty("perfTotal", pageViewPerfTelemetry.Data.perfTotal); + writer.WriteProperty("networkConnect", pageViewPerfTelemetry.Data.networkConnect); + writer.WriteProperty("sentRequest", pageViewPerfTelemetry.Data.sentRequest); + writer.WriteProperty("receivedResponse", pageViewPerfTelemetry.Data.receivedResponse); + writer.WriteProperty("measurements", pageViewPerfTelemetry.Data.measurements); + writer.WriteProperty("properties", pageViewPerfTelemetry.Data.properties); + + writer.WriteEndObject(); + } + + writer.WriteEndObject(); + } + + writer.WriteEndObject(); + } + private static void SerializeDependencyTelemetry(DependencyTelemetry dependencyTelemetry, JsonWriter writer) { writer.WriteStartObject(); @@ -546,7 +586,6 @@ private static void SerializeTraceTelemetry(TraceTelemetry traceTelemetry, JsonW { writer.WriteStartObject(); - // TODO: MetricTelemetry should write type as this.data.baseType once Common Schema 2.0 compliant. writer.WriteProperty("baseType", traceTelemetry.BaseType); writer.WritePropertyName("baseData"); { diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/RichPayloadEventSource.Keywords.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/RichPayloadEventSource.Keywords.cs index 8f3d2c1a5e..c92cde86d4 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/RichPayloadEventSource.Keywords.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/RichPayloadEventSource.Keywords.cs @@ -66,6 +66,11 @@ public sealed class Keywords /// Keyword for operations (Start/Stop). /// public const EventKeywords Operations = (EventKeywords)0x400; + + /// + /// Keyword for page view performance. + /// + public const EventKeywords PageViewPerformance = (EventKeywords)0x800; } } } diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/RichPayloadEventSource.TelemetryHandler.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/RichPayloadEventSource.TelemetryHandler.cs index c2c213764e..192cc8ce7f 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/RichPayloadEventSource.TelemetryHandler.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/RichPayloadEventSource.TelemetryHandler.cs @@ -72,6 +72,9 @@ private Dictionary> CreateTelemetryHandlers(EventSource // PageView telemetryHandlers.Add(typeof(PageViewTelemetry), this.CreateHandlerForPageViewTelemetry(eventSource, writeGenericMethod, eventSourceOptionsType, eventSourceOptionsKeywordsProperty)); + // PageView + telemetryHandlers.Add(typeof(PageViewPerformanceTelemetry), this.CreateHandlerForPageViewPerformanceTelemetry(eventSource, writeGenericMethod, eventSourceOptionsType, eventSourceOptionsKeywordsProperty)); + #pragma warning disable 618 // SessionState telemetryHandlers.Add(typeof(SessionStateTelemetry), this.CreateHandlerForSessionStateTelemetry(eventSource, writeGenericMethod, eventSourceOptionsType, eventSourceOptionsKeywordsProperty)); @@ -697,6 +700,64 @@ private Action CreateHandlerForPageViewTelemetry(EventSource eventSo }; } + /// + /// Create handler for page view performance telemetry. + /// + private Action CreateHandlerForPageViewPerformanceTelemetry(EventSource eventSource, MethodInfo writeGenericMethod, Type eventSourceOptionsType, PropertyInfo eventSourceOptionsKeywordsProperty) + { + var eventSourceOptions = Activator.CreateInstance(eventSourceOptionsType); + var keywords = Keywords.PageViews; + eventSourceOptionsKeywordsProperty.SetValue(eventSourceOptions, keywords); + var dummyPageViewPerfData = new PageViewPerfData(); + var writeMethod = writeGenericMethod.MakeGenericMethod(new + { + PartA_iKey = this.dummyPartAiKeyValue, + PartA_Tags = this.dummyPartATagsValue, + PartB_PageViewPerfData = new + { + // The properties and layout should be the same as PageViewPerfData_types.cs (EventData_types.cs) + dummyPageViewPerfData.perfTotal, + dummyPageViewPerfData.networkConnect, + dummyPageViewPerfData.sentRequest, + dummyPageViewPerfData.receivedResponse, + dummyPageViewPerfData.domProcessing, + dummyPageViewPerfData.url, + dummyPageViewPerfData.duration, + dummyPageViewPerfData.ver, + dummyPageViewPerfData.name, + dummyPageViewPerfData.properties, + dummyPageViewPerfData.measurements, + } + }.GetType()); + + return (item) => + { + if (this.EventSourceInternal.IsEnabled(EventLevel.Verbose, keywords)) + { + item.Sanitize(); + var telemetryItem = item as PageViewTelemetry; + var data = telemetryItem.Data; + var extendedData = new + { + // The properties and layout should be the same as the anonymous type in the above MakeGenericMethod + PartA_iKey = telemetryItem.Context.InstrumentationKey, + PartA_Tags = telemetryItem.Context.SanitizedTags, + PartB_PageViewPerfData = new + { + data.url, + data.duration, + data.ver, + data.name, + data.properties, + data.measurements, + } + }; + + writeMethod.Invoke(eventSource, new object[] { PageViewTelemetry.TelemetryName, eventSourceOptions, extendedData }); + } + }; + } + /// /// Create handler for session state telemetry. /// diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/RichPayloadEventSource.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/RichPayloadEventSource.cs index f88dc6d909..0955b764f3 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/RichPayloadEventSource.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/RichPayloadEventSource.cs @@ -170,6 +170,22 @@ public void Process(ITelemetry item) telemetryItem.Data, Keywords.PageViews); } + else if (item is PageViewPerformanceTelemetry) + { + if (!this.EventSourceInternal.IsEnabled(EventLevel.Verbose, Keywords.PageViewPerformance)) + { + return; + } + + item.Sanitize(); + var telemetryItem = item as PageViewPerformanceTelemetry; + this.WriteEvent( + PageViewPerformanceTelemetry.TelemetryName, + telemetryItem.Context.InstrumentationKey, + telemetryItem.Context.SanitizedTags, + telemetryItem.Data, + Keywords.PageViewPerformance); + } #pragma warning disable 618 else if (item is SessionStateTelemetry) { From eb821f271ec392c8affe6b8f7be582757f00942b Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Wed, 18 Jul 2018 14:30:06 -0700 Subject: [PATCH 02/74] Add ExceptionDetailsInfo class --- .../net45/PublicAPI.Shipped.txt | 6 +++ .../net46/PublicAPI.Shipped.txt | 6 +++ .../netstandard1.3/PublicAPI.Shipped.txt | 6 +++ .../DataContracts/ExceptionTelemetryTest.cs | 40 ++++++++++++++++--- .../DataContracts/ExceptionDetailsInfo.cs | 39 ++++++++++++++++++ .../DataContracts/ExceptionTelemetry.cs | 19 +++++++-- 6 files changed, 107 insertions(+), 9 deletions(-) create mode 100644 src/Microsoft.ApplicationInsights/DataContracts/ExceptionDetailsInfo.cs diff --git a/PublicAPI/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Shipped.txt b/PublicAPI/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Shipped.txt index 916d1e920e..48f1cc41a0 100644 --- a/PublicAPI/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Shipped.txt +++ b/PublicAPI/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Shipped.txt @@ -99,6 +99,11 @@ Microsoft.ApplicationInsights.DataContracts.ExceptionHandledAt Microsoft.ApplicationInsights.DataContracts.ExceptionHandledAt.Platform = 2 -> Microsoft.ApplicationInsights.DataContracts.ExceptionHandledAt Microsoft.ApplicationInsights.DataContracts.ExceptionHandledAt.Unhandled = 0 -> Microsoft.ApplicationInsights.DataContracts.ExceptionHandledAt Microsoft.ApplicationInsights.DataContracts.ExceptionHandledAt.UserCode = 1 -> Microsoft.ApplicationInsights.DataContracts.ExceptionHandledAt +Microsoft.ApplicationInsights.DataContracts.ExceptionDetailsInfo +Microsoft.ApplicationInsights.DataContracts.ExceptionDetailsInfo.TypeName.get -> string +Microsoft.ApplicationInsights.DataContracts.ExceptionDetailsInfo.TypeName.set -> void +Microsoft.ApplicationInsights.DataContracts.ExceptionDetailsInfo.Message.get -> string +Microsoft.ApplicationInsights.DataContracts.ExceptionDetailsInfo.Message.set -> void Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Context.get -> Microsoft.ApplicationInsights.DataContracts.TelemetryContext Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.DeepClone() -> Microsoft.ApplicationInsights.Channel.ITelemetry @@ -108,6 +113,7 @@ Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.ExceptionTelemetr Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.ExceptionTelemetry(System.Exception exception) -> void Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.HandledAt.get -> Microsoft.ApplicationInsights.DataContracts.ExceptionHandledAt Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.HandledAt.set -> void +Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.ExceptionDetailsInfoList.get -> System.Collections.Generic.IReadOnlyList Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Message.get -> string Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Message.set -> void Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Metrics.get -> System.Collections.Generic.IDictionary diff --git a/PublicAPI/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Shipped.txt b/PublicAPI/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Shipped.txt index 916d1e920e..48f1cc41a0 100644 --- a/PublicAPI/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Shipped.txt +++ b/PublicAPI/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Shipped.txt @@ -99,6 +99,11 @@ Microsoft.ApplicationInsights.DataContracts.ExceptionHandledAt Microsoft.ApplicationInsights.DataContracts.ExceptionHandledAt.Platform = 2 -> Microsoft.ApplicationInsights.DataContracts.ExceptionHandledAt Microsoft.ApplicationInsights.DataContracts.ExceptionHandledAt.Unhandled = 0 -> Microsoft.ApplicationInsights.DataContracts.ExceptionHandledAt Microsoft.ApplicationInsights.DataContracts.ExceptionHandledAt.UserCode = 1 -> Microsoft.ApplicationInsights.DataContracts.ExceptionHandledAt +Microsoft.ApplicationInsights.DataContracts.ExceptionDetailsInfo +Microsoft.ApplicationInsights.DataContracts.ExceptionDetailsInfo.TypeName.get -> string +Microsoft.ApplicationInsights.DataContracts.ExceptionDetailsInfo.TypeName.set -> void +Microsoft.ApplicationInsights.DataContracts.ExceptionDetailsInfo.Message.get -> string +Microsoft.ApplicationInsights.DataContracts.ExceptionDetailsInfo.Message.set -> void Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Context.get -> Microsoft.ApplicationInsights.DataContracts.TelemetryContext Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.DeepClone() -> Microsoft.ApplicationInsights.Channel.ITelemetry @@ -108,6 +113,7 @@ Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.ExceptionTelemetr Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.ExceptionTelemetry(System.Exception exception) -> void Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.HandledAt.get -> Microsoft.ApplicationInsights.DataContracts.ExceptionHandledAt Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.HandledAt.set -> void +Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.ExceptionDetailsInfoList.get -> System.Collections.Generic.IReadOnlyList Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Message.get -> string Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Message.set -> void Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Metrics.get -> System.Collections.Generic.IDictionary diff --git a/PublicAPI/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Shipped.txt b/PublicAPI/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Shipped.txt index 0994669abc..b6657d9b79 100644 --- a/PublicAPI/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Shipped.txt +++ b/PublicAPI/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Shipped.txt @@ -99,6 +99,11 @@ Microsoft.ApplicationInsights.DataContracts.ExceptionHandledAt Microsoft.ApplicationInsights.DataContracts.ExceptionHandledAt.Platform = 2 -> Microsoft.ApplicationInsights.DataContracts.ExceptionHandledAt Microsoft.ApplicationInsights.DataContracts.ExceptionHandledAt.Unhandled = 0 -> Microsoft.ApplicationInsights.DataContracts.ExceptionHandledAt Microsoft.ApplicationInsights.DataContracts.ExceptionHandledAt.UserCode = 1 -> Microsoft.ApplicationInsights.DataContracts.ExceptionHandledAt +Microsoft.ApplicationInsights.DataContracts.ExceptionDetailsInfo +Microsoft.ApplicationInsights.DataContracts.ExceptionDetailsInfo.TypeName.get -> string +Microsoft.ApplicationInsights.DataContracts.ExceptionDetailsInfo.TypeName.set -> void +Microsoft.ApplicationInsights.DataContracts.ExceptionDetailsInfo.Message.get -> string +Microsoft.ApplicationInsights.DataContracts.ExceptionDetailsInfo.Message.set -> void Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Context.get -> Microsoft.ApplicationInsights.DataContracts.TelemetryContext Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.DeepClone() -> Microsoft.ApplicationInsights.Channel.ITelemetry @@ -108,6 +113,7 @@ Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.ExceptionTelemetr Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.ExceptionTelemetry(System.Exception exception) -> void Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.HandledAt.get -> Microsoft.ApplicationInsights.DataContracts.ExceptionHandledAt Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.HandledAt.set -> void +Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.ExceptionDetailsInfoList.get -> System.Collections.Generic.IReadOnlyList Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Message.get -> string Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Message.set -> void Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Metrics.get -> System.Collections.Generic.IDictionary diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/ExceptionTelemetryTest.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/ExceptionTelemetryTest.cs index ebe4bb9f6e..3b2ad84ed0 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/ExceptionTelemetryTest.cs +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/ExceptionTelemetryTest.cs @@ -39,6 +39,28 @@ public void ExceptionTelemetryReturnsNonNullContext() Assert.IsNotNull(item.Context); } + [TestMethod] + public void ExceptionTelemetryReturnsNullExceptionDetails() + { + ExceptionTelemetry item = new ExceptionTelemetry(); + Assert.IsNull(item.ExceptionDetailsInfoList); + } + + [TestMethod] + public void ExceptionTelemetryExceptionDetailsUpdate() + { + var exception = new AggregateException("Test Exception", new Exception()); + ExceptionTelemetry item = new ExceptionTelemetry(exception); + IReadOnlyList newExceptionDetails = item.ExceptionDetailsInfoList; + string modifiedMessage = "Modified Message"; + string modifiedTypeName = "Modified TypeName"; + + newExceptionDetails[0].Message = modifiedMessage; + newExceptionDetails[0].TypeName = modifiedTypeName; + Assert.AreEqual(modifiedMessage, item.Exceptions[0].message); + Assert.AreEqual(modifiedTypeName, item.Exceptions[0].typeName); + } + [TestMethod] public void ExceptionsPropertyIsInternalUntilWeSortOutPublicInterface() { @@ -53,6 +75,7 @@ public void ConstructorAddsExceptionToExceptionPropertyAndExceptionsCollectionPr Assert.AreSame(constructorException, testExceptionTelemetry.Exception); Assert.AreEqual(constructorException.Message, testExceptionTelemetry.Exceptions.First().message); + Assert.AreEqual(constructorException.Message, testExceptionTelemetry.ExceptionDetailsInfoList.First().Message); } [TestMethod] @@ -66,6 +89,7 @@ public void ExceptionPropertySetterReplacesExceptionDetailsInExceptionsCollectio Assert.AreSame(nextException, testExceptionTelemetry.Exception); Assert.AreEqual(nextException.Message, testExceptionTelemetry.Exceptions.First().message); + Assert.AreEqual(nextException.Message, testExceptionTelemetry.ExceptionDetailsInfoList.First().Message); } #pragma warning disable 618 @@ -344,9 +368,12 @@ public void ExceptionPropertySetterHandlesAggregateExceptionsWithMultipleNestedE }; Assert.AreEqual(expectedSequence.Length, telemetry.Exceptions.Count); - int counter = 0; - foreach (ExceptionDetails details in telemetry.Exceptions) + Assert.AreEqual(expectedSequence.Length, telemetry.ExceptionDetailsInfoList.Count); + for(int counter = 0; counter < expectedSequence.Length; counter++) { + ExceptionDetails details = telemetry.Exceptions[counter]; + ExceptionDetailsInfo newExceptionDetails = telemetry.ExceptionDetailsInfoList[counter]; + Assert.ReferenceEquals(details, newExceptionDetails); if (details.typeName == "System.AggregateException") { AssertEx.StartsWith(expectedSequence[counter], details.message); @@ -355,7 +382,6 @@ public void ExceptionPropertySetterHandlesAggregateExceptionsWithMultipleNestedE { Assert.AreEqual(expectedSequence[counter], details.message); } - counter++; } } @@ -374,9 +400,12 @@ public void ExceptionPropertySetterHandlesAggregateExceptionsWithMultipleNestedE ExceptionTelemetry telemetry = new ExceptionTelemetry { Exception = rootLevelException }; Assert.AreEqual(Constants.MaxExceptionCountToSave + 1, telemetry.Exceptions.Count); - int counter = 0; - foreach (ExceptionDetails details in telemetry.Exceptions.Take(Constants.MaxExceptionCountToSave)) + Assert.AreEqual(Constants.MaxExceptionCountToSave + 1, telemetry.ExceptionDetailsInfoList.Count); + for(int counter = 0; counter < telemetry.Exceptions.Count; counter++) { + ExceptionDetails details = telemetry.Exceptions[counter]; + ExceptionDetailsInfo newExceptionDetails = telemetry.ExceptionDetailsInfoList[counter]; + Assert.ReferenceEquals(details, newExceptionDetails); if (details.typeName == "System.AggregateException") { AssertEx.StartsWith(counter.ToString(CultureInfo.InvariantCulture), details.message); @@ -385,7 +414,6 @@ public void ExceptionPropertySetterHandlesAggregateExceptionsWithMultipleNestedE { Assert.AreEqual(counter.ToString(CultureInfo.InvariantCulture), details.message); } - counter++; } ExceptionDetails first = telemetry.Exceptions.First(); diff --git a/src/Microsoft.ApplicationInsights/DataContracts/ExceptionDetailsInfo.cs b/src/Microsoft.ApplicationInsights/DataContracts/ExceptionDetailsInfo.cs new file mode 100644 index 0000000000..0c091a1702 --- /dev/null +++ b/src/Microsoft.ApplicationInsights/DataContracts/ExceptionDetailsInfo.cs @@ -0,0 +1,39 @@ +namespace Microsoft.ApplicationInsights.DataContracts +{ + using Microsoft.ApplicationInsights.Extensibility.Implementation.External; + + /// + /// Wrapper class for that lets user gets/sets TypeName and Message. + /// + public sealed class ExceptionDetailsInfo + { + private readonly ExceptionDetails internalExceptionDetails = null; + + /// + /// Constructs the + /// + /// Instance of + internal ExceptionDetailsInfo(ExceptionDetails exceptionDetails) + { + this.internalExceptionDetails = exceptionDetails; + } + + /// + /// Gets or sets type name of the underlying that this object represents. + /// + public string TypeName + { + get => this.internalExceptionDetails.typeName; + set => this.internalExceptionDetails.typeName = value; + } + + /// + /// Gets or sets message name of the underlying that this object represents. + /// + public string Message + { + get => this.internalExceptionDetails.message; + set => this.internalExceptionDetails.message = value; + } + } +} diff --git a/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs index 75fafb93ec..f9c61ca14e 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; using System.Globalization; + using System.Linq; using Microsoft.ApplicationInsights.Channel; using Microsoft.ApplicationInsights.Extensibility.Implementation; using Microsoft.ApplicationInsights.Extensibility.Implementation.External; @@ -11,13 +12,14 @@ /// Telemetry type used to track exceptions. /// Learn more /// - public sealed class ExceptionTelemetry : ITelemetry, ISupportProperties, ISupportSampling, ISupportMetrics + public sealed class ExceptionTelemetry : ITelemetry, ISupportProperties, ISupportSampling, ISupportMetrics { internal const string TelemetryName = "Exception"; internal readonly string BaseType = typeof(ExceptionData).Name; internal readonly ExceptionData Data; private readonly TelemetryContext context; + private IReadOnlyList exceptionDetailsInfoList; private Exception exception; private string message; @@ -169,6 +171,18 @@ public IDictionary Metrics get { return this.Data.measurements; } } + /// + /// Gets the list of . User can modify the contents of individual object, but + /// not the list itself. + /// + public IReadOnlyList ExceptionDetailsInfoList + { + get + { + return this.exceptionDetailsInfoList; + } + } + /// /// Gets a dictionary of application-defined property names and values providing additional information about this exception. /// Learn more @@ -216,8 +230,6 @@ public ITelemetry DeepClone() /// public void SetParsedStack(System.Diagnostics.StackFrame[] frames) { - List orderedStackTrace = new List(); - if (this.Exceptions != null && this.Exceptions.Count > 0) { if (frames != null && frames.Length > 0) @@ -312,6 +324,7 @@ private void UpdateExceptions(Exception exception) } this.Data.exceptions = exceptions; + this.exceptionDetailsInfoList = exceptions.Select(ex => new ExceptionDetailsInfo(ex)).ToList().AsReadOnly(); } } } From 4c843be573b11a7b5868711ad8db12e9f5804562 Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Wed, 18 Jul 2018 16:21:17 -0700 Subject: [PATCH 03/74] unit test fix --- .../Shared/DataContracts/ExceptionTelemetryTest.cs | 6 +++--- .../DataContracts/ExceptionDetailsInfo.cs | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/ExceptionTelemetryTest.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/ExceptionTelemetryTest.cs index 3b2ad84ed0..b9e0d6781f 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/ExceptionTelemetryTest.cs +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/ExceptionTelemetryTest.cs @@ -373,7 +373,7 @@ public void ExceptionPropertySetterHandlesAggregateExceptionsWithMultipleNestedE { ExceptionDetails details = telemetry.Exceptions[counter]; ExceptionDetailsInfo newExceptionDetails = telemetry.ExceptionDetailsInfoList[counter]; - Assert.ReferenceEquals(details, newExceptionDetails); + Assert.IsTrue(ReferenceEquals(details, newExceptionDetails.InternalExceptionDetails)); if (details.typeName == "System.AggregateException") { AssertEx.StartsWith(expectedSequence[counter], details.message); @@ -401,11 +401,11 @@ public void ExceptionPropertySetterHandlesAggregateExceptionsWithMultipleNestedE Assert.AreEqual(Constants.MaxExceptionCountToSave + 1, telemetry.Exceptions.Count); Assert.AreEqual(Constants.MaxExceptionCountToSave + 1, telemetry.ExceptionDetailsInfoList.Count); - for(int counter = 0; counter < telemetry.Exceptions.Count; counter++) + for(int counter = 0; counter < Constants.MaxExceptionCountToSave; counter++) { ExceptionDetails details = telemetry.Exceptions[counter]; ExceptionDetailsInfo newExceptionDetails = telemetry.ExceptionDetailsInfoList[counter]; - Assert.ReferenceEquals(details, newExceptionDetails); + Assert.IsTrue(ReferenceEquals(details, newExceptionDetails.InternalExceptionDetails)); if (details.typeName == "System.AggregateException") { AssertEx.StartsWith(counter.ToString(CultureInfo.InvariantCulture), details.message); diff --git a/src/Microsoft.ApplicationInsights/DataContracts/ExceptionDetailsInfo.cs b/src/Microsoft.ApplicationInsights/DataContracts/ExceptionDetailsInfo.cs index 0c091a1702..b042a4e4d1 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/ExceptionDetailsInfo.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/ExceptionDetailsInfo.cs @@ -7,7 +7,7 @@ /// public sealed class ExceptionDetailsInfo { - private readonly ExceptionDetails internalExceptionDetails = null; + internal readonly ExceptionDetails InternalExceptionDetails = null; /// /// Constructs the @@ -15,7 +15,7 @@ public sealed class ExceptionDetailsInfo /// Instance of internal ExceptionDetailsInfo(ExceptionDetails exceptionDetails) { - this.internalExceptionDetails = exceptionDetails; + this.InternalExceptionDetails = exceptionDetails; } /// @@ -23,8 +23,8 @@ internal ExceptionDetailsInfo(ExceptionDetails exceptionDetails) /// public string TypeName { - get => this.internalExceptionDetails.typeName; - set => this.internalExceptionDetails.typeName = value; + get => this.InternalExceptionDetails.typeName; + set => this.InternalExceptionDetails.typeName = value; } /// @@ -32,8 +32,8 @@ public string TypeName /// public string Message { - get => this.internalExceptionDetails.message; - set => this.internalExceptionDetails.message = value; + get => this.InternalExceptionDetails.message; + set => this.InternalExceptionDetails.message = value; } } } From cc0df07b60be0253e9df4510139c73557cb78805 Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Thu, 19 Jul 2018 12:51:04 -0700 Subject: [PATCH 04/74] Added GlobalProperties on TelemetryContext which is a distinct collection from ISupportProperties. Obsolete the current Properties. --- CHANGELOG.md | 2 ++ .../net45/PublicAPI.Shipped.txt | 1 + .../net46/PublicAPI.Shipped.txt | 1 + .../netstandard1.3/PublicAPI.Shipped.txt | 1 + .../DataContracts/TelemetryContext.cs | 3 ++- 5 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d37650ea3..9c6c9ae162 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ This changelog will be used to generate documentation on [release notes page](http://azure.microsoft.com/documentation/articles/app-insights-release-notes-dotnet/). +## Version 2.8.0-beta1 +- [Add a new distict properties collection, GlobalProperties, on TelemetryContext, and obsolete the Properties on TelemetryContext.](https://github.com/Microsoft/ApplicationInsights-dotnet/issues/820) ## Version 2.7.0-beta3 - [Allow to set flags on event](https://github.com/Microsoft/ApplicationInsights-dotnet/issues/844). It will be used in conjunction with the feature that will allow to keep IP addresses. diff --git a/PublicAPI/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Shipped.txt b/PublicAPI/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Shipped.txt index 916d1e920e..43384b30c0 100644 --- a/PublicAPI/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Shipped.txt +++ b/PublicAPI/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Shipped.txt @@ -244,6 +244,7 @@ Microsoft.ApplicationInsights.DataContracts.TelemetryContext.InstrumentationKey. Microsoft.ApplicationInsights.DataContracts.TelemetryContext.Location.get -> Microsoft.ApplicationInsights.Extensibility.Implementation.LocationContext Microsoft.ApplicationInsights.DataContracts.TelemetryContext.Operation.get -> Microsoft.ApplicationInsights.Extensibility.Implementation.OperationContext Microsoft.ApplicationInsights.DataContracts.TelemetryContext.Properties.get -> System.Collections.Generic.IDictionary +Microsoft.ApplicationInsights.DataContracts.TelemetryContext.GlobalProperties.get -> System.Collections.Generic.IDictionary Microsoft.ApplicationInsights.DataContracts.TelemetryContext.Session.get -> Microsoft.ApplicationInsights.Extensibility.Implementation.SessionContext Microsoft.ApplicationInsights.DataContracts.TelemetryContext.TelemetryContext() -> void Microsoft.ApplicationInsights.DataContracts.TelemetryContext.User.get -> Microsoft.ApplicationInsights.Extensibility.Implementation.UserContext diff --git a/PublicAPI/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Shipped.txt b/PublicAPI/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Shipped.txt index 916d1e920e..43384b30c0 100644 --- a/PublicAPI/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Shipped.txt +++ b/PublicAPI/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Shipped.txt @@ -244,6 +244,7 @@ Microsoft.ApplicationInsights.DataContracts.TelemetryContext.InstrumentationKey. Microsoft.ApplicationInsights.DataContracts.TelemetryContext.Location.get -> Microsoft.ApplicationInsights.Extensibility.Implementation.LocationContext Microsoft.ApplicationInsights.DataContracts.TelemetryContext.Operation.get -> Microsoft.ApplicationInsights.Extensibility.Implementation.OperationContext Microsoft.ApplicationInsights.DataContracts.TelemetryContext.Properties.get -> System.Collections.Generic.IDictionary +Microsoft.ApplicationInsights.DataContracts.TelemetryContext.GlobalProperties.get -> System.Collections.Generic.IDictionary Microsoft.ApplicationInsights.DataContracts.TelemetryContext.Session.get -> Microsoft.ApplicationInsights.Extensibility.Implementation.SessionContext Microsoft.ApplicationInsights.DataContracts.TelemetryContext.TelemetryContext() -> void Microsoft.ApplicationInsights.DataContracts.TelemetryContext.User.get -> Microsoft.ApplicationInsights.Extensibility.Implementation.UserContext diff --git a/PublicAPI/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Shipped.txt b/PublicAPI/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Shipped.txt index 0994669abc..265cc267e1 100644 --- a/PublicAPI/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Shipped.txt +++ b/PublicAPI/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Shipped.txt @@ -243,6 +243,7 @@ Microsoft.ApplicationInsights.DataContracts.TelemetryContext.InstrumentationKey. Microsoft.ApplicationInsights.DataContracts.TelemetryContext.Location.get -> Microsoft.ApplicationInsights.Extensibility.Implementation.LocationContext Microsoft.ApplicationInsights.DataContracts.TelemetryContext.Operation.get -> Microsoft.ApplicationInsights.Extensibility.Implementation.OperationContext Microsoft.ApplicationInsights.DataContracts.TelemetryContext.Properties.get -> System.Collections.Generic.IDictionary +Microsoft.ApplicationInsights.DataContracts.TelemetryContext.GlobalProperties.get -> System.Collections.Generic.IDictionary Microsoft.ApplicationInsights.DataContracts.TelemetryContext.Session.get -> Microsoft.ApplicationInsights.Extensibility.Implementation.SessionContext Microsoft.ApplicationInsights.DataContracts.TelemetryContext.TelemetryContext() -> void Microsoft.ApplicationInsights.DataContracts.TelemetryContext.User.get -> Microsoft.ApplicationInsights.Extensibility.Implementation.UserContext diff --git a/src/Microsoft.ApplicationInsights/DataContracts/TelemetryContext.cs b/src/Microsoft.ApplicationInsights/DataContracts/TelemetryContext.cs index bfc40703a4..2d342eb7f7 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/TelemetryContext.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/TelemetryContext.cs @@ -139,6 +139,7 @@ public LocationContext Location /// Gets a dictionary of application-defined property values. /// Learn more /// + [Obsolete("Use GlobalProperties to set global level properties. For properties at item level, use ISupportProperties.Properties.")] public IDictionary Properties { get { return this.properties; } @@ -149,7 +150,7 @@ public IDictionary Properties /// Future SDK versions could serialize this separately from the item level properties. /// Learn more /// - internal IDictionary GlobalProperties + public IDictionary GlobalProperties { get { return this.globalProperties; } } From a0bd54340ddba74e7cb7fefd4178f0da2ec8ac24 Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Thu, 19 Jul 2018 16:48:11 -0700 Subject: [PATCH 05/74] Add IExtension interface to support strongly typed extension for teleemtry types. --- .../Channel/ITelemetry.cs | 6 ++++ .../DataContracts/AvailabilityTelemetry.cs | 11 +++++++ .../DataContracts/DependencyTelemetry.cs | 10 +++++++ .../DataContracts/EventTelemetry.cs | 11 +++++++ .../DataContracts/ExceptionTelemetry.cs | 11 +++++++ .../DataContracts/MetricTelemetry.cs | 14 +++++++-- .../DataContracts/PageViewTelemetry.cs | 14 +++++++-- .../PerformanceCounterTelemetry.cs | 12 +++++++- .../DataContracts/RequestTelemetry.cs | 12 +++++++- .../DataContracts/SessionStateTelemetry.cs | 13 ++++++++- .../DataContracts/TraceTelemetry.cs | 11 +++++++ .../Extensibility/IExtension.cs | 13 +++++++++ .../Extensibility/ISerializationWriter.cs | 29 +++++++++++++++++++ .../Implementation/OperationTelemetry.cs | 5 ++++ .../Microsoft.ApplicationInsights.csproj | 12 +------- 15 files changed, 166 insertions(+), 18 deletions(-) create mode 100644 src/Microsoft.ApplicationInsights/Extensibility/IExtension.cs create mode 100644 src/Microsoft.ApplicationInsights/Extensibility/ISerializationWriter.cs diff --git a/src/Microsoft.ApplicationInsights/Channel/ITelemetry.cs b/src/Microsoft.ApplicationInsights/Channel/ITelemetry.cs index d4043ad045..bea3e655ed 100644 --- a/src/Microsoft.ApplicationInsights/Channel/ITelemetry.cs +++ b/src/Microsoft.ApplicationInsights/Channel/ITelemetry.cs @@ -2,6 +2,7 @@ { using System; using Microsoft.ApplicationInsights.DataContracts; + using Microsoft.ApplicationInsights.Extensibility; /// /// The base telemetry type for application insights. @@ -18,6 +19,11 @@ public interface ITelemetry /// TelemetryContext Context { get; } + /// + /// Gets or sets gets the extension used to extend this telemetry instance using new strong typed object. + /// + IExtension Extension { get; set; } + /// /// Gets or sets the value that defines absolute order of the telemetry item. /// diff --git a/src/Microsoft.ApplicationInsights/DataContracts/AvailabilityTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/AvailabilityTelemetry.cs index 8c0409cfd0..3dfbe192ea 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/AvailabilityTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/AvailabilityTelemetry.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Globalization; using Microsoft.ApplicationInsights.Channel; + using Microsoft.ApplicationInsights.Extensibility; using Microsoft.ApplicationInsights.Extensibility.Implementation; using Microsoft.ApplicationInsights.Extensibility.Implementation.External; @@ -19,6 +20,7 @@ public sealed class AvailabilityTelemetry : ITelemetry, ISupportProperties, ISup internal readonly string BaseType = typeof(AvailabilityData).Name; internal readonly AvailabilityData Data; private readonly TelemetryContext context; + private IExtension extension; /// /// Initializes a new instance of the class with empty properties. @@ -131,6 +133,15 @@ public TelemetryContext Context get { return this.context; } } + /// + /// Gets or sets gets the extension used to extend this telemetry instance using new strong typed object. + /// + public IExtension Extension + { + get { return this.extension; } + set { this.extension = value; } + } + /// /// Gets a dictionary of application-defined property names and values providing additional information about this availability test run. /// Learn more diff --git a/src/Microsoft.ApplicationInsights/DataContracts/DependencyTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/DependencyTelemetry.cs index 55a7e0d86f..a0b7257088 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/DependencyTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/DependencyTelemetry.cs @@ -23,6 +23,7 @@ public sealed class DependencyTelemetry : OperationTelemetry, ITelemetry, ISuppo internal readonly RemoteDependencyData InternalData; private readonly TelemetryContext context; + private IExtension extension; private IDictionary operationDetails; private double? samplingPercentage; @@ -124,6 +125,15 @@ public override TelemetryContext Context get { return this.context; } } + /// + /// Gets or sets gets the extension used to extend this telemetry instance using new strong typed object. + /// + public override IExtension Extension + { + get { return this.extension; } + set { this.extension = value; } + } + /// /// Gets or sets Dependency ID. /// diff --git a/src/Microsoft.ApplicationInsights/DataContracts/EventTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/EventTelemetry.cs index 172ce1fe19..7b4d60503b 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/EventTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/EventTelemetry.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Threading; using Microsoft.ApplicationInsights.Channel; + using Microsoft.ApplicationInsights.Extensibility; using Microsoft.ApplicationInsights.Extensibility.Implementation; using Microsoft.ApplicationInsights.Extensibility.Implementation.External; @@ -18,6 +19,7 @@ public sealed class EventTelemetry : ITelemetry, ISupportProperties, ISupportSam internal readonly string BaseType = typeof(EventData).Name; internal readonly EventData Data; private readonly TelemetryContext context; + private IExtension extension; private double? samplingPercentage; @@ -65,6 +67,15 @@ public TelemetryContext Context get { return this.context; } } + /// + /// Gets or sets gets the extension used to extend this telemetry instance using new strong typed object. + /// + public IExtension Extension + { + get { return this.extension; } + set { this.extension = value; } + } + /// /// Gets or sets the name of the event. /// diff --git a/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs index 75fafb93ec..46d12338b8 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Globalization; using Microsoft.ApplicationInsights.Channel; + using Microsoft.ApplicationInsights.Extensibility; using Microsoft.ApplicationInsights.Extensibility.Implementation; using Microsoft.ApplicationInsights.Extensibility.Implementation.External; @@ -18,6 +19,7 @@ public sealed class ExceptionTelemetry : ITelemetry, ISupportProperties, ISuppor internal readonly ExceptionData Data; private readonly TelemetryContext context; + private IExtension extension; private Exception exception; private string message; @@ -79,6 +81,15 @@ public TelemetryContext Context get { return this.context; } } + /// + /// Gets or sets gets the extension used to extend this telemetry instance using new strong typed object. + /// + public IExtension Extension + { + get { return this.extension; } + set { this.extension = value; } + } + /// /// Gets or sets the problemId. /// diff --git a/src/Microsoft.ApplicationInsights/DataContracts/MetricTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/MetricTelemetry.cs index a936256af0..4bff776d94 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/MetricTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/MetricTelemetry.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.ComponentModel; using Microsoft.ApplicationInsights.Channel; + using Microsoft.ApplicationInsights.Extensibility; using Microsoft.ApplicationInsights.Extensibility.Implementation; using Microsoft.ApplicationInsights.Extensibility.Implementation.External; @@ -15,10 +16,10 @@ public sealed class MetricTelemetry : ITelemetry, ISupportProperties { internal const string TelemetryName = "Metric"; - internal readonly string BaseType = typeof(MetricData).Name; - + internal readonly string BaseType = typeof(MetricData).Name; internal readonly MetricData Data; internal readonly DataPoint Metric; + private IExtension extension; /// /// Initializes a new instance of the class with empty @@ -148,6 +149,15 @@ private MetricTelemetry(MetricTelemetry source) /// public TelemetryContext Context { get; } + /// + /// Gets or sets gets the extension used to extend this telemetry instance using new strong typed object. + /// + public IExtension Extension + { + get { return this.extension; } + set { this.extension = value; } + } + /// /// Gets or sets the name of the metric. /// diff --git a/src/Microsoft.ApplicationInsights/DataContracts/PageViewTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/PageViewTelemetry.cs index a5442dd0a1..6ff658c8c7 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/PageViewTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/PageViewTelemetry.cs @@ -5,6 +5,7 @@ using System.Globalization; using System.Threading; using Microsoft.ApplicationInsights.Channel; + using Microsoft.ApplicationInsights.Extensibility; using Microsoft.ApplicationInsights.Extensibility.Implementation; using Microsoft.ApplicationInsights.Extensibility.Implementation.External; @@ -21,10 +22,10 @@ public sealed class PageViewTelemetry : ITelemetry, ISupportProperties, ISupport { internal const string TelemetryName = "PageView"; - internal readonly string BaseType = typeof(PageViewData).Name; - + internal readonly string BaseType = typeof(PageViewData).Name; internal readonly PageViewData Data; private readonly TelemetryContext context; + private IExtension extension; private double? samplingPercentage; @@ -75,6 +76,15 @@ public TelemetryContext Context get { return this.context; } } + /// + /// Gets or sets gets the extension used to extend this telemetry instance using new strong typed object. + /// + public IExtension Extension + { + get { return this.extension; } + set { this.extension = value; } + } + /// /// Gets or sets page view ID. /// diff --git a/src/Microsoft.ApplicationInsights/DataContracts/PerformanceCounterTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/PerformanceCounterTelemetry.cs index 7c89011484..325b3bf2d7 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/PerformanceCounterTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/PerformanceCounterTelemetry.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using Channel; + using Microsoft.ApplicationInsights.Extensibility; /// /// The class that represents information about performance counters. @@ -12,7 +13,7 @@ public sealed class PerformanceCounterTelemetry : ITelemetry, ISupportProperties { internal readonly MetricTelemetry Data; - + private IExtension extension; private string categoryName = string.Empty; private string counterName = string.Empty; @@ -94,6 +95,15 @@ public TelemetryContext Context } } + /// + /// Gets or sets gets the extension used to extend this telemetry instance using new strong typed object. + /// + public IExtension Extension + { + get { return this.extension; } + set { this.extension = value; } + } + /// /// Gets or sets the counter value. /// diff --git a/src/Microsoft.ApplicationInsights/DataContracts/RequestTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/RequestTelemetry.cs index 12f65d7267..d7a5eb7b0a 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/RequestTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/RequestTelemetry.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Globalization; using Microsoft.ApplicationInsights.Channel; + using Microsoft.ApplicationInsights.Extensibility; using Microsoft.ApplicationInsights.Extensibility.Implementation; using Microsoft.ApplicationInsights.Extensibility.Implementation.External; @@ -24,7 +25,7 @@ public sealed class RequestTelemetry : OperationTelemetry, ITelemetry, ISupportP internal readonly RequestData Data; private readonly TelemetryContext context; private bool successFieldSet; - + private IExtension extension; private double? samplingPercentage; /// @@ -82,6 +83,15 @@ public override TelemetryContext Context get { return this.context; } } + /// + /// Gets or sets gets the extension used to extend this telemetry instance using new strong typed object. + /// + public override IExtension Extension + { + get { return this.extension; } + set { this.extension = value; } + } + /// /// Gets or sets Request ID. /// diff --git a/src/Microsoft.ApplicationInsights/DataContracts/SessionStateTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/SessionStateTelemetry.cs index 6079268db8..da4ade2d16 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/SessionStateTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/SessionStateTelemetry.cs @@ -2,6 +2,7 @@ { using System; using Microsoft.ApplicationInsights.Channel; + using Microsoft.ApplicationInsights.Extensibility; /// /// Telemetry type used to track user sessions. @@ -9,10 +10,11 @@ [Obsolete("Session state events are no longer used. This telemetry item will be sent as EventTelemetry.")] public sealed class SessionStateTelemetry : ITelemetry { - internal readonly EventTelemetry Data; + internal readonly EventTelemetry Data; private readonly string startEventName = "Session started"; private readonly string endEventName = "Session ended"; + private IExtension extension; /// /// Initializes a new instance of the class. @@ -67,6 +69,15 @@ public TelemetryContext Context get { return this.Data.Context; } } + /// + /// Gets or sets gets the extension used to extend this telemetry instance using new strong typed object. + /// + public IExtension Extension + { + get { return this.extension; } + set { this.extension = value; } + } + /// /// Gets or sets the value that defines absolute order of the telemetry item. /// diff --git a/src/Microsoft.ApplicationInsights/DataContracts/TraceTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/TraceTelemetry.cs index 054c833699..40ebac0bed 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/TraceTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/TraceTelemetry.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; using Microsoft.ApplicationInsights.Channel; + using Microsoft.ApplicationInsights.Extensibility; using Microsoft.ApplicationInsights.Extensibility.Implementation; using Microsoft.ApplicationInsights.Extensibility.Implementation.External; @@ -18,6 +19,7 @@ public sealed class TraceTelemetry : ITelemetry, ISupportProperties, ISupportSam internal readonly string BaseType = typeof(MessageData).Name; internal readonly MessageData Data; private readonly TelemetryContext context; + private IExtension extension; private double? samplingPercentage; @@ -77,6 +79,15 @@ public TelemetryContext Context get { return this.context; } } + /// + /// Gets or sets gets the extension used to extend this telemetry instance using new strong typed object. + /// + public IExtension Extension + { + get { return this.extension; } + set { this.extension = value; } + } + /// /// Gets or sets the message text. For example, the text that would normally be written to a log file line. /// diff --git a/src/Microsoft.ApplicationInsights/Extensibility/IExtension.cs b/src/Microsoft.ApplicationInsights/Extensibility/IExtension.cs new file mode 100644 index 0000000000..06411e94e6 --- /dev/null +++ b/src/Microsoft.ApplicationInsights/Extensibility/IExtension.cs @@ -0,0 +1,13 @@ +namespace Microsoft.ApplicationInsights.Extensibility +{ + /// + /// The base interface for defining strongly typed extensions to the telemetry types. + /// + public interface IExtension + { + /// + /// Sanitizes the properties of the telemetry item based on DP constraints. + /// + void Serialize(ISerializationWriter serializationWriter); + } +} diff --git a/src/Microsoft.ApplicationInsights/Extensibility/ISerializationWriter.cs b/src/Microsoft.ApplicationInsights/Extensibility/ISerializationWriter.cs new file mode 100644 index 0000000000..a417da8c4d --- /dev/null +++ b/src/Microsoft.ApplicationInsights/Extensibility/ISerializationWriter.cs @@ -0,0 +1,29 @@ +namespace Microsoft.ApplicationInsights.Extensibility +{ + using System; + using System.Collections.Generic; + + /// + /// The interface for defining writers capable of serializing data into various formats. + /// + public interface ISerializationWriter + { + void WriteProperty(string name, string value); + + void WriteProperty(string name, double? value); + + void WriteProperty(string name, int? value); + + void WriteProperty(string name, bool? value); + + void WriteProperty(string name, TimeSpan? value); + + void WriteList(string name, IList items); + + void WriteDictionary(string name, IDictionary items); + + void WriteStartObject(string name); + + void WriteEndObject(string name); + } +} \ No newline at end of file diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/OperationTelemetry.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/OperationTelemetry.cs index f4db060d5d..bd87c0e7a4 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/OperationTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/OperationTelemetry.cs @@ -74,6 +74,11 @@ public DateTimeOffset StartTime /// public abstract string Sequence { get; set; } + /// + /// Gets or sets gets the extension used to extend this telemetry instance using new strong typed object. + /// + public abstract IExtension Extension { get; set; } + /// /// Gets or sets Time in StopWatch ticks representing begin time of the operation. Used internally /// for calculating duration between begin and end. diff --git a/src/Microsoft.ApplicationInsights/Microsoft.ApplicationInsights.csproj b/src/Microsoft.ApplicationInsights/Microsoft.ApplicationInsights.csproj index 2f8e05d4ab..2b5d2074e3 100644 --- a/src/Microsoft.ApplicationInsights/Microsoft.ApplicationInsights.csproj +++ b/src/Microsoft.ApplicationInsights/Microsoft.ApplicationInsights.csproj @@ -52,9 +52,7 @@ All - - All - + All @@ -67,14 +65,6 @@ - - - PublicAPI.Shipped.txt - - - PublicAPI.Unshipped.txt - - \ No newline at end of file From 49abc5f76859c63895ea502a0186746078010630 Mon Sep 17 00:00:00 2001 From: Sergey Kanzhelev Date: Thu, 19 Jul 2018 22:55:53 -0700 Subject: [PATCH 06/74] rich events fix --- .../Extensibility/Implementation/RichPayloadEventSource.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/RichPayloadEventSource.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/RichPayloadEventSource.cs index 59189eaadf..1b4f51ea12 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/RichPayloadEventSource.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/RichPayloadEventSource.cs @@ -198,6 +198,7 @@ public void Process(ITelemetry item) telemetryItem.Context.InstrumentationKey, telemetryItem.Context.SanitizedTags, telemetryItem.Data, + telemetryItem.Context.Flags, Keywords.PageViewPerformance); } #pragma warning disable 618 From b723515d3bf9423e1898e1b6d35315a250be549a Mon Sep 17 00:00:00 2001 From: Sergey Kanzhelev Date: Fri, 20 Jul 2018 00:11:44 -0700 Subject: [PATCH 07/74] added unit test --- .../net45/PublicAPI.Unshipped.txt | 2 + .../net46/PublicAPI.Unshipped.txt | 2 + .../netstandard1.3/PublicAPI.Unshipped.txt | 2 + .../PageViewPerformanceTelemetryTest.cs | 175 ++++++++++++++++++ ...ApplicationInsights.Shared.Tests.projitems | 3 +- .../PageViewPerformanceTelemetry.cs | 14 +- .../Implementation/JsonSerializer.cs | 3 +- 7 files changed, 197 insertions(+), 4 deletions(-) create mode 100644 Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/PageViewPerformanceTelemetryTest.cs diff --git a/PublicAPI/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Unshipped.txt b/PublicAPI/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Unshipped.txt index 5130bbb20f..36689f8d0e 100644 --- a/PublicAPI/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Unshipped.txt +++ b/PublicAPI/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Unshipped.txt @@ -1,4 +1,6 @@ Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Id.get -> string +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Id.set -> void Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Context.get -> Microsoft.ApplicationInsights.DataContracts.TelemetryContext Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.DeepClone() -> Microsoft.ApplicationInsights.Channel.ITelemetry Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.DomProcessing.get -> System.TimeSpan diff --git a/PublicAPI/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Unshipped.txt b/PublicAPI/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Unshipped.txt index 5130bbb20f..36689f8d0e 100644 --- a/PublicAPI/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Unshipped.txt +++ b/PublicAPI/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Unshipped.txt @@ -1,4 +1,6 @@ Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Id.get -> string +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Id.set -> void Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Context.get -> Microsoft.ApplicationInsights.DataContracts.TelemetryContext Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.DeepClone() -> Microsoft.ApplicationInsights.Channel.ITelemetry Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.DomProcessing.get -> System.TimeSpan diff --git a/PublicAPI/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Unshipped.txt b/PublicAPI/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Unshipped.txt index b74823fb00..bb7ac5d5cc 100644 --- a/PublicAPI/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Unshipped.txt +++ b/PublicAPI/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Unshipped.txt @@ -1,4 +1,6 @@ Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Id.get -> string +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Id.set -> void Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Context.get -> Microsoft.ApplicationInsights.DataContracts.TelemetryContext Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.DeepClone() -> Microsoft.ApplicationInsights.Channel.ITelemetry Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.DomProcessing.get -> System.TimeSpan diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/PageViewPerformanceTelemetryTest.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/PageViewPerformanceTelemetryTest.cs new file mode 100644 index 0000000000..41ab90e986 --- /dev/null +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/PageViewPerformanceTelemetryTest.cs @@ -0,0 +1,175 @@ +namespace Microsoft.ApplicationInsights.DataContracts +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.IO; + using System.Linq; + using System.Reflection; + using Microsoft.ApplicationInsights.Channel; + using Microsoft.ApplicationInsights.Extensibility; + using Microsoft.ApplicationInsights.Extensibility.Implementation; + using Microsoft.ApplicationInsights.TestFramework; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using CompareLogic = KellermanSoftware.CompareNetObjects.CompareLogic; + + + [TestClass] + public class PageViewPerformanceTelemetryTest + { + [TestMethod] + public void PageViewImplementsITelemetryContractConsistentlyWithOtherTelemetryTypes() + { + new ITelemetryTest().Run(); + } + + [TestMethod] + public void PageViewPerformanceTelemetryIsPublic() + { + Assert.IsTrue(typeof(PageViewPerformanceTelemetry).GetTypeInfo().IsPublic); + } + + [TestMethod] + public void PageViewPerformanceTelemetryReturnsNonNullContext() + { + PageViewPerformanceTelemetry item = new PageViewPerformanceTelemetry(); + Assert.IsNotNull(item.Context); + } + + [TestMethod] + public void PageViewPerformanceTelemetrySuppliesConstructorThatTakesNameParameter() + { + string expectedPageName = "My page view"; + var instance = new PageViewPerformanceTelemetry(expectedPageName); + Assert.AreEqual(expectedPageName, instance.Name); + } + + [TestMethod] + public void PageViewPerformanceTelemetryReturnsDefaultDurationAsTimespanZero() + { + PageViewPerformanceTelemetry item = new PageViewPerformanceTelemetry(); + Assert.AreEqual(TimeSpan.Zero, item.Duration); + } + + [TestMethod] + public void PageViewPerformanceTelemetrySerializesToJsonCorrectly() + { + var expected = new PageViewPerformanceTelemetry("My Page"); + expected.Url = new Uri("http://temp.org/page1"); + expected.Duration = TimeSpan.FromSeconds(123); + expected.Metrics.Add("Metric1", 30); + expected.Properties.Add("Property1", "Value1"); + + var item = TelemetryItemTestHelper.SerializeDeserializeTelemetryItem(expected); + + // NOTE: It's correct that we use the v1 name here, and therefore we test against it. + Assert.AreEqual(item.name, AI.ItemType.PageViewPerformance); + + Assert.AreEqual(typeof(AI.PageViewPerfData).Name, item.data.baseType); + Assert.AreEqual(2, item.data.baseData.ver); + Assert.AreEqual(expected.Name, item.data.baseData.name); + Assert.AreEqual(expected.Duration, TimeSpan.Parse(item.data.baseData.duration)); + Assert.AreEqual(expected.Url.ToString(), item.data.baseData.url); + + AssertEx.AreEqual(expected.Properties.ToArray(), item.data.baseData.properties.ToArray()); + } + + [TestMethod] + public void PageViewPerformanceTelemetryTelemetryPropertiesFromContextAndItemSerializesToPropertiesInJson() + { + var expected = new PageViewPerformanceTelemetry(); + expected.Context.GlobalProperties.Add("TestPropertyGlobal", "contextpropvalue"); + expected.Properties.Add("TestProperty", "TestPropertyValue"); + ((ITelemetry)expected).Sanitize(); + + Assert.AreEqual(1, expected.Properties.Count); + Assert.AreEqual(1, expected.Context.GlobalProperties.Count); + + Assert.IsTrue(expected.Properties.ContainsKey("TestProperty")); + Assert.IsTrue(expected.Context.GlobalProperties.ContainsKey("TestPropertyGlobal")); + + var item = TelemetryItemTestHelper.SerializeDeserializeTelemetryItem(expected); + + // Items added to both PageViewPerformanceTelemetry.Properties, and PageViewPerformanceTelemetry.Context.GlobalProperties are serialized to properties. + Assert.AreEqual(2, item.data.baseData.properties.Count); + Assert.IsTrue(item.data.baseData.properties.ContainsKey("TestPropertyGlobal")); + Assert.IsTrue(item.data.baseData.properties.ContainsKey("TestProperty")); + } + + [TestMethod] + public void SanitizeWillTrimAppropriateFields() + { + PageViewPerformanceTelemetry telemetry = new PageViewPerformanceTelemetry(); + telemetry.Name = new string('Z', Property.MaxNameLength + 1); + telemetry.Properties.Add(new string('X', Property.MaxDictionaryNameLength) + 'X', new string('X', Property.MaxValueLength + 1)); + telemetry.Properties.Add(new string('X', Property.MaxDictionaryNameLength) + 'Y', new string('X', Property.MaxValueLength + 1)); + telemetry.Metrics.Add(new string('Y', Property.MaxDictionaryNameLength) + 'X', 42.0); + telemetry.Metrics.Add(new string('Y', Property.MaxDictionaryNameLength) + 'Y', 42.0); + telemetry.Url = new Uri("http://foo.com/" + new string('Y', Property.MaxUrlLength + 1)); + + ((ITelemetry)telemetry).Sanitize(); + + Assert.AreEqual(new string('Z', Property.MaxNameLength), telemetry.Name); + + Assert.AreEqual(2, telemetry.Properties.Count); + string[] keys = telemetry.Properties.Keys.OrderBy(s => s).ToArray(); + string[] values = telemetry.Properties.Values.OrderBy(s => s).ToArray(); + Assert.AreEqual(new string('X', Property.MaxDictionaryNameLength), keys[1]); + Assert.AreEqual(new string('X', Property.MaxValueLength), values[1]); + Assert.AreEqual(new string('X', Property.MaxDictionaryNameLength - 3) + "1", keys[0]); + Assert.AreEqual(new string('X', Property.MaxValueLength), values[0]); + + Assert.AreEqual(2, telemetry.Metrics.Count); + keys = telemetry.Metrics.Keys.OrderBy(s => s).ToArray(); + Assert.AreEqual(new string('Y', Property.MaxDictionaryNameLength), keys[1]); + Assert.AreEqual(new string('Y', Property.MaxDictionaryNameLength - 3) + "1", keys[0]); + + Assert.AreEqual(new Uri("http://foo.com/" + new string('Y', Property.MaxUrlLength - 15)), telemetry.Url); + } + + [TestMethod] + public void SanitizePopulatesNameWithErrorBecauseItIsRequiredByEndpoint() + { + var telemetry = new PageViewPerformanceTelemetry { Name = null }; + + ((ITelemetry)telemetry).Sanitize(); + + Assert.AreEqual("n/a", telemetry.Name); + } + + [TestMethod] + public void PageViewPerformanceTelemetryImplementsISupportSamplingContract() + { + var telemetry = new PageViewPerformanceTelemetry(); + + Assert.IsNotNull(telemetry as ISupportSampling); + } + + [TestMethod] + public void PageViewPerformanceTelemetryHasCorrectValueOfSamplingPercentageAfterSerialization() + { + var telemetry = new PageViewPerformanceTelemetry("my page view"); + ((ISupportSampling)telemetry).SamplingPercentage = 10; + + var item = TelemetryItemTestHelper.SerializeDeserializeTelemetryItem(telemetry); + + Assert.AreEqual(10, item.sampleRate); + } + + [TestMethod] + public void PageViewPerformanceTelemetryDeepCloneCopiesAllProperties() + { + var pageView = new PageViewPerformanceTelemetry("My Page"); + pageView.Url = new Uri("http://temp.org/page1"); + pageView.Duration = TimeSpan.FromSeconds(123); + pageView.Metrics.Add("Metric1", 30); + pageView.Properties.Add("Property1", "Value1"); + + PageViewPerformanceTelemetry other = (PageViewPerformanceTelemetry)pageView.DeepClone(); + + CompareLogic deepComparator = new CompareLogic(); + var result = deepComparator.Compare(pageView, other); + Assert.IsTrue(result.AreEqual, result.DifferencesString); + } + } +} diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/Microsoft.ApplicationInsights.Shared.Tests.projitems b/Test/Microsoft.ApplicationInsights.Test/Shared/Microsoft.ApplicationInsights.Shared.Tests.projitems index 28b848cd0b..8778c13800 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/Microsoft.ApplicationInsights.Shared.Tests.projitems +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/Microsoft.ApplicationInsights.Shared.Tests.projitems @@ -10,6 +10,7 @@ + @@ -113,7 +114,7 @@ - + diff --git a/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs index 6d22ef39c8..df7a52f3ae 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs @@ -11,9 +11,9 @@ /// public sealed class PageViewPerformanceTelemetry : ITelemetry, ISupportProperties, ISupportSampling { - internal const string TelemetryName = "PageView"; + internal const string TelemetryName = "PageViewPerformance"; - internal readonly string BaseType = typeof(PageViewPerformanceTelemetry).Name; + internal readonly string BaseType = typeof(PageViewPerfData).Name; internal readonly PageViewPerfData Data; private readonly TelemetryContext context; @@ -67,6 +67,15 @@ public TelemetryContext Context get { return this.context; } } + /// + /// Gets or sets page view ID. + /// + public string Id + { + get { return this.Data.id; } + set { this.Data.id = value; } + } + /// /// Gets or sets the name of the page. /// @@ -205,6 +214,7 @@ void ITelemetry.Sanitize() this.Properties.SanitizeProperties(); this.Metrics.SanitizeMeasurements(); this.Url = this.Url.SanitizeUri(); + this.Id.SanitizeName(); } } } diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs index f50b73d3dd..826820b9b6 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs @@ -484,7 +484,7 @@ private static void SerializePageViewPerformanceTelemetry(PageViewPerformanceTel { writer.WriteStartObject(); - pageViewPerfTelemetry.WriteTelemetryName(writer, PageViewTelemetry.TelemetryName); + pageViewPerfTelemetry.WriteTelemetryName(writer, PageViewPerformanceTelemetry.TelemetryName); pageViewPerfTelemetry.WriteEnvelopeProperties(writer); writer.WritePropertyName("data"); { @@ -505,6 +505,7 @@ private static void SerializePageViewPerformanceTelemetry(PageViewPerformanceTel writer.WriteProperty("sentRequest", pageViewPerfTelemetry.Data.sentRequest); writer.WriteProperty("receivedResponse", pageViewPerfTelemetry.Data.receivedResponse); writer.WriteProperty("measurements", pageViewPerfTelemetry.Data.measurements); + Utils.CopyDictionary(pageViewPerfTelemetry.Context.GlobalProperties, pageViewPerfTelemetry.Data.properties); writer.WriteProperty("properties", pageViewPerfTelemetry.Data.properties); writer.WriteEndObject(); From 1cf6dac785245fc7952ae8b2da34be9c88769426 Mon Sep 17 00:00:00 2001 From: Sergey Kanzhelev Date: Fri, 20 Jul 2018 00:14:20 -0700 Subject: [PATCH 08/74] updated changelog --- CHANGELOG.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c6c9ae162..8766e48ba3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,11 +4,12 @@ This changelog will be used to generate documentation on [release notes page](ht ## Version 2.8.0-beta1 - [Add a new distict properties collection, GlobalProperties, on TelemetryContext, and obsolete the Properties on TelemetryContext.](https://github.com/Microsoft/ApplicationInsights-dotnet/issues/820) +- [Allow to track PageViewPerformance data type](https://github.com/Microsoft/ApplicationInsights-dotnet/issues/673). ## Version 2.7.0-beta3 - [Allow to set flags on event](https://github.com/Microsoft/ApplicationInsights-dotnet/issues/844). It will be used in conjunction with the feature that will allow to keep IP addresses. - [Fix: SerializationException resolving Activity in cross app-domain calls](https://github.com/Microsoft/ApplicationInsights-dotnet-server/issues/613) -- [Make HttpClient instance static to avoid re-creating with every transmission. This had caused connection/memory leaks in .net core 2.1] (https://github.com/Microsoft/ApplicationInsights-dotnet/issues/594) +- [Make HttpClient instance static to avoid re-creating with every transmission. This had caused connection/memory leaks in .net core 2.1](https://github.com/Microsoft/ApplicationInsights-dotnet/issues/594) Related: (https://github.com/Microsoft/ApplicationInsights-aspnetcore/issues/690) ## Version 2.7.0-beta2 @@ -55,7 +56,7 @@ This changelog will be used to generate documentation on [release notes page](ht - Remove calculation of sampling-score based on Context.User.Id [Issue #625](https://github.com/Microsoft/ApplicationInsights-dotnet/issues/625) - New sdk-driven "heartbeat" functionality added which sends health status at pre-configured intervals. See [extending heartbeat properties doc for more information](./docs/ExtendingHeartbeatProperties.md) - Fixes a bug in ServerTelemetryChannel which caused application to crash on non-windows platforms. - [Details on fix and workaround #654] (https://github.com/Microsoft/ApplicationInsights-dotnet/issues/654) + [Details on fix and workaround #654](https://github.com/Microsoft/ApplicationInsights-dotnet/issues/654) Original issue (https://github.com/Microsoft/ApplicationInsights-aspnetcore/issues/551) - [Fixed a bug with the `AdaptiveSamplingTelemetryProcessor` that would cause starvation over time. Issue #756 (dotnet-server)](https://github.com/Microsoft/ApplicationInsights-dotnet-server/issues/756) - Updated solution to build on Mac! @@ -99,7 +100,7 @@ This changelog will be used to generate documentation on [release notes page](ht - [Fixed a bug which caused SDK to stop sending telemetry.](https://github.com/Microsoft/ApplicationInsights-dotnet-server/issues/480) ## Version 2.3.0-beta3 -- [Added overloads of TelemetryClientExtensions.StartOperation.] (https://github.com/Microsoft/ApplicationInsights-dotnet/issues/163) +- [Added overloads of TelemetryClientExtensions.StartOperation.](https://github.com/Microsoft/ApplicationInsights-dotnet/issues/163) - Fire new ETW events for Operation Start/Stop. ## Version 2.3.0-beta2 From 69c4e0f0b4679d4b9295ff319d6876b474c92e89 Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Fri, 20 Jul 2018 01:28:10 -0700 Subject: [PATCH 09/74] 'updated --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d37650ea3..8be732813b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,8 +6,10 @@ This changelog will be used to generate documentation on [release notes page](ht ## Version 2.7.0-beta3 - [Allow to set flags on event](https://github.com/Microsoft/ApplicationInsights-dotnet/issues/844). It will be used in conjunction with the feature that will allow to keep IP addresses. - [Fix: SerializationException resolving Activity in cross app-domain calls](https://github.com/Microsoft/ApplicationInsights-dotnet-server/issues/613) -- [Make HttpClient instance static to avoid re-creating with every transmission. This had caused connection/memory leaks in .net core 2.1] (https://github.com/Microsoft/ApplicationInsights-dotnet/issues/594) +- [Make HttpClient instance static to avoid re-creating with every transmission. This had caused connection/memory leaks in .net core 2.1](https://github.com/Microsoft/ApplicationInsights-dotnet/issues/594) Related: (https://github.com/Microsoft/ApplicationInsights-aspnetcore/issues/690) +- Added method `ExceptionDetailsInfoList` on `ExceptionTelemetry` class that gives control to user to update exception +message and exception type of underlying `System.Exception` object that user wants to send to telemetry. Related discussion is [here](https://github.com/Microsoft/ApplicationInsights-dotnet/issues/498). ## Version 2.7.0-beta2 - [Fix: NullReferenceException if telemtery is tracked after TelemetryConfiguration is disposed](https://github.com/Microsoft/ApplicationInsights-dotnet-server/issues/928) From e15c33f8bdd815419f743b0f6b7059c24c58416a Mon Sep 17 00:00:00 2001 From: Dmitry-Matveev Date: Fri, 20 Jul 2018 10:25:49 -0700 Subject: [PATCH 10/74] Add Xml Doc back to Nuget --- AddXmlLanguage.targets | 6 ++++++ Common.props | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/AddXmlLanguage.targets b/AddXmlLanguage.targets index 7b7a508d2d..39cf879da7 100644 --- a/AddXmlLanguage.targets +++ b/AddXmlLanguage.targets @@ -64,4 +64,10 @@ + + + + + + \ No newline at end of file diff --git a/Common.props b/Common.props index 30d946a42d..ac97d9269a 100644 --- a/Common.props +++ b/Common.props @@ -32,4 +32,8 @@ true $(DefineConstants);TRACE + + + $(TargetsForTfmSpecificBuildOutput);AddXmlDocToNugetPackage + \ No newline at end of file From e41f2f02a5a62f99c0d6e418ed1f749e44e9ebb3 Mon Sep 17 00:00:00 2001 From: Dmitry-Matveev Date: Fri, 20 Jul 2018 10:46:25 -0700 Subject: [PATCH 11/74] Fix Linux Build --- AddXmlLanguage.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AddXmlLanguage.targets b/AddXmlLanguage.targets index 39cf879da7..0b33846033 100644 --- a/AddXmlLanguage.targets +++ b/AddXmlLanguage.targets @@ -65,7 +65,7 @@ - + From 26f70e3538d9d4f5e5d4dd48d4eb54f0fac6eab6 Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Fri, 20 Jul 2018 12:30:34 -0700 Subject: [PATCH 12/74] Added test for Extension in ITelemetry --- .../Shared/Channel/ITelemetryTest.cs | 32 ++++++++++++++++++- Test/TestFramework/Shared/StubTelemetry.cs | 2 ++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/Channel/ITelemetryTest.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/Channel/ITelemetryTest.cs index 536871a9c5..a5aed8fb67 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/Channel/ITelemetryTest.cs +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/Channel/ITelemetryTest.cs @@ -6,6 +6,7 @@ using Microsoft.ApplicationInsights.DataContracts; using AI; using Microsoft.VisualStudio.TestTools.UnitTesting; + using Microsoft.ApplicationInsights.Extensibility; internal class ITelemetryTest where TTelemetry : ITelemetry, new() @@ -18,6 +19,7 @@ public void Run() this.ClassShouldHaveParameterizedConstructorToSimplifyCreationOfValidTelemetryInstancesInUserCode(); this.ClassShouldImplementISupportCustomPropertiesIfItDefinesPropertiesProperty(); this.TestProperties(); + this.TestExtension(); this.SerializeWritesTimestampAsExpectedByEndpoint(); this.SerializeWritesSequenceAsExpectedByEndpoint(); this.SerializeWritesInstrumentationKeyAsExpectedByEndpoint(); @@ -25,10 +27,26 @@ public void Run() this.SerializeWritesDataBaseTypeAsExpectedByEndpoint(); } + private void TestExtension() + { + // Extention field exists + var extensionField = typeof(TTelemetry).GetRuntimeProperties().Any(p => p.Name == "Extension"); + Assert.IsNotNull(extensionField); + + TTelemetry tel = new TTelemetry(); + Assert.IsNull(tel.Extension, "Extension should be null by default"); + + // Set extension + var myExt = new MyExtension(); + tel.Extension = myExt; + + Assert.AreSame(myExt, tel.Extension, "Extension should be assignable."); + } + private void TestProperties() { foreach (PropertyInfo property in typeof(TTelemetry).GetRuntimeProperties()) - { + { this.TestProperty(property); } } @@ -237,5 +255,17 @@ private string ExtractTelemetryNameFromType(Type telemetryType) return result; } + + private class MyExtension : IExtension + { + int myIntField; + string myStringField; + + public void Serialize(ISerializationWriter serializationWriter) + { + serializationWriter.WriteProperty("myIntField", myIntField); + serializationWriter.WriteProperty("myStringField", myStringField); + } + } } } \ No newline at end of file diff --git a/Test/TestFramework/Shared/StubTelemetry.cs b/Test/TestFramework/Shared/StubTelemetry.cs index a012bae7fe..8e958132cf 100644 --- a/Test/TestFramework/Shared/StubTelemetry.cs +++ b/Test/TestFramework/Shared/StubTelemetry.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using Microsoft.ApplicationInsights.Channel; using Microsoft.ApplicationInsights.DataContracts; + using Microsoft.ApplicationInsights.Extensibility; using Microsoft.ApplicationInsights.Extensibility.Implementation; internal sealed class StubTelemetry : ITelemetry, ISupportProperties @@ -25,6 +26,7 @@ public StubTelemetry() public TelemetryContext Context { get; set; } public IDictionary Properties { get; set; } + public IExtension Extension { get; set; } public void Serialize(IJsonWriter writer) { From 1dbcc4c15bea5d3ad95e70f1188a71281d27382c Mon Sep 17 00:00:00 2001 From: Sergey Kanzhelev Date: Fri, 20 Jul 2018 15:41:46 -0700 Subject: [PATCH 13/74] fix unit test --- .../Shared/DataContracts/PageViewPerformanceTelemetryTest.cs | 2 +- .../DataContracts/PageViewPerformanceTelemetry.cs | 2 +- .../Extensibility/Implementation/JsonSerializer.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/PageViewPerformanceTelemetryTest.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/PageViewPerformanceTelemetryTest.cs index 41ab90e986..d4de5e358a 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/PageViewPerformanceTelemetryTest.cs +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/PageViewPerformanceTelemetryTest.cs @@ -65,7 +65,7 @@ public void PageViewPerformanceTelemetrySerializesToJsonCorrectly() // NOTE: It's correct that we use the v1 name here, and therefore we test against it. Assert.AreEqual(item.name, AI.ItemType.PageViewPerformance); - Assert.AreEqual(typeof(AI.PageViewPerfData).Name, item.data.baseType); + Assert.AreEqual(PageViewPerformanceTelemetry.BaseType, item.data.baseType); Assert.AreEqual(2, item.data.baseData.ver); Assert.AreEqual(expected.Name, item.data.baseData.name); Assert.AreEqual(expected.Duration, TimeSpan.Parse(item.data.baseData.duration)); diff --git a/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs index df7a52f3ae..29bdd7d4c9 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs @@ -13,7 +13,7 @@ public sealed class PageViewPerformanceTelemetry : ITelemetry, ISupportPropertie { internal const string TelemetryName = "PageViewPerformance"; - internal readonly string BaseType = typeof(PageViewPerfData).Name; + internal const string BaseType = "PageViewPerformanceData"; internal readonly PageViewPerfData Data; private readonly TelemetryContext context; diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs index 826820b9b6..ba515385ec 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs @@ -490,7 +490,7 @@ private static void SerializePageViewPerformanceTelemetry(PageViewPerformanceTel { writer.WriteStartObject(); - writer.WriteProperty("baseType", pageViewPerfTelemetry.BaseType); + writer.WriteProperty("baseType", PageViewPerformanceTelemetry.BaseType); writer.WritePropertyName("baseData"); { writer.WriteStartObject(); From e3c6a8b341933adda671a317dfaaf72fd6f1073a Mon Sep 17 00:00:00 2001 From: Sergey Kanzhelev Date: Fri, 20 Jul 2018 15:57:26 -0700 Subject: [PATCH 14/74] kick the build again --- .../DataContracts/PageViewPerformanceTelemetry.cs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs index 29bdd7d4c9..801dfbaa26 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs @@ -16,8 +16,6 @@ public sealed class PageViewPerformanceTelemetry : ITelemetry, ISupportPropertie internal const string BaseType = "PageViewPerformanceData"; internal readonly PageViewPerfData Data; - private readonly TelemetryContext context; - private double? samplingPercentage; /// @@ -26,7 +24,7 @@ public sealed class PageViewPerformanceTelemetry : ITelemetry, ISupportPropertie public PageViewPerformanceTelemetry() { this.Data = new PageViewPerfData(); - this.context = new TelemetryContext(this.Data.properties); + this.Context = new TelemetryContext(this.Data.properties); } /// @@ -46,7 +44,7 @@ public PageViewPerformanceTelemetry(string pageName) : this() private PageViewPerformanceTelemetry(PageViewPerformanceTelemetry source) { this.Data = source.Data.DeepClone(); - this.context = source.context.DeepClone(this.Data.properties); + this.Context = source.Context.DeepClone(this.Data.properties); } /// @@ -62,10 +60,7 @@ private PageViewPerformanceTelemetry(PageViewPerformanceTelemetry source) /// /// Gets the context associated with the current telemetry item. /// - public TelemetryContext Context - { - get { return this.context; } - } + public TelemetryContext Context { get; private set; } /// /// Gets or sets page view ID. From 137936e153e1b23b7cd3935e9bc0cb1cbcf39575 Mon Sep 17 00:00:00 2001 From: Alexander Kaplan Date: Fri, 20 Jul 2018 22:59:15 -0700 Subject: [PATCH 15/74] Constructing ExceptionTelemetry from custom data. --- .../net45/PublicAPI.Shipped.txt | 16 ++ .../net46/PublicAPI.Shipped.txt | 16 ++ .../netstandard1.3/PublicAPI.Shipped.txt | 16 ++ .../DataContracts/ExceptionTelemetryTest.cs | 101 +++++++++++- .../RichPayloadEventSourceTest.cs | 2 +- .../DataContracts/ExceptionDetailsInfo.cs | 24 ++- .../DataContracts/ExceptionInfo.cs | 85 ++++++++++ .../DataContracts/ExceptionTelemetry.cs | 156 ++++++++++++------ .../DataContracts/StackFrame.cs | 27 +++ .../Implementation/JsonSerializer.cs | 19 +-- ...RichPayloadEventSource.TelemetryHandler.cs | 4 +- .../Implementation/RichPayloadEventSource.cs | 2 +- 12 files changed, 395 insertions(+), 73 deletions(-) create mode 100644 src/Microsoft.ApplicationInsights/DataContracts/ExceptionInfo.cs create mode 100644 src/Microsoft.ApplicationInsights/DataContracts/StackFrame.cs diff --git a/PublicAPI/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Shipped.txt b/PublicAPI/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Shipped.txt index 48f1cc41a0..7c0e9b5ed0 100644 --- a/PublicAPI/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Shipped.txt +++ b/PublicAPI/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Shipped.txt @@ -100,10 +100,13 @@ Microsoft.ApplicationInsights.DataContracts.ExceptionHandledAt.Platform = 2 -> M Microsoft.ApplicationInsights.DataContracts.ExceptionHandledAt.Unhandled = 0 -> Microsoft.ApplicationInsights.DataContracts.ExceptionHandledAt Microsoft.ApplicationInsights.DataContracts.ExceptionHandledAt.UserCode = 1 -> Microsoft.ApplicationInsights.DataContracts.ExceptionHandledAt Microsoft.ApplicationInsights.DataContracts.ExceptionDetailsInfo +Microsoft.ApplicationInsights.DataContracts.ExceptionDetailsInfo.ExceptionDetailsInfo(int id, int outerId, string typeName, string message, bool hasFullStack, string stack, System.Collections.Generic.IEnumerable parsedStack) -> void Microsoft.ApplicationInsights.DataContracts.ExceptionDetailsInfo.TypeName.get -> string Microsoft.ApplicationInsights.DataContracts.ExceptionDetailsInfo.TypeName.set -> void Microsoft.ApplicationInsights.DataContracts.ExceptionDetailsInfo.Message.get -> string Microsoft.ApplicationInsights.DataContracts.ExceptionDetailsInfo.Message.set -> void +Microsoft.ApplicationInsights.DataContracts.StackFrame +Microsoft.ApplicationInsights.DataContracts.StackFrame.StackFrame(string assembly, string fileName, int level, int line, string method) -> void Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Context.get -> Microsoft.ApplicationInsights.DataContracts.TelemetryContext Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.DeepClone() -> Microsoft.ApplicationInsights.Channel.ITelemetry @@ -127,6 +130,19 @@ Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.SeverityLevel.get Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.SeverityLevel.set -> void Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Timestamp.get -> System.DateTimeOffset Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Timestamp.set -> void +Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.ExceptionInfo.get -> Microsoft.ApplicationInsights.DataContracts.ExceptionInfo +Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.ExceptionTelemetry(Microsoft.ApplicationInsights.DataContracts.ExceptionInfo exceptionInfo) -> void +Microsoft.ApplicationInsights.DataContracts.ExceptionInfo +Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.ExceptionDetailsInfoList.get -> System.Collections.Generic.IReadOnlyList +Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.ExceptionInfo(System.Collections.Generic.IEnumerable exceptionDetailsInfoList, Microsoft.ApplicationInsights.DataContracts.SeverityLevel? severityLevel, string problemId, System.Collections.Generic.IDictionary properties, System.Collections.Generic.IDictionary measurements) -> void +Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.Measurements.get -> System.Collections.Generic.IDictionary +Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.Measurements.set -> void +Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.ProblemId.get -> string +Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.ProblemId.set -> void +Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.Properties.get -> System.Collections.Generic.IDictionary +Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.Properties.set -> void +Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.SeverityLevel.get -> Microsoft.ApplicationInsights.DataContracts.SeverityLevel? +Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.SeverityLevel.set -> void Microsoft.ApplicationInsights.DataContracts.IJsonWriter Microsoft.ApplicationInsights.DataContracts.IJsonWriter.WriteComma() -> void Microsoft.ApplicationInsights.DataContracts.IJsonWriter.WriteEndArray() -> void diff --git a/PublicAPI/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Shipped.txt b/PublicAPI/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Shipped.txt index 48f1cc41a0..7c0e9b5ed0 100644 --- a/PublicAPI/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Shipped.txt +++ b/PublicAPI/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Shipped.txt @@ -100,10 +100,13 @@ Microsoft.ApplicationInsights.DataContracts.ExceptionHandledAt.Platform = 2 -> M Microsoft.ApplicationInsights.DataContracts.ExceptionHandledAt.Unhandled = 0 -> Microsoft.ApplicationInsights.DataContracts.ExceptionHandledAt Microsoft.ApplicationInsights.DataContracts.ExceptionHandledAt.UserCode = 1 -> Microsoft.ApplicationInsights.DataContracts.ExceptionHandledAt Microsoft.ApplicationInsights.DataContracts.ExceptionDetailsInfo +Microsoft.ApplicationInsights.DataContracts.ExceptionDetailsInfo.ExceptionDetailsInfo(int id, int outerId, string typeName, string message, bool hasFullStack, string stack, System.Collections.Generic.IEnumerable parsedStack) -> void Microsoft.ApplicationInsights.DataContracts.ExceptionDetailsInfo.TypeName.get -> string Microsoft.ApplicationInsights.DataContracts.ExceptionDetailsInfo.TypeName.set -> void Microsoft.ApplicationInsights.DataContracts.ExceptionDetailsInfo.Message.get -> string Microsoft.ApplicationInsights.DataContracts.ExceptionDetailsInfo.Message.set -> void +Microsoft.ApplicationInsights.DataContracts.StackFrame +Microsoft.ApplicationInsights.DataContracts.StackFrame.StackFrame(string assembly, string fileName, int level, int line, string method) -> void Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Context.get -> Microsoft.ApplicationInsights.DataContracts.TelemetryContext Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.DeepClone() -> Microsoft.ApplicationInsights.Channel.ITelemetry @@ -127,6 +130,19 @@ Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.SeverityLevel.get Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.SeverityLevel.set -> void Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Timestamp.get -> System.DateTimeOffset Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Timestamp.set -> void +Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.ExceptionInfo.get -> Microsoft.ApplicationInsights.DataContracts.ExceptionInfo +Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.ExceptionTelemetry(Microsoft.ApplicationInsights.DataContracts.ExceptionInfo exceptionInfo) -> void +Microsoft.ApplicationInsights.DataContracts.ExceptionInfo +Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.ExceptionDetailsInfoList.get -> System.Collections.Generic.IReadOnlyList +Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.ExceptionInfo(System.Collections.Generic.IEnumerable exceptionDetailsInfoList, Microsoft.ApplicationInsights.DataContracts.SeverityLevel? severityLevel, string problemId, System.Collections.Generic.IDictionary properties, System.Collections.Generic.IDictionary measurements) -> void +Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.Measurements.get -> System.Collections.Generic.IDictionary +Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.Measurements.set -> void +Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.ProblemId.get -> string +Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.ProblemId.set -> void +Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.Properties.get -> System.Collections.Generic.IDictionary +Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.Properties.set -> void +Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.SeverityLevel.get -> Microsoft.ApplicationInsights.DataContracts.SeverityLevel? +Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.SeverityLevel.set -> void Microsoft.ApplicationInsights.DataContracts.IJsonWriter Microsoft.ApplicationInsights.DataContracts.IJsonWriter.WriteComma() -> void Microsoft.ApplicationInsights.DataContracts.IJsonWriter.WriteEndArray() -> void diff --git a/PublicAPI/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Shipped.txt b/PublicAPI/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Shipped.txt index b6657d9b79..6adc792816 100644 --- a/PublicAPI/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Shipped.txt +++ b/PublicAPI/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Shipped.txt @@ -100,10 +100,13 @@ Microsoft.ApplicationInsights.DataContracts.ExceptionHandledAt.Platform = 2 -> M Microsoft.ApplicationInsights.DataContracts.ExceptionHandledAt.Unhandled = 0 -> Microsoft.ApplicationInsights.DataContracts.ExceptionHandledAt Microsoft.ApplicationInsights.DataContracts.ExceptionHandledAt.UserCode = 1 -> Microsoft.ApplicationInsights.DataContracts.ExceptionHandledAt Microsoft.ApplicationInsights.DataContracts.ExceptionDetailsInfo +Microsoft.ApplicationInsights.DataContracts.ExceptionDetailsInfo.ExceptionDetailsInfo(int id, int outerId, string typeName, string message, bool hasFullStack, string stack, System.Collections.Generic.IEnumerable parsedStack) -> void Microsoft.ApplicationInsights.DataContracts.ExceptionDetailsInfo.TypeName.get -> string Microsoft.ApplicationInsights.DataContracts.ExceptionDetailsInfo.TypeName.set -> void Microsoft.ApplicationInsights.DataContracts.ExceptionDetailsInfo.Message.get -> string Microsoft.ApplicationInsights.DataContracts.ExceptionDetailsInfo.Message.set -> void +Microsoft.ApplicationInsights.DataContracts.StackFrame +Microsoft.ApplicationInsights.DataContracts.StackFrame.StackFrame(string assembly, string fileName, int level, int line, string method) -> void Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Context.get -> Microsoft.ApplicationInsights.DataContracts.TelemetryContext Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.DeepClone() -> Microsoft.ApplicationInsights.Channel.ITelemetry @@ -126,6 +129,19 @@ Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.SeverityLevel.get Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.SeverityLevel.set -> void Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Timestamp.get -> System.DateTimeOffset Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Timestamp.set -> void +Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.ExceptionInfo.get -> Microsoft.ApplicationInsights.DataContracts.ExceptionInfo +Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.ExceptionTelemetry(Microsoft.ApplicationInsights.DataContracts.ExceptionInfo exceptionInfo) -> void +Microsoft.ApplicationInsights.DataContracts.ExceptionInfo +Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.ExceptionDetailsInfoList.get -> System.Collections.Generic.IReadOnlyList +Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.ExceptionInfo(System.Collections.Generic.IEnumerable exceptionDetailsInfoList, Microsoft.ApplicationInsights.DataContracts.SeverityLevel? severityLevel, string problemId, System.Collections.Generic.IDictionary properties, System.Collections.Generic.IDictionary measurements) -> void +Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.Measurements.get -> System.Collections.Generic.IDictionary +Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.Measurements.set -> void +Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.ProblemId.get -> string +Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.ProblemId.set -> void +Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.Properties.get -> System.Collections.Generic.IDictionary +Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.Properties.set -> void +Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.SeverityLevel.get -> Microsoft.ApplicationInsights.DataContracts.SeverityLevel? +Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.SeverityLevel.set -> void Microsoft.ApplicationInsights.DataContracts.IJsonWriter Microsoft.ApplicationInsights.DataContracts.IJsonWriter.WriteComma() -> void Microsoft.ApplicationInsights.DataContracts.IJsonWriter.WriteEndArray() -> void diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/ExceptionTelemetryTest.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/ExceptionTelemetryTest.cs index b9e0d6781f..149eb62632 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/ExceptionTelemetryTest.cs +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/ExceptionTelemetryTest.cs @@ -40,23 +40,118 @@ public void ExceptionTelemetryReturnsNonNullContext() } [TestMethod] - public void ExceptionTelemetryReturnsNullExceptionDetails() + public void ExceptionTelemetryCreatedBasedOnCustomData() { - ExceptionTelemetry item = new ExceptionTelemetry(); - Assert.IsNull(item.ExceptionDetailsInfoList); + // ARRANGE + var topLevelexceptionDetails = new ExceptionDetailsInfo(1, -1, "TopLevelException", "Top level exception", + true, "Top level exception stack", new[] + { + new StackFrame("Some.Assembly", "SomeFile.dll", 3, 33, "TopLevelMethod"), + new StackFrame("Some.Assembly", "SomeOtherFile.dll", 2, 22, "LowerLevelMethod"), + new StackFrame("Some.Assembly", "YetAnotherFile.dll", 1, 11, "LowLevelMethod") + }); + + var innerExceptionDetails = new ExceptionDetailsInfo(2, 1, "InnerException", "Inner exception", false, + "Inner exception stack", new[] + { + new StackFrame("Some.Assembly", "ImportantFile.dll", 2, 22, "InnerMethod"), + new StackFrame("Some.Assembly", "LessImportantFile.dll", 1, 11, "DeeperInnerMethod") + }); + + var exceptionInfo = new ExceptionInfo(new[] {topLevelexceptionDetails, innerExceptionDetails}, + SeverityLevel.Error, "ProblemId", + new Dictionary() {["property1"] = "value1", ["property2"] = "value2"}, + new Dictionary() {["property1"] = 1, ["property2"] = 2}); + + // ACT + ExceptionTelemetry item = new ExceptionTelemetry(exceptionInfo); + + item.ExceptionInfo.ExceptionDetailsInfoList[1].Message = "Inner exception modified"; + + // ASSERT + // use internal fields to validate + Assert.AreEqual(item.Data.Data.ver, 2); + Assert.AreEqual(item.Data.Data.problemId, "ProblemId"); + Assert.AreEqual(item.Data.Data.severityLevel, Extensibility.Implementation.External.SeverityLevel.Error); + + Assert.AreEqual(item.Data.Data.properties.Count, 2); + Assert.IsTrue(item.Data.Data.properties.Keys.Contains("property1")); + Assert.IsTrue(item.Data.Data.properties.Keys.Contains("property2")); + Assert.IsTrue(item.Data.Data.properties.Values.Contains("value1")); + Assert.IsTrue(item.Data.Data.properties.Values.Contains("value2")); + + Assert.AreEqual(item.Data.Data.measurements.Count, 2); + Assert.IsTrue(item.Data.Data.measurements.Keys.Contains("property1")); + Assert.IsTrue(item.Data.Data.measurements.Keys.Contains("property2")); + Assert.IsTrue(item.Data.Data.measurements.Values.Contains(1)); + Assert.IsTrue(item.Data.Data.measurements.Values.Contains(2)); + + Assert.AreEqual(item.Data.Data.exceptions.Count, 2); + + Assert.AreEqual(item.Data.Data.exceptions.First().id, 1); + Assert.AreEqual(item.Data.Data.exceptions.First().outerId, -1); + Assert.AreEqual(item.Data.Data.exceptions.First().typeName, "TopLevelException"); + Assert.AreEqual(item.Data.Data.exceptions.First().message, "Top level exception"); + Assert.AreEqual(item.Data.Data.exceptions.First().hasFullStack, true); + Assert.AreEqual(item.Data.Data.exceptions.First().stack, "Top level exception stack"); + Assert.AreEqual(item.Data.Data.exceptions.First().parsedStack.Count, 3); + + Assert.AreEqual(item.Data.Data.exceptions.First().parsedStack[0].assembly, "Some.Assembly"); + Assert.AreEqual(item.Data.Data.exceptions.First().parsedStack[0].fileName, "SomeFile.dll"); + Assert.AreEqual(item.Data.Data.exceptions.First().parsedStack[0].level, 3); + Assert.AreEqual(item.Data.Data.exceptions.First().parsedStack[0].line, 33); + Assert.AreEqual(item.Data.Data.exceptions.First().parsedStack[0].method, "TopLevelMethod"); + + Assert.AreEqual(item.Data.Data.exceptions.First().parsedStack[1].assembly, "Some.Assembly"); + Assert.AreEqual(item.Data.Data.exceptions.First().parsedStack[1].fileName, "SomeOtherFile.dll"); + Assert.AreEqual(item.Data.Data.exceptions.First().parsedStack[1].level, 2); + Assert.AreEqual(item.Data.Data.exceptions.First().parsedStack[1].line, 22); + Assert.AreEqual(item.Data.Data.exceptions.First().parsedStack[1].method, "LowerLevelMethod"); + + Assert.AreEqual(item.Data.Data.exceptions.First().parsedStack[2].assembly, "Some.Assembly"); + Assert.AreEqual(item.Data.Data.exceptions.First().parsedStack[2].fileName, "YetAnotherFile.dll"); + Assert.AreEqual(item.Data.Data.exceptions.First().parsedStack[2].level, 1); + Assert.AreEqual(item.Data.Data.exceptions.First().parsedStack[2].line, 11); + Assert.AreEqual(item.Data.Data.exceptions.First().parsedStack[2].method, "LowLevelMethod"); + + Assert.AreEqual(item.Data.Data.exceptions.Last().id, 2); + Assert.AreEqual(item.Data.Data.exceptions.Last().outerId, 1); + Assert.AreEqual(item.Data.Data.exceptions.Last().typeName, "InnerException"); + Assert.AreEqual(item.Data.Data.exceptions.Last().message, "Inner exception modified"); + Assert.AreEqual(item.Data.Data.exceptions.Last().hasFullStack, false); + Assert.AreEqual(item.Data.Data.exceptions.Last().stack, "Inner exception stack"); + Assert.AreEqual(item.Data.Data.exceptions.Last().parsedStack.Count, 2); + + Assert.AreEqual(item.Data.Data.exceptions.Last().parsedStack[0].assembly, "Some.Assembly"); + Assert.AreEqual(item.Data.Data.exceptions.Last().parsedStack[0].fileName, "ImportantFile.dll"); + Assert.AreEqual(item.Data.Data.exceptions.Last().parsedStack[0].level, 2); + Assert.AreEqual(item.Data.Data.exceptions.Last().parsedStack[0].line, 22); + Assert.AreEqual(item.Data.Data.exceptions.Last().parsedStack[0].method, "InnerMethod"); + + Assert.AreEqual(item.Data.Data.exceptions.Last().parsedStack[1].assembly, "Some.Assembly"); + Assert.AreEqual(item.Data.Data.exceptions.Last().parsedStack[1].fileName, "LessImportantFile.dll"); + Assert.AreEqual(item.Data.Data.exceptions.Last().parsedStack[1].level, 1); + Assert.AreEqual(item.Data.Data.exceptions.Last().parsedStack[1].line, 11); + Assert.AreEqual(item.Data.Data.exceptions.Last().parsedStack[1].method, "DeeperInnerMethod"); } [TestMethod] public void ExceptionTelemetryExceptionDetailsUpdate() { + // ARRANGE var exception = new AggregateException("Test Exception", new Exception()); ExceptionTelemetry item = new ExceptionTelemetry(exception); + + // ACT IReadOnlyList newExceptionDetails = item.ExceptionDetailsInfoList; + string modifiedMessage = "Modified Message"; string modifiedTypeName = "Modified TypeName"; newExceptionDetails[0].Message = modifiedMessage; newExceptionDetails[0].TypeName = modifiedTypeName; + + // ASSERT Assert.AreEqual(modifiedMessage, item.Exceptions[0].message); Assert.AreEqual(modifiedTypeName, item.Exceptions[0].typeName); } diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/Extensibility/Implementation/RichPayloadEventSourceTest.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/Extensibility/Implementation/RichPayloadEventSourceTest.cs index d6ce49935f..8e695667d6 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/Extensibility/Implementation/RichPayloadEventSourceTest.cs +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/Extensibility/Implementation/RichPayloadEventSourceTest.cs @@ -63,7 +63,7 @@ public void RichPayloadEventSourceEventSentTest() public void RichPayloadEventSourceExceptionSentTest() { var exceptionTelemetry = new ExceptionTelemetry(new SystemException("Test")); - exceptionTelemetry.Data.exceptions[0].parsedStack = new External.StackFrame[] { new External.StackFrame() }; + exceptionTelemetry.Data.Data.exceptions[0].parsedStack = new External.StackFrame[] { new External.StackFrame() }; this.DoTracking( RichPayloadEventSource.Keywords.Exceptions, diff --git a/src/Microsoft.ApplicationInsights/DataContracts/ExceptionDetailsInfo.cs b/src/Microsoft.ApplicationInsights/DataContracts/ExceptionDetailsInfo.cs index b042a4e4d1..ed39617b89 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/ExceptionDetailsInfo.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/ExceptionDetailsInfo.cs @@ -1,5 +1,7 @@ namespace Microsoft.ApplicationInsights.DataContracts { + using System.Collections.Generic; + using System.Linq; using Microsoft.ApplicationInsights.Extensibility.Implementation.External; /// @@ -10,9 +12,23 @@ public sealed class ExceptionDetailsInfo internal readonly ExceptionDetails InternalExceptionDetails = null; /// - /// Constructs the + /// Constructs the instance of . /// - /// Instance of + public ExceptionDetailsInfo(int id, int outerId, string typeName, string message, bool hasFullStack, + string stack, IEnumerable parsedStack) + { + this.InternalExceptionDetails = new ExceptionDetails() + { + id = id, + outerId = outerId, + typeName = typeName, + message = message, + hasFullStack = hasFullStack, + stack = stack, + parsedStack = parsedStack.Select(ps => ps.Data).ToList() + }; + } + internal ExceptionDetailsInfo(ExceptionDetails exceptionDetails) { this.InternalExceptionDetails = exceptionDetails; @@ -35,5 +51,7 @@ public string Message get => this.InternalExceptionDetails.message; set => this.InternalExceptionDetails.message = value; } + + internal ExceptionDetails ExceptionDetails => this.InternalExceptionDetails; } -} +} \ No newline at end of file diff --git a/src/Microsoft.ApplicationInsights/DataContracts/ExceptionInfo.cs b/src/Microsoft.ApplicationInsights/DataContracts/ExceptionInfo.cs new file mode 100644 index 0000000000..de18a72218 --- /dev/null +++ b/src/Microsoft.ApplicationInsights/DataContracts/ExceptionInfo.cs @@ -0,0 +1,85 @@ +namespace Microsoft.ApplicationInsights.DataContracts +{ + using System.Collections.Concurrent; + using System.Collections.Generic; + using System.Linq; + using Extensibility.Implementation; + using Extensibility.Implementation.External; + + /// + /// Wrapper class for that lets user provide exception data without having the actual Exception object. + /// + public sealed class ExceptionInfo + { + private readonly ExceptionData data; + + /// + /// Constructs the instance of + /// + public ExceptionInfo(IEnumerable exceptionDetailsInfoList, SeverityLevel? severityLevel, string problemId, + IDictionary properties, IDictionary measurements) + { + this.data = new ExceptionData + { + exceptions = exceptionDetailsInfoList.Select(edi => edi.ExceptionDetails).ToList(), + severityLevel = severityLevel.TranslateSeverityLevel(), + problemId = problemId, + properties = new ConcurrentDictionary(properties), + measurements = new ConcurrentDictionary(measurements) + }; + } + + internal ExceptionInfo(ExceptionData data) + { + this.data = data; + } + + /// + /// Gets a list of to modify as needed. + /// + public IReadOnlyList ExceptionDetailsInfoList => this.data.exceptions.Select(ed => new ExceptionDetailsInfo(ed)).ToList().AsReadOnly(); + + /// + /// Gets or sets Exception severity level. + /// + public SeverityLevel? SeverityLevel + { + get => this.data.severityLevel.TranslateSeverityLevel(); + set => this.data.severityLevel = value.TranslateSeverityLevel(); + } + + /// + /// Gets or sets problem id. + /// + public string ProblemId + { + get => this.data.problemId; + set => this.data.problemId = value; + } + + /// + /// Gets or sets properties collection. + /// + public IDictionary Properties + { + get => this.data.properties; + set => this.data.properties = value; + } + + /// + /// Gets or sets measurements collection. + /// + public IDictionary Measurements + { + get => this.data.measurements; + set => this.data.measurements = value; + } + + internal ExceptionData Data => this.data; + + internal ExceptionInfo DeepClone() + { + return new ExceptionInfo(this.data.DeepClone()); + } + } +} \ No newline at end of file diff --git a/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs index f9c61ca14e..30036f93ca 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs @@ -12,14 +12,16 @@ /// Telemetry type used to track exceptions. /// Learn more /// - public sealed class ExceptionTelemetry : ITelemetry, ISupportProperties, ISupportSampling, ISupportMetrics + public sealed class ExceptionTelemetry : ITelemetry, ISupportProperties, ISupportSampling, ISupportMetrics { internal const string TelemetryName = "Exception"; internal readonly string BaseType = typeof(ExceptionData).Name; - internal readonly ExceptionData Data; - private readonly TelemetryContext context; - private IReadOnlyList exceptionDetailsInfoList; + internal ExceptionInfo Data = null; + + private readonly bool isCreatedFromExceptionInfo = false; + + private TelemetryContext context; private Exception exception; private string message; @@ -30,8 +32,8 @@ public sealed class ExceptionTelemetry : ITelemetry, ISupportProperties, ISuppor /// public ExceptionTelemetry() { - this.Data = new ExceptionData(); - this.context = new TelemetryContext(this.Data.properties); + this.Data = new ExceptionInfo(new ExceptionData()); + this.context = new TelemetryContext(this.Data.Properties); } /// @@ -49,18 +51,38 @@ public ExceptionTelemetry(Exception exception) this.Exception = exception; } + /// + /// Initializes a new instance of the class. + /// + /// Exception info. + public ExceptionTelemetry(ExceptionInfo exceptionInfo) + { + this.isCreatedFromExceptionInfo = true; + + this.Data = exceptionInfo ?? throw new ArgumentNullException(nameof(exceptionInfo)); + this.context = new TelemetryContext(this.Data.Properties); + + this.UpdateData(null, exceptionInfo); + } + /// /// Initializes a new instance of the class by cloning an existing instance. /// /// Source instance of to clone from. private ExceptionTelemetry(ExceptionTelemetry source) { + this.isCreatedFromExceptionInfo = source.isCreatedFromExceptionInfo; + this.Data = source.Data.DeepClone(); - this.context = source.context.DeepClone(this.Data.properties); + this.context = source.context.DeepClone(this.Data.Properties); this.Sequence = source.Sequence; this.Timestamp = source.Timestamp; this.samplingPercentage = source.samplingPercentage; - this.Exception = source.Exception; + + if (!this.isCreatedFromExceptionInfo) + { + this.exception = source.Exception; + } } /// @@ -88,12 +110,12 @@ public string ProblemId { get { - return this.Data.problemId; + return this.Data.ProblemId; } set { - this.Data.problemId = value; + this.Data.ProblemId = value; } } @@ -127,16 +149,30 @@ public Exception Exception { get { - return this.exception; + return this.isCreatedFromExceptionInfo + ? throw new InvalidOperationException( + "The property is unavailable on an instance created from an ExceptionInfo object") + : this.exception; } set { + if (this.isCreatedFromExceptionInfo) + { + throw new InvalidOperationException( + "The property is unavailable on an instance created from an ExceptionInfo object"); + } + this.exception = value; - this.UpdateExceptions(value); + this.UpdateData(value, null); } } + /// + /// Gets the which describes the data contained within this . + /// + public ExceptionInfo ExceptionInfo => this.Data; + /// /// Gets or sets ExceptionTelemetry message. /// @@ -144,20 +180,29 @@ public string Message { get { - return this.message; + return this.isCreatedFromExceptionInfo + ? throw new InvalidOperationException( + "The property is unavailable on an instance created from an ExceptionInfo object") + : this.message; } set { + if (this.isCreatedFromExceptionInfo) + { + throw new InvalidOperationException( + "The property is unavailable on an instance created from an ExceptionInfo object"); + } + this.message = value; - if (this.Data.exceptions != null && this.Data.exceptions.Count > 0) + if (this.Data.ExceptionDetailsInfoList != null && this.Data.ExceptionDetailsInfoList.Count > 0) { - this.Data.exceptions[0].message = value; + this.Data.ExceptionDetailsInfoList[0].Message = value; } else { - this.UpdateExceptions(this.Exception); + this.UpdateData(this.Exception, null); } } } @@ -168,20 +213,14 @@ public string Message /// public IDictionary Metrics { - get { return this.Data.measurements; } + get { return this.Data.Measurements; } } /// /// Gets the list of . User can modify the contents of individual object, but /// not the list itself. /// - public IReadOnlyList ExceptionDetailsInfoList - { - get - { - return this.exceptionDetailsInfoList; - } - } + public IReadOnlyList ExceptionDetailsInfoList => this.Data.ExceptionDetailsInfoList; /// /// Gets a dictionary of application-defined property names and values providing additional information about this exception. @@ -189,7 +228,7 @@ public IReadOnlyList ExceptionDetailsInfoList /// public IDictionary Properties { - get { return this.Data.properties; } + get { return this.Data.Properties; } } /// @@ -197,8 +236,8 @@ public IDictionary Properties /// public SeverityLevel? SeverityLevel { - get { return this.Data.severityLevel.TranslateSeverityLevel(); } - set { this.Data.severityLevel = value.TranslateSeverityLevel(); } + get => this.Data.SeverityLevel; + set => this.Data.SeverityLevel = value; } /// @@ -213,7 +252,7 @@ public SeverityLevel? SeverityLevel internal IList Exceptions { - get { return this.Data.exceptions; } + get { return this.Data.Data.exceptions; } } /// @@ -236,12 +275,12 @@ public void SetParsedStack(System.Diagnostics.StackFrame[] frames) { int stackLength = 0; - this.Exceptions[0].parsedStack = new List(); + this.Exceptions[0].parsedStack = new List(); this.Exceptions[0].hasFullStack = true; for (int level = 0; level < frames.Length; level++) { - StackFrame sf = ExceptionConverter.GetStackFrame(frames[level], level); + var sf = ExceptionConverter.GetStackFrame(frames[level], level); stackLength += ExceptionConverter.GetStackFrameLength(sf); @@ -298,33 +337,44 @@ private void ConvertExceptionTree(Exception exception, ExceptionDetails parentEx } } - private void UpdateExceptions(Exception exception) + private void UpdateData(Exception exception, ExceptionInfo exceptionInfo) { - // collect the set of exceptions detail info from the passed in exception - List exceptions = new List(); - this.ConvertExceptionTree(exception, null, exceptions); - - // trim if we have too many, also add a custom exception to let the user know we're trimmed - if (exceptions.Count > Constants.MaxExceptionCountToSave) + if (this.isCreatedFromExceptionInfo) { - // TODO: when we localize these messages, we should consider not using InvariantCulture - // create our "message" exception. - InnerExceptionCountExceededException countExceededException = new InnerExceptionCountExceededException( - string.Format( - CultureInfo.InvariantCulture, - "The number of inner exceptions was {0} which is larger than {1}, the maximum number allowed during transmission. All but the first {1} have been dropped.", - exceptions.Count, - Constants.MaxExceptionCountToSave)); - - // remove all but the first N exceptions - exceptions.RemoveRange(Constants.MaxExceptionCountToSave, exceptions.Count - Constants.MaxExceptionCountToSave); - - // we'll add our new exception and parent it to the root exception (first one in the list) - exceptions.Add(ExceptionConverter.ConvertToExceptionDetails(countExceededException, exceptions[0])); + this.Data = exceptionInfo ?? throw new ArgumentNullException(nameof(exceptionInfo)); + this.context = new TelemetryContext(this.Data.Properties); } + else + { + // collect the set of exceptions detail info from the passed in exception + List exceptions = new List(); + this.ConvertExceptionTree(exception, null, exceptions); - this.Data.exceptions = exceptions; - this.exceptionDetailsInfoList = exceptions.Select(ex => new ExceptionDetailsInfo(ex)).ToList().AsReadOnly(); + // trim if we have too many, also add a custom exception to let the user know we're trimmed + if (exceptions.Count > Constants.MaxExceptionCountToSave) + { + // TODO: when we localize these messages, we should consider not using InvariantCulture + // create our "message" exception. + InnerExceptionCountExceededException countExceededException = + new InnerExceptionCountExceededException( + string.Format( + CultureInfo.InvariantCulture, + "The number of inner exceptions was {0} which is larger than {1}, the maximum number allowed during transmission. All but the first {1} have been dropped.", + exceptions.Count, + Constants.MaxExceptionCountToSave)); + + // remove all but the first N exceptions + exceptions.RemoveRange(Constants.MaxExceptionCountToSave, + exceptions.Count - Constants.MaxExceptionCountToSave); + + // we'll add our new exception and parent it to the root exception (first one in the list) + exceptions.Add(ExceptionConverter.ConvertToExceptionDetails(countExceededException, exceptions[0])); + } + + this.Data = new ExceptionInfo(exceptions.Select(ex => new ExceptionDetailsInfo(ex)), this.SeverityLevel, + this.ProblemId, this.Properties, this.Metrics); + this.context = new TelemetryContext(this.Data.Properties); + } } } } diff --git a/src/Microsoft.ApplicationInsights/DataContracts/StackFrame.cs b/src/Microsoft.ApplicationInsights/DataContracts/StackFrame.cs new file mode 100644 index 0000000000..b2755741dc --- /dev/null +++ b/src/Microsoft.ApplicationInsights/DataContracts/StackFrame.cs @@ -0,0 +1,27 @@ +namespace Microsoft.ApplicationInsights.DataContracts +{ + using System; + + /// + /// Wrapper class for for API exposure. + /// + public sealed class StackFrame + { + /// + /// Constructs an instance. + /// + public StackFrame(string assembly, string fileName, int level, int line, string method) + { + this.Data = new Extensibility.Implementation.External.StackFrame() + { + assembly = assembly, + fileName = fileName, + level = level, + line = line, + method = method + }; + } + + internal Extensibility.Implementation.External.StackFrame Data { get; private set; } = null; + } +} \ No newline at end of file diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs index 71ed3f126e..d7be34acca 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs @@ -11,7 +11,6 @@ using Microsoft.ApplicationInsights.Channel; using Microsoft.ApplicationInsights.DataContracts; using Microsoft.ApplicationInsights.Extensibility.Implementation.External; - using Microsoft.ApplicationInsights.Extensibility.Implementation.Platform; using Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing; /// @@ -190,7 +189,7 @@ private static void SerializeExceptions(IEnumerable exceptions int stackFrameArrayIndex = 0; - foreach (StackFrame frame in exceptionDetails.parsedStack) + foreach (External.StackFrame frame in exceptionDetails.parsedStack) { if (stackFrameArrayIndex++ != 0) { @@ -209,7 +208,7 @@ private static void SerializeExceptions(IEnumerable exceptions } } - private static void SerializeStackFrame(StackFrame frame, IJsonWriter writer) + private static void SerializeStackFrame(External.StackFrame frame, IJsonWriter writer) { writer.WriteProperty("level", frame.level); writer.WriteProperty( @@ -364,11 +363,11 @@ private static void SerializeExceptionTelemetry(ExceptionTelemetry exceptionTele { writer.WriteStartObject(); - writer.WriteProperty("ver", exceptionTelemetry.Data.ver); - writer.WriteProperty("problemId", exceptionTelemetry.Data.problemId); - Utils.CopyDictionary(exceptionTelemetry.Context.GlobalProperties, exceptionTelemetry.Data.properties); - writer.WriteProperty("properties", exceptionTelemetry.Data.properties); - writer.WriteProperty("measurements", exceptionTelemetry.Data.measurements); + writer.WriteProperty("ver", exceptionTelemetry.Data.Data.ver); + writer.WriteProperty("problemId", exceptionTelemetry.Data.Data.problemId); + Utils.CopyDictionary(exceptionTelemetry.Context.GlobalProperties, exceptionTelemetry.Data.Data.properties); + writer.WriteProperty("properties", exceptionTelemetry.Data.Data.properties); + writer.WriteProperty("measurements", exceptionTelemetry.Data.Data.measurements); writer.WritePropertyName("exceptions"); { writer.WriteStartArray(); @@ -378,9 +377,9 @@ private static void SerializeExceptionTelemetry(ExceptionTelemetry exceptionTele writer.WriteEndArray(); } - if (exceptionTelemetry.Data.severityLevel.HasValue) + if (exceptionTelemetry.Data.Data.severityLevel.HasValue) { - writer.WriteProperty("severityLevel", exceptionTelemetry.Data.severityLevel.Value.ToString()); + writer.WriteProperty("severityLevel", exceptionTelemetry.Data.Data.severityLevel.Value.ToString()); } writer.WriteEndObject(); diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/RichPayloadEventSource.TelemetryHandler.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/RichPayloadEventSource.TelemetryHandler.cs index ce26da562a..cc3e0e584b 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/RichPayloadEventSource.TelemetryHandler.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/RichPayloadEventSource.TelemetryHandler.cs @@ -502,7 +502,7 @@ private Action CreateHandlerForExceptionTelemetry(EventSource eventS eventSourceOptionsKeywordsProperty.SetValue(eventSourceOptions, keywords); var dummyExceptionData = new ExceptionData(); var dummyExceptionDetails = new ExceptionDetails(); - var dummyStackFrame = new StackFrame(); + var dummyStackFrame = new External.StackFrame(); var writeMethod = writeGenericMethod.MakeGenericMethod(new { PartA_iKey = this.dummyPartAiKeyValue, @@ -550,7 +550,7 @@ private Action CreateHandlerForExceptionTelemetry(EventSource eventS { item.Sanitize(); var telemetryItem = item as ExceptionTelemetry; - var data = telemetryItem.Data; + var data = telemetryItem.Data.Data; var extendedData = new { // The properties and layout should be the same as the anonymous type in the above MakeGenericMethod diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/RichPayloadEventSource.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/RichPayloadEventSource.cs index 529c7843ec..f4936fbb2b 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/RichPayloadEventSource.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/RichPayloadEventSource.cs @@ -144,7 +144,7 @@ public void Process(ITelemetry item) ExceptionTelemetry.TelemetryName, telemetryItem.Context.InstrumentationKey, telemetryItem.Context.SanitizedTags, - telemetryItem.Data, + telemetryItem.Data.Data, telemetryItem.Context.Flags, Keywords.Exceptions); } From 08e36e59af2e3d67e23049b760e0011590862a24 Mon Sep 17 00:00:00 2001 From: Alexander Kaplan Date: Sat, 21 Jul 2018 19:36:29 -0700 Subject: [PATCH 16/74] Updated CHANGELOG.MD --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8be732813b..c6f653d253 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ This changelog will be used to generate documentation on [release notes page](ht Related: (https://github.com/Microsoft/ApplicationInsights-aspnetcore/issues/690) - Added method `ExceptionDetailsInfoList` on `ExceptionTelemetry` class that gives control to user to update exception message and exception type of underlying `System.Exception` object that user wants to send to telemetry. Related discussion is [here](https://github.com/Microsoft/ApplicationInsights-dotnet/issues/498). +- Added an option of creating ExceptionTelemetry object off of custom exception information rather than a System.Exception object. ## Version 2.7.0-beta2 - [Fix: NullReferenceException if telemtery is tracked after TelemetryConfiguration is disposed](https://github.com/Microsoft/ApplicationInsights-dotnet-server/issues/928) From c2aa2c43b3e7e1e7a02c9483bdeca2bdc29d8330 Mon Sep 17 00:00:00 2001 From: Alexander Kaplan Date: Mon, 23 Jul 2018 11:02:20 -0700 Subject: [PATCH 17/74] PR feedback. --- CHANGELOG.md | 7 +- .../DataContracts/ExceptionTelemetry.cs | 74 ++++++++++--------- 2 files changed, 45 insertions(+), 36 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c6f653d253..4225da6f99 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,15 +2,16 @@ This changelog will be used to generate documentation on [release notes page](http://azure.microsoft.com/documentation/articles/app-insights-release-notes-dotnet/). +## Version 2.8.0-beta1 +- Added method `ExceptionDetailsInfoList` on `ExceptionTelemetry` class that gives control to user to update exception +message and exception type of underlying `System.Exception` object that user wants to send to telemetry. Related discussion is [here](https://github.com/Microsoft/ApplicationInsights-dotnet/issues/498). +- Added an option of creating ExceptionTelemetry object off of custom exception information rather than a System.Exception object. ## Version 2.7.0-beta3 - [Allow to set flags on event](https://github.com/Microsoft/ApplicationInsights-dotnet/issues/844). It will be used in conjunction with the feature that will allow to keep IP addresses. - [Fix: SerializationException resolving Activity in cross app-domain calls](https://github.com/Microsoft/ApplicationInsights-dotnet-server/issues/613) - [Make HttpClient instance static to avoid re-creating with every transmission. This had caused connection/memory leaks in .net core 2.1](https://github.com/Microsoft/ApplicationInsights-dotnet/issues/594) Related: (https://github.com/Microsoft/ApplicationInsights-aspnetcore/issues/690) -- Added method `ExceptionDetailsInfoList` on `ExceptionTelemetry` class that gives control to user to update exception -message and exception type of underlying `System.Exception` object that user wants to send to telemetry. Related discussion is [here](https://github.com/Microsoft/ApplicationInsights-dotnet/issues/498). -- Added an option of creating ExceptionTelemetry object off of custom exception information rather than a System.Exception object. ## Version 2.7.0-beta2 - [Fix: NullReferenceException if telemtery is tracked after TelemetryConfiguration is disposed](https://github.com/Microsoft/ApplicationInsights-dotnet-server/issues/928) diff --git a/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs index 30036f93ca..b181b227ec 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs @@ -62,7 +62,7 @@ public ExceptionTelemetry(ExceptionInfo exceptionInfo) this.Data = exceptionInfo ?? throw new ArgumentNullException(nameof(exceptionInfo)); this.context = new TelemetryContext(this.Data.Properties); - this.UpdateData(null, exceptionInfo); + this.UpdateData(exceptionInfo); } /// @@ -164,7 +164,7 @@ public Exception Exception } this.exception = value; - this.UpdateData(value, null); + this.UpdateData(value); } } @@ -202,7 +202,7 @@ public string Message } else { - this.UpdateData(this.Exception, null); + this.UpdateData(this.Exception); } } } @@ -337,44 +337,52 @@ private void ConvertExceptionTree(Exception exception, ExceptionDetails parentEx } } - private void UpdateData(Exception exception, ExceptionInfo exceptionInfo) + private void UpdateData(Exception exception) { if (this.isCreatedFromExceptionInfo) { - this.Data = exceptionInfo ?? throw new ArgumentNullException(nameof(exceptionInfo)); - this.context = new TelemetryContext(this.Data.Properties); + throw new InvalidOperationException("Operation is not supported given the state of the object."); } - else + + // collect the set of exceptions detail info from the passed in exception + List exceptions = new List(); + this.ConvertExceptionTree(exception, null, exceptions); + + // trim if we have too many, also add a custom exception to let the user know we're trimmed + if (exceptions.Count > Constants.MaxExceptionCountToSave) { - // collect the set of exceptions detail info from the passed in exception - List exceptions = new List(); - this.ConvertExceptionTree(exception, null, exceptions); + // TODO: when we localize these messages, we should consider not using InvariantCulture + // create our "message" exception. + InnerExceptionCountExceededException countExceededException = + new InnerExceptionCountExceededException( + string.Format( + CultureInfo.InvariantCulture, + "The number of inner exceptions was {0} which is larger than {1}, the maximum number allowed during transmission. All but the first {1} have been dropped.", + exceptions.Count, + Constants.MaxExceptionCountToSave)); + + // remove all but the first N exceptions + exceptions.RemoveRange(Constants.MaxExceptionCountToSave, + exceptions.Count - Constants.MaxExceptionCountToSave); + + // we'll add our new exception and parent it to the root exception (first one in the list) + exceptions.Add(ExceptionConverter.ConvertToExceptionDetails(countExceededException, exceptions[0])); + } - // trim if we have too many, also add a custom exception to let the user know we're trimmed - if (exceptions.Count > Constants.MaxExceptionCountToSave) - { - // TODO: when we localize these messages, we should consider not using InvariantCulture - // create our "message" exception. - InnerExceptionCountExceededException countExceededException = - new InnerExceptionCountExceededException( - string.Format( - CultureInfo.InvariantCulture, - "The number of inner exceptions was {0} which is larger than {1}, the maximum number allowed during transmission. All but the first {1} have been dropped.", - exceptions.Count, - Constants.MaxExceptionCountToSave)); - - // remove all but the first N exceptions - exceptions.RemoveRange(Constants.MaxExceptionCountToSave, - exceptions.Count - Constants.MaxExceptionCountToSave); - - // we'll add our new exception and parent it to the root exception (first one in the list) - exceptions.Add(ExceptionConverter.ConvertToExceptionDetails(countExceededException, exceptions[0])); - } + this.Data = new ExceptionInfo(exceptions.Select(ex => new ExceptionDetailsInfo(ex)), this.SeverityLevel, + this.ProblemId, this.Properties, this.Metrics); + this.context = new TelemetryContext(this.Data.Properties); + } - this.Data = new ExceptionInfo(exceptions.Select(ex => new ExceptionDetailsInfo(ex)), this.SeverityLevel, - this.ProblemId, this.Properties, this.Metrics); - this.context = new TelemetryContext(this.Data.Properties); + private void UpdateData(ExceptionInfo exceptionInfo) + { + if (!this.isCreatedFromExceptionInfo) + { + throw new InvalidOperationException("Operation is not supported given the state of the object."); } + + this.Data = exceptionInfo ?? throw new ArgumentNullException(nameof(exceptionInfo)); + this.context = new TelemetryContext(this.Data.Properties); } } } From e172d16bf6d8074f08672b16985d970823a58ab7 Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Thu, 26 Jul 2018 10:59:30 -0700 Subject: [PATCH 18/74] Added DeepClone method to IExtension. Modified all Telemetry types to do clone Extension. UnitTests --- .../Shared/Channel/ITelemetryTest.cs | 22 ++++++--------- .../AvailabilityTelemetryTest.cs | 11 +++++++- .../DataContracts/DependencyTelemetryTest.cs | 19 ++++++++++--- .../DataContracts/EventTelemetryTest.cs | 10 +++++++ .../DataContracts/ExceptionTelemetryTest.cs | 10 +++++++ .../DataContracts/MetricTelemetryTest.cs | 11 +++++++- .../DataContracts/PageViewTelemetryTest.cs | 11 +++++++- .../PerformanceCounterTelemetryTest.cs | 12 +++++++++ .../DataContracts/RequestTelemetryTest.cs | 9 +++++++ .../SessionStateTelemetryTest.cs | 12 +++++++++ .../DataContracts/TraceTelemetryTest.cs | 10 +++++++ .../Implementation/MyTestExtension.cs | 27 +++++++++++++++++++ ...ApplicationInsights.Shared.Tests.projitems | 3 ++- .../DataContracts/AvailabilityTelemetry.cs | 1 + .../DataContracts/DependencyTelemetry.cs | 1 + .../DataContracts/EventTelemetry.cs | 1 + .../DataContracts/ExceptionTelemetry.cs | 1 + .../DataContracts/MetricTelemetry.cs | 1 + .../DataContracts/PageViewTelemetry.cs | 1 + .../PerformanceCounterTelemetry.cs | 6 ++--- .../DataContracts/RequestTelemetry.cs | 1 + .../DataContracts/SessionStateTelemetry.cs | 6 ++--- .../DataContracts/TraceTelemetry.cs | 1 + .../Extensibility/IExtension.cs | 5 ++++ 24 files changed, 165 insertions(+), 27 deletions(-) create mode 100644 Test/Microsoft.ApplicationInsights.Test/Shared/Extensibility/Implementation/MyTestExtension.cs diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/Channel/ITelemetryTest.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/Channel/ITelemetryTest.cs index a5aed8fb67..784e5943ba 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/Channel/ITelemetryTest.cs +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/Channel/ITelemetryTest.cs @@ -7,6 +7,7 @@ using AI; using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.ApplicationInsights.Extensibility; + using Microsoft.ApplicationInsights.Extensibility.Implementation; internal class ITelemetryTest where TTelemetry : ITelemetry, new() @@ -37,7 +38,7 @@ private void TestExtension() Assert.IsNull(tel.Extension, "Extension should be null by default"); // Set extension - var myExt = new MyExtension(); + var myExt = new MyTestExtension(); tel.Extension = myExt; Assert.AreSame(myExt, tel.Extension, "Extension should be assignable."); @@ -233,6 +234,11 @@ private string ExtractTelemetryNameFromType(Type telemetryType) // handle TraceTelemetry separately result = "Message"; } + else if (telemetryType == typeof(DependencyTelemetry)) + { + // handle DeppendencyTelemetry separately + result = "RemoteDependency"; + } #pragma warning disable 618 else if (telemetryType == typeof(SessionStateTelemetry)) { @@ -254,18 +260,6 @@ private string ExtractTelemetryNameFromType(Type telemetryType) } return result; - } - - private class MyExtension : IExtension - { - int myIntField; - string myStringField; - - public void Serialize(ISerializationWriter serializationWriter) - { - serializationWriter.WriteProperty("myIntField", myIntField); - serializationWriter.WriteProperty("myStringField", myStringField); - } - } + } } } \ No newline at end of file diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/AvailabilityTelemetryTest.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/AvailabilityTelemetryTest.cs index 0da956a2a7..a77f7edff6 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/AvailabilityTelemetryTest.cs +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/AvailabilityTelemetryTest.cs @@ -147,6 +147,15 @@ public void AvailabilityTelemetryDeepCloneCopiesAllProperties() Assert.IsTrue(result.AreEqual, result.DifferencesString); } + [TestMethod] + public void AvailabilityTelemetryDeepCloneWithNullExtensionDoesNotThrow() + { + var telemetry = new AvailabilityTelemetry(); + // Extension is not set, means it'll be null. + // Validate that closing with null Extension does not throw. + var other = telemetry.DeepClone(); + } + private AvailabilityTelemetry CreateAvailabilityTelemetry() { AvailabilityTelemetry item = new AvailabilityTelemetry @@ -161,7 +170,7 @@ private AvailabilityTelemetry CreateAvailabilityTelemetry() item.Properties.Add("TestProperty", "TestValue"); item.Context.GlobalProperties.Add("TestPropertyGlobal", "TestValue"); item.Sequence = "12"; - + item.Extension = new MyTestExtension(); return item; } diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/DependencyTelemetryTest.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/DependencyTelemetryTest.cs index 246bbe16c5..a7846dc6da 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/DependencyTelemetryTest.cs +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/DependencyTelemetryTest.cs @@ -23,6 +23,12 @@ public void VerifyExpectedDefaultValue() Assert.AreEqual(true, defaultDependencyTelemetry.Success, "Success is expected to be true"); } + [TestMethod] + public void DependencyTelemetryITelemetryContractConsistentlyWithOtherTelemetryTypes() + { + new ITelemetryTest().Run(); + } + [TestMethod] public void DependencyTelemetryPropertiesFromContextAndItemSerializesToPropertiesInJson() { @@ -218,7 +224,6 @@ public void DependencyTelemetryGetUnsetOperationDetail() telemetry.ClearOperationDetails(); } -#if !NETCOREAPP1_1 [TestMethod] public void DependencyTelemetryDeepCloneCopiesAllProperties() { @@ -231,7 +236,15 @@ public void DependencyTelemetryDeepCloneCopiesAllProperties() ComparisonResult result = deepComparator.Compare(telemetry, other); Assert.IsTrue(result.AreEqual, result.DifferencesString); } -#endif + + [TestMethod] + public void DependencyTelemetryDeepCloneWithNullExtensionDoesNotThrow() + { + var telemetry = new DependencyTelemetry(); + // Extension is not set, means it'll be null. + // Validate that closing with null Extension does not throw. + var other = telemetry.DeepClone(); + } private DependencyTelemetry CreateRemoteDependencyTelemetry() { @@ -249,7 +262,7 @@ private DependencyTelemetry CreateRemoteDependencyTelemetry() item.Context.InstrumentationKey = Guid.NewGuid().ToString(); item.Properties.Add("TestProperty", "TestValue"); item.Context.GlobalProperties.Add("TestPropertyGlobal", "TestValue"); - + item.Extension = new MyTestExtension(); return item; } diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/EventTelemetryTest.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/EventTelemetryTest.cs index 6014c5a47b..2ff110125d 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/EventTelemetryTest.cs +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/EventTelemetryTest.cs @@ -153,6 +153,7 @@ public void EventTelemetryDeepCloneCopiesAllProperties() eventTelemetry.Name = "Test Event"; eventTelemetry.Properties["Test Property"] = "Test Value"; eventTelemetry.Metrics["Test Property"] = 4.2; + eventTelemetry.Extension = new MyTestExtension(); EventTelemetry other = (EventTelemetry)eventTelemetry.DeepClone(); CompareLogic deepComparator = new CompareLogic(); @@ -161,6 +162,15 @@ public void EventTelemetryDeepCloneCopiesAllProperties() Assert.IsTrue(result.AreEqual, result.DifferencesString); } + [TestMethod] + public void EventTelemetryDeepCloneWithNullExtensionDoesNotThrow() + { + var telemetry = new EventTelemetry(); + // Extension is not set, means it'll be null. + // Validate that closing with null Extension does not throw. + var other = telemetry.DeepClone(); + } + [TestMethod] public void EventTelemetryHasCorrectValueOfSamplingPercentageAfterSerialization() { diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/ExceptionTelemetryTest.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/ExceptionTelemetryTest.cs index ebe4bb9f6e..f7d36f7771 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/ExceptionTelemetryTest.cs +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/ExceptionTelemetryTest.cs @@ -465,6 +465,15 @@ public void ExceptionTelemetryDeepCloneCopiesAllProperties() Assert.IsTrue(result.AreEqual, result.DifferencesString); } + [TestMethod] + public void ExceptionTelemetryDeepCloneWithNullExtensionDoesNotThrow() + { + var telemetry = new ExceptionTelemetry(); + // Extension is not set, means it'll be null. + // Validate that closing with null Extension does not throw. + var other = telemetry.DeepClone(); + } + [TestMethod] public void ExceptionTelemetryPropertiesFromContextAndItemSerializesToPropertiesInJson() { @@ -508,6 +517,7 @@ private static ExceptionTelemetry CreateExceptionTelemetry(Exception exception = output.Context.GlobalProperties.Add("TestPropertyGlobal", "contextpropvalue"); output.Context.InstrumentationKey = "required"; output.Properties.Add("TestProperty", "TestPropertyValue"); + output.Extension = new MyTestExtension(); return output; } } diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/MetricTelemetryTest.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/MetricTelemetryTest.cs index b04132e065..d74fd5d751 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/MetricTelemetryTest.cs +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/MetricTelemetryTest.cs @@ -355,12 +355,21 @@ public void MetricTelemetryDeepCloneCopiesAllProperties() metric.Max = 6.4; metric.StandardDeviation = 0.5; metric.Properties.Add("Property1", "Value1"); - + metric.Extension = new MyTestExtension(); MetricTelemetry other = (MetricTelemetry)metric.DeepClone(); CompareLogic deepComparator = new CompareLogic(); var comparisonResult = deepComparator.Compare(metric, other); Assert.IsTrue(comparisonResult.AreEqual, comparisonResult.DifferencesString); } + + [TestMethod] + public void MetricTelemetryDeepCloneWithNullExtensionDoesNotThrow() + { + var telemetry = new MetricTelemetry(); + // Extension is not set, means it'll be null. + // Validate that closing with null Extension does not throw. + var other = telemetry.DeepClone(); + } } } diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/PageViewTelemetryTest.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/PageViewTelemetryTest.cs index 4e53611e31..7417b51bac 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/PageViewTelemetryTest.cs +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/PageViewTelemetryTest.cs @@ -164,12 +164,21 @@ public void PageViewTelemetryDeepCloneCopiesAllProperties() pageView.Duration = TimeSpan.FromSeconds(123); pageView.Metrics.Add("Metric1", 30); pageView.Properties.Add("Property1", "Value1"); - + pageView.Extension = new MyTestExtension(); PageViewTelemetry other = (PageViewTelemetry)pageView.DeepClone(); CompareLogic deepComparator = new CompareLogic(); var result = deepComparator.Compare(pageView, other); Assert.IsTrue(result.AreEqual, result.DifferencesString); } + + [TestMethod] + public void PageViewTelemetryDeepCloneWithNullExtensionDoesNotThrow() + { + var telemetry = new PageViewTelemetry(); + // Extension is not set, means it'll be null. + // Validate that closing with null Extension does not throw. + var other = telemetry.DeepClone(); + } } } diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/PerformanceCounterTelemetryTest.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/PerformanceCounterTelemetryTest.cs index 61dbae64de..58f415a70b 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/PerformanceCounterTelemetryTest.cs +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/PerformanceCounterTelemetryTest.cs @@ -2,6 +2,7 @@ { using System; using Microsoft.ApplicationInsights.Channel; + using Microsoft.ApplicationInsights.Extensibility.Implementation; using Microsoft.VisualStudio.TestTools.UnitTesting; using CompareLogic = KellermanSoftware.CompareNetObjects.CompareLogic; @@ -40,6 +41,7 @@ public void PerformanceCounterTelemetryDeepCloneCopiesAllProperties() PerformanceCounterTelemetry item = new PerformanceCounterTelemetry("someCategory", "someCounter", "an instance", 15.7); item.Timestamp = DateTimeOffset.Now; item.Properties.Add("p1", "p1Val"); + item.Extension = new MyTestExtension(); PerformanceCounterTelemetry other = (PerformanceCounterTelemetry)item.DeepClone(); @@ -48,6 +50,16 @@ public void PerformanceCounterTelemetryDeepCloneCopiesAllProperties() var result = deepComparator.Compare(item, other); Assert.IsTrue(result.AreEqual, result.DifferencesString); } + + [TestMethod] + public void PerformanceCounterTelemetryDeepCloneWithNullExtensionDoesNotThrow() + { + var telemetry = new PerformanceCounterTelemetry(); + // Extension is not set, means it'll be null. + // Validate that closing with null Extension does not throw. + var other = telemetry.DeepClone(); + } + #pragma warning restore 618 } } diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/RequestTelemetryTest.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/RequestTelemetryTest.cs index f536615390..065447ba8d 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/RequestTelemetryTest.cs +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/RequestTelemetryTest.cs @@ -251,6 +251,14 @@ public void RequestTelemetryDeepCloneCopiesAllProperties() Assert.IsTrue(result.AreEqual, result.DifferencesString); } + [TestMethod] + public void RequestTelemetryDeepCloneWithNullExtensionDoesNotThrow() + { + var telemetry = new RequestTelemetry(); + // Extension is not set, means it'll be null. + // Validate that closing with null Extension does not throw. + var other = telemetry.DeepClone(); + } private RequestTelemetry CreateTestTelemetry() { var request = new RequestTelemetry(); @@ -264,6 +272,7 @@ private RequestTelemetry CreateTestTelemetry() request.Metrics.Add("Metric1", 30); request.Properties.Add("itempropkey", "::1"); request.Context.GlobalProperties.Add("contextpropkey", "contextpropvalue"); + request.Extension = new MyTestExtension(); return request; } } diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/SessionStateTelemetryTest.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/SessionStateTelemetryTest.cs index 70343d45c8..3a77326311 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/SessionStateTelemetryTest.cs +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/SessionStateTelemetryTest.cs @@ -5,6 +5,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using KellermanSoftware.CompareNetObjects; + using Microsoft.ApplicationInsights.Extensibility.Implementation; [TestClass] public class SessionStateTelemetryTest @@ -60,6 +61,7 @@ public void SessionStateTelemetryDeepCloneCopiesAllProperties() { var telemetry = new SessionStateTelemetry(); telemetry.State = SessionState.End; + telemetry.Extension = new MyTestExtension(); var other = telemetry.DeepClone(); CompareLogic deepComparator = new CompareLogic(); @@ -67,6 +69,16 @@ public void SessionStateTelemetryDeepCloneCopiesAllProperties() var result = deepComparator.Compare(telemetry, other); Assert.IsTrue(result.AreEqual, result.DifferencesString); } + + [TestMethod] + public void SessionStateTelemetryDeepCloneWithNullExtensionDoesNotThrow() + { + var telemetry = new SessionStateTelemetry(); + // Extension is not set, means it'll be null. + // Validate that closing with null Extension does not throw. + var other = telemetry.DeepClone(); + } + #pragma warning restore 618 } } diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/TraceTelemetryTest.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/TraceTelemetryTest.cs index d3239f2996..b933f6edc7 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/TraceTelemetryTest.cs +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/TraceTelemetryTest.cs @@ -155,6 +155,7 @@ public void TraceTelemetryDeepCloneCopiesAllProperties() trace.SeverityLevel = SeverityLevel.Warning; trace.Sequence = "123456"; trace.Timestamp = DateTimeOffset.Now; + trace.Extension = new MyTestExtension(); var other = trace.DeepClone(); var deepComparator = new CompareLogic(); @@ -163,6 +164,15 @@ public void TraceTelemetryDeepCloneCopiesAllProperties() Assert.IsTrue(result.AreEqual, result.DifferencesString); } + [TestMethod] + public void TraceTelemetryDeepCloneWithNullExtensionDoesNotThrow() + { + var trace = new TraceTelemetry(); + // Extension is not set, means it'll be null. + // Validate that closing with null Extension does not throw. + var other = trace.DeepClone(); + } + [TestMethod] public void TraceTelemetryPropertiesFromContextAndItemSerializesToPropertiesInJson() { diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/Extensibility/Implementation/MyTestExtension.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/Extensibility/Implementation/MyTestExtension.cs new file mode 100644 index 0000000000..b44ceb3716 --- /dev/null +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/Extensibility/Implementation/MyTestExtension.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Microsoft.ApplicationInsights.Extensibility.Implementation +{ + public class MyTestExtension : IExtension + { + int myIntField; + string myStringField; + + public IExtension DeepClone() + { + var other = new MyTestExtension(); + other.myIntField = this.myIntField; + other.myStringField = this.myStringField; + + return other; + } + + public void Serialize(ISerializationWriter serializationWriter) + { + serializationWriter.WriteProperty("myIntField", myIntField); + serializationWriter.WriteProperty("myStringField", myStringField); + } + } +} diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/Microsoft.ApplicationInsights.Shared.Tests.projitems b/Test/Microsoft.ApplicationInsights.Test/Shared/Microsoft.ApplicationInsights.Shared.Tests.projitems index 28b848cd0b..37dba40146 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/Microsoft.ApplicationInsights.Shared.Tests.projitems +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/Microsoft.ApplicationInsights.Shared.Tests.projitems @@ -10,6 +10,7 @@ + @@ -113,7 +114,7 @@ - + diff --git a/src/Microsoft.ApplicationInsights/DataContracts/AvailabilityTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/AvailabilityTelemetry.cs index 3dfbe192ea..500d536c4e 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/AvailabilityTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/AvailabilityTelemetry.cs @@ -57,6 +57,7 @@ private AvailabilityTelemetry(AvailabilityTelemetry source) this.context = source.context.DeepClone(this.Data.properties); this.Sequence = source.Sequence; this.Timestamp = source.Timestamp; + this.extension = source.extension?.DeepClone(); } /// diff --git a/src/Microsoft.ApplicationInsights/DataContracts/DependencyTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/DependencyTelemetry.cs index a0b7257088..fc3b53472e 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/DependencyTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/DependencyTelemetry.cs @@ -99,6 +99,7 @@ private DependencyTelemetry(DependencyTelemetry source) this.Timestamp = source.Timestamp; this.samplingPercentage = source.samplingPercentage; this.successFieldSet = source.successFieldSet; + this.extension = source.extension?.DeepClone(); // Only clone the details if the source has had details initialized if (source.operationDetails != null) diff --git a/src/Microsoft.ApplicationInsights/DataContracts/EventTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/EventTelemetry.cs index 7b4d60503b..0efd71df67 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/EventTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/EventTelemetry.cs @@ -47,6 +47,7 @@ private EventTelemetry(EventTelemetry source) this.Sequence = source.Sequence; this.Timestamp = source.Timestamp; this.samplingPercentage = source.samplingPercentage; + this.extension = source.extension?.DeepClone(); } /// diff --git a/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs index 46d12338b8..defc56624f 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs @@ -61,6 +61,7 @@ private ExceptionTelemetry(ExceptionTelemetry source) this.Timestamp = source.Timestamp; this.samplingPercentage = source.samplingPercentage; this.Exception = source.Exception; + this.extension = source.extension?.DeepClone(); } /// diff --git a/src/Microsoft.ApplicationInsights/DataContracts/MetricTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/MetricTelemetry.cs index 4bff776d94..889e5ebfa9 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/MetricTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/MetricTelemetry.cs @@ -132,6 +132,7 @@ private MetricTelemetry(MetricTelemetry source) this.Context = source.Context.DeepClone(this.Data.properties); this.Sequence = source.Sequence; this.Timestamp = source.Timestamp; + this.extension = source.extension?.DeepClone(); } /// diff --git a/src/Microsoft.ApplicationInsights/DataContracts/PageViewTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/PageViewTelemetry.cs index 6ff658c8c7..7848d03476 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/PageViewTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/PageViewTelemetry.cs @@ -56,6 +56,7 @@ private PageViewTelemetry(PageViewTelemetry source) { this.Data = source.Data.DeepClone(); this.context = source.context.DeepClone(this.Data.properties); + this.extension = source.extension?.DeepClone(); } /// diff --git a/src/Microsoft.ApplicationInsights/DataContracts/PerformanceCounterTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/PerformanceCounterTelemetry.cs index 325b3bf2d7..762690608e 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/PerformanceCounterTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/PerformanceCounterTelemetry.cs @@ -49,7 +49,7 @@ private PerformanceCounterTelemetry(PerformanceCounterTelemetry source) { this.Data = (MetricTelemetry)source.Data.DeepClone(); this.categoryName = source.categoryName; - this.counterName = source.counterName; + this.counterName = source.counterName; } /// @@ -100,8 +100,8 @@ public TelemetryContext Context /// public IExtension Extension { - get { return this.extension; } - set { this.extension = value; } + get { return this.Data.Extension; } + set { this.Data.Extension = value; } } /// diff --git a/src/Microsoft.ApplicationInsights/DataContracts/RequestTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/RequestTelemetry.cs index d7a5eb7b0a..14c2f020c8 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/RequestTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/RequestTelemetry.cs @@ -63,6 +63,7 @@ private RequestTelemetry(RequestTelemetry source) this.Sequence = source.Sequence; this.Timestamp = source.Timestamp; this.successFieldSet = source.successFieldSet; + this.extension = source.extension?.DeepClone(); } /// diff --git a/src/Microsoft.ApplicationInsights/DataContracts/SessionStateTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/SessionStateTelemetry.cs index da4ade2d16..68dfcaf567 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/SessionStateTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/SessionStateTelemetry.cs @@ -42,7 +42,7 @@ public SessionStateTelemetry(SessionState state) /// Source instance of to clone from. private SessionStateTelemetry(SessionStateTelemetry source) { - this.Data = (EventTelemetry)source.Data.DeepClone(); + this.Data = (EventTelemetry)source.Data.DeepClone(); } /// @@ -74,8 +74,8 @@ public TelemetryContext Context /// public IExtension Extension { - get { return this.extension; } - set { this.extension = value; } + get { return this.Data.Extension; } + set { this.Data.Extension = value; } } /// diff --git a/src/Microsoft.ApplicationInsights/DataContracts/TraceTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/TraceTelemetry.cs index 40ebac0bed..508c41a5b2 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/TraceTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/TraceTelemetry.cs @@ -59,6 +59,7 @@ private TraceTelemetry(TraceTelemetry source) this.Sequence = source.Sequence; this.Timestamp = source.Timestamp; this.samplingPercentage = source.samplingPercentage; + this.extension = source.extension?.DeepClone(); } /// diff --git a/src/Microsoft.ApplicationInsights/Extensibility/IExtension.cs b/src/Microsoft.ApplicationInsights/Extensibility/IExtension.cs index 06411e94e6..e9820c48fa 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/IExtension.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/IExtension.cs @@ -9,5 +9,10 @@ public interface IExtension /// Sanitizes the properties of the telemetry item based on DP constraints. /// void Serialize(ISerializationWriter serializationWriter); + + /// + /// Clones the members of the element. + /// + IExtension DeepClone(); } } From 73121d13bb03243937f5091302fa5d36850603a0 Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Thu, 26 Jul 2018 11:08:01 -0700 Subject: [PATCH 19/74] Pageview PerformanceTelemetry modified to include IExtension. Changelog updation --- CHANGELOG.md | 1 + .../PageViewPerformanceTelemetryTest.cs | 11 +++++++++++ .../DataContracts/PageViewPerformanceTelemetry.cs | 12 ++++++++++++ 3 files changed, 24 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8766e48ba3..b88473244a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ This changelog will be used to generate documentation on [release notes page](ht ## Version 2.8.0-beta1 - [Add a new distict properties collection, GlobalProperties, on TelemetryContext, and obsolete the Properties on TelemetryContext.](https://github.com/Microsoft/ApplicationInsights-dotnet/issues/820) +- [Added support for strongly typed extensibility for Telemetry types using IExtension.](https://github.com/Microsoft/ApplicationInsights-dotnet/issues/871) - [Allow to track PageViewPerformance data type](https://github.com/Microsoft/ApplicationInsights-dotnet/issues/673). ## Version 2.7.0-beta3 diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/PageViewPerformanceTelemetryTest.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/PageViewPerformanceTelemetryTest.cs index d4de5e358a..72b4bb68a2 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/PageViewPerformanceTelemetryTest.cs +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/PageViewPerformanceTelemetryTest.cs @@ -164,6 +164,8 @@ public void PageViewPerformanceTelemetryDeepCloneCopiesAllProperties() pageView.Duration = TimeSpan.FromSeconds(123); pageView.Metrics.Add("Metric1", 30); pageView.Properties.Add("Property1", "Value1"); + pageView.Extension = new MyTestExtension(); + PageViewPerformanceTelemetry other = (PageViewPerformanceTelemetry)pageView.DeepClone(); @@ -171,5 +173,14 @@ public void PageViewPerformanceTelemetryDeepCloneCopiesAllProperties() var result = deepComparator.Compare(pageView, other); Assert.IsTrue(result.AreEqual, result.DifferencesString); } + + [TestMethod] + public void PageViewPerformanceTelemetryDeepCloneWithNullExtensionDoesNotThrow() + { + var telemetry = new PageViewPerformanceTelemetry(); + // Extension is not set, means it'll be null. + // Validate that closing with null Extension does not throw. + var other = telemetry.DeepClone(); + } } } diff --git a/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs index 801dfbaa26..62caf2cd13 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; using Microsoft.ApplicationInsights.Channel; + using Microsoft.ApplicationInsights.Extensibility; using Microsoft.ApplicationInsights.Extensibility.Implementation; using Microsoft.ApplicationInsights.Extensibility.Implementation.External; @@ -16,6 +17,7 @@ public sealed class PageViewPerformanceTelemetry : ITelemetry, ISupportPropertie internal const string BaseType = "PageViewPerformanceData"; internal readonly PageViewPerfData Data; + private IExtension extension; private double? samplingPercentage; /// @@ -45,6 +47,7 @@ private PageViewPerformanceTelemetry(PageViewPerformanceTelemetry source) { this.Data = source.Data.DeepClone(); this.Context = source.Context.DeepClone(this.Data.properties); + this.extension = source.extension?.DeepClone(); } /// @@ -62,6 +65,15 @@ private PageViewPerformanceTelemetry(PageViewPerformanceTelemetry source) /// public TelemetryContext Context { get; private set; } + /// + /// Gets or sets gets the extension used to extend this telemetry instance using new strong typed object. + /// + public IExtension Extension + { + get { return this.extension; } + set { this.extension = value; } + } + /// /// Gets or sets page view ID. /// From e1434ff290446961fe65ba9acee2f3ea58df7725 Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Thu, 26 Jul 2018 13:14:15 -0700 Subject: [PATCH 20/74] Typos and spacing --- .../Shared/Channel/ITelemetryTest.cs | 4 ++-- .../Shared/DataContracts/AvailabilityTelemetryTest.cs | 2 +- .../Shared/DataContracts/DependencyTelemetryTest.cs | 2 +- .../Shared/DataContracts/EventTelemetryTest.cs | 2 +- .../Shared/DataContracts/ExceptionTelemetryTest.cs | 2 +- .../Shared/DataContracts/MetricTelemetryTest.cs | 2 +- .../Shared/DataContracts/PageViewPerformanceTelemetryTest.cs | 2 +- .../Shared/DataContracts/PageViewTelemetryTest.cs | 2 +- .../Shared/DataContracts/PerformanceCounterTelemetryTest.cs | 2 +- .../Shared/DataContracts/RequestTelemetryTest.cs | 2 +- .../Shared/DataContracts/SessionStateTelemetryTest.cs | 2 +- .../Shared/DataContracts/TraceTelemetryTest.cs | 2 +- 12 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/Channel/ITelemetryTest.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/Channel/ITelemetryTest.cs index 784e5943ba..623ec6152b 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/Channel/ITelemetryTest.cs +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/Channel/ITelemetryTest.cs @@ -47,7 +47,7 @@ private void TestExtension() private void TestProperties() { foreach (PropertyInfo property in typeof(TTelemetry).GetRuntimeProperties()) - { + { this.TestProperty(property); } } @@ -260,6 +260,6 @@ private string ExtractTelemetryNameFromType(Type telemetryType) } return result; - } + } } } \ No newline at end of file diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/AvailabilityTelemetryTest.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/AvailabilityTelemetryTest.cs index a77f7edff6..a6917e163d 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/AvailabilityTelemetryTest.cs +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/AvailabilityTelemetryTest.cs @@ -152,7 +152,7 @@ public void AvailabilityTelemetryDeepCloneWithNullExtensionDoesNotThrow() { var telemetry = new AvailabilityTelemetry(); // Extension is not set, means it'll be null. - // Validate that closing with null Extension does not throw. + // Validate that cloning with null Extension does not throw. var other = telemetry.DeepClone(); } diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/DependencyTelemetryTest.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/DependencyTelemetryTest.cs index a7846dc6da..0e98aaa269 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/DependencyTelemetryTest.cs +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/DependencyTelemetryTest.cs @@ -242,7 +242,7 @@ public void DependencyTelemetryDeepCloneWithNullExtensionDoesNotThrow() { var telemetry = new DependencyTelemetry(); // Extension is not set, means it'll be null. - // Validate that closing with null Extension does not throw. + // Validate that cloning with null Extension does not throw. var other = telemetry.DeepClone(); } diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/EventTelemetryTest.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/EventTelemetryTest.cs index 2ff110125d..137393da17 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/EventTelemetryTest.cs +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/EventTelemetryTest.cs @@ -167,7 +167,7 @@ public void EventTelemetryDeepCloneWithNullExtensionDoesNotThrow() { var telemetry = new EventTelemetry(); // Extension is not set, means it'll be null. - // Validate that closing with null Extension does not throw. + // Validate that cloning with null Extension does not throw. var other = telemetry.DeepClone(); } diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/ExceptionTelemetryTest.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/ExceptionTelemetryTest.cs index f7d36f7771..1825019f21 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/ExceptionTelemetryTest.cs +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/ExceptionTelemetryTest.cs @@ -470,7 +470,7 @@ public void ExceptionTelemetryDeepCloneWithNullExtensionDoesNotThrow() { var telemetry = new ExceptionTelemetry(); // Extension is not set, means it'll be null. - // Validate that closing with null Extension does not throw. + // Validate that cloning with null Extension does not throw. var other = telemetry.DeepClone(); } diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/MetricTelemetryTest.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/MetricTelemetryTest.cs index d74fd5d751..9807d2ac84 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/MetricTelemetryTest.cs +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/MetricTelemetryTest.cs @@ -368,7 +368,7 @@ public void MetricTelemetryDeepCloneWithNullExtensionDoesNotThrow() { var telemetry = new MetricTelemetry(); // Extension is not set, means it'll be null. - // Validate that closing with null Extension does not throw. + // Validate that cloning with null Extension does not throw. var other = telemetry.DeepClone(); } } diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/PageViewPerformanceTelemetryTest.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/PageViewPerformanceTelemetryTest.cs index 72b4bb68a2..092a82c1aa 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/PageViewPerformanceTelemetryTest.cs +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/PageViewPerformanceTelemetryTest.cs @@ -179,7 +179,7 @@ public void PageViewPerformanceTelemetryDeepCloneWithNullExtensionDoesNotThrow() { var telemetry = new PageViewPerformanceTelemetry(); // Extension is not set, means it'll be null. - // Validate that closing with null Extension does not throw. + // Validate that cloning with null Extension does not throw. var other = telemetry.DeepClone(); } } diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/PageViewTelemetryTest.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/PageViewTelemetryTest.cs index 7417b51bac..d55f973607 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/PageViewTelemetryTest.cs +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/PageViewTelemetryTest.cs @@ -177,7 +177,7 @@ public void PageViewTelemetryDeepCloneWithNullExtensionDoesNotThrow() { var telemetry = new PageViewTelemetry(); // Extension is not set, means it'll be null. - // Validate that closing with null Extension does not throw. + // Validate that cloning with null Extension does not throw. var other = telemetry.DeepClone(); } } diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/PerformanceCounterTelemetryTest.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/PerformanceCounterTelemetryTest.cs index 58f415a70b..260cb3cc62 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/PerformanceCounterTelemetryTest.cs +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/PerformanceCounterTelemetryTest.cs @@ -56,7 +56,7 @@ public void PerformanceCounterTelemetryDeepCloneWithNullExtensionDoesNotThrow() { var telemetry = new PerformanceCounterTelemetry(); // Extension is not set, means it'll be null. - // Validate that closing with null Extension does not throw. + // Validate that cloning with null Extension does not throw. var other = telemetry.DeepClone(); } diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/RequestTelemetryTest.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/RequestTelemetryTest.cs index 065447ba8d..40e74dd50b 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/RequestTelemetryTest.cs +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/RequestTelemetryTest.cs @@ -256,7 +256,7 @@ public void RequestTelemetryDeepCloneWithNullExtensionDoesNotThrow() { var telemetry = new RequestTelemetry(); // Extension is not set, means it'll be null. - // Validate that closing with null Extension does not throw. + // Validate that cloning with null Extension does not throw. var other = telemetry.DeepClone(); } private RequestTelemetry CreateTestTelemetry() diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/SessionStateTelemetryTest.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/SessionStateTelemetryTest.cs index 3a77326311..f15a4910c0 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/SessionStateTelemetryTest.cs +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/SessionStateTelemetryTest.cs @@ -75,7 +75,7 @@ public void SessionStateTelemetryDeepCloneWithNullExtensionDoesNotThrow() { var telemetry = new SessionStateTelemetry(); // Extension is not set, means it'll be null. - // Validate that closing with null Extension does not throw. + // Validate that cloning with null Extension does not throw. var other = telemetry.DeepClone(); } diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/TraceTelemetryTest.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/TraceTelemetryTest.cs index b933f6edc7..a69518e0f2 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/TraceTelemetryTest.cs +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/TraceTelemetryTest.cs @@ -169,7 +169,7 @@ public void TraceTelemetryDeepCloneWithNullExtensionDoesNotThrow() { var trace = new TraceTelemetry(); // Extension is not set, means it'll be null. - // Validate that closing with null Extension does not throw. + // Validate that cloning with null Extension does not throw. var other = trace.DeepClone(); } From e40a36fba3b0125d597dc4a9b7e0847a50947326 Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Thu, 26 Jul 2018 13:33:53 -0700 Subject: [PATCH 21/74] Minor changes. --- .../DataContracts/PerformanceCounterTelemetry.cs | 2 +- .../DataContracts/SessionStateTelemetry.cs | 4 ++-- .../Extensibility/IExtension.cs | 6 +++--- .../Extensibility/ISerializationWriter.cs | 2 +- .../Microsoft.ApplicationInsights.csproj | 16 +++++++++++++--- 5 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/Microsoft.ApplicationInsights/DataContracts/PerformanceCounterTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/PerformanceCounterTelemetry.cs index 762690608e..2ef4c7973a 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/PerformanceCounterTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/PerformanceCounterTelemetry.cs @@ -49,7 +49,7 @@ private PerformanceCounterTelemetry(PerformanceCounterTelemetry source) { this.Data = (MetricTelemetry)source.Data.DeepClone(); this.categoryName = source.categoryName; - this.counterName = source.counterName; + this.counterName = source.counterName; } /// diff --git a/src/Microsoft.ApplicationInsights/DataContracts/SessionStateTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/SessionStateTelemetry.cs index 68dfcaf567..2c8924c2b2 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/SessionStateTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/SessionStateTelemetry.cs @@ -10,7 +10,7 @@ [Obsolete("Session state events are no longer used. This telemetry item will be sent as EventTelemetry.")] public sealed class SessionStateTelemetry : ITelemetry { - internal readonly EventTelemetry Data; + internal readonly EventTelemetry Data; private readonly string startEventName = "Session started"; private readonly string endEventName = "Session ended"; @@ -42,7 +42,7 @@ public SessionStateTelemetry(SessionState state) /// Source instance of to clone from. private SessionStateTelemetry(SessionStateTelemetry source) { - this.Data = (EventTelemetry)source.Data.DeepClone(); + this.Data = (EventTelemetry)source.Data.DeepClone(); } /// diff --git a/src/Microsoft.ApplicationInsights/Extensibility/IExtension.cs b/src/Microsoft.ApplicationInsights/Extensibility/IExtension.cs index e9820c48fa..5b922b9725 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/IExtension.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/IExtension.cs @@ -1,17 +1,17 @@ namespace Microsoft.ApplicationInsights.Extensibility { /// - /// The base interface for defining strongly typed extensions to the telemetry types. + /// Interface for defining strongly typed extensions to telemetry types. /// public interface IExtension { /// - /// Sanitizes the properties of the telemetry item based on DP constraints. + /// Writes serialization info about the class using the given /// void Serialize(ISerializationWriter serializationWriter); /// - /// Clones the members of the element. + /// Deep clones the members of the class. /// IExtension DeepClone(); } diff --git a/src/Microsoft.ApplicationInsights/Extensibility/ISerializationWriter.cs b/src/Microsoft.ApplicationInsights/Extensibility/ISerializationWriter.cs index a417da8c4d..fa288bd4ca 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/ISerializationWriter.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/ISerializationWriter.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; /// - /// The interface for defining writers capable of serializing data into various formats. + /// The interface for defining writers capable of serializing data into various formats. /// public interface ISerializationWriter { diff --git a/src/Microsoft.ApplicationInsights/Microsoft.ApplicationInsights.csproj b/src/Microsoft.ApplicationInsights/Microsoft.ApplicationInsights.csproj index 2b5d2074e3..a455590552 100644 --- a/src/Microsoft.ApplicationInsights/Microsoft.ApplicationInsights.csproj +++ b/src/Microsoft.ApplicationInsights/Microsoft.ApplicationInsights.csproj @@ -52,8 +52,10 @@ All - - + + All + + All @@ -65,6 +67,14 @@ - + + + PublicAPI.Shipped.txt + + + PublicAPI.Unshipped.txt + + + \ No newline at end of file From 6a506fa02d21c2ac7c671b316875d06903e59a5f Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Thu, 26 Jul 2018 14:40:08 -0700 Subject: [PATCH 22/74] Added IExtension field to public api for all known types. --- .../net45/PublicAPI.Unshipped.txt | 28 ++++++++++++++++++- .../net46/PublicAPI.Unshipped.txt | 28 ++++++++++++++++++- .../netstandard1.3/PublicAPI.Unshipped.txt | 28 ++++++++++++++++++- 3 files changed, 81 insertions(+), 3 deletions(-) diff --git a/PublicAPI/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Unshipped.txt b/PublicAPI/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Unshipped.txt index 36689f8d0e..50432cffcd 100644 --- a/PublicAPI/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Unshipped.txt +++ b/PublicAPI/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Unshipped.txt @@ -309,4 +309,30 @@ static readonly Microsoft.ApplicationInsights.MetricConfigurations.Common -> Mic virtual Microsoft.ApplicationInsights.Metrics.MetricConfiguration.Equals(Microsoft.ApplicationInsights.Metrics.MetricConfiguration other) -> bool Microsoft.ApplicationInsights.DataContracts.TelemetryContext.Flags.get -> long Microsoft.ApplicationInsights.DataContracts.TelemetryContext.Flags.set -> void -const Microsoft.ApplicationInsights.DataContracts.TelemetryContext.FlagDropIdentifiers = 2097152 -> long \ No newline at end of file +const Microsoft.ApplicationInsights.DataContracts.TelemetryContext.FlagDropIdentifiers = 2097152 -> long +Microsoft.ApplicationInsights.Channel.ITelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension +Microsoft.ApplicationInsights.Channel.ITelemetry.Extension.set -> void +Microsoft.ApplicationInsights.DataContracts.AvailabilityTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension +Microsoft.ApplicationInsights.DataContracts.AvailabilityTelemetry.Extension.set -> void +Microsoft.ApplicationInsights.DataContracts.EventTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension +Microsoft.ApplicationInsights.DataContracts.EventTelemetry.Extension.set -> void +Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension +Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Extension.set -> void +Microsoft.ApplicationInsights.DataContracts.MetricTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension +Microsoft.ApplicationInsights.DataContracts.MetricTelemetry.Extension.set -> void +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Extension.set -> void +Microsoft.ApplicationInsights.DataContracts.PageViewTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension +Microsoft.ApplicationInsights.DataContracts.PageViewTelemetry.Extension.set -> void +Microsoft.ApplicationInsights.DataContracts.PerformanceCounterTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension +Microsoft.ApplicationInsights.DataContracts.PerformanceCounterTelemetry.Extension.set -> void +Microsoft.ApplicationInsights.DataContracts.SessionStateTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension +Microsoft.ApplicationInsights.DataContracts.SessionStateTelemetry.Extension.set -> void +Microsoft.ApplicationInsights.DataContracts.TraceTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension +Microsoft.ApplicationInsights.DataContracts.TraceTelemetry.Extension.set -> void +override Microsoft.ApplicationInsights.DataContracts.DependencyTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension +override Microsoft.ApplicationInsights.DataContracts.DependencyTelemetry.Extension.set -> void +override Microsoft.ApplicationInsights.DataContracts.RequestTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension +override Microsoft.ApplicationInsights.DataContracts.RequestTelemetry.Extension.set -> void +abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension +abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTelemetry.Extension.set -> void \ No newline at end of file diff --git a/PublicAPI/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Unshipped.txt b/PublicAPI/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Unshipped.txt index 36689f8d0e..50432cffcd 100644 --- a/PublicAPI/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Unshipped.txt +++ b/PublicAPI/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Unshipped.txt @@ -309,4 +309,30 @@ static readonly Microsoft.ApplicationInsights.MetricConfigurations.Common -> Mic virtual Microsoft.ApplicationInsights.Metrics.MetricConfiguration.Equals(Microsoft.ApplicationInsights.Metrics.MetricConfiguration other) -> bool Microsoft.ApplicationInsights.DataContracts.TelemetryContext.Flags.get -> long Microsoft.ApplicationInsights.DataContracts.TelemetryContext.Flags.set -> void -const Microsoft.ApplicationInsights.DataContracts.TelemetryContext.FlagDropIdentifiers = 2097152 -> long \ No newline at end of file +const Microsoft.ApplicationInsights.DataContracts.TelemetryContext.FlagDropIdentifiers = 2097152 -> long +Microsoft.ApplicationInsights.Channel.ITelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension +Microsoft.ApplicationInsights.Channel.ITelemetry.Extension.set -> void +Microsoft.ApplicationInsights.DataContracts.AvailabilityTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension +Microsoft.ApplicationInsights.DataContracts.AvailabilityTelemetry.Extension.set -> void +Microsoft.ApplicationInsights.DataContracts.EventTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension +Microsoft.ApplicationInsights.DataContracts.EventTelemetry.Extension.set -> void +Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension +Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Extension.set -> void +Microsoft.ApplicationInsights.DataContracts.MetricTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension +Microsoft.ApplicationInsights.DataContracts.MetricTelemetry.Extension.set -> void +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Extension.set -> void +Microsoft.ApplicationInsights.DataContracts.PageViewTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension +Microsoft.ApplicationInsights.DataContracts.PageViewTelemetry.Extension.set -> void +Microsoft.ApplicationInsights.DataContracts.PerformanceCounterTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension +Microsoft.ApplicationInsights.DataContracts.PerformanceCounterTelemetry.Extension.set -> void +Microsoft.ApplicationInsights.DataContracts.SessionStateTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension +Microsoft.ApplicationInsights.DataContracts.SessionStateTelemetry.Extension.set -> void +Microsoft.ApplicationInsights.DataContracts.TraceTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension +Microsoft.ApplicationInsights.DataContracts.TraceTelemetry.Extension.set -> void +override Microsoft.ApplicationInsights.DataContracts.DependencyTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension +override Microsoft.ApplicationInsights.DataContracts.DependencyTelemetry.Extension.set -> void +override Microsoft.ApplicationInsights.DataContracts.RequestTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension +override Microsoft.ApplicationInsights.DataContracts.RequestTelemetry.Extension.set -> void +abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension +abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTelemetry.Extension.set -> void \ No newline at end of file diff --git a/PublicAPI/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Unshipped.txt b/PublicAPI/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Unshipped.txt index bb7ac5d5cc..ce40cfc539 100644 --- a/PublicAPI/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Unshipped.txt +++ b/PublicAPI/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Unshipped.txt @@ -310,4 +310,30 @@ virtual Microsoft.ApplicationInsights.Metrics.MetricConfiguration.Equals(Microso Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.SetParsedStack(System.Diagnostics.StackFrame[] frames) -> void Microsoft.ApplicationInsights.DataContracts.TelemetryContext.Flags.get -> long Microsoft.ApplicationInsights.DataContracts.TelemetryContext.Flags.set -> void -const Microsoft.ApplicationInsights.DataContracts.TelemetryContext.FlagDropIdentifiers = 2097152 -> long \ No newline at end of file +const Microsoft.ApplicationInsights.DataContracts.TelemetryContext.FlagDropIdentifiers = 2097152 -> long +Microsoft.ApplicationInsights.Channel.ITelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension +Microsoft.ApplicationInsights.Channel.ITelemetry.Extension.set -> void +Microsoft.ApplicationInsights.DataContracts.AvailabilityTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension +Microsoft.ApplicationInsights.DataContracts.AvailabilityTelemetry.Extension.set -> void +Microsoft.ApplicationInsights.DataContracts.EventTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension +Microsoft.ApplicationInsights.DataContracts.EventTelemetry.Extension.set -> void +Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension +Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Extension.set -> void +Microsoft.ApplicationInsights.DataContracts.MetricTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension +Microsoft.ApplicationInsights.DataContracts.MetricTelemetry.Extension.set -> void +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Extension.set -> void +Microsoft.ApplicationInsights.DataContracts.PageViewTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension +Microsoft.ApplicationInsights.DataContracts.PageViewTelemetry.Extension.set -> void +Microsoft.ApplicationInsights.DataContracts.PerformanceCounterTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension +Microsoft.ApplicationInsights.DataContracts.PerformanceCounterTelemetry.Extension.set -> void +Microsoft.ApplicationInsights.DataContracts.SessionStateTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension +Microsoft.ApplicationInsights.DataContracts.SessionStateTelemetry.Extension.set -> void +Microsoft.ApplicationInsights.DataContracts.TraceTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension +Microsoft.ApplicationInsights.DataContracts.TraceTelemetry.Extension.set -> void +override Microsoft.ApplicationInsights.DataContracts.DependencyTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension +override Microsoft.ApplicationInsights.DataContracts.DependencyTelemetry.Extension.set -> void +override Microsoft.ApplicationInsights.DataContracts.RequestTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension +override Microsoft.ApplicationInsights.DataContracts.RequestTelemetry.Extension.set -> void +abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension +abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTelemetry.Extension.set -> void \ No newline at end of file From 2efefde3951c65aa5a70c38b9f8a44711df5f077 Mon Sep 17 00:00:00 2001 From: Alexander Kaplan Date: Thu, 26 Jul 2018 14:40:24 -0700 Subject: [PATCH 23/74] PR feedback. --- .../net45/PublicAPI.Shipped.txt | 14 +------------- .../net46/PublicAPI.Shipped.txt | 14 +------------- .../netstandard1.3/PublicAPI.Shipped.txt | 14 +------------- .../DataContracts/ExceptionTelemetryTest.cs | 11 +++++------ .../DataContracts/ExceptionInfo.cs | 2 +- .../DataContracts/ExceptionTelemetry.cs | 18 ++++++++++-------- 6 files changed, 19 insertions(+), 54 deletions(-) diff --git a/PublicAPI/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Shipped.txt b/PublicAPI/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Shipped.txt index c85a15b636..8007a9f1fd 100644 --- a/PublicAPI/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Shipped.txt +++ b/PublicAPI/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Shipped.txt @@ -114,6 +114,7 @@ Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Exception.get -> Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Exception.set -> void Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.ExceptionTelemetry() -> void Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.ExceptionTelemetry(System.Exception exception) -> void +Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.ExceptionTelemetry(System.Collections.Generic.IEnumerable exceptionDetailsInfoList, Microsoft.ApplicationInsights.DataContracts.SeverityLevel? severityLevel, string problemId, System.Collections.Generic.IDictionary properties, System.Collections.Generic.IDictionary measurements) -> void Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.HandledAt.get -> Microsoft.ApplicationInsights.DataContracts.ExceptionHandledAt Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.HandledAt.set -> void Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.ExceptionDetailsInfoList.get -> System.Collections.Generic.IReadOnlyList @@ -130,19 +131,6 @@ Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.SeverityLevel.get Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.SeverityLevel.set -> void Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Timestamp.get -> System.DateTimeOffset Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Timestamp.set -> void -Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.ExceptionInfo.get -> Microsoft.ApplicationInsights.DataContracts.ExceptionInfo -Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.ExceptionTelemetry(Microsoft.ApplicationInsights.DataContracts.ExceptionInfo exceptionInfo) -> void -Microsoft.ApplicationInsights.DataContracts.ExceptionInfo -Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.ExceptionDetailsInfoList.get -> System.Collections.Generic.IReadOnlyList -Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.ExceptionInfo(System.Collections.Generic.IEnumerable exceptionDetailsInfoList, Microsoft.ApplicationInsights.DataContracts.SeverityLevel? severityLevel, string problemId, System.Collections.Generic.IDictionary properties, System.Collections.Generic.IDictionary measurements) -> void -Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.Measurements.get -> System.Collections.Generic.IDictionary -Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.Measurements.set -> void -Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.ProblemId.get -> string -Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.ProblemId.set -> void -Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.Properties.get -> System.Collections.Generic.IDictionary -Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.Properties.set -> void -Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.SeverityLevel.get -> Microsoft.ApplicationInsights.DataContracts.SeverityLevel? -Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.SeverityLevel.set -> void Microsoft.ApplicationInsights.DataContracts.IJsonWriter Microsoft.ApplicationInsights.DataContracts.IJsonWriter.WriteComma() -> void Microsoft.ApplicationInsights.DataContracts.IJsonWriter.WriteEndArray() -> void diff --git a/PublicAPI/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Shipped.txt b/PublicAPI/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Shipped.txt index c85a15b636..8007a9f1fd 100644 --- a/PublicAPI/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Shipped.txt +++ b/PublicAPI/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Shipped.txt @@ -114,6 +114,7 @@ Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Exception.get -> Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Exception.set -> void Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.ExceptionTelemetry() -> void Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.ExceptionTelemetry(System.Exception exception) -> void +Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.ExceptionTelemetry(System.Collections.Generic.IEnumerable exceptionDetailsInfoList, Microsoft.ApplicationInsights.DataContracts.SeverityLevel? severityLevel, string problemId, System.Collections.Generic.IDictionary properties, System.Collections.Generic.IDictionary measurements) -> void Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.HandledAt.get -> Microsoft.ApplicationInsights.DataContracts.ExceptionHandledAt Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.HandledAt.set -> void Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.ExceptionDetailsInfoList.get -> System.Collections.Generic.IReadOnlyList @@ -130,19 +131,6 @@ Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.SeverityLevel.get Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.SeverityLevel.set -> void Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Timestamp.get -> System.DateTimeOffset Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Timestamp.set -> void -Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.ExceptionInfo.get -> Microsoft.ApplicationInsights.DataContracts.ExceptionInfo -Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.ExceptionTelemetry(Microsoft.ApplicationInsights.DataContracts.ExceptionInfo exceptionInfo) -> void -Microsoft.ApplicationInsights.DataContracts.ExceptionInfo -Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.ExceptionDetailsInfoList.get -> System.Collections.Generic.IReadOnlyList -Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.ExceptionInfo(System.Collections.Generic.IEnumerable exceptionDetailsInfoList, Microsoft.ApplicationInsights.DataContracts.SeverityLevel? severityLevel, string problemId, System.Collections.Generic.IDictionary properties, System.Collections.Generic.IDictionary measurements) -> void -Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.Measurements.get -> System.Collections.Generic.IDictionary -Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.Measurements.set -> void -Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.ProblemId.get -> string -Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.ProblemId.set -> void -Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.Properties.get -> System.Collections.Generic.IDictionary -Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.Properties.set -> void -Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.SeverityLevel.get -> Microsoft.ApplicationInsights.DataContracts.SeverityLevel? -Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.SeverityLevel.set -> void Microsoft.ApplicationInsights.DataContracts.IJsonWriter Microsoft.ApplicationInsights.DataContracts.IJsonWriter.WriteComma() -> void Microsoft.ApplicationInsights.DataContracts.IJsonWriter.WriteEndArray() -> void diff --git a/PublicAPI/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Shipped.txt b/PublicAPI/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Shipped.txt index 2151d48ca2..8f5b72affe 100644 --- a/PublicAPI/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Shipped.txt +++ b/PublicAPI/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Shipped.txt @@ -114,6 +114,7 @@ Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Exception.get -> Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Exception.set -> void Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.ExceptionTelemetry() -> void Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.ExceptionTelemetry(System.Exception exception) -> void +Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.ExceptionTelemetry(System.Collections.Generic.IEnumerable exceptionDetailsInfoList, Microsoft.ApplicationInsights.DataContracts.SeverityLevel? severityLevel, string problemId, System.Collections.Generic.IDictionary properties, System.Collections.Generic.IDictionary measurements) -> void Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.HandledAt.get -> Microsoft.ApplicationInsights.DataContracts.ExceptionHandledAt Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.HandledAt.set -> void Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.ExceptionDetailsInfoList.get -> System.Collections.Generic.IReadOnlyList @@ -129,19 +130,6 @@ Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.SeverityLevel.get Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.SeverityLevel.set -> void Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Timestamp.get -> System.DateTimeOffset Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Timestamp.set -> void -Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.ExceptionInfo.get -> Microsoft.ApplicationInsights.DataContracts.ExceptionInfo -Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.ExceptionTelemetry(Microsoft.ApplicationInsights.DataContracts.ExceptionInfo exceptionInfo) -> void -Microsoft.ApplicationInsights.DataContracts.ExceptionInfo -Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.ExceptionDetailsInfoList.get -> System.Collections.Generic.IReadOnlyList -Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.ExceptionInfo(System.Collections.Generic.IEnumerable exceptionDetailsInfoList, Microsoft.ApplicationInsights.DataContracts.SeverityLevel? severityLevel, string problemId, System.Collections.Generic.IDictionary properties, System.Collections.Generic.IDictionary measurements) -> void -Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.Measurements.get -> System.Collections.Generic.IDictionary -Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.Measurements.set -> void -Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.ProblemId.get -> string -Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.ProblemId.set -> void -Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.Properties.get -> System.Collections.Generic.IDictionary -Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.Properties.set -> void -Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.SeverityLevel.get -> Microsoft.ApplicationInsights.DataContracts.SeverityLevel? -Microsoft.ApplicationInsights.DataContracts.ExceptionInfo.SeverityLevel.set -> void Microsoft.ApplicationInsights.DataContracts.IJsonWriter Microsoft.ApplicationInsights.DataContracts.IJsonWriter.WriteComma() -> void Microsoft.ApplicationInsights.DataContracts.IJsonWriter.WriteEndArray() -> void diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/ExceptionTelemetryTest.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/ExceptionTelemetryTest.cs index 149eb62632..086bd3815c 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/ExceptionTelemetryTest.cs +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/ExceptionTelemetryTest.cs @@ -58,20 +58,19 @@ public void ExceptionTelemetryCreatedBasedOnCustomData() new StackFrame("Some.Assembly", "LessImportantFile.dll", 1, 11, "DeeperInnerMethod") }); - var exceptionInfo = new ExceptionInfo(new[] {topLevelexceptionDetails, innerExceptionDetails}, + // ACT + ExceptionTelemetry item = new ExceptionTelemetry(new[] {topLevelexceptionDetails, innerExceptionDetails}, SeverityLevel.Error, "ProblemId", new Dictionary() {["property1"] = "value1", ["property2"] = "value2"}, new Dictionary() {["property1"] = 1, ["property2"] = 2}); - // ACT - ExceptionTelemetry item = new ExceptionTelemetry(exceptionInfo); - - item.ExceptionInfo.ExceptionDetailsInfoList[1].Message = "Inner exception modified"; + item.ExceptionDetailsInfoList[1].Message = "Inner exception modified"; + item.ProblemId = "ProblemId modified"; // ASSERT // use internal fields to validate Assert.AreEqual(item.Data.Data.ver, 2); - Assert.AreEqual(item.Data.Data.problemId, "ProblemId"); + Assert.AreEqual(item.Data.Data.problemId, "ProblemId modified"); Assert.AreEqual(item.Data.Data.severityLevel, Extensibility.Implementation.External.SeverityLevel.Error); Assert.AreEqual(item.Data.Data.properties.Count, 2); diff --git a/src/Microsoft.ApplicationInsights/DataContracts/ExceptionInfo.cs b/src/Microsoft.ApplicationInsights/DataContracts/ExceptionInfo.cs index de18a72218..869a84a56d 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/ExceptionInfo.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/ExceptionInfo.cs @@ -9,7 +9,7 @@ /// /// Wrapper class for that lets user provide exception data without having the actual Exception object. /// - public sealed class ExceptionInfo + internal sealed class ExceptionInfo { private readonly ExceptionData data; diff --git a/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs index b181b227ec..23d8d48ae8 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs @@ -54,12 +54,19 @@ public ExceptionTelemetry(Exception exception) /// /// Initializes a new instance of the class. /// - /// Exception info. - public ExceptionTelemetry(ExceptionInfo exceptionInfo) + /// Exception info. + /// Severity level. + /// Problem id. + /// Properties. + /// Measurements. + public ExceptionTelemetry(IEnumerable exceptionDetailsInfoList, SeverityLevel? severityLevel, string problemId, + IDictionary properties, IDictionary measurements) { this.isCreatedFromExceptionInfo = true; - this.Data = exceptionInfo ?? throw new ArgumentNullException(nameof(exceptionInfo)); + ExceptionInfo exceptionInfo = new ExceptionInfo(exceptionDetailsInfoList, severityLevel, problemId, properties, measurements); + + this.Data = exceptionInfo; this.context = new TelemetryContext(this.Data.Properties); this.UpdateData(exceptionInfo); @@ -168,11 +175,6 @@ public Exception Exception } } - /// - /// Gets the which describes the data contained within this . - /// - public ExceptionInfo ExceptionInfo => this.Data; - /// /// Gets or sets ExceptionTelemetry message. /// From e1e2f125cea6ef753927df52150a022cd4da0366 Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Thu, 26 Jul 2018 14:41:50 -0700 Subject: [PATCH 24/74] Add IExtension to unshipped public api --- .../net45/PublicAPI.Unshipped.txt | 5 ++++- .../net46/PublicAPI.Unshipped.txt | 5 ++++- .../netstandard1.3/PublicAPI.Unshipped.txt | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/PublicAPI/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Unshipped.txt b/PublicAPI/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Unshipped.txt index 50432cffcd..617345c1f4 100644 --- a/PublicAPI/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Unshipped.txt +++ b/PublicAPI/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Unshipped.txt @@ -335,4 +335,7 @@ override Microsoft.ApplicationInsights.DataContracts.DependencyTelemetry.Extensi override Microsoft.ApplicationInsights.DataContracts.RequestTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension override Microsoft.ApplicationInsights.DataContracts.RequestTelemetry.Extension.set -> void abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension -abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTelemetry.Extension.set -> void \ No newline at end of file +abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTelemetry.Extension.set -> void +Microsoft.ApplicationInsights.Extensibility.IExtension +Microsoft.ApplicationInsights.Extensibility.IExtension.DeepClone() -> Microsoft.ApplicationInsights.Extensibility.IExtension +Microsoft.ApplicationInsights.Extensibility.IExtension.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void \ No newline at end of file diff --git a/PublicAPI/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Unshipped.txt b/PublicAPI/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Unshipped.txt index 50432cffcd..617345c1f4 100644 --- a/PublicAPI/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Unshipped.txt +++ b/PublicAPI/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Unshipped.txt @@ -335,4 +335,7 @@ override Microsoft.ApplicationInsights.DataContracts.DependencyTelemetry.Extensi override Microsoft.ApplicationInsights.DataContracts.RequestTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension override Microsoft.ApplicationInsights.DataContracts.RequestTelemetry.Extension.set -> void abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension -abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTelemetry.Extension.set -> void \ No newline at end of file +abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTelemetry.Extension.set -> void +Microsoft.ApplicationInsights.Extensibility.IExtension +Microsoft.ApplicationInsights.Extensibility.IExtension.DeepClone() -> Microsoft.ApplicationInsights.Extensibility.IExtension +Microsoft.ApplicationInsights.Extensibility.IExtension.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void \ No newline at end of file diff --git a/PublicAPI/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Unshipped.txt b/PublicAPI/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Unshipped.txt index ce40cfc539..80a857b62a 100644 --- a/PublicAPI/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Unshipped.txt +++ b/PublicAPI/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Unshipped.txt @@ -336,4 +336,7 @@ override Microsoft.ApplicationInsights.DataContracts.DependencyTelemetry.Extensi override Microsoft.ApplicationInsights.DataContracts.RequestTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension override Microsoft.ApplicationInsights.DataContracts.RequestTelemetry.Extension.set -> void abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension -abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTelemetry.Extension.set -> void \ No newline at end of file +abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTelemetry.Extension.set -> void +Microsoft.ApplicationInsights.Extensibility.IExtension +Microsoft.ApplicationInsights.Extensibility.IExtension.DeepClone() -> Microsoft.ApplicationInsights.Extensibility.IExtension +Microsoft.ApplicationInsights.Extensibility.IExtension.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void \ No newline at end of file From fd64f870da64da4f1bfd9cc4c73b7e6c87bb478a Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Thu, 26 Jul 2018 14:43:32 -0700 Subject: [PATCH 25/74] Add ISerializationWriter to public api unshipped --- .../net45/PublicAPI.Unshipped.txt | 12 +++++++++++- .../net46/PublicAPI.Unshipped.txt | 12 +++++++++++- .../netstandard1.3/PublicAPI.Unshipped.txt | 12 +++++++++++- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/PublicAPI/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Unshipped.txt b/PublicAPI/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Unshipped.txt index 617345c1f4..4ec51aec0a 100644 --- a/PublicAPI/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Unshipped.txt +++ b/PublicAPI/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Unshipped.txt @@ -338,4 +338,14 @@ abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTel abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTelemetry.Extension.set -> void Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.Extensibility.IExtension.DeepClone() -> Microsoft.ApplicationInsights.Extensibility.IExtension -Microsoft.ApplicationInsights.Extensibility.IExtension.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void \ No newline at end of file +Microsoft.ApplicationInsights.Extensibility.IExtension.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteDictionary(string name, System.Collections.Generic.IDictionary items) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteEndObject(string name) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteList(string name, System.Collections.Generic.IList items) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, System.TimeSpan? value) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, bool? value) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, double? value) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, int? value) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, string value) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteStartObject(string name) -> void \ No newline at end of file diff --git a/PublicAPI/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Unshipped.txt b/PublicAPI/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Unshipped.txt index 617345c1f4..4ec51aec0a 100644 --- a/PublicAPI/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Unshipped.txt +++ b/PublicAPI/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Unshipped.txt @@ -338,4 +338,14 @@ abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTel abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTelemetry.Extension.set -> void Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.Extensibility.IExtension.DeepClone() -> Microsoft.ApplicationInsights.Extensibility.IExtension -Microsoft.ApplicationInsights.Extensibility.IExtension.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void \ No newline at end of file +Microsoft.ApplicationInsights.Extensibility.IExtension.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteDictionary(string name, System.Collections.Generic.IDictionary items) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteEndObject(string name) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteList(string name, System.Collections.Generic.IList items) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, System.TimeSpan? value) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, bool? value) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, double? value) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, int? value) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, string value) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteStartObject(string name) -> void \ No newline at end of file diff --git a/PublicAPI/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Unshipped.txt b/PublicAPI/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Unshipped.txt index 80a857b62a..f6b7c1dcb0 100644 --- a/PublicAPI/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Unshipped.txt +++ b/PublicAPI/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Unshipped.txt @@ -339,4 +339,14 @@ abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTel abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTelemetry.Extension.set -> void Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.Extensibility.IExtension.DeepClone() -> Microsoft.ApplicationInsights.Extensibility.IExtension -Microsoft.ApplicationInsights.Extensibility.IExtension.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void \ No newline at end of file +Microsoft.ApplicationInsights.Extensibility.IExtension.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteDictionary(string name, System.Collections.Generic.IDictionary items) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteEndObject(string name) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteList(string name, System.Collections.Generic.IList items) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, System.TimeSpan? value) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, bool? value) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, double? value) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, int? value) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, string value) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteStartObject(string name) -> void \ No newline at end of file From 56c04c917be7c4ffc81fc8920e4687d7c15361ff Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Thu, 26 Jul 2018 14:45:44 -0700 Subject: [PATCH 26/74] Remove extension from ununsed places --- .../DataContracts/PerformanceCounterTelemetry.cs | 3 +-- .../DataContracts/SessionStateTelemetry.cs | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.ApplicationInsights/DataContracts/PerformanceCounterTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/PerformanceCounterTelemetry.cs index 2ef4c7973a..729a6f0b3a 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/PerformanceCounterTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/PerformanceCounterTelemetry.cs @@ -12,8 +12,7 @@ [Obsolete("Use MetricTelemetry instead.")] public sealed class PerformanceCounterTelemetry : ITelemetry, ISupportProperties { - internal readonly MetricTelemetry Data; - private IExtension extension; + internal readonly MetricTelemetry Data; private string categoryName = string.Empty; private string counterName = string.Empty; diff --git a/src/Microsoft.ApplicationInsights/DataContracts/SessionStateTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/SessionStateTelemetry.cs index 2c8924c2b2..90ffc011a9 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/SessionStateTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/SessionStateTelemetry.cs @@ -13,8 +13,7 @@ public sealed class SessionStateTelemetry : ITelemetry internal readonly EventTelemetry Data; private readonly string startEventName = "Session started"; - private readonly string endEventName = "Session ended"; - private IExtension extension; + private readonly string endEventName = "Session ended"; /// /// Initializes a new instance of the class. From 1ee2fdb5a85b3ad895a6c9bb05dab0fbac3992fd Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Thu, 26 Jul 2018 14:48:06 -0700 Subject: [PATCH 27/74] Comments --- .../Extensibility/ISerializationWriter.cs | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/Microsoft.ApplicationInsights/Extensibility/ISerializationWriter.cs b/src/Microsoft.ApplicationInsights/Extensibility/ISerializationWriter.cs index fa288bd4ca..e923033994 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/ISerializationWriter.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/ISerializationWriter.cs @@ -8,22 +8,49 @@ /// public interface ISerializationWriter { + /// + /// Writes name and value for a string field + /// void WriteProperty(string name, string value); + /// + /// Writes name and value for a double field + /// void WriteProperty(string name, double? value); + /// + /// Writes name and value for a int field + /// void WriteProperty(string name, int? value); + /// + /// Writes name and value for a boolean field + /// void WriteProperty(string name, bool? value); + /// + /// Writes name and value for a TimeSpan field + /// void WriteProperty(string name, TimeSpan? value); + /// + /// Writes name and values for a IList field + /// void WriteList(string name, IList items); + /// + /// Writes name and value for a IDictionary field + /// void WriteDictionary(string name, IDictionary items); + /// + /// Marks beginning of a complex object. + /// void WriteStartObject(string name); + /// + /// Marks ending of a complex object. + /// void WriteEndObject(string name); } } \ No newline at end of file From e2e0456857176dbddb4411b8f2879b4561e9c7e6 Mon Sep 17 00:00:00 2001 From: Alexander Kaplan Date: Thu, 26 Jul 2018 15:39:12 -0700 Subject: [PATCH 28/74] PR feedback. --- .../DataContracts/ExceptionDetailsInfo.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Microsoft.ApplicationInsights/DataContracts/ExceptionDetailsInfo.cs b/src/Microsoft.ApplicationInsights/DataContracts/ExceptionDetailsInfo.cs index ed39617b89..059508196f 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/ExceptionDetailsInfo.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/ExceptionDetailsInfo.cs @@ -14,6 +14,13 @@ public sealed class ExceptionDetailsInfo /// /// Constructs the instance of . /// + /// Exception id. + /// Parent exception's id. + /// Type name for the exception. + /// Exception message. + /// Indicates that this exception has full stack information. + /// Exception's stack trace. + /// Exception's stack. public ExceptionDetailsInfo(int id, int outerId, string typeName, string message, bool hasFullStack, string stack, IEnumerable parsedStack) { From a4e015fada0c4baf4c96b079b791873b94e6424e Mon Sep 17 00:00:00 2001 From: hungrybear88 Date: Fri, 27 Jul 2018 22:22:51 +1200 Subject: [PATCH 29/74] add hex checking and parsing add unit test --- .../TelemetryConfigurationFactoryTest.cs | 8 ++++++++ .../Implementation/TelemetryConfigurationFactory.cs | 13 +++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/Extensibility/TelemetryConfigurationFactoryTest.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/Extensibility/TelemetryConfigurationFactoryTest.cs index 514fd90b4b..8809b943ab 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/Extensibility/TelemetryConfigurationFactoryTest.cs +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/Extensibility/TelemetryConfigurationFactoryTest.cs @@ -328,6 +328,14 @@ public void LoadInstanceConvertsValueToExpectedTypeGivenXmlDefinitionWithNoChild object instance = TestableTelemetryConfigurationFactory.LoadInstance(definition, typeof(int), null, null); Assert.AreEqual(42, instance); } + + [TestMethod] + public void LoadInstanceConvertsValueToExpectedTypeGivenXmlDefinitionWithNoChildElementsParseHexValue() + { + var definition = new XElement("Definition", "0x42"); + object instance = TestableTelemetryConfigurationFactory.LoadInstance(definition, typeof(int), null, null); + Assert.AreEqual(66, instance); + } [TestMethod] public void LoadInstanceTrimsValueOfGivenXmlElementToIgnoreWhitespaceUsersMayAddToConfiguration() diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/TelemetryConfigurationFactory.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/TelemetryConfigurationFactory.cs index 107eaab0f7..6acd914866 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/TelemetryConfigurationFactory.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/TelemetryConfigurationFactory.cs @@ -411,7 +411,16 @@ private static void LoadInstanceFromValue(XElement definition, Type expectedType } else { - instance = Convert.ChangeType(valueString, expectedType, CultureInfo.InvariantCulture); + if (valueString.ToLower().IndexOf("0x") == 0) + { + CultureInfo provider = CultureInfo.InvariantCulture; + + instance = Int32.Parse(valueString.Remove(0, 2), NumberStyles.AllowHexSpecifier, provider); + } + else + { + instance = Convert.ChangeType(valueString, expectedType, CultureInfo.InvariantCulture); + } } } catch (InvalidCastException e) @@ -458,4 +467,4 @@ private static IEnumerable GetPropertyDefinitions(XElement instanceDef return attributeDefinitions.Concat(elementDefinitions); } } -} \ No newline at end of file +} From 3e1b432fc4cbf4b5b0eb8e08f77c18a9c2c73ab1 Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Mon, 30 Jul 2018 12:04:59 -0700 Subject: [PATCH 30/74] Remove syntactical erros arising from previous merge! --- .../DataContracts/ExceptionTelemetry.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs index 32ce2fb8bb..41ebf99277 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs @@ -17,17 +17,14 @@ public sealed class ExceptionTelemetry : ITelemetry, ISupportProperties, ISuppor { internal const string TelemetryName = "Exception"; internal readonly string BaseType = typeof(ExceptionData).Name; - internal ExceptionInfo Data = null; private readonly bool isCreatedFromExceptionInfo = false; private TelemetryContext context; - private readonly TelemetryContext context; private IExtension extension; private Exception exception; private string message; - private double? samplingPercentage; /// @@ -93,7 +90,7 @@ private ExceptionTelemetry(ExceptionTelemetry source) { this.exception = source.Exception; } - } + this.extension = source.extension?.DeepClone(); } From e4a675aca37f724e56cdb149369cadb87cf47735 Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Mon, 30 Jul 2018 12:40:56 -0700 Subject: [PATCH 31/74] Modify linux build def to publix trx files correctly --- .vsts/linux-build.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.vsts/linux-build.yml b/.vsts/linux-build.yml index da01572659..d9fa8d08b2 100644 --- a/.vsts/linux-build.yml +++ b/.vsts/linux-build.yml @@ -33,6 +33,9 @@ steps: arguments: "--configuration Release --filter TestCategory!=WindowsOnly" - task: PublishTestResults@2 + inputs: + testRunner: "VSTest" + testResultsFiles: "**/*.trx" - task: DotNetCoreCLI@1 inputs: From 7dd1132b7b2f870d792f3a6ca013be0ff0cfa1ef Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Mon, 30 Jul 2018 13:40:52 -0700 Subject: [PATCH 32/74] Linux build to emit trx files from test runs. --- .vsts/linux-build.yml | 4 ++-- src/Microsoft.ApplicationInsights/Channel/ITelemetry.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.vsts/linux-build.yml b/.vsts/linux-build.yml index d9fa8d08b2..3df2f59681 100644 --- a/.vsts/linux-build.yml +++ b/.vsts/linux-build.yml @@ -20,7 +20,7 @@ steps: inputs: command: "test" projects: "Test/**/*netcoreapp20*.csproj" - arguments: "--configuration Release --filter TestCategory!=WindowsOnly" + arguments: "--configuration Release -l trx --filter TestCategory!=WindowsOnly" - task: DotNetCoreInstaller@0 inputs: @@ -30,7 +30,7 @@ steps: inputs: command: "test" projects: "Test/**/*netcoreapp11*.csproj" - arguments: "--configuration Release --filter TestCategory!=WindowsOnly" + arguments: "--configuration Release -l trx --filter TestCategory!=WindowsOnly" - task: PublishTestResults@2 inputs: diff --git a/src/Microsoft.ApplicationInsights/Channel/ITelemetry.cs b/src/Microsoft.ApplicationInsights/Channel/ITelemetry.cs index bea3e655ed..6d9cf3aafa 100644 --- a/src/Microsoft.ApplicationInsights/Channel/ITelemetry.cs +++ b/src/Microsoft.ApplicationInsights/Channel/ITelemetry.cs @@ -20,7 +20,7 @@ public interface ITelemetry TelemetryContext Context { get; } /// - /// Gets or sets gets the extension used to extend this telemetry instance using new strong typed object. + /// Gets or sets gets the extension used to extend this telemetry instance using new strongly typed object. /// IExtension Extension { get; set; } From a466c3e8c0ebfe442490d987bcbf986128ba6ba2 Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Mon, 30 Jul 2018 14:23:52 -0700 Subject: [PATCH 33/74] Fix build break from previous PR --- .../Implementation/TelemetryConfigurationFactory.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/TelemetryConfigurationFactory.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/TelemetryConfigurationFactory.cs index 6acd914866..0397e54b6e 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/TelemetryConfigurationFactory.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/TelemetryConfigurationFactory.cs @@ -411,7 +411,7 @@ private static void LoadInstanceFromValue(XElement definition, Type expectedType } else { - if (valueString.ToLower().IndexOf("0x") == 0) + if (valueString.ToLowerInvariant().IndexOf("0x", StringComparison.OrdinalIgnoreCase) == 0) { CultureInfo provider = CultureInfo.InvariantCulture; From 1c3516dc94bb43942ef2ec2768967cb669269e15 Mon Sep 17 00:00:00 2001 From: MS-TimothyMothra Date: Mon, 30 Jul 2018 16:50:32 -0700 Subject: [PATCH 34/74] bump version 2.7.0 (#880) --- GlobalStaticVersion.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GlobalStaticVersion.props b/GlobalStaticVersion.props index cc89942a9e..429cabe8c5 100644 --- a/GlobalStaticVersion.props +++ b/GlobalStaticVersion.props @@ -9,7 +9,7 @@ 7 0 - beta4 + All From 1a6cdf4e2d411854c790905c693c6e9b72045188 Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Wed, 1 Aug 2018 12:50:11 -0700 Subject: [PATCH 38/74] Bump version to 2.8.0-beta1 --- GlobalStaticVersion.props | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/GlobalStaticVersion.props b/GlobalStaticVersion.props index 429cabe8c5..348586b4b6 100644 --- a/GlobalStaticVersion.props +++ b/GlobalStaticVersion.props @@ -6,10 +6,10 @@ Update for every public release. --> 2 - 7 + 8 0 - + beta1 - 2018-05-21 + 2018-08-01 $([MSBuild]::Divide($([System.DateTime]::Now.Subtract($([System.DateTime]::Parse($(SemanticVersionDate)))).TotalMinutes), 5).ToString('F0')) From ab9ceca0edef997d74c5d6247ce6f7c550fc5818 Mon Sep 17 00:00:00 2001 From: MS-TimothyMothra Date: Wed, 1 Aug 2018 13:03:36 -0700 Subject: [PATCH 39/74] bump version 2.7.1 (#885) --- GlobalStaticVersion.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GlobalStaticVersion.props b/GlobalStaticVersion.props index 429cabe8c5..b5d71cd462 100644 --- a/GlobalStaticVersion.props +++ b/GlobalStaticVersion.props @@ -7,7 +7,7 @@ --> 2 7 - 0 + 1 \ No newline at end of file From 3057f671dbfda1967d9002d0c671f062d701a97d Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Fri, 3 Aug 2018 11:16:53 -0700 Subject: [PATCH 43/74] al telemetry now does time and name as per old formats --- .../DataContracts/AvailabilityTelemetry.cs | 4 +-- .../DataContracts/DependencyTelemetry.cs | 5 ++-- .../DataContracts/EventTelemetry.cs | 5 ++-- .../DataContracts/ExceptionTelemetry.cs | 4 +-- .../DataContracts/MetricTelemetry.cs | 21 +++++---------- .../PageViewPerformanceTelemetry.cs | 5 ++-- .../DataContracts/PageViewTelemetry.cs | 4 +-- .../DataContracts/RequestTelemetry.cs | 4 +-- .../DataContracts/TraceTelemetry.cs | 5 ++-- .../Extensibility/ISerializationWriter.cs | 15 ----------- .../External/DataPointIExtension.cs | 27 +++++++++++++++++++ .../Implementation/JsonSerializationWriter.cs | 22 +++------------ .../Implementation/JsonSerializer.cs | 18 ++++++------- .../Extensibility/Implementation/Telemetry.cs | 5 ++-- 14 files changed, 70 insertions(+), 74 deletions(-) create mode 100644 src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/DataPointIExtension.cs diff --git a/src/Microsoft.ApplicationInsights/DataContracts/AvailabilityTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/AvailabilityTelemetry.cs index 14ff73a374..2336b0ffb0 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/AvailabilityTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/AvailabilityTelemetry.cs @@ -189,8 +189,8 @@ IExtension IExtension.DeepClone() /// public void Serialize(ISerializationWriter serializationWriter) { - serializationWriter.WriteProperty("name", TelemetryName); - serializationWriter.WriteProperty("time", TimeSpan.FromTicks(this.Timestamp.Ticks)); + serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName)); + serializationWriter.WriteProperty("time", this.Timestamp.UtcDateTime.ToString("o", CultureInfo.InvariantCulture)); serializationWriter.WriteProperty("seq", this.Sequence); serializationWriter.WriteProperty("iKey", this.Context.InstrumentationKey); diff --git a/src/Microsoft.ApplicationInsights/DataContracts/DependencyTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/DependencyTelemetry.cs index bc570c1cfa..57c3fed5a4 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/DependencyTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/DependencyTelemetry.cs @@ -4,6 +4,7 @@ namespace Microsoft.ApplicationInsights.DataContracts using System.Collections.Concurrent; using System.Collections.Generic; using System.ComponentModel; + using System.Globalization; using Microsoft.ApplicationInsights.Channel; using Microsoft.ApplicationInsights.Extensibility; using Microsoft.ApplicationInsights.Extensibility.Implementation; @@ -343,8 +344,8 @@ public void SetOperationDetail(string key, object detail) /// public void Serialize(ISerializationWriter serializationWriter) { - serializationWriter.WriteProperty("name", TelemetryName); - serializationWriter.WriteProperty("time", TimeSpan.FromTicks(this.Timestamp.Ticks)); + serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName)); + serializationWriter.WriteProperty("time", this.Timestamp.UtcDateTime.ToString("o", CultureInfo.InvariantCulture)); serializationWriter.WriteProperty("sampleRate", this.samplingPercentage); serializationWriter.WriteProperty("seq", this.Sequence); diff --git a/src/Microsoft.ApplicationInsights/DataContracts/EventTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/EventTelemetry.cs index bbd4f68188..c3fab0e270 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/EventTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/EventTelemetry.cs @@ -2,6 +2,7 @@ { using System; using System.Collections.Generic; + using System.Globalization; using System.Threading; using Microsoft.ApplicationInsights.Channel; using Microsoft.ApplicationInsights.Extensibility; @@ -145,8 +146,8 @@ IExtension IExtension.DeepClone() /// public void Serialize(ISerializationWriter serializationWriter) { - serializationWriter.WriteProperty("name", TelemetryName); - serializationWriter.WriteProperty("time", TimeSpan.FromTicks(this.Timestamp.Ticks)); + serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName)); + serializationWriter.WriteProperty("time", this.Timestamp.UtcDateTime.ToString("o", CultureInfo.InvariantCulture)); serializationWriter.WriteProperty("sampleRate", this.samplingPercentage); serializationWriter.WriteProperty("seq", this.Sequence); diff --git a/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs index 16c82325a0..e34c9088ca 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs @@ -288,8 +288,8 @@ IExtension IExtension.DeepClone() /// public void Serialize(ISerializationWriter serializationWriter) { - serializationWriter.WriteProperty("name", TelemetryName); - serializationWriter.WriteProperty("time", TimeSpan.FromTicks(this.Timestamp.Ticks)); + serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName)); + serializationWriter.WriteProperty("time", this.Timestamp.UtcDateTime.ToString("o", CultureInfo.InvariantCulture)); serializationWriter.WriteProperty("seq", this.Sequence); serializationWriter.WriteProperty("iKey", this.Context.InstrumentationKey); diff --git a/src/Microsoft.ApplicationInsights/DataContracts/MetricTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/MetricTelemetry.cs index 854377b11a..f02444b125 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/MetricTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/MetricTelemetry.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; using System.ComponentModel; + using System.Globalization; using Microsoft.ApplicationInsights.Channel; using Microsoft.ApplicationInsights.Extensibility; using Microsoft.ApplicationInsights.Extensibility.Implementation; @@ -261,8 +262,8 @@ IExtension IExtension.DeepClone() /// public void Serialize(ISerializationWriter serializationWriter) { - serializationWriter.WriteProperty("name", TelemetryName); - serializationWriter.WriteProperty("time", TimeSpan.FromTicks(this.Timestamp.Ticks)); + serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName)); + serializationWriter.WriteProperty("time", this.Timestamp.UtcDateTime.ToString("o", CultureInfo.InvariantCulture)); serializationWriter.WriteProperty("seq", this.Sequence); serializationWriter.WriteProperty("iKey", this.Context.InstrumentationKey); @@ -276,18 +277,10 @@ public void Serialize(ISerializationWriter serializationWriter) serializationWriter.WriteProperty("ver", this.Data.ver); - serializationWriter.WriteStartList("metrics"); - serializationWriter.WriteStartObject(); - serializationWriter.WriteProperty("ns", this.MetricNamespace); - serializationWriter.WriteProperty("name", this.Metric.name); - serializationWriter.WriteProperty("kind", this.Metric.kind.ToString()); - serializationWriter.WriteProperty("value", this.Metric.value); - serializationWriter.WriteProperty("count", this.Metric.count); - serializationWriter.WriteProperty("min", this.Metric.min); - serializationWriter.WriteProperty("max", this.Metric.max); - serializationWriter.WriteProperty("stdDev", this.Metric.stdDev); - serializationWriter.WriteEndObject(); - serializationWriter.WriteEndList(); + IList metricLists = new List(); + metricLists.Add(this.Metric); + + serializationWriter.WriteList("metrics", metricLists); serializationWriter.WriteDictionary("properties", this.Data.properties); serializationWriter.WriteEndObject(); // basedata diff --git a/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs index 1e319059d7..671d624354 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs @@ -2,6 +2,7 @@ { using System; using System.Collections.Generic; + using System.Globalization; using Microsoft.ApplicationInsights.Channel; using Microsoft.ApplicationInsights.Extensibility; using Microsoft.ApplicationInsights.Extensibility.Implementation; @@ -235,8 +236,8 @@ IExtension IExtension.DeepClone() /// public void Serialize(ISerializationWriter serializationWriter) { - serializationWriter.WriteProperty("name", TelemetryName); - serializationWriter.WriteProperty("time", TimeSpan.FromTicks(this.Timestamp.Ticks)); + serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName)); + serializationWriter.WriteProperty("time", this.Timestamp.UtcDateTime.ToString("o", CultureInfo.InvariantCulture)); serializationWriter.WriteProperty("sampleRate", this.samplingPercentage); serializationWriter.WriteProperty("seq", this.Sequence); diff --git a/src/Microsoft.ApplicationInsights/DataContracts/PageViewTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/PageViewTelemetry.cs index b4c458b48a..24ee950443 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/PageViewTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/PageViewTelemetry.cs @@ -189,8 +189,8 @@ IExtension IExtension.DeepClone() /// public void Serialize(ISerializationWriter serializationWriter) { - serializationWriter.WriteProperty("name", TelemetryName); - serializationWriter.WriteProperty("time", TimeSpan.FromTicks(this.Timestamp.Ticks)); + serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName)); + serializationWriter.WriteProperty("time", this.Timestamp.UtcDateTime.ToString("o", CultureInfo.InvariantCulture)); serializationWriter.WriteProperty("sampleRate", this.samplingPercentage); serializationWriter.WriteProperty("seq", this.Sequence); diff --git a/src/Microsoft.ApplicationInsights/DataContracts/RequestTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/RequestTelemetry.cs index e3ea52c0d2..88b30df7a5 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/RequestTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/RequestTelemetry.cs @@ -238,8 +238,8 @@ public override ITelemetry DeepClone() /// public void Serialize(ISerializationWriter serializationWriter) { - serializationWriter.WriteProperty("name", TelemetryName); - serializationWriter.WriteProperty("time", TimeSpan.FromTicks(this.Timestamp.Ticks)); + serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName)); + serializationWriter.WriteProperty("time", this.Timestamp.UtcDateTime.ToString("o", CultureInfo.InvariantCulture)); serializationWriter.WriteProperty("sampleRate", this.samplingPercentage); serializationWriter.WriteProperty("seq", this.Sequence); diff --git a/src/Microsoft.ApplicationInsights/DataContracts/TraceTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/TraceTelemetry.cs index b87ba848db..5aa52c11f7 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/TraceTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/TraceTelemetry.cs @@ -2,6 +2,7 @@ { using System; using System.Collections.Generic; + using System.Globalization; using Microsoft.ApplicationInsights.Channel; using Microsoft.ApplicationInsights.Extensibility; using Microsoft.ApplicationInsights.Extensibility.Implementation; @@ -146,8 +147,8 @@ IExtension IExtension.DeepClone() /// public void Serialize(ISerializationWriter serializationWriter) { - serializationWriter.WriteProperty("name", TelemetryName); - serializationWriter.WriteProperty("time", TimeSpan.FromTicks(this.Timestamp.Ticks)); + serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName)); + serializationWriter.WriteProperty("time", this.Timestamp.UtcDateTime.ToString("o", CultureInfo.InvariantCulture)); serializationWriter.WriteProperty("sampleRate", this.samplingPercentage); serializationWriter.WriteProperty("seq", this.Sequence); diff --git a/src/Microsoft.ApplicationInsights/Extensibility/ISerializationWriter.cs b/src/Microsoft.ApplicationInsights/Extensibility/ISerializationWriter.cs index 21ca84ee74..c71c1b35d2 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/ISerializationWriter.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/ISerializationWriter.cs @@ -58,11 +58,6 @@ public interface ISerializationWriter /// void WriteDictionary(string name, IDictionary items); - /// - /// Marks beginning of a complex object. - /// - void WriteStartObject(); - /// /// Marks beginning of a complex object. /// @@ -72,15 +67,5 @@ public interface ISerializationWriter /// Marks ending of a complex object. /// void WriteEndObject(); - - /// - /// Starts a list of items. - /// - void WriteStartList(string name); - - /// - /// Marks ending of a list of items. - /// - void WriteEndList(); } } \ No newline at end of file diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/DataPointIExtension.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/DataPointIExtension.cs new file mode 100644 index 0000000000..e99ed0d680 --- /dev/null +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/DataPointIExtension.cs @@ -0,0 +1,27 @@ +namespace Microsoft.ApplicationInsights.Extensibility.Implementation.External +{ + using Microsoft.ApplicationInsights.DataContracts; + + /// + /// Partial class to implement IExtension + /// + internal partial class DataPoint : IExtension + { + public void Serialize(ISerializationWriter serializationWriter) + { + serializationWriter.WriteProperty("ns", this.ns); + serializationWriter.WriteProperty("name", this.name); + serializationWriter.WriteProperty("kind", this.kind.ToString()); + serializationWriter.WriteProperty("value", this.value); + serializationWriter.WriteProperty("count", this.count); + serializationWriter.WriteProperty("min", this.min); + serializationWriter.WriteProperty("max", this.max); + serializationWriter.WriteProperty("stdDev", this.stdDev); + } + + IExtension IExtension.DeepClone() + { + return this.DeepClone(); + } + } +} diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializationWriter.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializationWriter.cs index b4c109f790..afe7291e09 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializationWriter.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializationWriter.cs @@ -15,14 +15,7 @@ public JsonSerializationWriter(TextWriter textWriter) { this.textWriter = textWriter; this.textWriter.Write('{'); - } - - /// - public void WriteStartObject() - { - this.textWriter.Write('{'); - this.currentObjectHasProperties = false; - } + } /// public void WriteStartObject(string name) @@ -172,17 +165,10 @@ public void WriteEndObject() this.textWriter.Write('}'); } - /// - public void WriteStartList(string name) + private void WriteStartObject() { - this.WritePropertyName(name); - this.WriteStartArray(); - } - - /// - public void WriteEndList() - { - this.WriteEndArray(); + this.textWriter.Write('{'); + this.currentObjectHasProperties = false; } /// diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs index 222aebae66..5954a6500f 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs @@ -341,7 +341,7 @@ private static void SerializeEventTelemetry(EventTelemetry eventTelemetry, JsonW { writer.WriteStartObject(); - eventTelemetry.WriteTelemetryName(writer, EventTelemetry.TelemetryName); + // eventTelemetry.WriteTelemetryName(EventTelemetry.TelemetryName); eventTelemetry.WriteEnvelopeProperties(writer); writer.WritePropertyName("data"); { @@ -370,7 +370,7 @@ private static void SerializeExceptionTelemetry(ExceptionTelemetry exceptionTele { writer.WriteStartObject(); - exceptionTelemetry.WriteTelemetryName(writer, ExceptionTelemetry.TelemetryName); + // exceptionTelemetry.WriteTelemetryName(writer, ExceptionTelemetry.TelemetryName); exceptionTelemetry.WriteEnvelopeProperties(writer); writer.WritePropertyName("data"); { @@ -413,7 +413,7 @@ private static void SerializeMetricTelemetry(MetricTelemetry metricTelemetry, Js { writer.WriteStartObject(); - metricTelemetry.WriteTelemetryName(writer, MetricTelemetry.TelemetryName); + // metricTelemetry.WriteTelemetryName(writer, MetricTelemetry.TelemetryName); metricTelemetry.WriteEnvelopeProperties(writer); writer.WritePropertyName("data"); { @@ -464,7 +464,7 @@ private static void SerializePageViewTelemetry(PageViewTelemetry pageViewTelemet { writer.WriteStartObject(); - pageViewTelemetry.WriteTelemetryName(writer, PageViewTelemetry.TelemetryName); + // pageViewTelemetry.WriteTelemetryName(writer, PageViewTelemetry.TelemetryName); pageViewTelemetry.WriteEnvelopeProperties(writer); writer.WritePropertyName("data"); { @@ -496,7 +496,7 @@ private static void SerializePageViewPerformanceTelemetry(PageViewPerformanceTel { writer.WriteStartObject(); - pageViewPerfTelemetry.WriteTelemetryName(writer, PageViewPerformanceTelemetry.TelemetryName); + // pageViewPerfTelemetry.WriteTelemetryName(writer, PageViewPerformanceTelemetry.TelemetryName); pageViewPerfTelemetry.WriteEnvelopeProperties(writer); writer.WritePropertyName("data"); { @@ -533,7 +533,7 @@ private static void SerializeDependencyTelemetry(DependencyTelemetry dependencyT { writer.WriteStartObject(); - dependencyTelemetry.WriteTelemetryName(writer, DependencyTelemetry.TelemetryName); + // dependencyTelemetry.WriteTelemetryName(writer, DependencyTelemetry.TelemetryName); dependencyTelemetry.WriteEnvelopeProperties(writer); writer.WritePropertyName("data"); { @@ -569,7 +569,7 @@ private static void SerializeRequestTelemetry(RequestTelemetry requestTelemetry, { jsonWriter.WriteStartObject(); - requestTelemetry.WriteTelemetryName(jsonWriter, RequestTelemetry.TelemetryName); + // requestTelemetry.WriteTelemetryName(jsonWriter, RequestTelemetry.TelemetryName); requestTelemetry.WriteEnvelopeProperties(jsonWriter); jsonWriter.WritePropertyName("data"); { @@ -605,7 +605,7 @@ private static void SerializeTraceTelemetry(TraceTelemetry traceTelemetry, JsonW { writer.WriteStartObject(); - traceTelemetry.WriteTelemetryName(writer, TraceTelemetry.TelemetryName); + // traceTelemetry.WriteTelemetryName(writer, TraceTelemetry.TelemetryName); traceTelemetry.WriteEnvelopeProperties(writer); writer.WritePropertyName("data"); { @@ -643,7 +643,7 @@ private static void SerializeAvailability(AvailabilityTelemetry availabilityTele { writer.WriteStartObject(); - availabilityTelemetry.WriteTelemetryName(writer, AvailabilityTelemetry.TelemetryName); + // availabilityTelemetry.WriteTelemetryName(writer, AvailabilityTelemetry.TelemetryName); availabilityTelemetry.WriteEnvelopeProperties(writer); writer.WritePropertyName("data"); { diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Telemetry.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Telemetry.cs index 632b5c305d..87e50b6ab2 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Telemetry.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Telemetry.cs @@ -25,7 +25,7 @@ public static void WriteEnvelopeProperties(this ITelemetry telemetry, IJsonWrite WriteTelemetryContext(json, telemetry.Context); } - public static void WriteTelemetryName(this ITelemetry telemetry, IJsonWriter json, string telemetryName) + public static string WriteTelemetryName(this ITelemetry telemetry, string telemetryName) { // A different event name prefix is sent for normal mode and developer mode. bool isDevMode = false; @@ -44,7 +44,8 @@ public static void WriteTelemetryName(this ITelemetry telemetry, IJsonWriter jso isDevMode ? Constants.DevModeTelemetryNamePrefix : Constants.TelemetryNamePrefix, NormalizeInstrumentationKey(telemetry.Context.InstrumentationKey), telemetryName); - json.WriteProperty("name", eventName); + + return eventName; } public static void WriteTelemetryContext(IJsonWriter json, TelemetryContext context) From f6ab449905580d49c0273f00a444db2e60f69a12 Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Fri, 3 Aug 2018 11:37:24 -0700 Subject: [PATCH 44/74] Check for null severity level. Added StartObject for every Type --- .../DataContracts/AvailabilityTelemetry.cs | 1 + .../DataContracts/DependencyTelemetry.cs | 1 + .../DataContracts/EventTelemetry.cs | 1 + .../DataContracts/ExceptionTelemetry.cs | 2 ++ .../DataContracts/MetricTelemetry.cs | 1 + .../DataContracts/PageViewPerformanceTelemetry.cs | 1 + .../DataContracts/PageViewTelemetry.cs | 1 + .../DataContracts/RequestTelemetry.cs | 1 + .../DataContracts/TraceTelemetry.cs | 3 ++- .../Extensibility/ISerializationWriter.cs | 5 +++++ .../Implementation/JsonSerializationWriter.cs | 11 ++++++++++- 11 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.ApplicationInsights/DataContracts/AvailabilityTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/AvailabilityTelemetry.cs index 2336b0ffb0..5caea5af10 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/AvailabilityTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/AvailabilityTelemetry.cs @@ -189,6 +189,7 @@ IExtension IExtension.DeepClone() /// public void Serialize(ISerializationWriter serializationWriter) { + serializationWriter.WriteStartObject(); serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName)); serializationWriter.WriteProperty("time", this.Timestamp.UtcDateTime.ToString("o", CultureInfo.InvariantCulture)); serializationWriter.WriteProperty("seq", this.Sequence); diff --git a/src/Microsoft.ApplicationInsights/DataContracts/DependencyTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/DependencyTelemetry.cs index 57c3fed5a4..9a1437524c 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/DependencyTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/DependencyTelemetry.cs @@ -344,6 +344,7 @@ public void SetOperationDetail(string key, object detail) /// public void Serialize(ISerializationWriter serializationWriter) { + serializationWriter.WriteStartObject(); serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName)); serializationWriter.WriteProperty("time", this.Timestamp.UtcDateTime.ToString("o", CultureInfo.InvariantCulture)); serializationWriter.WriteProperty("sampleRate", this.samplingPercentage); diff --git a/src/Microsoft.ApplicationInsights/DataContracts/EventTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/EventTelemetry.cs index c3fab0e270..8d1b639a99 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/EventTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/EventTelemetry.cs @@ -146,6 +146,7 @@ IExtension IExtension.DeepClone() /// public void Serialize(ISerializationWriter serializationWriter) { + serializationWriter.WriteStartObject(); serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName)); serializationWriter.WriteProperty("time", this.Timestamp.UtcDateTime.ToString("o", CultureInfo.InvariantCulture)); serializationWriter.WriteProperty("sampleRate", this.samplingPercentage); diff --git a/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs index e34c9088ca..41e8628f7a 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs @@ -288,8 +288,10 @@ IExtension IExtension.DeepClone() /// public void Serialize(ISerializationWriter serializationWriter) { + serializationWriter.WriteStartObject(); serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName)); serializationWriter.WriteProperty("time", this.Timestamp.UtcDateTime.ToString("o", CultureInfo.InvariantCulture)); + serializationWriter.WriteProperty("sampleRate", this.samplingPercentage); serializationWriter.WriteProperty("seq", this.Sequence); serializationWriter.WriteProperty("iKey", this.Context.InstrumentationKey); diff --git a/src/Microsoft.ApplicationInsights/DataContracts/MetricTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/MetricTelemetry.cs index f02444b125..a7767dc7b9 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/MetricTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/MetricTelemetry.cs @@ -262,6 +262,7 @@ IExtension IExtension.DeepClone() /// public void Serialize(ISerializationWriter serializationWriter) { + serializationWriter.WriteStartObject(); serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName)); serializationWriter.WriteProperty("time", this.Timestamp.UtcDateTime.ToString("o", CultureInfo.InvariantCulture)); serializationWriter.WriteProperty("seq", this.Sequence); diff --git a/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs index 671d624354..4685b5ac48 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs @@ -236,6 +236,7 @@ IExtension IExtension.DeepClone() /// public void Serialize(ISerializationWriter serializationWriter) { + serializationWriter.WriteStartObject(); serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName)); serializationWriter.WriteProperty("time", this.Timestamp.UtcDateTime.ToString("o", CultureInfo.InvariantCulture)); serializationWriter.WriteProperty("sampleRate", this.samplingPercentage); diff --git a/src/Microsoft.ApplicationInsights/DataContracts/PageViewTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/PageViewTelemetry.cs index 24ee950443..727eab7252 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/PageViewTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/PageViewTelemetry.cs @@ -189,6 +189,7 @@ IExtension IExtension.DeepClone() /// public void Serialize(ISerializationWriter serializationWriter) { + serializationWriter.WriteStartObject(); serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName)); serializationWriter.WriteProperty("time", this.Timestamp.UtcDateTime.ToString("o", CultureInfo.InvariantCulture)); serializationWriter.WriteProperty("sampleRate", this.samplingPercentage); diff --git a/src/Microsoft.ApplicationInsights/DataContracts/RequestTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/RequestTelemetry.cs index 88b30df7a5..005aca6911 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/RequestTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/RequestTelemetry.cs @@ -238,6 +238,7 @@ public override ITelemetry DeepClone() /// public void Serialize(ISerializationWriter serializationWriter) { + serializationWriter.WriteStartObject(); serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName)); serializationWriter.WriteProperty("time", this.Timestamp.UtcDateTime.ToString("o", CultureInfo.InvariantCulture)); serializationWriter.WriteProperty("sampleRate", this.samplingPercentage); diff --git a/src/Microsoft.ApplicationInsights/DataContracts/TraceTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/TraceTelemetry.cs index 5aa52c11f7..f43eecbdb6 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/TraceTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/TraceTelemetry.cs @@ -147,6 +147,7 @@ IExtension IExtension.DeepClone() /// public void Serialize(ISerializationWriter serializationWriter) { + serializationWriter.WriteStartObject(); serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName)); serializationWriter.WriteProperty("time", this.Timestamp.UtcDateTime.ToString("o", CultureInfo.InvariantCulture)); serializationWriter.WriteProperty("sampleRate", this.samplingPercentage); @@ -163,7 +164,7 @@ public void Serialize(ISerializationWriter serializationWriter) serializationWriter.WriteProperty("ver", this.Data.ver); serializationWriter.WriteProperty("message", this.Data.message); - serializationWriter.WriteProperty("severityLevel", this.SeverityLevel.Value.ToString()); + serializationWriter.WriteProperty("severityLevel", this.SeverityLevel.HasValue ? this.SeverityLevel.Value.ToString() : null); serializationWriter.WriteDictionary("properties", this.Data.properties); serializationWriter.WriteDictionary("measurements", this.Data.measurements); diff --git a/src/Microsoft.ApplicationInsights/Extensibility/ISerializationWriter.cs b/src/Microsoft.ApplicationInsights/Extensibility/ISerializationWriter.cs index c71c1b35d2..7a1a51dca1 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/ISerializationWriter.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/ISerializationWriter.cs @@ -63,6 +63,11 @@ public interface ISerializationWriter /// void WriteStartObject(string name); + /// + /// Marks beginning of a complex object. + /// + void WriteStartObject(); + /// /// Marks ending of a complex object. /// diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializationWriter.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializationWriter.cs index afe7291e09..08b8134724 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializationWriter.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializationWriter.cs @@ -14,8 +14,15 @@ internal class JsonSerializationWriter : ISerializationWriter public JsonSerializationWriter(TextWriter textWriter) { this.textWriter = textWriter; + // this.textWriter.Write('{'); + } + + /// + public void WriteStartObject() + { this.textWriter.Write('{'); - } + this.currentObjectHasProperties = false; + } /// public void WriteStartObject(string name) @@ -165,11 +172,13 @@ public void WriteEndObject() this.textWriter.Write('}'); } +/* private void WriteStartObject() { this.textWriter.Write('{'); this.currentObjectHasProperties = false; } +*/ /// /// Writes the specified property name enclosed in double quotation marks followed by a colon. From f0d70a2d1e6d2cbfa75709abefc63593085ea41e Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Fri, 3 Aug 2018 11:39:42 -0700 Subject: [PATCH 45/74] removed temp things. --- ConsoleApp3/App.config | 6 - ConsoleApp3/ConsoleApp3.csproj | 61 ------ ConsoleApp3/JsonSerializationWriter.cs | 245 ----------------------- ConsoleApp3/Program.cs | 45 ----- Microsoft.ApplicationInsights.sln | 44 ---- TestAppStableSDK/Program.cs | 38 ---- TestAppStableSDK/TestAppStableSDK.csproj | 14 -- 7 files changed, 453 deletions(-) delete mode 100644 ConsoleApp3/App.config delete mode 100644 ConsoleApp3/ConsoleApp3.csproj delete mode 100644 ConsoleApp3/JsonSerializationWriter.cs delete mode 100644 ConsoleApp3/Program.cs delete mode 100644 TestAppStableSDK/Program.cs delete mode 100644 TestAppStableSDK/TestAppStableSDK.csproj diff --git a/ConsoleApp3/App.config b/ConsoleApp3/App.config deleted file mode 100644 index bae5d6d814..0000000000 --- a/ConsoleApp3/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/ConsoleApp3/ConsoleApp3.csproj b/ConsoleApp3/ConsoleApp3.csproj deleted file mode 100644 index 129185144f..0000000000 --- a/ConsoleApp3/ConsoleApp3.csproj +++ /dev/null @@ -1,61 +0,0 @@ - - - - - Debug - AnyCPU - {C6AE3952-C62E-4AC3-BFFE-EC456DFDC4B5} - Exe - ConsoleApp3 - ConsoleApp3 - v4.6.1 - 512 - true - - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - - - {e9ecee96-dd50-42f6-9f33-0978cdfa15ed} - Microsoft.ApplicationInsights - - - - - - - \ No newline at end of file diff --git a/ConsoleApp3/JsonSerializationWriter.cs b/ConsoleApp3/JsonSerializationWriter.cs deleted file mode 100644 index 6d6785c0fc..0000000000 --- a/ConsoleApp3/JsonSerializationWriter.cs +++ /dev/null @@ -1,245 +0,0 @@ -using Microsoft.ApplicationInsights.Extensibility; -using System; -using System.Collections.Generic; -using System.Globalization; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ConsoleApp3 -{ - public class JsonSerializationWriter : ISerializationWriter - { - private readonly TextWriter textWriter; - private bool currentObjectHasProperties; - - internal JsonSerializationWriter(TextWriter textWriter) - { - this.textWriter = textWriter; - this.textWriter.Write('{'); - } - - public void Flush() - { - this.textWriter.Flush(); - } - - // ISerializationWriter - public void WriteStartObject(string name) - { - this.WritePropertyName(name); - this.textWriter.Write('{'); - this.currentObjectHasProperties = false; - } - - // ISerializationWriter - public void WriteProperty(string name, string value) - { - if (!string.IsNullOrEmpty(value)) - { - this.WritePropertyName(name); - this.WriteString(value); - } - } - - public void WriteProperty(string name, int? value) - { - if (value.HasValue) - { - this.WritePropertyName(name); - this.textWriter.Write(value.Value.ToString(CultureInfo.InvariantCulture)); - } - } - - public void WriteProperty(string name, bool? value) - { - if (value.HasValue) - { - this.WritePropertyName(name); - this.textWriter.Write(value.Value ? "true" : "false"); - } - } - - // ISerializationWriter - public void WriteProperty(string name, double? value) - { - if (value.HasValue) - { - this.WritePropertyName(name); - this.textWriter.Write(value.Value.ToString(CultureInfo.InvariantCulture)); - } - } - - // ISerializationWriter - public void WriteProperty(string name, TimeSpan? value) - { - if (value.HasValue) - { - this.WriteProperty(name, value.Value.ToString(string.Empty, CultureInfo.InvariantCulture)); - } - } - - public void WriteProperty(string name, DateTimeOffset? value) - { - if (value.HasValue) - { - this.WriteProperty(name, value.Value.ToString("o", CultureInfo.InvariantCulture)); - } - } - - public void WriteList(string name, IList items) - { - if (items != null && items.Count > 0) - { - this.WritePropertyName(name); - this.WriteStartArray(); - foreach (var item in items) - { - this.WriteComma(); - this.WriteRawValue(item); - } - this.WriteEndArray(); - - this.WriteEndObject(); - } - } - - public void WriteDictionary(string name, IDictionary values) - { - if (values != null && values.Count > 0) - { - this.WritePropertyName(name); - this.WriteStartObject(name); - foreach (KeyValuePair item in values) - { - this.WriteProperty(item.Key, item.Value); - } - - this.WriteEndObject(); - } - } - - public void WriteDictionary(string name, IDictionary values) - { - if (values != null && values.Count > 0) - { - this.WriteStartObject(name); - foreach (KeyValuePair item in values) - { - this.WriteProperty(item.Key, item.Value); - } - - this.WriteEndObject(); - } - } - - public void WriteEndObject() - { - this.textWriter.Write('}'); - } - - - private void WriteStartArray() - { - this.textWriter.Write('['); - } - - private void WriteEndArray() - { - this.textWriter.Write(']'); - } - - private void WriteComma() - { - this.textWriter.Write(','); - } - - private void WriteRawValue(object value) - { - this.textWriter.Write(string.Format(CultureInfo.InvariantCulture, "{0}", value)); - } - - /// - /// Writes the specified property name enclosed in double quotation marks followed by a colon. - /// - /// - /// When this method is called multiple times, the second call after - /// and all subsequent calls will write a coma before the name. - /// - private void WritePropertyName(string name) - { - if (name == null) - { - throw new ArgumentNullException("name"); - } - - if (name.Length == 0) - { - throw new ArgumentException("name"); - } - - if (this.currentObjectHasProperties) - { - this.textWriter.Write(','); - } - else - { - this.currentObjectHasProperties = true; - } - - this.WriteString(name); - this.textWriter.Write(':'); - } - - private void WriteString(string value) - { - this.textWriter.Write('"'); - - foreach (char c in value) - { - switch (c) - { - case '\\': - this.textWriter.Write("\\\\"); - break; - case '"': - this.textWriter.Write("\\\""); - break; - case '\n': - this.textWriter.Write("\\n"); - break; - case '\b': - this.textWriter.Write("\\b"); - break; - case '\f': - this.textWriter.Write("\\f"); - break; - case '\r': - this.textWriter.Write("\\r"); - break; - case '\t': - this.textWriter.Write("\\t"); - break; - default: - if (!char.IsControl(c)) - { - this.textWriter.Write(c); - } - else - { - this.textWriter.Write(@"\u"); - this.textWriter.Write(((ushort)c).ToString("x4", CultureInfo.InvariantCulture)); - } - - break; - } - } - - this.textWriter.Write('"'); - } - - - } -} - diff --git a/ConsoleApp3/Program.cs b/ConsoleApp3/Program.cs deleted file mode 100644 index c280645d9f..0000000000 --- a/ConsoleApp3/Program.cs +++ /dev/null @@ -1,45 +0,0 @@ -using Microsoft.ApplicationInsights; -using Microsoft.ApplicationInsights.DataContracts; -using Microsoft.ApplicationInsights.Extensibility; -using Microsoft.ApplicationInsights.Extensibility.Implementation; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ConsoleApp3 -{ - class Program - { - static void Main(string[] args) - { - TelemetryClient client = new TelemetryClient(); - - - client.Context.InstrumentationKey = "myikey"; - client.Context.Properties.Add("TC.Context.Property", "SomeValue"); - //client.Context.GlobalProperties.Add("TC.Context.GlobalProperty", "SomeValue"); - - var met = new MetricTelemetry("mymetric", 38.09); - client.TrackMetric(met); - - try - { - ThrowExc(); - } - catch (Exception ex) - { - client.TrackException(ex); - } - } - - private static void ThrowExc() - { - int x = 0; - int y = 10 / x; - - } - } -} diff --git a/Microsoft.ApplicationInsights.sln b/Microsoft.ApplicationInsights.sln index 7735118f5d..80e7ce1b31 100644 --- a/Microsoft.ApplicationInsights.sln +++ b/Microsoft.ApplicationInsights.sln @@ -61,10 +61,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TelemetryChannel.netcoreapp EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TelemetryChannel.netcoreapp20.Tests", "Test\ServerTelemetryChannel.Test\NetCore20.Tests\TelemetryChannel.netcoreapp20.Tests.csproj", "{14FA551E-886A-4D1B-B716-567EB4954C8E}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp3", "ConsoleApp3\ConsoleApp3.csproj", "{C6AE3952-C62E-4AC3-BFFE-EC456DFDC4B5}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestAppStableSDK", "TestAppStableSDK\TestAppStableSDK.csproj", "{6C524958-D58C-4ECD-8B2D-DA8492DCBD2B}" -EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution Test\Microsoft.ApplicationInsights.Test\Shared\Microsoft.ApplicationInsights.Shared.Tests.projitems*{0927e682-4a56-45b6-8125-94fa066b2f57}*SharedItemsImports = 4 @@ -310,46 +306,6 @@ Global {14FA551E-886A-4D1B-B716-567EB4954C8E}.Release|x64.Build.0 = Release|Any CPU {14FA551E-886A-4D1B-B716-567EB4954C8E}.Release|x86.ActiveCfg = Release|Any CPU {14FA551E-886A-4D1B-B716-567EB4954C8E}.Release|x86.Build.0 = Release|Any CPU - {C6AE3952-C62E-4AC3-BFFE-EC456DFDC4B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C6AE3952-C62E-4AC3-BFFE-EC456DFDC4B5}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C6AE3952-C62E-4AC3-BFFE-EC456DFDC4B5}.Debug|ARM.ActiveCfg = Debug|Any CPU - {C6AE3952-C62E-4AC3-BFFE-EC456DFDC4B5}.Debug|ARM.Build.0 = Debug|Any CPU - {C6AE3952-C62E-4AC3-BFFE-EC456DFDC4B5}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {C6AE3952-C62E-4AC3-BFFE-EC456DFDC4B5}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {C6AE3952-C62E-4AC3-BFFE-EC456DFDC4B5}.Debug|x64.ActiveCfg = Debug|Any CPU - {C6AE3952-C62E-4AC3-BFFE-EC456DFDC4B5}.Debug|x64.Build.0 = Debug|Any CPU - {C6AE3952-C62E-4AC3-BFFE-EC456DFDC4B5}.Debug|x86.ActiveCfg = Debug|Any CPU - {C6AE3952-C62E-4AC3-BFFE-EC456DFDC4B5}.Debug|x86.Build.0 = Debug|Any CPU - {C6AE3952-C62E-4AC3-BFFE-EC456DFDC4B5}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C6AE3952-C62E-4AC3-BFFE-EC456DFDC4B5}.Release|Any CPU.Build.0 = Release|Any CPU - {C6AE3952-C62E-4AC3-BFFE-EC456DFDC4B5}.Release|ARM.ActiveCfg = Release|Any CPU - {C6AE3952-C62E-4AC3-BFFE-EC456DFDC4B5}.Release|ARM.Build.0 = Release|Any CPU - {C6AE3952-C62E-4AC3-BFFE-EC456DFDC4B5}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {C6AE3952-C62E-4AC3-BFFE-EC456DFDC4B5}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {C6AE3952-C62E-4AC3-BFFE-EC456DFDC4B5}.Release|x64.ActiveCfg = Release|Any CPU - {C6AE3952-C62E-4AC3-BFFE-EC456DFDC4B5}.Release|x64.Build.0 = Release|Any CPU - {C6AE3952-C62E-4AC3-BFFE-EC456DFDC4B5}.Release|x86.ActiveCfg = Release|Any CPU - {C6AE3952-C62E-4AC3-BFFE-EC456DFDC4B5}.Release|x86.Build.0 = Release|Any CPU - {6C524958-D58C-4ECD-8B2D-DA8492DCBD2B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6C524958-D58C-4ECD-8B2D-DA8492DCBD2B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6C524958-D58C-4ECD-8B2D-DA8492DCBD2B}.Debug|ARM.ActiveCfg = Debug|Any CPU - {6C524958-D58C-4ECD-8B2D-DA8492DCBD2B}.Debug|ARM.Build.0 = Debug|Any CPU - {6C524958-D58C-4ECD-8B2D-DA8492DCBD2B}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {6C524958-D58C-4ECD-8B2D-DA8492DCBD2B}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {6C524958-D58C-4ECD-8B2D-DA8492DCBD2B}.Debug|x64.ActiveCfg = Debug|Any CPU - {6C524958-D58C-4ECD-8B2D-DA8492DCBD2B}.Debug|x64.Build.0 = Debug|Any CPU - {6C524958-D58C-4ECD-8B2D-DA8492DCBD2B}.Debug|x86.ActiveCfg = Debug|Any CPU - {6C524958-D58C-4ECD-8B2D-DA8492DCBD2B}.Debug|x86.Build.0 = Debug|Any CPU - {6C524958-D58C-4ECD-8B2D-DA8492DCBD2B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6C524958-D58C-4ECD-8B2D-DA8492DCBD2B}.Release|Any CPU.Build.0 = Release|Any CPU - {6C524958-D58C-4ECD-8B2D-DA8492DCBD2B}.Release|ARM.ActiveCfg = Release|Any CPU - {6C524958-D58C-4ECD-8B2D-DA8492DCBD2B}.Release|ARM.Build.0 = Release|Any CPU - {6C524958-D58C-4ECD-8B2D-DA8492DCBD2B}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {6C524958-D58C-4ECD-8B2D-DA8492DCBD2B}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {6C524958-D58C-4ECD-8B2D-DA8492DCBD2B}.Release|x64.ActiveCfg = Release|Any CPU - {6C524958-D58C-4ECD-8B2D-DA8492DCBD2B}.Release|x64.Build.0 = Release|Any CPU - {6C524958-D58C-4ECD-8B2D-DA8492DCBD2B}.Release|x86.ActiveCfg = Release|Any CPU - {6C524958-D58C-4ECD-8B2D-DA8492DCBD2B}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/TestAppStableSDK/Program.cs b/TestAppStableSDK/Program.cs deleted file mode 100644 index 354ca2b5f6..0000000000 --- a/TestAppStableSDK/Program.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.ApplicationInsights; -using Microsoft.ApplicationInsights.DataContracts; -using System; - -namespace TestAppStableSDK -{ - class Program - { - static void Main(string[] args) - { - TelemetryClient client = new TelemetryClient(); - - - client.Context.InstrumentationKey = "myikey"; - client.Context.Properties.Add("TC.Context.Property", "SomeValue"); - //client.Context.GlobalProperties.Add("TC.Context.GlobalProperty", "SomeValue"); - - var met = new MetricTelemetry("mymetric", 38.09); - client.TrackMetric(met); - - try - { - ThrowExc(); - } - catch (Exception ex) - { - client.TrackException(ex); - } - } - - private static void ThrowExc() - { - int x = 0; - int y = 10 / x; - - } - } -} diff --git a/TestAppStableSDK/TestAppStableSDK.csproj b/TestAppStableSDK/TestAppStableSDK.csproj deleted file mode 100644 index 221e89b169..0000000000 --- a/TestAppStableSDK/TestAppStableSDK.csproj +++ /dev/null @@ -1,14 +0,0 @@ - - - - Exe - netcoreapp2.0 - false - false - - - - - - - From 805468bdd77ac5dd0545a2edb79f6ff56cc8b928 Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Mon, 6 Aug 2018 08:54:05 -0700 Subject: [PATCH 46/74] exception handle severity level correctly --- .../DataContracts/ExceptionTelemetry.cs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs index 41e8628f7a..8cadf4a5aa 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs @@ -305,13 +305,9 @@ public void Serialize(ISerializationWriter serializationWriter) serializationWriter.WriteProperty("ver", this.Data.Data.ver); serializationWriter.WriteProperty("problemId", this.Data.Data.problemId); - serializationWriter.WriteList("exceptions", this.Exceptions.ToList()); - - if (this.Data.Data.severityLevel.HasValue) - { - serializationWriter.WriteProperty("severityLevel", this.Data.Data.severityLevel.Value.ToString()); - } - + serializationWriter.WriteList("exceptions", this.Exceptions.ToList()); + serializationWriter.WriteProperty("severityLevel", this.Data.Data.severityLevel.HasValue ? this.Data.Data.severityLevel.Value.ToString() : null); + serializationWriter.WriteDictionary("properties", this.Data.Data.properties); serializationWriter.WriteDictionary("measurements", this.Data.Data.measurements); serializationWriter.WriteEndObject(); // basedata From 4bed4017f26fd295df28cbe7df1b14e94ed229e8 Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Mon, 6 Aug 2018 11:25:37 -0700 Subject: [PATCH 47/74] Individual Telemetry implementations need not call start stop but serialization module does that. --- .../JsonSerializationWriterTests.cs | 10 +++++---- .../DataContracts/AvailabilityTelemetry.cs | 6 ++--- .../DataContracts/DependencyTelemetry.cs | 6 ++--- .../DataContracts/EventTelemetry.cs | 6 ++--- .../DataContracts/ExceptionTelemetry.cs | 6 ++--- .../DataContracts/MetricTelemetry.cs | 6 ++--- .../PageViewPerformanceTelemetry.cs | 6 ++--- .../DataContracts/PageViewTelemetry.cs | 6 ++--- .../DataContracts/RequestTelemetry.cs | 2 -- .../DataContracts/TraceTelemetry.cs | 2 -- .../Implementation/JsonSerializer.cs | 22 +++++++++++++++++++ 11 files changed, 42 insertions(+), 36 deletions(-) diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/Extensibility/Implementation/JsonSerializationWriterTests.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/Extensibility/Implementation/JsonSerializationWriterTests.cs index 991009c6dc..ea4be011ad 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/Extensibility/Implementation/JsonSerializationWriterTests.cs +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/Extensibility/Implementation/JsonSerializationWriterTests.cs @@ -34,7 +34,10 @@ public void SerializeAsStringMethodSerializesATelemetryCorrectly() var stringBuilder = new StringBuilder(); using (StringWriter stringWriter = new StringWriter(stringBuilder, CultureInfo.InvariantCulture)) { - dbExtension.Serialize(new JsonSerializationWriter(stringWriter)); + var jsonSerializationWriter = new JsonSerializationWriter(stringWriter); + jsonSerializationWriter.WriteStartObject(); + dbExtension.Serialize(jsonSerializationWriter); + jsonSerializationWriter.WriteEndObject(); } string actualJson = stringBuilder.ToString(); @@ -75,12 +78,11 @@ public IExtension DeepClone() } public void Serialize(ISerializationWriter serializationWriter) - { + { serializationWriter.WriteProperty("DatabaseId", DatabaseId); serializationWriter.WriteProperty("DatabaseServer", DatabaseServer); serializationWriter.WriteProperty("DatabaseLocation", DatabaseLocation); - serializationWriter.WriteList("Connections", Connections.ToList()); - serializationWriter.WriteEndObject(); + serializationWriter.WriteList("Connections", Connections.ToList()); } } diff --git a/src/Microsoft.ApplicationInsights/DataContracts/AvailabilityTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/AvailabilityTelemetry.cs index 5caea5af10..e8f4b8d0bd 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/AvailabilityTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/AvailabilityTelemetry.cs @@ -188,8 +188,7 @@ IExtension IExtension.DeepClone() /// public void Serialize(ISerializationWriter serializationWriter) - { - serializationWriter.WriteStartObject(); + { serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName)); serializationWriter.WriteProperty("time", this.Timestamp.UtcDateTime.ToString("o", CultureInfo.InvariantCulture)); serializationWriter.WriteProperty("seq", this.Sequence); @@ -214,8 +213,7 @@ public void Serialize(ISerializationWriter serializationWriter) serializationWriter.WriteDictionary("properties", this.Data.properties); serializationWriter.WriteDictionary("measurements", this.Data.measurements); serializationWriter.WriteEndObject(); // basedata - serializationWriter.WriteEndObject(); // data - serializationWriter.WriteEndObject(); // overall + serializationWriter.WriteEndObject(); // data } /// diff --git a/src/Microsoft.ApplicationInsights/DataContracts/DependencyTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/DependencyTelemetry.cs index 9a1437524c..ef879262ac 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/DependencyTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/DependencyTelemetry.cs @@ -343,8 +343,7 @@ public void SetOperationDetail(string key, object detail) /// public void Serialize(ISerializationWriter serializationWriter) - { - serializationWriter.WriteStartObject(); + { serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName)); serializationWriter.WriteProperty("time", this.Timestamp.UtcDateTime.ToString("o", CultureInfo.InvariantCulture)); serializationWriter.WriteProperty("sampleRate", this.samplingPercentage); @@ -371,8 +370,7 @@ public void Serialize(ISerializationWriter serializationWriter) serializationWriter.WriteDictionary("properties", this.InternalData.properties); serializationWriter.WriteDictionary("measurements", this.InternalData.measurements); serializationWriter.WriteEndObject(); // basedata - serializationWriter.WriteEndObject(); // data - serializationWriter.WriteEndObject(); // overall + serializationWriter.WriteEndObject(); // data } /// diff --git a/src/Microsoft.ApplicationInsights/DataContracts/EventTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/EventTelemetry.cs index 8d1b639a99..63c84f628a 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/EventTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/EventTelemetry.cs @@ -145,8 +145,7 @@ IExtension IExtension.DeepClone() /// public void Serialize(ISerializationWriter serializationWriter) - { - serializationWriter.WriteStartObject(); + { serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName)); serializationWriter.WriteProperty("time", this.Timestamp.UtcDateTime.ToString("o", CultureInfo.InvariantCulture)); serializationWriter.WriteProperty("sampleRate", this.samplingPercentage); @@ -167,8 +166,7 @@ public void Serialize(ISerializationWriter serializationWriter) serializationWriter.WriteDictionary("properties", this.Data.properties); serializationWriter.WriteDictionary("measurements", this.Data.measurements); serializationWriter.WriteEndObject(); // basedata - serializationWriter.WriteEndObject(); // data - serializationWriter.WriteEndObject(); // overall + serializationWriter.WriteEndObject(); // data } } } diff --git a/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs index 8cadf4a5aa..f3f5f59f23 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs @@ -287,8 +287,7 @@ IExtension IExtension.DeepClone() /// public void Serialize(ISerializationWriter serializationWriter) - { - serializationWriter.WriteStartObject(); + { serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName)); serializationWriter.WriteProperty("time", this.Timestamp.UtcDateTime.ToString("o", CultureInfo.InvariantCulture)); serializationWriter.WriteProperty("sampleRate", this.samplingPercentage); @@ -311,8 +310,7 @@ public void Serialize(ISerializationWriter serializationWriter) serializationWriter.WriteDictionary("properties", this.Data.Data.properties); serializationWriter.WriteDictionary("measurements", this.Data.Data.measurements); serializationWriter.WriteEndObject(); // basedata - serializationWriter.WriteEndObject(); // data - serializationWriter.WriteEndObject(); // overall + serializationWriter.WriteEndObject(); // data } /// diff --git a/src/Microsoft.ApplicationInsights/DataContracts/MetricTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/MetricTelemetry.cs index a7767dc7b9..ab76a0eccf 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/MetricTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/MetricTelemetry.cs @@ -261,8 +261,7 @@ IExtension IExtension.DeepClone() /// public void Serialize(ISerializationWriter serializationWriter) - { - serializationWriter.WriteStartObject(); + { serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName)); serializationWriter.WriteProperty("time", this.Timestamp.UtcDateTime.ToString("o", CultureInfo.InvariantCulture)); serializationWriter.WriteProperty("seq", this.Sequence); @@ -285,8 +284,7 @@ public void Serialize(ISerializationWriter serializationWriter) serializationWriter.WriteDictionary("properties", this.Data.properties); serializationWriter.WriteEndObject(); // basedata - serializationWriter.WriteEndObject(); // data - serializationWriter.WriteEndObject(); // overall + serializationWriter.WriteEndObject(); // data } /// diff --git a/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs index 4685b5ac48..796f13274a 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs @@ -235,8 +235,7 @@ IExtension IExtension.DeepClone() /// public void Serialize(ISerializationWriter serializationWriter) - { - serializationWriter.WriteStartObject(); + { serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName)); serializationWriter.WriteProperty("time", this.Timestamp.UtcDateTime.ToString("o", CultureInfo.InvariantCulture)); serializationWriter.WriteProperty("sampleRate", this.samplingPercentage); @@ -263,8 +262,7 @@ public void Serialize(ISerializationWriter serializationWriter) serializationWriter.WriteDictionary("properties", this.Data.properties); serializationWriter.WriteDictionary("measurements", this.Data.measurements); serializationWriter.WriteEndObject(); // basedata - serializationWriter.WriteEndObject(); // data - serializationWriter.WriteEndObject(); // overall + serializationWriter.WriteEndObject(); // data } } } diff --git a/src/Microsoft.ApplicationInsights/DataContracts/PageViewTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/PageViewTelemetry.cs index 727eab7252..1f139ef9eb 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/PageViewTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/PageViewTelemetry.cs @@ -188,8 +188,7 @@ IExtension IExtension.DeepClone() /// public void Serialize(ISerializationWriter serializationWriter) - { - serializationWriter.WriteStartObject(); + { serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName)); serializationWriter.WriteProperty("time", this.Timestamp.UtcDateTime.ToString("o", CultureInfo.InvariantCulture)); serializationWriter.WriteProperty("sampleRate", this.samplingPercentage); @@ -211,8 +210,7 @@ public void Serialize(ISerializationWriter serializationWriter) serializationWriter.WriteDictionary("properties", this.Data.properties); serializationWriter.WriteDictionary("measurements", this.Data.measurements); serializationWriter.WriteEndObject(); // basedata - serializationWriter.WriteEndObject(); // data - serializationWriter.WriteEndObject(); // overall + serializationWriter.WriteEndObject(); // data } /// diff --git a/src/Microsoft.ApplicationInsights/DataContracts/RequestTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/RequestTelemetry.cs index 005aca6911..0fed43e5ea 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/RequestTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/RequestTelemetry.cs @@ -238,7 +238,6 @@ public override ITelemetry DeepClone() /// public void Serialize(ISerializationWriter serializationWriter) { - serializationWriter.WriteStartObject(); serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName)); serializationWriter.WriteProperty("time", this.Timestamp.UtcDateTime.ToString("o", CultureInfo.InvariantCulture)); serializationWriter.WriteProperty("sampleRate", this.samplingPercentage); @@ -266,7 +265,6 @@ public void Serialize(ISerializationWriter serializationWriter) serializationWriter.WriteDictionary("measurements", this.Data.measurements); serializationWriter.WriteEndObject(); // basedata serializationWriter.WriteEndObject(); // data - serializationWriter.WriteEndObject(); // overall } /// diff --git a/src/Microsoft.ApplicationInsights/DataContracts/TraceTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/TraceTelemetry.cs index f43eecbdb6..34ba19d798 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/TraceTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/TraceTelemetry.cs @@ -147,7 +147,6 @@ IExtension IExtension.DeepClone() /// public void Serialize(ISerializationWriter serializationWriter) { - serializationWriter.WriteStartObject(); serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName)); serializationWriter.WriteProperty("time", this.Timestamp.UtcDateTime.ToString("o", CultureInfo.InvariantCulture)); serializationWriter.WriteProperty("sampleRate", this.samplingPercentage); @@ -170,7 +169,6 @@ public void Serialize(ISerializationWriter serializationWriter) serializationWriter.WriteDictionary("measurements", this.Data.measurements); serializationWriter.WriteEndObject(); // basedata serializationWriter.WriteEndObject(); // data - serializationWriter.WriteEndObject(); // overall } /// diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs index 5954a6500f..6d0139371a 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs @@ -239,71 +239,93 @@ private static void SerializeTelemetryItem(ITelemetry telemetryItem, JsonSeriali if (telemetryItem is EventTelemetry) { EventTelemetry eventTelemetry = telemetryItem as EventTelemetry; + jsonSerializationWriter.WriteStartObject(); eventTelemetry.Serialize(jsonSerializationWriter); + jsonSerializationWriter.WriteEndObject(); // SerializeEventTelemetry(eventTelemetry, jsonWriter); } else if (telemetryItem is ExceptionTelemetry) { ExceptionTelemetry exceptionTelemetry = telemetryItem as ExceptionTelemetry; + jsonSerializationWriter.WriteStartObject(); exceptionTelemetry.Serialize(jsonSerializationWriter); + jsonSerializationWriter.WriteEndObject(); // SerializeExceptionTelemetry(exceptionTelemetry, jsonWriter); } else if (telemetryItem is MetricTelemetry) { MetricTelemetry metricTelemetry = telemetryItem as MetricTelemetry; + jsonSerializationWriter.WriteStartObject(); metricTelemetry.Serialize(jsonSerializationWriter); + jsonSerializationWriter.WriteEndObject(); // SerializeMetricTelemetry(metricTelemetry, jsonWriter); } else if (telemetryItem is PageViewTelemetry) { PageViewTelemetry pageViewTelemetry = telemetryItem as PageViewTelemetry; + jsonSerializationWriter.WriteStartObject(); pageViewTelemetry.Serialize(jsonSerializationWriter); + jsonSerializationWriter.WriteEndObject(); // SerializePageViewTelemetry(pageViewTelemetry, jsonWriter); } else if (telemetryItem is PageViewPerformanceTelemetry) { PageViewPerformanceTelemetry pageViewPerfTelemetry = telemetryItem as PageViewPerformanceTelemetry; + jsonSerializationWriter.WriteStartObject(); pageViewPerfTelemetry.Serialize(jsonSerializationWriter); + jsonSerializationWriter.WriteEndObject(); // SerializePageViewPerformanceTelemetry(pageViewPerfTelemetry, jsonWriter); } else if (telemetryItem is DependencyTelemetry) { DependencyTelemetry remoteDependencyTelemetry = telemetryItem as DependencyTelemetry; + jsonSerializationWriter.WriteStartObject(); remoteDependencyTelemetry.Serialize(jsonSerializationWriter); + jsonSerializationWriter.WriteEndObject(); // SerializeDependencyTelemetry(remoteDependencyTelemetry, jsonWriter); } else if (telemetryItem is RequestTelemetry) { RequestTelemetry requestTelemetry = telemetryItem as RequestTelemetry; + jsonSerializationWriter.WriteStartObject(); requestTelemetry.Serialize(jsonSerializationWriter); + jsonSerializationWriter.WriteEndObject(); // SerializeRequestTelemetry(requestTelemetry, jsonWriter); } #pragma warning disable 618 else if (telemetryItem is SessionStateTelemetry) { EventTelemetry telemetry = (telemetryItem as SessionStateTelemetry).Data; + jsonSerializationWriter.WriteStartObject(); telemetry.Serialize(jsonSerializationWriter); + jsonSerializationWriter.WriteEndObject(); // SerializeEventTelemetry(telemetry, jsonWriter); } #pragma warning restore 618 else if (telemetryItem is TraceTelemetry) { TraceTelemetry traceTelemetry = telemetryItem as TraceTelemetry; + jsonSerializationWriter.WriteStartObject(); traceTelemetry.Serialize(jsonSerializationWriter); + jsonSerializationWriter.WriteEndObject(); // SerializeTraceTelemetry(traceTelemetry, jsonWriter); } #pragma warning disable 618 else if (telemetryItem is PerformanceCounterTelemetry) { MetricTelemetry telemetry = (telemetryItem as PerformanceCounterTelemetry).Data; + jsonSerializationWriter.WriteStartObject(); telemetry.Serialize(jsonSerializationWriter); + jsonSerializationWriter.WriteEndObject(); // SerializeMetricTelemetry(telemetry, jsonWriter); } else if (telemetryItem is AvailabilityTelemetry) { AvailabilityTelemetry availabilityTelemetry = telemetryItem as AvailabilityTelemetry; + jsonSerializationWriter.WriteStartObject(); availabilityTelemetry.Serialize(jsonSerializationWriter); + jsonSerializationWriter.WriteEndObject(); // SerializeAvailability(availabilityTelemetry, jsonWriter); } else From 08ed95af5a6308f62f0ca5989e54c832fd9336da Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Mon, 6 Aug 2018 12:10:03 -0700 Subject: [PATCH 48/74] Serialization to completely dependend on Serialize method of IExtension --- .../PerformanceCounterTelemetry.cs | 18 +++- .../DataContracts/SessionStateTelemetry.cs | 20 +++- .../Implementation/JsonSerializationWriter.cs | 18 +--- .../Implementation/JsonSerializer.cs | 97 ++----------------- 4 files changed, 40 insertions(+), 113 deletions(-) diff --git a/src/Microsoft.ApplicationInsights/DataContracts/PerformanceCounterTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/PerformanceCounterTelemetry.cs index 729a6f0b3a..370260ee7c 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/PerformanceCounterTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/PerformanceCounterTelemetry.cs @@ -10,7 +10,7 @@ /// The class that represents information about performance counters. /// [Obsolete("Use MetricTelemetry instead.")] - public sealed class PerformanceCounterTelemetry : ITelemetry, ISupportProperties + public sealed class PerformanceCounterTelemetry : ITelemetry, ISupportProperties, IExtension { internal readonly MetricTelemetry Data; private string categoryName = string.Empty; @@ -192,10 +192,24 @@ public ITelemetry DeepClone() return new PerformanceCounterTelemetry(this); } + /// + /// Deeply clones the Extension of object. + /// + IExtension IExtension.DeepClone() + { + return new PerformanceCounterTelemetry(this); + } + + /// + public void Serialize(ISerializationWriter serializationWriter) + { + this.Data.Serialize(serializationWriter); + } + /// /// Sanitizes the properties based on constraints. /// - void ITelemetry.Sanitize() + void ITelemetry.Sanitize() { ((ITelemetry)this.Data).Sanitize(); } diff --git a/src/Microsoft.ApplicationInsights/DataContracts/SessionStateTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/SessionStateTelemetry.cs index 90ffc011a9..58d40ef454 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/SessionStateTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/SessionStateTelemetry.cs @@ -8,12 +8,12 @@ /// Telemetry type used to track user sessions. /// [Obsolete("Session state events are no longer used. This telemetry item will be sent as EventTelemetry.")] - public sealed class SessionStateTelemetry : ITelemetry + public sealed class SessionStateTelemetry : ITelemetry, IExtension { internal readonly EventTelemetry Data; private readonly string startEventName = "Session started"; - private readonly string endEventName = "Session ended"; + private readonly string endEventName = "Session ended"; /// /// Initializes a new instance of the class. @@ -132,6 +132,14 @@ public ITelemetry DeepClone() return new SessionStateTelemetry(this); } + /// + /// Deeply clones the Extension of object. + /// + IExtension IExtension.DeepClone() + { + return new SessionStateTelemetry(this); + } + /// /// Sanitizes this telemetry instance to ensure it can be accepted by the Application Insights. /// @@ -139,5 +147,11 @@ void ITelemetry.Sanitize() { ((ITelemetry)this.Data).Sanitize(); } + + /// + public void Serialize(ISerializationWriter serializationWriter) + { + this.Data.Serialize(serializationWriter); + } } -} +} \ No newline at end of file diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializationWriter.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializationWriter.cs index 08b8134724..3c6da73740 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializationWriter.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializationWriter.cs @@ -13,8 +13,7 @@ internal class JsonSerializationWriter : ISerializationWriter public JsonSerializationWriter(TextWriter textWriter) { - this.textWriter = textWriter; - // this.textWriter.Write('{'); + this.textWriter = textWriter; } /// @@ -172,21 +171,6 @@ public void WriteEndObject() this.textWriter.Write('}'); } -/* - private void WriteStartObject() - { - this.textWriter.Write('{'); - this.currentObjectHasProperties = false; - } -*/ - - /// - /// Writes the specified property name enclosed in double quotation marks followed by a colon. - /// - /// - /// When this method is called multiple times, the second call after - /// and all subsequent calls will write a coma before the name. - /// private void WritePropertyName(string name) { if (name == null) diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs index 6d0139371a..81c6ed2af5 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs @@ -235,102 +235,17 @@ private static Stream CreateCompressedStream(Stream stream) } private static void SerializeTelemetryItem(ITelemetry telemetryItem, JsonSerializationWriter jsonSerializationWriter) - { - if (telemetryItem is EventTelemetry) + { + if (telemetryItem is IExtension) { - EventTelemetry eventTelemetry = telemetryItem as EventTelemetry; - jsonSerializationWriter.WriteStartObject(); - eventTelemetry.Serialize(jsonSerializationWriter); - jsonSerializationWriter.WriteEndObject(); - // SerializeEventTelemetry(eventTelemetry, jsonWriter); - } - else if (telemetryItem is ExceptionTelemetry) - { - ExceptionTelemetry exceptionTelemetry = telemetryItem as ExceptionTelemetry; - jsonSerializationWriter.WriteStartObject(); - exceptionTelemetry.Serialize(jsonSerializationWriter); - jsonSerializationWriter.WriteEndObject(); - // SerializeExceptionTelemetry(exceptionTelemetry, jsonWriter); - } - else if (telemetryItem is MetricTelemetry) - { - MetricTelemetry metricTelemetry = telemetryItem as MetricTelemetry; - jsonSerializationWriter.WriteStartObject(); - metricTelemetry.Serialize(jsonSerializationWriter); - jsonSerializationWriter.WriteEndObject(); - // SerializeMetricTelemetry(metricTelemetry, jsonWriter); - } - else if (telemetryItem is PageViewTelemetry) - { - PageViewTelemetry pageViewTelemetry = telemetryItem as PageViewTelemetry; - jsonSerializationWriter.WriteStartObject(); - pageViewTelemetry.Serialize(jsonSerializationWriter); - jsonSerializationWriter.WriteEndObject(); - // SerializePageViewTelemetry(pageViewTelemetry, jsonWriter); - } - else if (telemetryItem is PageViewPerformanceTelemetry) - { - PageViewPerformanceTelemetry pageViewPerfTelemetry = telemetryItem as PageViewPerformanceTelemetry; - jsonSerializationWriter.WriteStartObject(); - pageViewPerfTelemetry.Serialize(jsonSerializationWriter); - jsonSerializationWriter.WriteEndObject(); - // SerializePageViewPerformanceTelemetry(pageViewPerfTelemetry, jsonWriter); - } - else if (telemetryItem is DependencyTelemetry) - { - DependencyTelemetry remoteDependencyTelemetry = telemetryItem as DependencyTelemetry; - jsonSerializationWriter.WriteStartObject(); - remoteDependencyTelemetry.Serialize(jsonSerializationWriter); - jsonSerializationWriter.WriteEndObject(); - - // SerializeDependencyTelemetry(remoteDependencyTelemetry, jsonWriter); - } - else if (telemetryItem is RequestTelemetry) - { - RequestTelemetry requestTelemetry = telemetryItem as RequestTelemetry; - jsonSerializationWriter.WriteStartObject(); - requestTelemetry.Serialize(jsonSerializationWriter); - jsonSerializationWriter.WriteEndObject(); - // SerializeRequestTelemetry(requestTelemetry, jsonWriter); - } -#pragma warning disable 618 - else if (telemetryItem is SessionStateTelemetry) - { - EventTelemetry telemetry = (telemetryItem as SessionStateTelemetry).Data; - jsonSerializationWriter.WriteStartObject(); - telemetry.Serialize(jsonSerializationWriter); - jsonSerializationWriter.WriteEndObject(); - // SerializeEventTelemetry(telemetry, jsonWriter); - } -#pragma warning restore 618 - else if (telemetryItem is TraceTelemetry) - { - TraceTelemetry traceTelemetry = telemetryItem as TraceTelemetry; - jsonSerializationWriter.WriteStartObject(); - traceTelemetry.Serialize(jsonSerializationWriter); - jsonSerializationWriter.WriteEndObject(); - // SerializeTraceTelemetry(traceTelemetry, jsonWriter); - } -#pragma warning disable 618 - else if (telemetryItem is PerformanceCounterTelemetry) - { - MetricTelemetry telemetry = (telemetryItem as PerformanceCounterTelemetry).Data; + IExtension telemetry = telemetryItem as IExtension; jsonSerializationWriter.WriteStartObject(); telemetry.Serialize(jsonSerializationWriter); - jsonSerializationWriter.WriteEndObject(); - // SerializeMetricTelemetry(telemetry, jsonWriter); - } - else if (telemetryItem is AvailabilityTelemetry) - { - AvailabilityTelemetry availabilityTelemetry = telemetryItem as AvailabilityTelemetry; - jsonSerializationWriter.WriteStartObject(); - availabilityTelemetry.Serialize(jsonSerializationWriter); - jsonSerializationWriter.WriteEndObject(); - // SerializeAvailability(availabilityTelemetry, jsonWriter); - } + jsonSerializationWriter.WriteEndObject(); + } else { - string msg = string.Format(CultureInfo.InvariantCulture, "Unknown telemetry type: {0}", telemetryItem.GetType()); + string msg = string.Format(CultureInfo.InvariantCulture, "Unable to serialize. Unknown telemetry type: {0}", telemetryItem.GetType()); CoreEventSource.Log.LogVerbose(msg); } } From c5131994074d94ac7bb03a62cc9766cf63d17504 Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Mon, 6 Aug 2018 14:27:42 -0700 Subject: [PATCH 49/74] Supportwriting complex combject in ISerializationWriter --- .../JsonSerializationWriterTests.cs | 54 ++++++++++++++----- .../Extensibility/ISerializationWriter.cs | 7 ++- .../Implementation/JsonSerializationWriter.cs | 8 +++ 3 files changed, 55 insertions(+), 14 deletions(-) diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/Extensibility/Implementation/JsonSerializationWriterTests.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/Extensibility/Implementation/JsonSerializationWriterTests.cs index ea4be011ad..c8f6b4a886 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/Extensibility/Implementation/JsonSerializationWriterTests.cs +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/Extensibility/Implementation/JsonSerializationWriterTests.cs @@ -22,12 +22,14 @@ public class JsonSerializationWriterTests public void SerializeAsStringMethodSerializesATelemetryCorrectly() { var dbExtension = new DatabaseExtension(); - dbExtension.DatabaseId = 10908; - dbExtension.DatabaseLocation = "Virginia"; + dbExtension.DatabaseId = 10908; dbExtension.DatabaseServer = "azpacalbcluster011"; + + dbExtension.DBLocation = new DBLocation() { city = "Bellevue", state = "WA" }; + var cons = new List(); - cons.Add(new DBConnection() { userid = "cijo", password = "secretcijo" }); - cons.Add(new DBConnection() { userid = "anu", password = "secretanu" }); + cons.Add(new DBConnection() { userid = "user1", password = "usersecret1" }); + cons.Add(new DBConnection() { userid = "user2", password = "usersecret2" }); dbExtension.Connections = cons; @@ -42,15 +44,21 @@ public void SerializeAsStringMethodSerializesATelemetryCorrectly() string actualJson = stringBuilder.ToString(); Trace.WriteLine(actualJson); - - // Expected: {"name":"Microsoft.ApplicationInsights.Exception","time":"0001-01-01T00:00:00.0000000+00:00","data":{"baseType":"ExceptionData","baseData":{"ver":2,"handledAt":"Unhandled","exceptions":[]}}} - // Deserialize (Validates a valid JSON string) + JObject obj = JsonConvert.DeserializeObject(actualJson); - - // Validates 2 random properties - Assert.IsNotNull(actualJson); + Assert.IsNotNull(actualJson); Assert.AreEqual("10908", obj["DatabaseId"].ToString()); + Assert.AreEqual("azpacalbcluster011", obj["DatabaseServer"].ToString()); + + Assert.AreEqual("Bellevue", obj["DBLocation"]["city"].ToString()); + Assert.AreEqual("WA", obj["DBLocation"]["state"].ToString()); + + Assert.AreEqual("user1", obj["Connections"][0]["userid"].ToString()); + Assert.AreEqual("usersecret1", obj["Connections"][0]["password"].ToString()); + + Assert.AreEqual("user2", obj["Connections"][1]["userid"].ToString()); + Assert.AreEqual("usersecret2", obj["Connections"][1]["password"].ToString()); } } @@ -58,15 +66,15 @@ public class DatabaseExtension : IExtension { public int DatabaseId; public string DatabaseServer; - public string DatabaseLocation; public IList Connections; + public DBLocation DBLocation; public IExtension DeepClone() { DatabaseExtension other = new DatabaseExtension(); other.DatabaseId = this.DatabaseId; other.DatabaseServer = this.DatabaseServer; - other.DatabaseLocation = this.DatabaseLocation; + other.DBLocation = (DBLocation) this.DBLocation.DeepClone(); IList others = new List(); foreach(var item in this.Connections) { @@ -81,7 +89,7 @@ public void Serialize(ISerializationWriter serializationWriter) { serializationWriter.WriteProperty("DatabaseId", DatabaseId); serializationWriter.WriteProperty("DatabaseServer", DatabaseServer); - serializationWriter.WriteProperty("DatabaseLocation", DatabaseLocation); + serializationWriter.WriteProperty("DBLocation", DBLocation); serializationWriter.WriteList("Connections", Connections.ToList()); } } @@ -105,4 +113,24 @@ public void Serialize(ISerializationWriter serializationWriter) serializationWriter.WriteProperty("password", password); } } + + public class DBLocation : IExtension + { + public string city; + public string state; + + public IExtension DeepClone() + { + DBLocation other = new DBLocation(); + other.city = this.city; + other.state = this.state; + return other; + } + + public void Serialize(ISerializationWriter serializationWriter) + { + serializationWriter.WriteProperty("city", city); + serializationWriter.WriteProperty("state", state); + } + } } \ No newline at end of file diff --git a/src/Microsoft.ApplicationInsights/Extensibility/ISerializationWriter.cs b/src/Microsoft.ApplicationInsights/Extensibility/ISerializationWriter.cs index 7a1a51dca1..46827579f3 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/ISerializationWriter.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/ISerializationWriter.cs @@ -39,7 +39,12 @@ public interface ISerializationWriter void WriteProperty(string name, DateTimeOffset? value); /// - /// Writes name and values for a IList field of string + /// Writes name and value for a IExtension field + /// + void WriteProperty(string name, IExtension value); + + /// + /// Writes name and values for a IList field of strings /// void WriteList(string name, IList items); diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializationWriter.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializationWriter.cs index 3c6da73740..e3d0fa955a 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializationWriter.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializationWriter.cs @@ -133,6 +133,14 @@ public void WriteList(string name, IList items) } } + /// + public void WriteProperty(string name, IExtension value) + { + this.WriteStartObject(name); + value.Serialize(this); + this.WriteEndObject(); + } + /// public void WriteDictionary(string name, IDictionary values) { From e1bf7462fdb4e51901fbf1b9c95f072874c482eb Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Mon, 6 Aug 2018 15:34:03 -0700 Subject: [PATCH 50/74] Make base data implement IExtension and use WriteComplex Property API for ISerialziationWriter --- .../JsonSerializationWriterTests.cs | 43 ++++++++++++++++++- .../DataContracts/AvailabilityTelemetry.cs | 13 +----- .../DataContracts/DependencyTelemetry.cs | 15 +------ .../DataContracts/EventTelemetry.cs | 9 +--- .../DataContracts/ExceptionTelemetry.cs | 11 +---- .../DataContracts/MetricTelemetry.cs | 2 - .../External/AvailabilityDataIExtension.cs | 28 ++++++++++++ .../External/EventDataIExtension.cs | 26 +++++++++++ .../External/ExceptionDataIExtension.cs | 30 +++++++++++++ .../External/ExceptionDetailsIExtension.cs | 2 +- .../External/MetricDataIExtension.cs | 25 +++++++++++ .../RemoteDependencyDataIExtension.cs | 32 ++++++++++++++ 12 files changed, 189 insertions(+), 47 deletions(-) create mode 100644 src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/AvailabilityDataIExtension.cs create mode 100644 src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/EventDataIExtension.cs create mode 100644 src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/ExceptionDataIExtension.cs create mode 100644 src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/MetricDataIExtension.cs create mode 100644 src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/RemoteDependencyDataIExtension.cs diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/Extensibility/Implementation/JsonSerializationWriterTests.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/Extensibility/Implementation/JsonSerializationWriterTests.cs index c8f6b4a886..75f37f18d3 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/Extensibility/Implementation/JsonSerializationWriterTests.cs +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/Extensibility/Implementation/JsonSerializationWriterTests.cs @@ -4,6 +4,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Newtonsoft.Json; using Newtonsoft.Json.Linq; + using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; @@ -59,7 +60,47 @@ public void SerializeAsStringMethodSerializesATelemetryCorrectly() Assert.AreEqual("user2", obj["Connections"][1]["userid"].ToString()); Assert.AreEqual("usersecret2", obj["Connections"][1]["password"].ToString()); - } + } + + [TestMethod] + public void SerializeAsStringMethodSerializesExceptionCorrectly() + { + + ExceptionTelemetry myex = null; + try + { + int x = 0; + int y = 10 / x; + } + catch (Exception ex) + { + myex = new ExceptionTelemetry(ex); + } + + var stringBuilder = new StringBuilder(); + using (StringWriter stringWriter = new StringWriter(stringBuilder, CultureInfo.InvariantCulture)) + { + var jsonSerializationWriter = new JsonSerializationWriter(stringWriter); + myex.Serialize(jsonSerializationWriter); + } + string actualJson = stringBuilder.ToString(); + Trace.WriteLine(actualJson); + + JObject obj = JsonConvert.DeserializeObject(actualJson); + + Assert.IsNotNull(actualJson); + Assert.AreEqual("10908", obj["DatabaseId"].ToString()); + Assert.AreEqual("azpacalbcluster011", obj["DatabaseServer"].ToString()); + + Assert.AreEqual("Bellevue", obj["DBLocation"]["city"].ToString()); + Assert.AreEqual("WA", obj["DBLocation"]["state"].ToString()); + + Assert.AreEqual("user1", obj["Connections"][0]["userid"].ToString()); + Assert.AreEqual("usersecret1", obj["Connections"][0]["password"].ToString()); + + Assert.AreEqual("user2", obj["Connections"][1]["userid"].ToString()); + Assert.AreEqual("usersecret2", obj["Connections"][1]["password"].ToString()); + } } public class DatabaseExtension : IExtension diff --git a/src/Microsoft.ApplicationInsights/DataContracts/AvailabilityTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/AvailabilityTelemetry.cs index e8f4b8d0bd..7b45eb1b48 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/AvailabilityTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/AvailabilityTelemetry.cs @@ -200,19 +200,10 @@ public void Serialize(ISerializationWriter serializationWriter) Utils.CopyDictionary(this.Context.GlobalProperties, this.Data.properties); serializationWriter.WriteStartObject("data"); serializationWriter.WriteProperty("baseType", this.BaseType); - serializationWriter.WriteStartObject("baseData"); - - serializationWriter.WriteProperty("ver", this.Data.ver); - serializationWriter.WriteProperty("id", this.Data.id); - serializationWriter.WriteProperty("name", this.Data.name); - serializationWriter.WriteProperty("duration", this.Data.duration); - serializationWriter.WriteProperty("success", this.Data.success); - serializationWriter.WriteProperty("runLocation", this.Data.runLocation); - serializationWriter.WriteProperty("message", this.Data.message); - + serializationWriter.WriteProperty("baseData", this.Data); serializationWriter.WriteDictionary("properties", this.Data.properties); serializationWriter.WriteDictionary("measurements", this.Data.measurements); - serializationWriter.WriteEndObject(); // basedata + serializationWriter.WriteEndObject(); // data } diff --git a/src/Microsoft.ApplicationInsights/DataContracts/DependencyTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/DependencyTelemetry.cs index ef879262ac..5649bf069e 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/DependencyTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/DependencyTelemetry.cs @@ -356,20 +356,7 @@ public void Serialize(ISerializationWriter serializationWriter) Utils.CopyDictionary(this.Context.GlobalProperties, this.InternalData.properties); serializationWriter.WriteStartObject("data"); serializationWriter.WriteProperty("baseType", this.BaseType); - serializationWriter.WriteStartObject("baseData"); - - serializationWriter.WriteProperty("ver", this.InternalData.ver); - serializationWriter.WriteProperty("name", this.InternalData.name); - serializationWriter.WriteProperty("id", this.InternalData.id); - serializationWriter.WriteProperty("data", this.InternalData.data); - serializationWriter.WriteProperty("duration", this.InternalData.duration); - serializationWriter.WriteProperty("resultCode", this.InternalData.resultCode); - serializationWriter.WriteProperty("success", this.InternalData.success); - serializationWriter.WriteProperty("type", this.InternalData.type); - serializationWriter.WriteProperty("target", this.InternalData.target); - serializationWriter.WriteDictionary("properties", this.InternalData.properties); - serializationWriter.WriteDictionary("measurements", this.InternalData.measurements); - serializationWriter.WriteEndObject(); // basedata + serializationWriter.WriteProperty("baseData", this.InternalData); serializationWriter.WriteEndObject(); // data } diff --git a/src/Microsoft.ApplicationInsights/DataContracts/EventTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/EventTelemetry.cs index 63c84f628a..3ceacfbf63 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/EventTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/EventTelemetry.cs @@ -158,14 +158,7 @@ public void Serialize(ISerializationWriter serializationWriter) Utils.CopyDictionary(this.Context.GlobalProperties, this.Data.properties); serializationWriter.WriteStartObject("data"); serializationWriter.WriteProperty("baseType", this.BaseType); - serializationWriter.WriteStartObject("baseData"); - - serializationWriter.WriteProperty("ver", this.Data.ver); - serializationWriter.WriteProperty("name", this.Data.name); - - serializationWriter.WriteDictionary("properties", this.Data.properties); - serializationWriter.WriteDictionary("measurements", this.Data.measurements); - serializationWriter.WriteEndObject(); // basedata + serializationWriter.WriteProperty("baseData", this.Data); serializationWriter.WriteEndObject(); // data } } diff --git a/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs index f3f5f59f23..82fd583c21 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs @@ -300,16 +300,7 @@ public void Serialize(ISerializationWriter serializationWriter) Utils.CopyDictionary(this.Context.GlobalProperties, this.Data.Data.properties); serializationWriter.WriteStartObject("data"); serializationWriter.WriteProperty("baseType", this.BaseType); - serializationWriter.WriteStartObject("baseData"); - - serializationWriter.WriteProperty("ver", this.Data.Data.ver); - serializationWriter.WriteProperty("problemId", this.Data.Data.problemId); - serializationWriter.WriteList("exceptions", this.Exceptions.ToList()); - serializationWriter.WriteProperty("severityLevel", this.Data.Data.severityLevel.HasValue ? this.Data.Data.severityLevel.Value.ToString() : null); - - serializationWriter.WriteDictionary("properties", this.Data.Data.properties); - serializationWriter.WriteDictionary("measurements", this.Data.Data.measurements); - serializationWriter.WriteEndObject(); // basedata + serializationWriter.WriteProperty("baseData", this.Data.Data); serializationWriter.WriteEndObject(); // data } diff --git a/src/Microsoft.ApplicationInsights/DataContracts/MetricTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/MetricTelemetry.cs index ab76a0eccf..ff77cc6753 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/MetricTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/MetricTelemetry.cs @@ -276,10 +276,8 @@ public void Serialize(ISerializationWriter serializationWriter) serializationWriter.WriteStartObject("baseData"); serializationWriter.WriteProperty("ver", this.Data.ver); - IList metricLists = new List(); metricLists.Add(this.Metric); - serializationWriter.WriteList("metrics", metricLists); serializationWriter.WriteDictionary("properties", this.Data.properties); diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/AvailabilityDataIExtension.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/AvailabilityDataIExtension.cs new file mode 100644 index 0000000000..b84a3a099b --- /dev/null +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/AvailabilityDataIExtension.cs @@ -0,0 +1,28 @@ +namespace Microsoft.ApplicationInsights.Extensibility.Implementation.External +{ + using System.Diagnostics; + using Microsoft.ApplicationInsights; + using Microsoft.ApplicationInsights.DataContracts; + + /// + /// Partial class to implement IExtension + /// + internal partial class AvailabilityData : IExtension + { + public void Serialize(ISerializationWriter serializationWriter) + { + serializationWriter.WriteProperty("ver", this.ver); + serializationWriter.WriteProperty("id", this.id); + serializationWriter.WriteProperty("name", this.name); + serializationWriter.WriteProperty("duration", this.duration); + serializationWriter.WriteProperty("success", this.success); + serializationWriter.WriteProperty("runLocation", this.runLocation); + serializationWriter.WriteProperty("message", this.message); + } + + IExtension IExtension.DeepClone() + { + return this.DeepClone(); + } + } +} diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/EventDataIExtension.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/EventDataIExtension.cs new file mode 100644 index 0000000000..bb26e7117a --- /dev/null +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/EventDataIExtension.cs @@ -0,0 +1,26 @@ +namespace Microsoft.ApplicationInsights.Extensibility.Implementation.External +{ + using System.Diagnostics; + using Microsoft.ApplicationInsights; + using Microsoft.ApplicationInsights.DataContracts; + + /// + /// Partial class to implement IExtension + /// + internal partial class EventData : IExtension + { + public void Serialize(ISerializationWriter serializationWriter) + { + serializationWriter.WriteProperty("ver", this.ver); + serializationWriter.WriteProperty("name", this.name); + + serializationWriter.WriteDictionary("properties", this.properties); + serializationWriter.WriteDictionary("measurements", this.measurements); + } + + IExtension IExtension.DeepClone() + { + return this.DeepClone(); + } + } +} diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/ExceptionDataIExtension.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/ExceptionDataIExtension.cs new file mode 100644 index 0000000000..797aebcdb8 --- /dev/null +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/ExceptionDataIExtension.cs @@ -0,0 +1,30 @@ +namespace Microsoft.ApplicationInsights.Extensibility.Implementation.External +{ + using System; + using System.Diagnostics; + using System.Linq; + using Microsoft.ApplicationInsights; + using Microsoft.ApplicationInsights.DataContracts; + + /// + /// Additional implementation for ExceptionDetails. + /// + internal partial class ExceptionData : IExtension + { + IExtension IExtension.DeepClone() + { + return this.DeepClone(); + } + + public void Serialize(ISerializationWriter serializationWriter) + { + serializationWriter.WriteProperty("ver", this.ver); + serializationWriter.WriteProperty("problemId", this.problemId); + serializationWriter.WriteList("exceptions", this.exceptions.ToList()); + serializationWriter.WriteProperty("severityLevel", this.severityLevel.HasValue ? this.severityLevel.Value.ToString() : null); + + serializationWriter.WriteDictionary("properties", this.properties); + serializationWriter.WriteDictionary("measurements", this.measurements); + } + } +} diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/ExceptionDetailsIExtension.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/ExceptionDetailsIExtension.cs index e3492f4f59..76881c72ad 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/ExceptionDetailsIExtension.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/ExceptionDetailsIExtension.cs @@ -10,7 +10,7 @@ internal partial class ExceptionDetails : IExtension { public IExtension DeepClone() { - throw new NotImplementedException(); + return null; } public void Serialize(ISerializationWriter serializationWriter) diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/MetricDataIExtension.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/MetricDataIExtension.cs new file mode 100644 index 0000000000..22a7570007 --- /dev/null +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/MetricDataIExtension.cs @@ -0,0 +1,25 @@ +namespace Microsoft.ApplicationInsights.Extensibility.Implementation.External +{ + using System.Diagnostics; + using System.Linq; + using Microsoft.ApplicationInsights; + using Microsoft.ApplicationInsights.DataContracts; + + /// + /// Partial class to implement IExtension + /// + internal partial class MetricData : IExtension + { + public void Serialize(ISerializationWriter serializationWriter) + { + serializationWriter.WriteProperty("ver", this.ver); + serializationWriter.WriteList("metrics", this.metrics.ToList()); + serializationWriter.WriteDictionary("properties", this.properties); + } + + IExtension IExtension.DeepClone() + { + return this.DeepClone(); + } + } +} \ No newline at end of file diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/RemoteDependencyDataIExtension.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/RemoteDependencyDataIExtension.cs new file mode 100644 index 0000000000..27a3614520 --- /dev/null +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/RemoteDependencyDataIExtension.cs @@ -0,0 +1,32 @@ +namespace Microsoft.ApplicationInsights.Extensibility.Implementation.External +{ + using System.Diagnostics; + using Microsoft.ApplicationInsights; + using Microsoft.ApplicationInsights.DataContracts; + + /// + /// Partial class to implement IExtension + /// + internal partial class RemoteDependencyData : IExtension + { + public void Serialize(ISerializationWriter serializationWriter) + { + serializationWriter.WriteProperty("ver", this.ver); + serializationWriter.WriteProperty("name", this.name); + serializationWriter.WriteProperty("id", this.id); + serializationWriter.WriteProperty("data", this.data); + serializationWriter.WriteProperty("duration", this.duration); + serializationWriter.WriteProperty("resultCode", this.resultCode); + serializationWriter.WriteProperty("success", this.success); + serializationWriter.WriteProperty("type", this.type); + serializationWriter.WriteProperty("target", this.target); + serializationWriter.WriteDictionary("properties", this.properties); + serializationWriter.WriteDictionary("measurements", this.measurements); + } + + IExtension IExtension.DeepClone() + { + return this.DeepClone(); + } + } +} \ No newline at end of file From a38871dd511554a4b8a0e6cc6ce8d4664e0147ad Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Mon, 6 Aug 2018 22:50:49 -0700 Subject: [PATCH 51/74] Removed dead code. entire serialization occurs by ISerializationWriter now. --- .../DataContracts/MetricTelemetryTest.cs | 2 +- .../JsonSerializationWriterTests.cs | 15 +- .../DataContracts/AvailabilityTelemetry.cs | 5 - .../DataContracts/MetricTelemetry.cs | 10 +- .../PageViewPerformanceTelemetry.cs | 15 +- .../DataContracts/PageViewTelemetry.cs | 10 +- .../DataContracts/RequestTelemetry.cs | 15 +- .../DataContracts/TraceTelemetry.cs | 10 +- .../External/AvailabilityDataIExtension.cs | 2 + .../External/MessageDataIExtension.cs | 27 ++ .../External/PageViewDataIExtension.cs | 25 ++ .../External/PageViewPerfDataIExtension.cs | 28 ++ .../External/RequestDataIExtension.cs | 31 ++ .../Implementation/JsonSerializer.cs | 422 ------------------ 14 files changed, 122 insertions(+), 495 deletions(-) create mode 100644 src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/MessageDataIExtension.cs create mode 100644 src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/PageViewDataIExtension.cs create mode 100644 src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/PageViewPerfDataIExtension.cs create mode 100644 src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/RequestDataIExtension.cs diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/MetricTelemetryTest.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/MetricTelemetryTest.cs index 9807d2ac84..82213c309f 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/MetricTelemetryTest.cs +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/MetricTelemetryTest.cs @@ -27,7 +27,7 @@ public void MetricTelemetryImplementsITelemetryContract() } [TestMethod] - public void EventTelemetryReturnsNonNullContext() + public void MetricTelemetryReturnsNonNullContext() { MetricTelemetry item = new MetricTelemetry(); Assert.IsNotNull(item.Context); diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/Extensibility/Implementation/JsonSerializationWriterTests.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/Extensibility/Implementation/JsonSerializationWriterTests.cs index 75f37f18d3..8d001cf059 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/Extensibility/Implementation/JsonSerializationWriterTests.cs +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/Extensibility/Implementation/JsonSerializationWriterTests.cs @@ -81,7 +81,9 @@ public void SerializeAsStringMethodSerializesExceptionCorrectly() using (StringWriter stringWriter = new StringWriter(stringBuilder, CultureInfo.InvariantCulture)) { var jsonSerializationWriter = new JsonSerializationWriter(stringWriter); - myex.Serialize(jsonSerializationWriter); + jsonSerializationWriter.WriteStartObject(); + myex.Serialize(jsonSerializationWriter); + jsonSerializationWriter.WriteEndObject(); } string actualJson = stringBuilder.ToString(); Trace.WriteLine(actualJson); @@ -89,17 +91,6 @@ public void SerializeAsStringMethodSerializesExceptionCorrectly() JObject obj = JsonConvert.DeserializeObject(actualJson); Assert.IsNotNull(actualJson); - Assert.AreEqual("10908", obj["DatabaseId"].ToString()); - Assert.AreEqual("azpacalbcluster011", obj["DatabaseServer"].ToString()); - - Assert.AreEqual("Bellevue", obj["DBLocation"]["city"].ToString()); - Assert.AreEqual("WA", obj["DBLocation"]["state"].ToString()); - - Assert.AreEqual("user1", obj["Connections"][0]["userid"].ToString()); - Assert.AreEqual("usersecret1", obj["Connections"][0]["password"].ToString()); - - Assert.AreEqual("user2", obj["Connections"][1]["userid"].ToString()); - Assert.AreEqual("usersecret2", obj["Connections"][1]["password"].ToString()); } } diff --git a/src/Microsoft.ApplicationInsights/DataContracts/AvailabilityTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/AvailabilityTelemetry.cs index 7b45eb1b48..1517250ad4 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/AvailabilityTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/AvailabilityTelemetry.cs @@ -192,18 +192,13 @@ public void Serialize(ISerializationWriter serializationWriter) serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName)); serializationWriter.WriteProperty("time", this.Timestamp.UtcDateTime.ToString("o", CultureInfo.InvariantCulture)); serializationWriter.WriteProperty("seq", this.Sequence); - serializationWriter.WriteProperty("iKey", this.Context.InstrumentationKey); serializationWriter.WriteProperty("flags", this.Context.Flags); - serializationWriter.WriteDictionary("tags", this.Context.SanitizedTags); Utils.CopyDictionary(this.Context.GlobalProperties, this.Data.properties); serializationWriter.WriteStartObject("data"); serializationWriter.WriteProperty("baseType", this.BaseType); serializationWriter.WriteProperty("baseData", this.Data); - serializationWriter.WriteDictionary("properties", this.Data.properties); - serializationWriter.WriteDictionary("measurements", this.Data.measurements); - serializationWriter.WriteEndObject(); // data } diff --git a/src/Microsoft.ApplicationInsights/DataContracts/MetricTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/MetricTelemetry.cs index ff77cc6753..f47d2280d5 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/MetricTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/MetricTelemetry.cs @@ -273,15 +273,7 @@ public void Serialize(ISerializationWriter serializationWriter) Utils.CopyDictionary(this.Context.GlobalProperties, this.Data.properties); serializationWriter.WriteStartObject("data"); serializationWriter.WriteProperty("baseType", this.BaseType); - serializationWriter.WriteStartObject("baseData"); - - serializationWriter.WriteProperty("ver", this.Data.ver); - IList metricLists = new List(); - metricLists.Add(this.Metric); - serializationWriter.WriteList("metrics", metricLists); - - serializationWriter.WriteDictionary("properties", this.Data.properties); - serializationWriter.WriteEndObject(); // basedata + serializationWriter.WriteProperty("baseData", this.Data); serializationWriter.WriteEndObject(); // data } diff --git a/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs index 796f13274a..7b90aa145e 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs @@ -248,20 +248,7 @@ public void Serialize(ISerializationWriter serializationWriter) Utils.CopyDictionary(this.Context.GlobalProperties, this.Data.properties); serializationWriter.WriteStartObject("data"); serializationWriter.WriteProperty("baseType", BaseType); - serializationWriter.WriteStartObject("baseData"); - - serializationWriter.WriteProperty("ver", this.Data.ver); - serializationWriter.WriteProperty("name", this.Data.name); - serializationWriter.WriteProperty("url", this.Data.url); - serializationWriter.WriteProperty("duration", this.Data.duration); - serializationWriter.WriteProperty("domProcessing", this.Data.domProcessing); - serializationWriter.WriteProperty("perfTotal", this.Data.perfTotal); - serializationWriter.WriteProperty("networkConnect", this.Data.networkConnect); - serializationWriter.WriteProperty("sentRequest", this.Data.sentRequest); - serializationWriter.WriteProperty("receivedResponse", this.Data.receivedResponse); - serializationWriter.WriteDictionary("properties", this.Data.properties); - serializationWriter.WriteDictionary("measurements", this.Data.measurements); - serializationWriter.WriteEndObject(); // basedata + serializationWriter.WriteProperty("baseData", this.Data); serializationWriter.WriteEndObject(); // data } } diff --git a/src/Microsoft.ApplicationInsights/DataContracts/PageViewTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/PageViewTelemetry.cs index 1f139ef9eb..c24212a5ea 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/PageViewTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/PageViewTelemetry.cs @@ -201,15 +201,7 @@ public void Serialize(ISerializationWriter serializationWriter) Utils.CopyDictionary(this.Context.GlobalProperties, this.Data.properties); serializationWriter.WriteStartObject("data"); serializationWriter.WriteProperty("baseType", this.BaseType); - serializationWriter.WriteStartObject("baseData"); - - serializationWriter.WriteProperty("ver", this.Data.ver); - serializationWriter.WriteProperty("name", this.Data.name); - serializationWriter.WriteProperty("url", this.Data.url); - serializationWriter.WriteProperty("duration", this.Data.duration); - serializationWriter.WriteDictionary("properties", this.Data.properties); - serializationWriter.WriteDictionary("measurements", this.Data.measurements); - serializationWriter.WriteEndObject(); // basedata + serializationWriter.WriteProperty("baseData", this.Data); serializationWriter.WriteEndObject(); // data } diff --git a/src/Microsoft.ApplicationInsights/DataContracts/RequestTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/RequestTelemetry.cs index 0fed43e5ea..44c117bcdb 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/RequestTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/RequestTelemetry.cs @@ -250,20 +250,7 @@ public void Serialize(ISerializationWriter serializationWriter) Utils.CopyDictionary(this.Context.GlobalProperties, this.Data.properties); serializationWriter.WriteStartObject("data"); serializationWriter.WriteProperty("baseType", this.BaseType); - serializationWriter.WriteStartObject("baseData"); - - serializationWriter.WriteProperty("ver", this.Data.ver); - serializationWriter.WriteProperty("id", this.Data.id); - serializationWriter.WriteProperty("source", this.Data.source); - serializationWriter.WriteProperty("name", this.Data.name); - serializationWriter.WriteProperty("duration", this.Duration); - serializationWriter.WriteProperty("success", this.Data.success); - serializationWriter.WriteProperty("responseCode", this.Data.responseCode); - serializationWriter.WriteProperty("url", this.Data.url); - - serializationWriter.WriteDictionary("properties", this.Data.properties); - serializationWriter.WriteDictionary("measurements", this.Data.measurements); - serializationWriter.WriteEndObject(); // basedata + serializationWriter.WriteProperty("baseData", this.Data); serializationWriter.WriteEndObject(); // data } diff --git a/src/Microsoft.ApplicationInsights/DataContracts/TraceTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/TraceTelemetry.cs index 34ba19d798..63135a13b9 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/TraceTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/TraceTelemetry.cs @@ -159,15 +159,7 @@ public void Serialize(ISerializationWriter serializationWriter) Utils.CopyDictionary(this.Context.GlobalProperties, this.Data.properties); serializationWriter.WriteStartObject("data"); serializationWriter.WriteProperty("baseType", this.BaseType); - serializationWriter.WriteStartObject("baseData"); - - serializationWriter.WriteProperty("ver", this.Data.ver); - serializationWriter.WriteProperty("message", this.Data.message); - serializationWriter.WriteProperty("severityLevel", this.SeverityLevel.HasValue ? this.SeverityLevel.Value.ToString() : null); - - serializationWriter.WriteDictionary("properties", this.Data.properties); - serializationWriter.WriteDictionary("measurements", this.Data.measurements); - serializationWriter.WriteEndObject(); // basedata + serializationWriter.WriteProperty("baseData", this.Data); serializationWriter.WriteEndObject(); // data } diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/AvailabilityDataIExtension.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/AvailabilityDataIExtension.cs index b84a3a099b..4b6d898892 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/AvailabilityDataIExtension.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/AvailabilityDataIExtension.cs @@ -18,6 +18,8 @@ public void Serialize(ISerializationWriter serializationWriter) serializationWriter.WriteProperty("success", this.success); serializationWriter.WriteProperty("runLocation", this.runLocation); serializationWriter.WriteProperty("message", this.message); + serializationWriter.WriteDictionary("properties", this.properties); + serializationWriter.WriteDictionary("measurements", this.measurements); } IExtension IExtension.DeepClone() diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/MessageDataIExtension.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/MessageDataIExtension.cs new file mode 100644 index 0000000000..a2418f7684 --- /dev/null +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/MessageDataIExtension.cs @@ -0,0 +1,27 @@ +namespace Microsoft.ApplicationInsights.Extensibility.Implementation.External +{ + using System; + using System.Diagnostics; + using Microsoft.ApplicationInsights; + using Microsoft.ApplicationInsights.DataContracts; + + /// + /// Partial class to implement IExtension + /// + internal partial class MessageData : IExtension + { + public void Serialize(ISerializationWriter serializationWriter) + { + serializationWriter.WriteProperty("ver", this.ver); + serializationWriter.WriteProperty("message", this.message); + serializationWriter.WriteProperty("severityLevel", this.severityLevel.HasValue ? this.severityLevel.Value.ToString() : null); + serializationWriter.WriteDictionary("properties", this.properties); + serializationWriter.WriteDictionary("measurements", this.measurements); + } + + IExtension IExtension.DeepClone() + { + return this.DeepClone(); + } + } +} diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/PageViewDataIExtension.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/PageViewDataIExtension.cs new file mode 100644 index 0000000000..69fae6266a --- /dev/null +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/PageViewDataIExtension.cs @@ -0,0 +1,25 @@ +namespace Microsoft.ApplicationInsights.Extensibility.Implementation.External +{ + using Microsoft.ApplicationInsights.DataContracts; + + /// + /// Partial class to implement IExtension + /// + internal partial class PageViewData : IExtension + { + public new void Serialize(ISerializationWriter serializationWriter) + { + serializationWriter.WriteProperty("ver", this.ver); + serializationWriter.WriteProperty("name", this.name); + serializationWriter.WriteProperty("url", this.url); + serializationWriter.WriteProperty("duration", this.duration); + serializationWriter.WriteDictionary("properties", this.properties); + serializationWriter.WriteDictionary("measurements", this.measurements); + } + + IExtension IExtension.DeepClone() + { + return this.DeepClone(); + } + } +} \ No newline at end of file diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/PageViewPerfDataIExtension.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/PageViewPerfDataIExtension.cs new file mode 100644 index 0000000000..fd1d6d3f55 --- /dev/null +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/PageViewPerfDataIExtension.cs @@ -0,0 +1,28 @@ +namespace Microsoft.ApplicationInsights.Extensibility.Implementation.External +{ + /// + /// Partial class to implement IExtension + /// + internal partial class PageViewPerfData : IExtension + { + public new void Serialize(ISerializationWriter serializationWriter) + { + serializationWriter.WriteProperty("ver", this.ver); + serializationWriter.WriteProperty("name", this.name); + serializationWriter.WriteProperty("url", this.url); + serializationWriter.WriteProperty("duration", this.duration); + serializationWriter.WriteProperty("domProcessing", this.domProcessing); + serializationWriter.WriteProperty("perfTotal", this.perfTotal); + serializationWriter.WriteProperty("networkConnect", this.networkConnect); + serializationWriter.WriteProperty("sentRequest", this.sentRequest); + serializationWriter.WriteProperty("receivedResponse", this.receivedResponse); + serializationWriter.WriteDictionary("properties", this.properties); + serializationWriter.WriteDictionary("measurements", this.measurements); + } + + IExtension IExtension.DeepClone() + { + return this.DeepClone(); + } + } +} \ No newline at end of file diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/RequestDataIExtension.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/RequestDataIExtension.cs new file mode 100644 index 0000000000..0ba1b0ac76 --- /dev/null +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/RequestDataIExtension.cs @@ -0,0 +1,31 @@ +namespace Microsoft.ApplicationInsights.Extensibility.Implementation.External +{ + using System.Diagnostics; + using Microsoft.ApplicationInsights; + using Microsoft.ApplicationInsights.DataContracts; + + /// + /// Partial class to implement IExtension + /// + internal partial class RequestData : IExtension + { + public void Serialize(ISerializationWriter serializationWriter) + { + serializationWriter.WriteProperty("ver", this.ver); + serializationWriter.WriteProperty("id", this.id); + serializationWriter.WriteProperty("source", this.source); + serializationWriter.WriteProperty("name", this.name); + serializationWriter.WriteProperty("duration", Utils.ValidateDuration(this.duration)); + serializationWriter.WriteProperty("success", this.success); + serializationWriter.WriteProperty("responseCode", this.responseCode); + serializationWriter.WriteProperty("url", this.url); + serializationWriter.WriteDictionary("properties", this.properties); + serializationWriter.WriteDictionary("measurements", this.measurements); + } + + IExtension IExtension.DeepClone() + { + return this.DeepClone(); + } + } +} \ No newline at end of file diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs index 81c6ed2af5..e473bf0700 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs @@ -9,8 +9,6 @@ using System.IO.Compression; using System.Text; using Microsoft.ApplicationInsights.Channel; - using Microsoft.ApplicationInsights.DataContracts; - using Microsoft.ApplicationInsights.Extensibility.Implementation.External; using Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing; /// @@ -147,85 +145,6 @@ internal static string SerializeAsString(ITelemetry telemetry) return SerializeAsString(new ITelemetry[] { telemetry }); } - #region Exception Serializer helper - - private static void SerializeExceptions(IEnumerable exceptions, IJsonWriter writer) - { - int exceptionArrayIndex = 0; - - foreach (ExceptionDetails exceptionDetails in exceptions) - { - if (exceptionArrayIndex++ != 0) - { - writer.WriteComma(); - } - - writer.WriteStartObject(); - writer.WriteProperty("id", exceptionDetails.id); - if (exceptionDetails.outerId != 0) - { - writer.WriteProperty("outerId", exceptionDetails.outerId); - } - - writer.WriteProperty( - "typeName", - Utils.PopulateRequiredStringValue(exceptionDetails.typeName, "typeName", typeof(ExceptionTelemetry).FullName)); - writer.WriteProperty( - "message", - Utils.PopulateRequiredStringValue(exceptionDetails.message, "message", typeof(ExceptionTelemetry).FullName)); - - if (exceptionDetails.hasFullStack) - { - writer.WriteProperty("hasFullStack", exceptionDetails.hasFullStack); - } - - writer.WriteProperty("stack", exceptionDetails.stack); - - if (exceptionDetails.parsedStack.Count > 0) - { - writer.WritePropertyName("parsedStack"); - - writer.WriteStartArray(); - - int stackFrameArrayIndex = 0; - - foreach (External.StackFrame frame in exceptionDetails.parsedStack) - { - if (stackFrameArrayIndex++ != 0) - { - writer.WriteComma(); - } - - writer.WriteStartObject(); - SerializeStackFrame(frame, writer); - writer.WriteEndObject(); - } - - writer.WriteEndArray(); - } - - writer.WriteEndObject(); - } - } - - private static void SerializeStackFrame(External.StackFrame frame, IJsonWriter writer) - { - writer.WriteProperty("level", frame.level); - writer.WriteProperty( - "method", - Utils.PopulateRequiredStringValue(frame.method, "StackFrameMethod", typeof(ExceptionTelemetry).FullName)); - writer.WriteProperty("assembly", frame.assembly); - writer.WriteProperty("fileName", frame.fileName); - - // 0 means it is unavailable - if (frame.line != 0) - { - writer.WriteProperty("line", frame.line); - } - } - - #endregion Exception Serializer helper - /// /// Creates a GZIP compression stream that wraps . For windows phone 8.0 it returns . /// @@ -271,346 +190,5 @@ private static void SeializeToStream(IEnumerable telemetryItems, Tex SerializeTelemetryItem(telemetryItem, jsonSerializationWriter); } } - - #region Serialize methods for each ITelemetry implementation - - private static void SerializeEventTelemetry(EventTelemetry eventTelemetry, JsonWriter writer) - { - writer.WriteStartObject(); - - // eventTelemetry.WriteTelemetryName(EventTelemetry.TelemetryName); - eventTelemetry.WriteEnvelopeProperties(writer); - writer.WritePropertyName("data"); - { - writer.WriteStartObject(); - - writer.WriteProperty("baseType", eventTelemetry.BaseType); - writer.WritePropertyName("baseData"); - { - writer.WriteStartObject(); - - writer.WriteProperty("ver", eventTelemetry.Data.ver); - writer.WriteProperty("name", eventTelemetry.Data.name); - writer.WriteProperty("measurements", eventTelemetry.Data.measurements); - Utils.CopyDictionary(eventTelemetry.Context.GlobalProperties, eventTelemetry.Data.properties); - writer.WriteProperty("properties", eventTelemetry.Data.properties); - writer.WriteEndObject(); - } - - writer.WriteEndObject(); - } - - writer.WriteEndObject(); - } - - private static void SerializeExceptionTelemetry(ExceptionTelemetry exceptionTelemetry, JsonWriter writer) - { - writer.WriteStartObject(); - - // exceptionTelemetry.WriteTelemetryName(writer, ExceptionTelemetry.TelemetryName); - exceptionTelemetry.WriteEnvelopeProperties(writer); - writer.WritePropertyName("data"); - { - writer.WriteStartObject(); - - writer.WriteProperty("baseType", exceptionTelemetry.BaseType); - writer.WritePropertyName("baseData"); - { - writer.WriteStartObject(); - - writer.WriteProperty("ver", exceptionTelemetry.Data.Data.ver); - writer.WriteProperty("problemId", exceptionTelemetry.Data.Data.problemId); - Utils.CopyDictionary(exceptionTelemetry.Context.GlobalProperties, exceptionTelemetry.Data.Data.properties); - writer.WriteProperty("properties", exceptionTelemetry.Data.Data.properties); - writer.WriteProperty("measurements", exceptionTelemetry.Data.Data.measurements); - writer.WritePropertyName("exceptions"); - { - writer.WriteStartArray(); - - SerializeExceptions(exceptionTelemetry.Exceptions, writer); - - writer.WriteEndArray(); - } - - if (exceptionTelemetry.Data.Data.severityLevel.HasValue) - { - writer.WriteProperty("severityLevel", exceptionTelemetry.Data.Data.severityLevel.Value.ToString()); - } - - writer.WriteEndObject(); - } - - writer.WriteEndObject(); - } - - writer.WriteEndObject(); - } - - private static void SerializeMetricTelemetry(MetricTelemetry metricTelemetry, JsonWriter writer) - { - writer.WriteStartObject(); - - // metricTelemetry.WriteTelemetryName(writer, MetricTelemetry.TelemetryName); - metricTelemetry.WriteEnvelopeProperties(writer); - writer.WritePropertyName("data"); - { - writer.WriteStartObject(); - - // TODO: MetricTelemetry should write type as this.data.baseType once Common Schema 2.0 compliant. - writer.WriteProperty("baseType", metricTelemetry.BaseType); - writer.WritePropertyName("baseData"); - { - writer.WriteStartObject(); - - writer.WriteProperty("ver", metricTelemetry.Data.ver); - writer.WritePropertyName("metrics"); - { - writer.WriteStartArray(); - writer.WriteStartObject(); - - string metricNamespace = metricTelemetry.Metric.ns; - if (false == String.IsNullOrEmpty(metricNamespace)) - { - writer.WriteProperty("ns", metricNamespace); - } - - writer.WriteProperty("name", metricTelemetry.Metric.name); - writer.WriteProperty("kind", metricTelemetry.Metric.kind.ToString()); - writer.WriteProperty("value", metricTelemetry.Metric.value); - writer.WriteProperty("count", metricTelemetry.Metric.count); - writer.WriteProperty("min", metricTelemetry.Metric.min); - writer.WriteProperty("max", metricTelemetry.Metric.max); - writer.WriteProperty("stdDev", metricTelemetry.Metric.stdDev); - writer.WriteEndObject(); - writer.WriteEndArray(); - } - - Utils.CopyDictionary(metricTelemetry.Context.GlobalProperties, metricTelemetry.Data.properties); - writer.WriteProperty("properties", metricTelemetry.Data.properties); - - writer.WriteEndObject(); - } - - writer.WriteEndObject(); - } - - writer.WriteEndObject(); - } - - private static void SerializePageViewTelemetry(PageViewTelemetry pageViewTelemetry, JsonWriter writer) - { - writer.WriteStartObject(); - - // pageViewTelemetry.WriteTelemetryName(writer, PageViewTelemetry.TelemetryName); - pageViewTelemetry.WriteEnvelopeProperties(writer); - writer.WritePropertyName("data"); - { - writer.WriteStartObject(); - - writer.WriteProperty("baseType", pageViewTelemetry.BaseType); - writer.WritePropertyName("baseData"); - { - writer.WriteStartObject(); - - writer.WriteProperty("ver", pageViewTelemetry.Data.ver); - writer.WriteProperty("name", pageViewTelemetry.Data.name); - writer.WriteProperty("url", pageViewTelemetry.Data.url); - writer.WriteProperty("duration", pageViewTelemetry.Data.duration); - writer.WriteProperty("measurements", pageViewTelemetry.Data.measurements); - Utils.CopyDictionary(pageViewTelemetry.Context.GlobalProperties, pageViewTelemetry.Data.properties); - writer.WriteProperty("properties", pageViewTelemetry.Data.properties); - - writer.WriteEndObject(); - } - - writer.WriteEndObject(); - } - - writer.WriteEndObject(); - } - - private static void SerializePageViewPerformanceTelemetry(PageViewPerformanceTelemetry pageViewPerfTelemetry, JsonWriter writer) - { - writer.WriteStartObject(); - - // pageViewPerfTelemetry.WriteTelemetryName(writer, PageViewPerformanceTelemetry.TelemetryName); - pageViewPerfTelemetry.WriteEnvelopeProperties(writer); - writer.WritePropertyName("data"); - { - writer.WriteStartObject(); - - writer.WriteProperty("baseType", PageViewPerformanceTelemetry.BaseType); - writer.WritePropertyName("baseData"); - { - writer.WriteStartObject(); - - writer.WriteProperty("ver", pageViewPerfTelemetry.Data.ver); - writer.WriteProperty("name", pageViewPerfTelemetry.Data.name); - writer.WriteProperty("url", pageViewPerfTelemetry.Data.url); - writer.WriteProperty("duration", pageViewPerfTelemetry.Data.duration); - writer.WriteProperty("domProcessing", pageViewPerfTelemetry.Data.domProcessing); - writer.WriteProperty("perfTotal", pageViewPerfTelemetry.Data.perfTotal); - writer.WriteProperty("networkConnect", pageViewPerfTelemetry.Data.networkConnect); - writer.WriteProperty("sentRequest", pageViewPerfTelemetry.Data.sentRequest); - writer.WriteProperty("receivedResponse", pageViewPerfTelemetry.Data.receivedResponse); - writer.WriteProperty("measurements", pageViewPerfTelemetry.Data.measurements); - Utils.CopyDictionary(pageViewPerfTelemetry.Context.GlobalProperties, pageViewPerfTelemetry.Data.properties); - writer.WriteProperty("properties", pageViewPerfTelemetry.Data.properties); - - writer.WriteEndObject(); - } - - writer.WriteEndObject(); - } - - writer.WriteEndObject(); - } - - private static void SerializeDependencyTelemetry(DependencyTelemetry dependencyTelemetry, JsonWriter writer) - { - writer.WriteStartObject(); - - // dependencyTelemetry.WriteTelemetryName(writer, DependencyTelemetry.TelemetryName); - dependencyTelemetry.WriteEnvelopeProperties(writer); - writer.WritePropertyName("data"); - { - writer.WriteStartObject(); - - writer.WriteProperty("baseType", dependencyTelemetry.BaseType); - writer.WritePropertyName("baseData"); - { - writer.WriteStartObject(); - - writer.WriteProperty("ver", dependencyTelemetry.InternalData.ver); - writer.WriteProperty("name", dependencyTelemetry.InternalData.name); - writer.WriteProperty("id", dependencyTelemetry.InternalData.id); - writer.WriteProperty("data", dependencyTelemetry.InternalData.data); - writer.WriteProperty("duration", dependencyTelemetry.InternalData.duration); - writer.WriteProperty("resultCode", dependencyTelemetry.InternalData.resultCode); - writer.WriteProperty("success", dependencyTelemetry.InternalData.success); - writer.WriteProperty("type", dependencyTelemetry.InternalData.type); - writer.WriteProperty("target", dependencyTelemetry.InternalData.target); - Utils.CopyDictionary(dependencyTelemetry.Context.GlobalProperties, dependencyTelemetry.InternalData.properties); - writer.WriteProperty("properties", dependencyTelemetry.InternalData.properties); - writer.WriteProperty("measurements", dependencyTelemetry.InternalData.measurements); - writer.WriteEndObject(); - } - - writer.WriteEndObject(); - } - - writer.WriteEndObject(); - } - - private static void SerializeRequestTelemetry(RequestTelemetry requestTelemetry, JsonWriter jsonWriter) - { - jsonWriter.WriteStartObject(); - - // requestTelemetry.WriteTelemetryName(jsonWriter, RequestTelemetry.TelemetryName); - requestTelemetry.WriteEnvelopeProperties(jsonWriter); - jsonWriter.WritePropertyName("data"); - { - jsonWriter.WriteStartObject(); - - jsonWriter.WriteProperty("baseType", requestTelemetry.BaseType); - jsonWriter.WritePropertyName("baseData"); - { - jsonWriter.WriteStartObject(); - - jsonWriter.WriteProperty("ver", requestTelemetry.Data.ver); - jsonWriter.WriteProperty("id", requestTelemetry.Data.id); - jsonWriter.WriteProperty("source", requestTelemetry.Data.source); - jsonWriter.WriteProperty("name", requestTelemetry.Data.name); - jsonWriter.WriteProperty("duration", requestTelemetry.Duration); - jsonWriter.WriteProperty("success", requestTelemetry.Data.success); - jsonWriter.WriteProperty("responseCode", requestTelemetry.Data.responseCode); - jsonWriter.WriteProperty("url", requestTelemetry.Data.url); - jsonWriter.WriteProperty("measurements", requestTelemetry.Data.measurements); - Utils.CopyDictionary(requestTelemetry.Context.GlobalProperties, requestTelemetry.Data.properties); - jsonWriter.WriteProperty("properties", requestTelemetry.Data.properties); - - jsonWriter.WriteEndObject(); - } - - jsonWriter.WriteEndObject(); - } - - jsonWriter.WriteEndObject(); - } - - private static void SerializeTraceTelemetry(TraceTelemetry traceTelemetry, JsonWriter writer) - { - writer.WriteStartObject(); - - // traceTelemetry.WriteTelemetryName(writer, TraceTelemetry.TelemetryName); - traceTelemetry.WriteEnvelopeProperties(writer); - writer.WritePropertyName("data"); - { - writer.WriteStartObject(); - - writer.WriteProperty("baseType", traceTelemetry.BaseType); - writer.WritePropertyName("baseData"); - { - writer.WriteStartObject(); - - writer.WriteProperty("ver", traceTelemetry.Data.ver); - writer.WriteProperty("message", traceTelemetry.Message); - - if (traceTelemetry.SeverityLevel.HasValue) - { - writer.WriteProperty("severityLevel", traceTelemetry.SeverityLevel.Value.ToString()); - } - - Utils.CopyDictionary(traceTelemetry.Context.GlobalProperties, traceTelemetry.Data.properties); - writer.WriteProperty("properties", traceTelemetry.Properties); // TODO: handle case where the property dictionary doesn't need to be instantiated. - - writer.WriteEndObject(); - } - - writer.WriteEndObject(); - } - - writer.WriteEndObject(); - } - - /// - /// Serializes this object in JSON format. - /// - private static void SerializeAvailability(AvailabilityTelemetry availabilityTelemetry, JsonWriter writer) - { - writer.WriteStartObject(); - - // availabilityTelemetry.WriteTelemetryName(writer, AvailabilityTelemetry.TelemetryName); - availabilityTelemetry.WriteEnvelopeProperties(writer); - writer.WritePropertyName("data"); - { - writer.WriteStartObject(); - - writer.WriteProperty("baseType", availabilityTelemetry.BaseType); - writer.WritePropertyName("baseData"); - { - writer.WriteStartObject(); - - writer.WriteProperty("ver", availabilityTelemetry.Data.ver); - writer.WriteProperty("id", availabilityTelemetry.Data.id); - writer.WriteProperty("name", availabilityTelemetry.Data.name); - writer.WriteProperty("duration", availabilityTelemetry.Duration); - writer.WriteProperty("success", availabilityTelemetry.Data.success); - writer.WriteProperty("runLocation", availabilityTelemetry.Data.runLocation); - writer.WriteProperty("message", availabilityTelemetry.Data.message); - Utils.CopyDictionary(availabilityTelemetry.Context.GlobalProperties, availabilityTelemetry.Data.properties); - writer.WriteProperty("properties", availabilityTelemetry.Data.properties); - writer.WriteProperty("measurements", availabilityTelemetry.Data.measurements); - - writer.WriteEndObject(); - } - - writer.WriteEndObject(); - } - - writer.WriteEndObject(); - } - - #endregion Serialize methods for each ITelemetry implementation } } From 66c981d6390606f6fcb3a04224822090b9b13e58 Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Mon, 6 Aug 2018 22:59:17 -0700 Subject: [PATCH 52/74] Dependency - duration serializes to default value when not set --- .../DataContracts/DependencyTelemetryTest.cs | 20 +++++++++++++++++++ .../RemoteDependencyDataIExtension.cs | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/DependencyTelemetryTest.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/DependencyTelemetryTest.cs index 0e98aaa269..4334d1575e 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/DependencyTelemetryTest.cs +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/DependencyTelemetryTest.cs @@ -2,6 +2,8 @@ { using System; using System.Collections.Generic; + using System.Globalization; + using System.IO; using System.Linq; using KellermanSoftware.CompareNetObjects; using Microsoft.ApplicationInsights.Channel; @@ -86,6 +88,24 @@ public void SerializeWritesNullValuesAsExpectedByEndpoint() Assert.AreEqual(2, item.data.baseData.ver); } + [TestMethod] + public void SerializePopulatesRequiredFieldsOfDependencyTelemetry() + { + using (StringWriter stringWriter = new StringWriter(CultureInfo.InvariantCulture)) + { + var depTelemetry = new DependencyTelemetry(); + depTelemetry.Context.InstrumentationKey = Guid.NewGuid().ToString(); + ((ITelemetry)depTelemetry).Sanitize(); + var item = TelemetryItemTestHelper.SerializeDeserializeTelemetryItem(depTelemetry); + + Assert.AreEqual(2, item.data.baseData.ver); + Assert.IsNotNull(item.data.baseData.id); + Assert.IsNotNull(item.time); + Assert.AreEqual(new TimeSpan(), TimeSpan.Parse(item.data.baseData.duration)); + Assert.IsTrue(item.data.baseData.success); + } + } + [TestMethod] public void RemoteDependencyTelemetrySerializesStructuredIKeyToJsonCorrectlyPreservingPrefixCasing() { diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/RemoteDependencyDataIExtension.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/RemoteDependencyDataIExtension.cs index 27a3614520..3fa8d67f3f 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/RemoteDependencyDataIExtension.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/RemoteDependencyDataIExtension.cs @@ -15,7 +15,7 @@ public void Serialize(ISerializationWriter serializationWriter) serializationWriter.WriteProperty("name", this.name); serializationWriter.WriteProperty("id", this.id); serializationWriter.WriteProperty("data", this.data); - serializationWriter.WriteProperty("duration", this.duration); + serializationWriter.WriteProperty("duration", Utils.ValidateDuration(this.duration)); serializationWriter.WriteProperty("resultCode", this.resultCode); serializationWriter.WriteProperty("success", this.success); serializationWriter.WriteProperty("type", this.type); From b9173694571dcfb1cbc34cc2c505a5149176e147 Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Mon, 6 Aug 2018 23:06:00 -0700 Subject: [PATCH 53/74] minor --- .../JsonSerializationWriterTests.cs | 33 +------------------ 1 file changed, 1 insertion(+), 32 deletions(-) diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/Extensibility/Implementation/JsonSerializationWriterTests.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/Extensibility/Implementation/JsonSerializationWriterTests.cs index 8d001cf059..2a14fb0ee6 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/Extensibility/Implementation/JsonSerializationWriterTests.cs +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/Extensibility/Implementation/JsonSerializationWriterTests.cs @@ -60,38 +60,7 @@ public void SerializeAsStringMethodSerializesATelemetryCorrectly() Assert.AreEqual("user2", obj["Connections"][1]["userid"].ToString()); Assert.AreEqual("usersecret2", obj["Connections"][1]["password"].ToString()); - } - - [TestMethod] - public void SerializeAsStringMethodSerializesExceptionCorrectly() - { - - ExceptionTelemetry myex = null; - try - { - int x = 0; - int y = 10 / x; - } - catch (Exception ex) - { - myex = new ExceptionTelemetry(ex); - } - - var stringBuilder = new StringBuilder(); - using (StringWriter stringWriter = new StringWriter(stringBuilder, CultureInfo.InvariantCulture)) - { - var jsonSerializationWriter = new JsonSerializationWriter(stringWriter); - jsonSerializationWriter.WriteStartObject(); - myex.Serialize(jsonSerializationWriter); - jsonSerializationWriter.WriteEndObject(); - } - string actualJson = stringBuilder.ToString(); - Trace.WriteLine(actualJson); - - JObject obj = JsonConvert.DeserializeObject(actualJson); - - Assert.IsNotNull(actualJson); - } + } } public class DatabaseExtension : IExtension From 719fbbf41395c2a3a875bd8649d462ead66f8f07 Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Tue, 7 Aug 2018 11:36:02 -0700 Subject: [PATCH 54/74] Unit test the JsonSerializationWriter by serializing a complex object --- .../JsonSerializationWriterTests.cs | 199 +++++++++++++----- .../PerformanceCounterTelemetry.cs | 2 +- .../Implementation/JsonSerializationWriter.cs | 14 +- 3 files changed, 154 insertions(+), 61 deletions(-) diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/Extensibility/Implementation/JsonSerializationWriterTests.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/Extensibility/Implementation/JsonSerializationWriterTests.cs index 2a14fb0ee6..c9bce70ba7 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/Extensibility/Implementation/JsonSerializationWriterTests.cs +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/Extensibility/Implementation/JsonSerializationWriterTests.cs @@ -20,26 +20,48 @@ public class JsonSerializationWriterTests { [TestMethod] - public void SerializeAsStringMethodSerializesATelemetryCorrectly() + public void SerializeComplexObject() { - var dbExtension = new DatabaseExtension(); - dbExtension.DatabaseId = 10908; - dbExtension.DatabaseServer = "azpacalbcluster011"; - - dbExtension.DBLocation = new DBLocation() { city = "Bellevue", state = "WA" }; - - var cons = new List(); - cons.Add(new DBConnection() { userid = "user1", password = "usersecret1" }); - cons.Add(new DBConnection() { userid = "user2", password = "usersecret2" }); - dbExtension.Connections = cons; - + var complexExtension = new ComplexExtension(); + var mySubSubExtension1 = new MySubSubExtension() { Field3 = "Value1 for field3", Field4 = 100.00 }; + var mySubSubExtension2 = new MySubSubExtension() { Field3 = "Value2 for field3", Field4 = 200.00 }; + var mySubExtension1 = new MySubExtension() { Field1 = "Value1 for field1", Field2 = 100 , MySubSubExtension = mySubSubExtension1 }; + var mySubExtension2 = new MySubExtension() { Field1 = "Value2 for field1", Field2 = 200, MySubSubExtension = mySubSubExtension2 }; + var listExtension = new List(); + listExtension.Add(mySubExtension1); + listExtension.Add(mySubExtension2); + + var listString = new List(); + listString.Add("Item1"); + listString.Add("Item2"); + listString.Add("Item3"); + + complexExtension.MyBoolField = true; + complexExtension.MyDateTimeOffsetField = DateTimeOffset.Now; + complexExtension.MyDoubleField = 100.10; + complexExtension.MyIntField = 100; + complexExtension.MyStringField = "ValueStringField"; + complexExtension.MyTimeSpanField = TimeSpan.FromSeconds(2); + complexExtension.MySubExtensionField = mySubExtension1; + complexExtension.MyExtensionListField = listExtension; + complexExtension.MyStringListField = listString; + + var dicString = new Dictionary(); + dicString.Add("Key1", "Value1"); + dicString.Add("Key2", "Value2"); + complexExtension.MyStringDictionaryField = dicString; + + var dicDouble = new Dictionary(); + dicDouble.Add("Key1", 1000.000); + dicDouble.Add("Key2", 2000.000); + complexExtension.MyDoubleDictionaryField = dicDouble; var stringBuilder = new StringBuilder(); using (StringWriter stringWriter = new StringWriter(stringBuilder, CultureInfo.InvariantCulture)) { var jsonSerializationWriter = new JsonSerializationWriter(stringWriter); jsonSerializationWriter.WriteStartObject(); - dbExtension.Serialize(jsonSerializationWriter); + complexExtension.Serialize(jsonSerializationWriter); jsonSerializationWriter.WriteEndObject(); } @@ -49,89 +71,154 @@ public void SerializeAsStringMethodSerializesATelemetryCorrectly() JObject obj = JsonConvert.DeserializeObject(actualJson); Assert.IsNotNull(actualJson); - Assert.AreEqual("10908", obj["DatabaseId"].ToString()); - Assert.AreEqual("azpacalbcluster011", obj["DatabaseServer"].ToString()); + Assert.AreEqual("ValueStringField", obj["MyStringField"].ToString()); + Assert.AreEqual(100, int.Parse(obj["MyIntField"].ToString())); + Assert.AreEqual(100.10, double.Parse(obj["MyDoubleField"].ToString())); + Assert.AreEqual(true, bool.Parse(obj["MyBoolField"].ToString())); + Assert.AreEqual(TimeSpan.FromSeconds(2), TimeSpan.Parse(obj["MyTimeSpanField"].ToString())); + //Assert.AreEqual(DateTimeOffset., double.Parse(obj["MyDateTimeOffsetField"].ToString())); + + Assert.AreEqual("Value1 for field1",obj["MySubExtensionField"]["Field1"].ToString()); + Assert.AreEqual(100, int.Parse(obj["MySubExtensionField"]["Field2"].ToString())); + + Assert.AreEqual("Value1 for field3", obj["MySubExtensionField"]["MySubSubExtension"]["Field3"].ToString()); + Assert.AreEqual(100, int.Parse(obj["MySubExtensionField"]["MySubSubExtension"]["Field4"].ToString())); - Assert.AreEqual("Bellevue", obj["DBLocation"]["city"].ToString()); - Assert.AreEqual("WA", obj["DBLocation"]["state"].ToString()); + Assert.AreEqual("Item1", obj["MyStringListField"][0].ToString()); + Assert.AreEqual("Item2", obj["MyStringListField"][1].ToString()); + Assert.AreEqual("Item3", obj["MyStringListField"][2].ToString()); - Assert.AreEqual("user1", obj["Connections"][0]["userid"].ToString()); - Assert.AreEqual("usersecret1", obj["Connections"][0]["password"].ToString()); + Assert.AreEqual("Value1 for field1", obj["MyExtensionListField"][0]["Field1"].ToString()); + Assert.AreEqual(100, int.Parse(obj["MyExtensionListField"][0]["Field2"].ToString())); + Assert.AreEqual("Value1 for field3", obj["MyExtensionListField"][0]["MySubSubExtension"]["Field3"].ToString()); + Assert.AreEqual(100, int.Parse(obj["MyExtensionListField"][0]["MySubSubExtension"]["Field4"].ToString())); - Assert.AreEqual("user2", obj["Connections"][1]["userid"].ToString()); - Assert.AreEqual("usersecret2", obj["Connections"][1]["password"].ToString()); - } + Assert.AreEqual("Value2 for field1", obj["MyExtensionListField"][1]["Field1"].ToString()); + Assert.AreEqual(200, int.Parse(obj["MyExtensionListField"][1]["Field2"].ToString())); + Assert.AreEqual("Value2 for field3", obj["MyExtensionListField"][1]["MySubSubExtension"]["Field3"].ToString()); + Assert.AreEqual(200, int.Parse(obj["MyExtensionListField"][1]["MySubSubExtension"]["Field4"].ToString())); + + Assert.AreEqual("Value1", obj["MyStringDictionaryField"]["Key1"].ToString()); + Assert.AreEqual("Value2", obj["MyStringDictionaryField"]["Key2"].ToString()); + + Assert.AreEqual(1000, double.Parse(obj["MyDoubleDictionaryField"]["Key1"].ToString())); + Assert.AreEqual(2000, double.Parse(obj["MyDoubleDictionaryField"]["Key2"].ToString())); + + } } - public class DatabaseExtension : IExtension + public class ComplexExtension : IExtension { - public int DatabaseId; - public string DatabaseServer; - public IList Connections; - public DBLocation DBLocation; - + public string MyStringField; + public int MyIntField; + public double MyDoubleField; + public bool MyBoolField; + public TimeSpan MyTimeSpanField; + public DateTimeOffset MyDateTimeOffsetField; + public MySubExtension MySubExtensionField; + public IList MyStringListField; + public IList MyExtensionListField; + public IDictionary MyStringDictionaryField; + public IDictionary MyDoubleDictionaryField; + public IExtension DeepClone() { - DatabaseExtension other = new DatabaseExtension(); - other.DatabaseId = this.DatabaseId; - other.DatabaseServer = this.DatabaseServer; - other.DBLocation = (DBLocation) this.DBLocation.DeepClone(); - IList others = new List(); - foreach(var item in this.Connections) + ComplexExtension other = new ComplexExtension(); + other.MyStringField = this.MyStringField; + other.MyIntField = this.MyIntField; + other.MyDoubleField = this.MyDoubleField; + other.MyBoolField = this.MyBoolField; + other.MyTimeSpanField = this.MyTimeSpanField; + other.MyDateTimeOffsetField = this.MyDateTimeOffsetField; + other.MySubExtensionField = (MySubExtension) this.MySubExtensionField.DeepClone(); + + IList otherString = new List(); + foreach(var item in this.MyStringListField) + { + otherString.Add(item); + } + other.MyStringListField = otherString; + + IList others = new List(); + foreach(var item in this.MyExtensionListField) + { + others.Add((MySubExtension) item.DeepClone()); + } + other.MyExtensionListField = others; + + IDictionary otherStringDic = new Dictionary(); + foreach (var item in this.MyStringDictionaryField) + { + otherStringDic.Add(item.Key, item.Value); + } + other.MyStringDictionaryField = otherStringDic; + + IDictionary otherDoubleDic = new Dictionary(); + foreach (var item in this.MyDoubleDictionaryField) { - others.Add((DBConnection) item.DeepClone()); + otherDoubleDic.Add(item.Key, item.Value); } + other.MyDoubleDictionaryField = otherDoubleDic; - other.Connections = others; return other; } public void Serialize(ISerializationWriter serializationWriter) { - serializationWriter.WriteProperty("DatabaseId", DatabaseId); - serializationWriter.WriteProperty("DatabaseServer", DatabaseServer); - serializationWriter.WriteProperty("DBLocation", DBLocation); - serializationWriter.WriteList("Connections", Connections.ToList()); + serializationWriter.WriteProperty("MyStringField", MyStringField); + serializationWriter.WriteProperty("MyIntField", MyIntField); + serializationWriter.WriteProperty("MyDoubleField", MyDoubleField); + serializationWriter.WriteProperty("MyBoolField", MyBoolField); + serializationWriter.WriteProperty("MyTimeSpanField", MyTimeSpanField); + serializationWriter.WriteProperty("MyDateTimeOffsetField", MyDateTimeOffsetField); + serializationWriter.WriteProperty("MySubExtensionField", MySubExtensionField); + serializationWriter.WriteList("MyStringListField", MyStringListField); + serializationWriter.WriteList("MyExtensionListField", MyExtensionListField.ToList()); + serializationWriter.WriteDictionary("MyStringDictionaryField", MyStringDictionaryField); + serializationWriter.WriteDictionary("MyDoubleDictionaryField", MyDoubleDictionaryField); } } - public class DBConnection : IExtension + public class MySubExtension : IExtension { - public string userid; - public string password; + public string Field1; + public int Field2; + public IExtension MySubSubExtension; public IExtension DeepClone() { - DBConnection other = new DBConnection(); - other.userid = this.userid; - other.password = this.password; + MySubExtension other = new MySubExtension(); + other.Field1 = this.Field1; + other.Field2 = this.Field2; + other.MySubSubExtension = this.MySubSubExtension.DeepClone(); return other; } public void Serialize(ISerializationWriter serializationWriter) { - serializationWriter.WriteProperty("userid", userid); - serializationWriter.WriteProperty("password", password); + serializationWriter.WriteProperty("Field1", Field1); + serializationWriter.WriteProperty("Field2", Field2); + serializationWriter.WriteProperty("MySubSubExtension", MySubSubExtension); } } - public class DBLocation : IExtension + public class MySubSubExtension : IExtension { - public string city; - public string state; + public string Field3; + public double Field4; public IExtension DeepClone() { - DBLocation other = new DBLocation(); - other.city = this.city; - other.state = this.state; + MySubSubExtension other = new MySubSubExtension(); + other.Field3 = this.Field3; + other.Field4 = this.Field4; return other; } public void Serialize(ISerializationWriter serializationWriter) { - serializationWriter.WriteProperty("city", city); - serializationWriter.WriteProperty("state", state); + serializationWriter.WriteProperty("Field3", Field3); + serializationWriter.WriteProperty("Field4", Field4); } } } \ No newline at end of file diff --git a/src/Microsoft.ApplicationInsights/DataContracts/PerformanceCounterTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/PerformanceCounterTelemetry.cs index 370260ee7c..d94cdb77b2 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/PerformanceCounterTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/PerformanceCounterTelemetry.cs @@ -209,7 +209,7 @@ public void Serialize(ISerializationWriter serializationWriter) /// /// Sanitizes the properties based on constraints. /// - void ITelemetry.Sanitize() + void ITelemetry.Sanitize() { ((ITelemetry)this.Data).Sanitize(); } diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializationWriter.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializationWriter.cs index e3d0fa955a..097c7ca784 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializationWriter.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializationWriter.cs @@ -92,19 +92,25 @@ public void WriteProperty(string name, DateTimeOffset? value) /// public void WriteList(string name, IList items) { + bool commaNeeded = false; if (items != null && items.Count > 0) { this.WritePropertyName(name); + this.WriteStartArray(); + foreach (var item in items) { - this.WriteComma(); - this.WriteRawValue(item); + if (commaNeeded) + { + this.WriteComma(); + } + + this.WriteString(item); + commaNeeded = true; } this.WriteEndArray(); - - this.WriteEndObject(); } } From d3ad81b3907032efd0142b6a6fa4a968031ede39 Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Tue, 7 Aug 2018 15:04:09 -0700 Subject: [PATCH 55/74] Serialize duration correctly --- .../PageViewPerformanceTelemetryTest.cs | 23 +++++++++++++++++++ .../DataContracts/PageViewTelemetryTest.cs | 17 ++++++++++++++ .../External/AvailabilityDataIExtension.cs | 2 +- .../External/DataPointIExtension.cs | 2 +- .../External/ExceptionDataIExtension.cs | 2 +- .../External/PageViewDataIExtension.cs | 2 +- .../External/PageViewPerfDataIExtension.cs | 12 +++++----- .../External/StackFrameIExtension.cs | 2 +- 8 files changed, 51 insertions(+), 11 deletions(-) diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/PageViewPerformanceTelemetryTest.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/PageViewPerformanceTelemetryTest.cs index 092a82c1aa..cd668cbe5a 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/PageViewPerformanceTelemetryTest.cs +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/PageViewPerformanceTelemetryTest.cs @@ -96,6 +96,29 @@ public void PageViewPerformanceTelemetryTelemetryPropertiesFromContextAndItemSer Assert.IsTrue(item.data.baseData.properties.ContainsKey("TestProperty")); } + [TestMethod] + public void SerializePopulatesRequiredFieldsOfPageViewPerfTelemetry() + { + using (StringWriter stringWriter = new StringWriter(CultureInfo.InvariantCulture)) + { + var pvTelemetry = new PageViewPerformanceTelemetry(); + pvTelemetry.Context.InstrumentationKey = Guid.NewGuid().ToString(); + ((ITelemetry)pvTelemetry).Sanitize(); + var item = TelemetryItemTestHelper.SerializeDeserializeTelemetryItem(pvTelemetry); + + Assert.AreEqual(2, item.data.baseData.ver); + Assert.IsNotNull(item.data.baseData.id); + Assert.IsNotNull(item.time); + Assert.AreEqual(new TimeSpan(), TimeSpan.Parse(item.data.baseData.duration)); + Assert.AreEqual(new TimeSpan(), TimeSpan.Parse(item.data.baseData.domProcessing)); + Assert.AreEqual(new TimeSpan(), TimeSpan.Parse(item.data.baseData.networkConnect)); + Assert.AreEqual(new TimeSpan(), TimeSpan.Parse(item.data.baseData.perfTotal)); + Assert.AreEqual(new TimeSpan(), TimeSpan.Parse(item.data.baseData.receivedResponse)); + Assert.AreEqual(new TimeSpan(), TimeSpan.Parse(item.data.baseData.sentRequest)); + } + } + + [TestMethod] public void SanitizeWillTrimAppropriateFields() { diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/PageViewTelemetryTest.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/PageViewTelemetryTest.cs index d55f973607..c0ef2a6a9b 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/PageViewTelemetryTest.cs +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/PageViewTelemetryTest.cs @@ -96,6 +96,23 @@ public void PageViewTelemetryTelemetryPropertiesFromContextAndItemSerializesToPr Assert.IsTrue(item.data.baseData.properties.ContainsKey("TestProperty")); } + [TestMethod] + public void SerializePopulatesRequiredFieldsOfPageViewPerfTelemetry() + { + using (StringWriter stringWriter = new StringWriter(CultureInfo.InvariantCulture)) + { + var pvTelemetry = new PageViewTelemetry(); + pvTelemetry.Context.InstrumentationKey = Guid.NewGuid().ToString(); + ((ITelemetry)pvTelemetry).Sanitize(); + var item = TelemetryItemTestHelper.SerializeDeserializeTelemetryItem(pvTelemetry); + + Assert.AreEqual(2, item.data.baseData.ver); + Assert.IsNotNull(item.data.baseData.id); + Assert.IsNotNull(item.time); + Assert.AreEqual(new TimeSpan(), TimeSpan.Parse(item.data.baseData.duration)); + } + } + [TestMethod] public void SanitizeWillTrimAppropriateFields() { diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/AvailabilityDataIExtension.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/AvailabilityDataIExtension.cs index 4b6d898892..86b56e39ce 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/AvailabilityDataIExtension.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/AvailabilityDataIExtension.cs @@ -14,7 +14,7 @@ public void Serialize(ISerializationWriter serializationWriter) serializationWriter.WriteProperty("ver", this.ver); serializationWriter.WriteProperty("id", this.id); serializationWriter.WriteProperty("name", this.name); - serializationWriter.WriteProperty("duration", this.duration); + serializationWriter.WriteProperty("duration", Utils.ValidateDuration(this.duration)); serializationWriter.WriteProperty("success", this.success); serializationWriter.WriteProperty("runLocation", this.runLocation); serializationWriter.WriteProperty("message", this.message); diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/DataPointIExtension.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/DataPointIExtension.cs index e99ed0d680..cabd3c5bbb 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/DataPointIExtension.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/DataPointIExtension.cs @@ -13,7 +13,7 @@ public void Serialize(ISerializationWriter serializationWriter) serializationWriter.WriteProperty("name", this.name); serializationWriter.WriteProperty("kind", this.kind.ToString()); serializationWriter.WriteProperty("value", this.value); - serializationWriter.WriteProperty("count", this.count); + serializationWriter.WriteProperty("count", this.count.HasValue ? this.count : 1); serializationWriter.WriteProperty("min", this.min); serializationWriter.WriteProperty("max", this.max); serializationWriter.WriteProperty("stdDev", this.stdDev); diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/ExceptionDataIExtension.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/ExceptionDataIExtension.cs index 797aebcdb8..5059263850 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/ExceptionDataIExtension.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/ExceptionDataIExtension.cs @@ -21,7 +21,7 @@ public void Serialize(ISerializationWriter serializationWriter) serializationWriter.WriteProperty("ver", this.ver); serializationWriter.WriteProperty("problemId", this.problemId); serializationWriter.WriteList("exceptions", this.exceptions.ToList()); - serializationWriter.WriteProperty("severityLevel", this.severityLevel.HasValue ? this.severityLevel.Value.ToString() : null); + serializationWriter.WriteProperty("severityLevel", this.severityLevel.TranslateSeverityLevel().HasValue ? this.severityLevel.TranslateSeverityLevel().Value.ToString() : null); serializationWriter.WriteDictionary("properties", this.properties); serializationWriter.WriteDictionary("measurements", this.measurements); diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/PageViewDataIExtension.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/PageViewDataIExtension.cs index 69fae6266a..6f817ebe60 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/PageViewDataIExtension.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/PageViewDataIExtension.cs @@ -12,7 +12,7 @@ internal partial class PageViewData : IExtension serializationWriter.WriteProperty("ver", this.ver); serializationWriter.WriteProperty("name", this.name); serializationWriter.WriteProperty("url", this.url); - serializationWriter.WriteProperty("duration", this.duration); + serializationWriter.WriteProperty("duration", Utils.ValidateDuration(this.duration)); serializationWriter.WriteDictionary("properties", this.properties); serializationWriter.WriteDictionary("measurements", this.measurements); } diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/PageViewPerfDataIExtension.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/PageViewPerfDataIExtension.cs index fd1d6d3f55..2f8c752be6 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/PageViewPerfDataIExtension.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/PageViewPerfDataIExtension.cs @@ -10,12 +10,12 @@ internal partial class PageViewPerfData : IExtension serializationWriter.WriteProperty("ver", this.ver); serializationWriter.WriteProperty("name", this.name); serializationWriter.WriteProperty("url", this.url); - serializationWriter.WriteProperty("duration", this.duration); - serializationWriter.WriteProperty("domProcessing", this.domProcessing); - serializationWriter.WriteProperty("perfTotal", this.perfTotal); - serializationWriter.WriteProperty("networkConnect", this.networkConnect); - serializationWriter.WriteProperty("sentRequest", this.sentRequest); - serializationWriter.WriteProperty("receivedResponse", this.receivedResponse); + serializationWriter.WriteProperty("duration", Utils.ValidateDuration(this.duration)); + serializationWriter.WriteProperty("domProcessing", Utils.ValidateDuration(this.domProcessing)); + serializationWriter.WriteProperty("perfTotal", Utils.ValidateDuration(this.perfTotal)); + serializationWriter.WriteProperty("networkConnect", Utils.ValidateDuration(this.networkConnect)); + serializationWriter.WriteProperty("sentRequest", Utils.ValidateDuration(this.sentRequest)); + serializationWriter.WriteProperty("receivedResponse", Utils.ValidateDuration(this.receivedResponse)); serializationWriter.WriteDictionary("properties", this.properties); serializationWriter.WriteDictionary("measurements", this.measurements); } diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/StackFrameIExtension.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/StackFrameIExtension.cs index 1df0add02b..3e245ef533 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/StackFrameIExtension.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/StackFrameIExtension.cs @@ -9,7 +9,7 @@ internal partial class StackFrame : IExtension { public IExtension DeepClone() { - throw new NotImplementedException(); + return null; } public void Serialize(ISerializationWriter serializationWriter) From 17f8ee07974b5a5fc0a495a5addebc83a64621d1 Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Tue, 7 Aug 2018 15:39:31 -0700 Subject: [PATCH 56/74] Reuse code to write envelop properties --- .../Shared/DataContracts/PageViewTelemetryTest.cs | 2 +- .../Shared/DataContracts/TelemetryContextTest.cs | 2 +- .../DataContracts/AvailabilityTelemetry.cs | 6 +----- .../DataContracts/DependencyTelemetry.cs | 8 +------- .../DataContracts/EventTelemetry.cs | 9 +-------- .../DataContracts/ExceptionTelemetry.cs | 9 +-------- .../DataContracts/MetricTelemetry.cs | 8 +------- .../DataContracts/PageViewPerformanceTelemetry.cs | 9 +-------- .../DataContracts/PageViewTelemetry.cs | 9 +-------- .../DataContracts/RequestTelemetry.cs | 9 +-------- .../DataContracts/TraceTelemetry.cs | 9 +-------- .../Extensibility/Implementation/Telemetry.cs | 6 +++--- 12 files changed, 14 insertions(+), 72 deletions(-) diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/PageViewTelemetryTest.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/PageViewTelemetryTest.cs index c0ef2a6a9b..fa671beb86 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/PageViewTelemetryTest.cs +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/PageViewTelemetryTest.cs @@ -97,7 +97,7 @@ public void PageViewTelemetryTelemetryPropertiesFromContextAndItemSerializesToPr } [TestMethod] - public void SerializePopulatesRequiredFieldsOfPageViewPerfTelemetry() + public void SerializePopulatesRequiredFieldsOfPageViewTelemetry() { using (StringWriter stringWriter = new StringWriter(CultureInfo.InvariantCulture)) { diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/TelemetryContextTest.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/TelemetryContextTest.cs index 96dd2dd272..5458a5b1bc 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/TelemetryContextTest.cs +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/TelemetryContextTest.cs @@ -252,7 +252,7 @@ private static string CopyAndSerialize(TelemetryContext source) using (var stringWriter = new StringWriter(CultureInfo.InvariantCulture)) { - Telemetry.WriteTelemetryContext(new JsonWriter(stringWriter), source); + Telemetry.WriteTelemetryContext(new JsonSerializationWriter(stringWriter), source); return stringWriter.ToString(); } } diff --git a/src/Microsoft.ApplicationInsights/DataContracts/AvailabilityTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/AvailabilityTelemetry.cs index 1517250ad4..f866c379f6 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/AvailabilityTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/AvailabilityTelemetry.cs @@ -190,11 +190,7 @@ IExtension IExtension.DeepClone() public void Serialize(ISerializationWriter serializationWriter) { serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName)); - serializationWriter.WriteProperty("time", this.Timestamp.UtcDateTime.ToString("o", CultureInfo.InvariantCulture)); - serializationWriter.WriteProperty("seq", this.Sequence); - serializationWriter.WriteProperty("iKey", this.Context.InstrumentationKey); - serializationWriter.WriteProperty("flags", this.Context.Flags); - serializationWriter.WriteDictionary("tags", this.Context.SanitizedTags); + this.WriteEnvelopeProperties(serializationWriter); Utils.CopyDictionary(this.Context.GlobalProperties, this.Data.properties); serializationWriter.WriteStartObject("data"); serializationWriter.WriteProperty("baseType", this.BaseType); diff --git a/src/Microsoft.ApplicationInsights/DataContracts/DependencyTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/DependencyTelemetry.cs index 5649bf069e..ccc543a996 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/DependencyTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/DependencyTelemetry.cs @@ -345,14 +345,8 @@ public void SetOperationDetail(string key, object detail) public void Serialize(ISerializationWriter serializationWriter) { serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName)); - serializationWriter.WriteProperty("time", this.Timestamp.UtcDateTime.ToString("o", CultureInfo.InvariantCulture)); - serializationWriter.WriteProperty("sampleRate", this.samplingPercentage); - serializationWriter.WriteProperty("seq", this.Sequence); + this.WriteEnvelopeProperties(serializationWriter); - serializationWriter.WriteProperty("iKey", this.Context.InstrumentationKey); - serializationWriter.WriteProperty("flags", this.Context.Flags); - - serializationWriter.WriteDictionary("tags", this.Context.SanitizedTags); Utils.CopyDictionary(this.Context.GlobalProperties, this.InternalData.properties); serializationWriter.WriteStartObject("data"); serializationWriter.WriteProperty("baseType", this.BaseType); diff --git a/src/Microsoft.ApplicationInsights/DataContracts/EventTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/EventTelemetry.cs index 3ceacfbf63..63793772e0 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/EventTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/EventTelemetry.cs @@ -147,14 +147,7 @@ IExtension IExtension.DeepClone() public void Serialize(ISerializationWriter serializationWriter) { serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName)); - serializationWriter.WriteProperty("time", this.Timestamp.UtcDateTime.ToString("o", CultureInfo.InvariantCulture)); - serializationWriter.WriteProperty("sampleRate", this.samplingPercentage); - serializationWriter.WriteProperty("seq", this.Sequence); - - serializationWriter.WriteProperty("iKey", this.Context.InstrumentationKey); - serializationWriter.WriteProperty("flags", this.Context.Flags); - - serializationWriter.WriteDictionary("tags", this.Context.SanitizedTags); + this.WriteEnvelopeProperties(serializationWriter); Utils.CopyDictionary(this.Context.GlobalProperties, this.Data.properties); serializationWriter.WriteStartObject("data"); serializationWriter.WriteProperty("baseType", this.BaseType); diff --git a/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs index 82fd583c21..a1fbe9336e 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs @@ -289,14 +289,7 @@ IExtension IExtension.DeepClone() public void Serialize(ISerializationWriter serializationWriter) { serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName)); - serializationWriter.WriteProperty("time", this.Timestamp.UtcDateTime.ToString("o", CultureInfo.InvariantCulture)); - serializationWriter.WriteProperty("sampleRate", this.samplingPercentage); - serializationWriter.WriteProperty("seq", this.Sequence); - - serializationWriter.WriteProperty("iKey", this.Context.InstrumentationKey); - serializationWriter.WriteProperty("flags", this.Context.Flags); - - serializationWriter.WriteDictionary("tags", this.Context.SanitizedTags); + this.WriteEnvelopeProperties(serializationWriter); Utils.CopyDictionary(this.Context.GlobalProperties, this.Data.Data.properties); serializationWriter.WriteStartObject("data"); serializationWriter.WriteProperty("baseType", this.BaseType); diff --git a/src/Microsoft.ApplicationInsights/DataContracts/MetricTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/MetricTelemetry.cs index f47d2280d5..79eba9c06a 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/MetricTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/MetricTelemetry.cs @@ -263,13 +263,7 @@ IExtension IExtension.DeepClone() public void Serialize(ISerializationWriter serializationWriter) { serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName)); - serializationWriter.WriteProperty("time", this.Timestamp.UtcDateTime.ToString("o", CultureInfo.InvariantCulture)); - serializationWriter.WriteProperty("seq", this.Sequence); - - serializationWriter.WriteProperty("iKey", this.Context.InstrumentationKey); - serializationWriter.WriteProperty("flags", this.Context.Flags); - - serializationWriter.WriteDictionary("tags", this.Context.SanitizedTags); + this.WriteEnvelopeProperties(serializationWriter); Utils.CopyDictionary(this.Context.GlobalProperties, this.Data.properties); serializationWriter.WriteStartObject("data"); serializationWriter.WriteProperty("baseType", this.BaseType); diff --git a/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs index 7b90aa145e..24d6474137 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs @@ -237,14 +237,7 @@ IExtension IExtension.DeepClone() public void Serialize(ISerializationWriter serializationWriter) { serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName)); - serializationWriter.WriteProperty("time", this.Timestamp.UtcDateTime.ToString("o", CultureInfo.InvariantCulture)); - serializationWriter.WriteProperty("sampleRate", this.samplingPercentage); - serializationWriter.WriteProperty("seq", this.Sequence); - - serializationWriter.WriteProperty("iKey", this.Context.InstrumentationKey); - serializationWriter.WriteProperty("flags", this.Context.Flags); - - serializationWriter.WriteDictionary("tags", this.Context.SanitizedTags); + this.WriteEnvelopeProperties(serializationWriter); Utils.CopyDictionary(this.Context.GlobalProperties, this.Data.properties); serializationWriter.WriteStartObject("data"); serializationWriter.WriteProperty("baseType", BaseType); diff --git a/src/Microsoft.ApplicationInsights/DataContracts/PageViewTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/PageViewTelemetry.cs index c24212a5ea..16dbaae4e5 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/PageViewTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/PageViewTelemetry.cs @@ -190,14 +190,7 @@ IExtension IExtension.DeepClone() public void Serialize(ISerializationWriter serializationWriter) { serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName)); - serializationWriter.WriteProperty("time", this.Timestamp.UtcDateTime.ToString("o", CultureInfo.InvariantCulture)); - serializationWriter.WriteProperty("sampleRate", this.samplingPercentage); - serializationWriter.WriteProperty("seq", this.Sequence); - - serializationWriter.WriteProperty("iKey", this.Context.InstrumentationKey); - serializationWriter.WriteProperty("flags", this.Context.Flags); - - serializationWriter.WriteDictionary("tags", this.Context.SanitizedTags); + this.WriteEnvelopeProperties(serializationWriter); Utils.CopyDictionary(this.Context.GlobalProperties, this.Data.properties); serializationWriter.WriteStartObject("data"); serializationWriter.WriteProperty("baseType", this.BaseType); diff --git a/src/Microsoft.ApplicationInsights/DataContracts/RequestTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/RequestTelemetry.cs index 44c117bcdb..fa962e4a78 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/RequestTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/RequestTelemetry.cs @@ -239,14 +239,7 @@ public override ITelemetry DeepClone() public void Serialize(ISerializationWriter serializationWriter) { serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName)); - serializationWriter.WriteProperty("time", this.Timestamp.UtcDateTime.ToString("o", CultureInfo.InvariantCulture)); - serializationWriter.WriteProperty("sampleRate", this.samplingPercentage); - serializationWriter.WriteProperty("seq", this.Sequence); - - serializationWriter.WriteProperty("iKey", this.Context.InstrumentationKey); - serializationWriter.WriteProperty("flags", this.Context.Flags); - - serializationWriter.WriteDictionary("tags", this.Context.SanitizedTags); + this.WriteEnvelopeProperties(serializationWriter); Utils.CopyDictionary(this.Context.GlobalProperties, this.Data.properties); serializationWriter.WriteStartObject("data"); serializationWriter.WriteProperty("baseType", this.BaseType); diff --git a/src/Microsoft.ApplicationInsights/DataContracts/TraceTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/TraceTelemetry.cs index 63135a13b9..fee5ddeafb 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/TraceTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/TraceTelemetry.cs @@ -148,14 +148,7 @@ IExtension IExtension.DeepClone() public void Serialize(ISerializationWriter serializationWriter) { serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName)); - serializationWriter.WriteProperty("time", this.Timestamp.UtcDateTime.ToString("o", CultureInfo.InvariantCulture)); - serializationWriter.WriteProperty("sampleRate", this.samplingPercentage); - serializationWriter.WriteProperty("seq", this.Sequence); - - serializationWriter.WriteProperty("iKey", this.Context.InstrumentationKey); - serializationWriter.WriteProperty("flags", this.Context.Flags); - - serializationWriter.WriteDictionary("tags", this.Context.SanitizedTags); + this.WriteEnvelopeProperties(serializationWriter); Utils.CopyDictionary(this.Context.GlobalProperties, this.Data.properties); serializationWriter.WriteStartObject("data"); serializationWriter.WriteProperty("baseType", this.BaseType); diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Telemetry.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Telemetry.cs index 87e50b6ab2..056d2098fc 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Telemetry.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Telemetry.cs @@ -7,7 +7,7 @@ internal static class Telemetry { - public static void WriteEnvelopeProperties(this ITelemetry telemetry, IJsonWriter json) + public static void WriteEnvelopeProperties(this ITelemetry telemetry, ISerializationWriter json) { json.WriteProperty("time", telemetry.Timestamp.UtcDateTime.ToString("o", CultureInfo.InvariantCulture)); @@ -48,7 +48,7 @@ public static string WriteTelemetryName(this ITelemetry telemetry, string teleme return eventName; } - public static void WriteTelemetryContext(IJsonWriter json, TelemetryContext context) + public static void WriteTelemetryContext(ISerializationWriter json, TelemetryContext context) { if (context != null) { @@ -58,7 +58,7 @@ public static void WriteTelemetryContext(IJsonWriter json, TelemetryContext cont json.WriteProperty("flags", context.Flags); } - json.WriteProperty("tags", context.SanitizedTags); + json.WriteDictionary("tags", context.SanitizedTags); } } From f9000fca85512074877e1f3d366e89bab32fd701 Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Tue, 7 Aug 2018 16:06:35 -0700 Subject: [PATCH 57/74] Renamings and testing jsonserializationwriter --- .../DataContracts/TelemetryItemTestHelper.cs | 4 +- .../JsonSerializationWriterTests.cs | 8 +- .../Implementation/JsonWriterTest.cs | 112 +++---- .../Extensibility/ISerializationWriter.cs | 8 +- .../External/AvailabilityDataIExtension.cs | 4 +- .../External/EventDataIExtension.cs | 4 +- .../External/ExceptionDataIExtension.cs | 6 +- .../External/ExceptionDetailsIExtension.cs | 2 +- .../External/MessageDataIExtension.cs | 4 +- .../External/MetricDataIExtension.cs | 4 +- .../External/PageViewDataIExtension.cs | 4 +- .../External/PageViewPerfDataIExtension.cs | 4 +- .../RemoteDependencyDataIExtension.cs | 4 +- .../External/RequestDataIExtension.cs | 4 +- .../Implementation/JsonSerializationWriter.cs | 22 +- .../Implementation/JsonWriter.cs | 314 ------------------ .../Extensibility/Implementation/Telemetry.cs | 2 +- 17 files changed, 97 insertions(+), 413 deletions(-) delete mode 100644 src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonWriter.cs diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/TelemetryItemTestHelper.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/TelemetryItemTestHelper.cs index 07b8df65eb..d2b023e5ce 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/TelemetryItemTestHelper.cs +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/DataContracts/TelemetryItemTestHelper.cs @@ -1,14 +1,12 @@ namespace Microsoft.ApplicationInsights.DataContracts { - using System.Globalization; using System.IO; using System.Text; using Microsoft.ApplicationInsights.Channel; using Newtonsoft.Json; using Newtonsoft.Json.Linq; - + using JsonSerializer = Microsoft.ApplicationInsights.Extensibility.Implementation.JsonSerializer; - using JsonWriter = Microsoft.ApplicationInsights.Extensibility.Implementation.JsonWriter; internal static class TelemetryItemTestHelper { diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/Extensibility/Implementation/JsonSerializationWriterTests.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/Extensibility/Implementation/JsonSerializationWriterTests.cs index c9bce70ba7..1436bb41a0 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/Extensibility/Implementation/JsonSerializationWriterTests.cs +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/Extensibility/Implementation/JsonSerializationWriterTests.cs @@ -172,10 +172,10 @@ public void Serialize(ISerializationWriter serializationWriter) serializationWriter.WriteProperty("MyTimeSpanField", MyTimeSpanField); serializationWriter.WriteProperty("MyDateTimeOffsetField", MyDateTimeOffsetField); serializationWriter.WriteProperty("MySubExtensionField", MySubExtensionField); - serializationWriter.WriteList("MyStringListField", MyStringListField); - serializationWriter.WriteList("MyExtensionListField", MyExtensionListField.ToList()); - serializationWriter.WriteDictionary("MyStringDictionaryField", MyStringDictionaryField); - serializationWriter.WriteDictionary("MyDoubleDictionaryField", MyDoubleDictionaryField); + serializationWriter.WriteProperty("MyStringListField", MyStringListField); + serializationWriter.WriteProperty("MyExtensionListField", MyExtensionListField.ToList()); + serializationWriter.WriteProperty("MyStringDictionaryField", MyStringDictionaryField); + serializationWriter.WriteProperty("MyDoubleDictionaryField", MyDoubleDictionaryField); } } diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/Extensibility/Implementation/JsonWriterTest.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/Extensibility/Implementation/JsonWriterTest.cs index 0b5910a5b1..895d349a0b 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/Extensibility/Implementation/JsonWriterTest.cs +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/Extensibility/Implementation/JsonWriterTest.cs @@ -10,12 +10,12 @@ using Microsoft.ApplicationInsights.TestFramework; [TestClass] - public class JsonWriterTest + public class JsonSerializationWriterTest { [TestMethod] public void ClassIsInternalAndNotMeantToBeAccessedByCustomers() { - Assert.IsFalse(typeof(JsonWriter).GetTypeInfo().IsPublic); + Assert.IsFalse(typeof(JsonSerializationWriter).GetTypeInfo().IsPublic); } [TestMethod] @@ -23,7 +23,7 @@ public void WriteStartArrayWritesOpeningSquareBracket() { using (var stringWriter = new StringWriter(CultureInfo.InvariantCulture)) { - new JsonWriter(stringWriter).WriteStartArray(); + new JsonSerializationWriter(stringWriter).WriteStartArray(); Assert.AreEqual("[", stringWriter.ToString()); } } @@ -33,7 +33,7 @@ public void WriteStartObjectWritesOpeningCurlyBrace() { using (var stringWriter = new StringWriter(CultureInfo.InvariantCulture)) { - new JsonWriter(stringWriter).WriteStartObject(); + new JsonSerializationWriter(stringWriter).WriteStartObject(); Assert.AreEqual("{", stringWriter.ToString()); } } @@ -43,7 +43,7 @@ public void WriteEndArrayWritesClosingSquareBracket() { using (var stringWriter = new StringWriter(CultureInfo.InvariantCulture)) { - new JsonWriter(stringWriter).WriteEndArray(); + new JsonSerializationWriter(stringWriter).WriteEndArray(); Assert.AreEqual("]", stringWriter.ToString()); } } @@ -53,7 +53,7 @@ public void WriteEndObjectWritesClosingCurlyBrace() { using (var stringWriter = new StringWriter(CultureInfo.InvariantCulture)) { - new JsonWriter(stringWriter).WriteEndObject(); + new JsonSerializationWriter(stringWriter).WriteEndObject(); Assert.AreEqual("}", stringWriter.ToString()); } } @@ -63,7 +63,7 @@ public void WriteRawValueWritesValueWithoutEscapingValue() { using (var stringWriter = new StringWriter(CultureInfo.InvariantCulture)) { - new JsonWriter(stringWriter).WriteRawValue(@"Test\Name"); + new JsonSerializationWriter(stringWriter).WriteRawValue(@"Test\Name"); Assert.AreEqual(@"Test\Name", stringWriter.ToString()); } } @@ -77,7 +77,7 @@ public void WritePropertyIntWritesIntValueWithoutQuotationMark() { const string Name = "name"; const int Value = 42; - new JsonWriter(stringWriter).WriteProperty(Name, Value); + new JsonSerializationWriter(stringWriter).WriteProperty(Name, Value); Assert.AreEqual("\"" + Name + "\":" + Value, stringWriter.ToString()); } } @@ -87,7 +87,7 @@ public void WritePropertyIntDoesNothingIfValueIsNullBecauseItAssumesPropertyIsOp { using (var stringWriter = new StringWriter(CultureInfo.InvariantCulture)) { - new JsonWriter(stringWriter).WriteProperty("name", (int?)null); + new JsonSerializationWriter(stringWriter).WriteProperty("name", (int?)null); Assert.AreEqual(string.Empty, stringWriter.ToString()); } } @@ -103,7 +103,7 @@ public void WritePropertyDoubleWritesDoubleValueWithoutQuotationMark() { const string Name = "name"; const double Value = 42.3; - new JsonWriter(stringWriter).WriteProperty(Name, Value); + new JsonSerializationWriter(stringWriter).WriteProperty(Name, Value); Assert.AreEqual("\"" + Name + "\":" + Value.ToString(CultureInfo.InvariantCulture), stringWriter.ToString()); } } @@ -113,7 +113,7 @@ public void WritePropertyDoubleDoesNothingIfValueIsNullBecauseItAssumesPropertyI { using (var stringWriter = new StringWriter(CultureInfo.InvariantCulture)) { - new JsonWriter(stringWriter).WriteProperty("name", (double?)null); + new JsonSerializationWriter(stringWriter).WriteProperty("name", (double?)null); Assert.AreEqual(string.Empty, stringWriter.ToString()); } } @@ -129,7 +129,7 @@ public void WritePropertyTimeSpanWritesTimeSpanValueWithQuotationMark() { const string Name = "name"; TimeSpan value = TimeSpan.FromSeconds(123); - new JsonWriter(stringWriter).WriteProperty(Name, value); + new JsonSerializationWriter(stringWriter).WriteProperty(Name, value); Assert.AreEqual("\"" + Name + "\":\"" + value + "\"", stringWriter.ToString()); } } @@ -139,7 +139,7 @@ public void WritePropertyTimeSpanDoesNothingIfValueIsNullBecauseItAssumesPropert { using (var stringWriter = new StringWriter(CultureInfo.InvariantCulture)) { - new JsonWriter(stringWriter).WriteProperty("name", (TimeSpan?)null); + new JsonSerializationWriter(stringWriter).WriteProperty("name", (TimeSpan?)null); Assert.AreEqual(string.Empty, stringWriter.ToString()); } } @@ -155,7 +155,7 @@ public void WritePropertyStringWritesValueInDoubleQuotes() { const string Name = "name"; const string Value = "value"; - new JsonWriter(stringWriter).WriteProperty(Name, Value); + new JsonSerializationWriter(stringWriter).WriteProperty(Name, Value); Assert.AreEqual("\"" + Name + "\":\"" + Value + "\"", stringWriter.ToString()); } } @@ -165,7 +165,7 @@ public void WritePropertyStringThrowsArgumentNullExceptionForNameInputAsNull() { using (var stringWriter = new StringWriter(CultureInfo.InvariantCulture)) { - var writer = new JsonWriter(stringWriter); + var writer = new JsonSerializationWriter(stringWriter); AssertEx.Throws(() => writer.WriteProperty(null, "value")); } } @@ -175,7 +175,7 @@ public void WritePropertyStringDoesNothingIfValueIsNullBecauseItAssumesPropertyI { using (var stringWriter = new StringWriter(CultureInfo.InvariantCulture)) { - new JsonWriter(stringWriter).WriteProperty("name", (string)null); + new JsonSerializationWriter(stringWriter).WriteProperty("name", (string)null); Assert.AreEqual(string.Empty, stringWriter.ToString()); } } @@ -185,7 +185,7 @@ public void WritePropertyStringDoesNothingIfValueIsEmptyBecauseItAssumesProperty { using (var stringWriter = new StringWriter(CultureInfo.InvariantCulture)) { - new JsonWriter(stringWriter).WriteProperty("name", string.Empty); + new JsonSerializationWriter(stringWriter).WriteProperty("name", string.Empty); Assert.AreEqual(string.Empty, stringWriter.ToString()); } } @@ -201,7 +201,7 @@ public void WritePropertyBooleanWritesValueWithoutQuotationMarks() { const string Name = "name"; const bool Value = true; - new JsonWriter(stringWriter).WriteProperty(Name, Value); + new JsonSerializationWriter(stringWriter).WriteProperty(Name, Value); string expectedValue = Value.ToString().ToLowerInvariant(); Assert.AreEqual("\"" + Name + "\":" + expectedValue, stringWriter.ToString()); } @@ -212,7 +212,7 @@ public void WritePropertyBooleanDoesNothingIfValueIsNullBecauseItAssumesProperty { using (var stringWriter = new StringWriter(CultureInfo.InvariantCulture)) { - new JsonWriter(stringWriter).WriteProperty("name", (bool?)null); + new JsonSerializationWriter(stringWriter).WriteProperty("name", (bool?)null); Assert.AreEqual(string.Empty, stringWriter.ToString()); } } @@ -224,7 +224,7 @@ public void WritePropertyBooleanWritesFalseBecauseItIsExplicitlySet() { const string Name = "name"; const bool Value = false; - new JsonWriter(stringWriter).WriteProperty(Name, Value); + new JsonSerializationWriter(stringWriter).WriteProperty(Name, Value); string expectedValue = Value.ToString().ToLowerInvariant(); Assert.AreEqual("\"" + Name + "\":" + expectedValue, stringWriter.ToString()); } @@ -241,7 +241,7 @@ public void WritePropertyDateTimeOffsetWritesValueInQuotationMarksAndRoundTripDa { const string Name = "name"; DateTimeOffset value = DateTimeOffset.UtcNow; - new JsonWriter(stringWriter).WriteProperty(Name, value); + new JsonSerializationWriter(stringWriter).WriteProperty(Name, value); string expectedValue = value.ToString("o", CultureInfo.InvariantCulture); Assert.AreEqual("\"" + Name + "\":\"" + expectedValue + "\"", stringWriter.ToString()); } @@ -252,7 +252,7 @@ public void WritePropertyDateTimeOffsetDoesNothingIfValueIsNullBecauseItAssumesP { using (var stringWriter = new StringWriter(CultureInfo.InvariantCulture)) { - new JsonWriter(stringWriter).WriteProperty("name", (DateTimeOffset?)null); + new JsonSerializationWriter(stringWriter).WriteProperty("name", (DateTimeOffset?)null); Assert.AreEqual(string.Empty, stringWriter.ToString()); } } @@ -266,7 +266,7 @@ public void WritePropertyIDictionaryDoubleWritesPropertyNameFollowedByValuesInCu { using (var stringWriter = new StringWriter(CultureInfo.InvariantCulture)) { - var writer = new JsonWriter(stringWriter); + var writer = new JsonSerializationWriter(stringWriter); writer.WriteProperty("name", new Dictionary { { "key1", 1 } }); AssertEx.StartsWith("\"name\":{", stringWriter.ToString(), StringComparison.OrdinalIgnoreCase); AssertEx.EndsWith("}", stringWriter.ToString(), StringComparison.OrdinalIgnoreCase); @@ -278,7 +278,7 @@ public void WritePropertyIDictionaryDoubleWritesValuesWithoutDoubleQuotes() { using (var stringWriter = new StringWriter(CultureInfo.InvariantCulture)) { - var writer = new JsonWriter(stringWriter); + var writer = new JsonSerializationWriter(stringWriter); writer.WriteProperty("name", new Dictionary { { "key1", 1 } }); AssertEx.Contains("\"key1\":1", stringWriter.ToString(), StringComparison.OrdinalIgnoreCase); } @@ -289,7 +289,7 @@ public void WritePropertyIDictionaryDoubleDoesNothingWhenDictionaryIsNullBecause { using (var stringWriter = new StringWriter(CultureInfo.InvariantCulture)) { - new JsonWriter(stringWriter).WriteProperty("name", (IDictionary)null); + new JsonSerializationWriter(stringWriter).WriteProperty("name", (IDictionary)null); Assert.AreEqual(string.Empty, stringWriter.ToString()); } } @@ -299,7 +299,7 @@ public void WritePropertyIDictionaryDoubleDoesNothingWhenDictionaryIsEmptyBecaus { using (var stringWriter = new StringWriter(CultureInfo.InvariantCulture)) { - new JsonWriter(stringWriter).WriteProperty("name", new Dictionary()); + new JsonSerializationWriter(stringWriter).WriteProperty("name", new Dictionary()); Assert.AreEqual(string.Empty, stringWriter.ToString()); } } @@ -313,7 +313,7 @@ public void WritePropertyIDictionaryStringStringWritesPropertyNameFollowedByValu { using (var stringWriter = new StringWriter(CultureInfo.InvariantCulture)) { - var writer = new JsonWriter(stringWriter); + var writer = new JsonSerializationWriter(stringWriter); writer.WriteProperty("name", new Dictionary { { "key1", "1" } }); AssertEx.StartsWith("\"name\":{", stringWriter.ToString(), StringComparison.OrdinalIgnoreCase); AssertEx.EndsWith("}", stringWriter.ToString(), StringComparison.OrdinalIgnoreCase); @@ -325,7 +325,7 @@ public void WritePropertyIDictionaryStringStringWritesValuesWithoutDoubleQuotes( { using (var stringWriter = new StringWriter(CultureInfo.InvariantCulture)) { - var writer = new JsonWriter(stringWriter); + var writer = new JsonSerializationWriter(stringWriter); writer.WriteProperty("name", new Dictionary { { "key1", "1" } }); AssertEx.Contains("\"key1\":\"1\"", stringWriter.ToString(), StringComparison.OrdinalIgnoreCase); } @@ -336,7 +336,7 @@ public void WritePropertyIDictionaryStringStringDoesNothingWhenDictionaryIsNullB { using (var stringWriter = new StringWriter(CultureInfo.InvariantCulture)) { - new JsonWriter(stringWriter).WriteProperty("name", (IDictionary)null); + new JsonSerializationWriter(stringWriter).WriteProperty("name", (IDictionary)null); Assert.AreEqual(string.Empty, stringWriter.ToString()); } } @@ -346,7 +346,7 @@ public void WritePropertyIDictionaryStringStringDoesNothingWhenDictionaryIsEmpty { using (var stringWriter = new StringWriter(CultureInfo.InvariantCulture)) { - new JsonWriter(stringWriter).WriteProperty("name", new Dictionary()); + new JsonSerializationWriter(stringWriter).WriteProperty("name", new Dictionary()); Assert.AreEqual(string.Empty, stringWriter.ToString()); } } @@ -360,7 +360,7 @@ public void WritePropertyNameWritesPropertyNameEnclosedInDoubleQuotationMarksFol { using (var stringWriter = new StringWriter(CultureInfo.InvariantCulture)) { - new TestableJsonWriter(stringWriter).WritePropertyName("TestProperty"); + new TestableJsonSerializationWriter(stringWriter).WritePropertyName("TestProperty"); Assert.AreEqual("\"TestProperty\":", stringWriter.ToString()); } } @@ -370,9 +370,9 @@ public void WritePropertyNamePrependsPropertyNameWithComaWhenCurrentObjectAlread { using (var stringWriter = new StringWriter(CultureInfo.InvariantCulture)) { - var jsonWriter = new TestableJsonWriter(stringWriter); - jsonWriter.WritePropertyName("Property1"); - jsonWriter.WritePropertyName("Property2"); + var JsonSerializationWriter = new TestableJsonSerializationWriter(stringWriter); + JsonSerializationWriter.WritePropertyName("Property1"); + JsonSerializationWriter.WritePropertyName("Property2"); AssertEx.Contains(",\"Property2\"", stringWriter.ToString(), StringComparison.OrdinalIgnoreCase); } } @@ -382,10 +382,10 @@ public void WritePropertyNameDoesNotPrependPropertyNameWithComaWhenNewObjectWasS { using (var stringWriter = new StringWriter(CultureInfo.InvariantCulture)) { - var jsonWriter = new TestableJsonWriter(stringWriter); - jsonWriter.WritePropertyName("Property1"); - jsonWriter.WriteStartObject(); - jsonWriter.WritePropertyName("Property2"); + var JsonSerializationWriter = new TestableJsonSerializationWriter(stringWriter); + JsonSerializationWriter.WritePropertyName("Property1"); + JsonSerializationWriter.WriteStartObject(); + JsonSerializationWriter.WritePropertyName("Property2"); AssertEx.Contains("{\"Property2\"", stringWriter.ToString(), StringComparison.OrdinalIgnoreCase); } } @@ -395,8 +395,8 @@ public void WritePropertyNameThrowsArgumentExceptionWhenPropertyNameIsEmptyToPre { using (var stringWriter = new StringWriter(CultureInfo.InvariantCulture)) { - var jsonWriter = new JsonWriter(stringWriter); - AssertEx.Throws(() => jsonWriter.WritePropertyName(string.Empty)); + var JsonSerializationWriter = new JsonSerializationWriter(stringWriter); + AssertEx.Throws(() => JsonSerializationWriter.WritePropertyName(string.Empty)); } } @@ -409,8 +409,8 @@ public void WriteStringEscapesQuotationMark() { using (var stringWriter = new StringWriter(CultureInfo.InvariantCulture)) { - var jsonWriter = new TestableJsonWriter(stringWriter); - jsonWriter.WriteString("Test\"Value"); + var JsonSerializationWriter = new TestableJsonSerializationWriter(stringWriter); + JsonSerializationWriter.WriteString("Test\"Value"); AssertEx.Contains("Test\\\"Value", stringWriter.ToString(), StringComparison.OrdinalIgnoreCase); } } @@ -420,8 +420,8 @@ public void WriteStringEscapesBackslash() { using (var stringWriter = new StringWriter(CultureInfo.InvariantCulture)) { - var jsonWriter = new TestableJsonWriter(stringWriter); - jsonWriter.WriteString("Test\\Value"); + var JsonSerializationWriter = new TestableJsonSerializationWriter(stringWriter); + JsonSerializationWriter.WriteString("Test\\Value"); AssertEx.Contains("Test\\\\Value", stringWriter.ToString(), StringComparison.OrdinalIgnoreCase); } } @@ -431,8 +431,8 @@ public void WriteStringEscapesBackspace() { using (var stringWriter = new StringWriter(CultureInfo.InvariantCulture)) { - var jsonWriter = new TestableJsonWriter(stringWriter); - jsonWriter.WriteString("Test\bValue"); + var JsonSerializationWriter = new TestableJsonSerializationWriter(stringWriter); + JsonSerializationWriter.WriteString("Test\bValue"); AssertEx.Contains("Test\\bValue", stringWriter.ToString(), StringComparison.OrdinalIgnoreCase); } } @@ -442,8 +442,8 @@ public void WriteStringEscapesFormFeed() { using (var stringWriter = new StringWriter(CultureInfo.InvariantCulture)) { - var jsonWriter = new TestableJsonWriter(stringWriter); - jsonWriter.WriteString("Test\fValue"); + var JsonSerializationWriter = new TestableJsonSerializationWriter(stringWriter); + JsonSerializationWriter.WriteString("Test\fValue"); AssertEx.Contains("Test\\fValue", stringWriter.ToString(), StringComparison.OrdinalIgnoreCase); } } @@ -453,8 +453,8 @@ public void WriteStringEscapesNewline() { using (var stringWriter = new StringWriter(CultureInfo.InvariantCulture)) { - var jsonWriter = new TestableJsonWriter(stringWriter); - jsonWriter.WriteProperty("name", "Test\nValue"); + var JsonSerializationWriter = new TestableJsonSerializationWriter(stringWriter); + JsonSerializationWriter.WriteProperty("name", "Test\nValue"); AssertEx.Contains("Test\\nValue", stringWriter.ToString(), StringComparison.OrdinalIgnoreCase); } } @@ -464,8 +464,8 @@ public void WriteStringEscapesCarriageReturn() { using (var stringWriter = new StringWriter(CultureInfo.InvariantCulture)) { - var jsonWriter = new TestableJsonWriter(stringWriter); - jsonWriter.WriteProperty("name", "Test\rValue"); + var JsonSerializationWriter = new TestableJsonSerializationWriter(stringWriter); + JsonSerializationWriter.WriteProperty("name", "Test\rValue"); AssertEx.Contains("Test\\rValue", stringWriter.ToString(), StringComparison.OrdinalIgnoreCase); } } @@ -475,17 +475,17 @@ public void WriteStringEscapesHorizontalTab() { using (var stringWriter = new StringWriter(CultureInfo.InvariantCulture)) { - var jsonWriter = new TestableJsonWriter(stringWriter); - jsonWriter.WriteProperty("name", "Test\tValue"); + var JsonSerializationWriter = new TestableJsonSerializationWriter(stringWriter); + JsonSerializationWriter.WriteProperty("name", "Test\tValue"); AssertEx.Contains("Test\\tValue", stringWriter.ToString(), StringComparison.OrdinalIgnoreCase); } } #endregion - private class TestableJsonWriter : JsonWriter + private class TestableJsonSerializationWriter : JsonSerializationWriter { - public TestableJsonWriter(TextWriter textWriter) + public TestableJsonSerializationWriter(TextWriter textWriter) : base(textWriter) { } diff --git a/src/Microsoft.ApplicationInsights/Extensibility/ISerializationWriter.cs b/src/Microsoft.ApplicationInsights/Extensibility/ISerializationWriter.cs index 46827579f3..4822c973d9 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/ISerializationWriter.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/ISerializationWriter.cs @@ -46,22 +46,22 @@ public interface ISerializationWriter /// /// Writes name and values for a IList field of strings /// - void WriteList(string name, IList items); + void WriteProperty(string name, IList items); /// /// Writes name and values for a IList field of objects implementing IExtension /// - void WriteList(string name, IList items); + void WriteProperty(string name, IList items); /// /// Writes name and value for a IDictionary field with string,string as key,value /// - void WriteDictionary(string name, IDictionary items); + void WriteProperty(string name, IDictionary items); /// /// Writes name and value for a IDictionary field with string,string as key,value /// - void WriteDictionary(string name, IDictionary items); + void WriteProperty(string name, IDictionary items); /// /// Marks beginning of a complex object. diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/AvailabilityDataIExtension.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/AvailabilityDataIExtension.cs index 86b56e39ce..432d93f02a 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/AvailabilityDataIExtension.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/AvailabilityDataIExtension.cs @@ -18,8 +18,8 @@ public void Serialize(ISerializationWriter serializationWriter) serializationWriter.WriteProperty("success", this.success); serializationWriter.WriteProperty("runLocation", this.runLocation); serializationWriter.WriteProperty("message", this.message); - serializationWriter.WriteDictionary("properties", this.properties); - serializationWriter.WriteDictionary("measurements", this.measurements); + serializationWriter.WriteProperty("properties", this.properties); + serializationWriter.WriteProperty("measurements", this.measurements); } IExtension IExtension.DeepClone() diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/EventDataIExtension.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/EventDataIExtension.cs index bb26e7117a..8dd371c53a 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/EventDataIExtension.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/EventDataIExtension.cs @@ -14,8 +14,8 @@ public void Serialize(ISerializationWriter serializationWriter) serializationWriter.WriteProperty("ver", this.ver); serializationWriter.WriteProperty("name", this.name); - serializationWriter.WriteDictionary("properties", this.properties); - serializationWriter.WriteDictionary("measurements", this.measurements); + serializationWriter.WriteProperty("properties", this.properties); + serializationWriter.WriteProperty("measurements", this.measurements); } IExtension IExtension.DeepClone() diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/ExceptionDataIExtension.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/ExceptionDataIExtension.cs index 5059263850..594a106aee 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/ExceptionDataIExtension.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/ExceptionDataIExtension.cs @@ -20,11 +20,11 @@ public void Serialize(ISerializationWriter serializationWriter) { serializationWriter.WriteProperty("ver", this.ver); serializationWriter.WriteProperty("problemId", this.problemId); - serializationWriter.WriteList("exceptions", this.exceptions.ToList()); + serializationWriter.WriteProperty("exceptions", this.exceptions.ToList()); serializationWriter.WriteProperty("severityLevel", this.severityLevel.TranslateSeverityLevel().HasValue ? this.severityLevel.TranslateSeverityLevel().Value.ToString() : null); - serializationWriter.WriteDictionary("properties", this.properties); - serializationWriter.WriteDictionary("measurements", this.measurements); + serializationWriter.WriteProperty("properties", this.properties); + serializationWriter.WriteProperty("measurements", this.measurements); } } } diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/ExceptionDetailsIExtension.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/ExceptionDetailsIExtension.cs index 76881c72ad..49933ee01f 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/ExceptionDetailsIExtension.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/ExceptionDetailsIExtension.cs @@ -21,7 +21,7 @@ public void Serialize(ISerializationWriter serializationWriter) serializationWriter.WriteProperty("message", this.message); serializationWriter.WriteProperty("hasFullStack", this.hasFullStack); serializationWriter.WriteProperty("stack", this.stack); - serializationWriter.WriteList("parsedStack", this.parsedStack.ToList()); + serializationWriter.WriteProperty("parsedStack", this.parsedStack.ToList()); } } } \ No newline at end of file diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/MessageDataIExtension.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/MessageDataIExtension.cs index a2418f7684..dc451a9ab2 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/MessageDataIExtension.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/MessageDataIExtension.cs @@ -15,8 +15,8 @@ public void Serialize(ISerializationWriter serializationWriter) serializationWriter.WriteProperty("ver", this.ver); serializationWriter.WriteProperty("message", this.message); serializationWriter.WriteProperty("severityLevel", this.severityLevel.HasValue ? this.severityLevel.Value.ToString() : null); - serializationWriter.WriteDictionary("properties", this.properties); - serializationWriter.WriteDictionary("measurements", this.measurements); + serializationWriter.WriteProperty("properties", this.properties); + serializationWriter.WriteProperty("measurements", this.measurements); } IExtension IExtension.DeepClone() diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/MetricDataIExtension.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/MetricDataIExtension.cs index 22a7570007..6da0ee9d26 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/MetricDataIExtension.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/MetricDataIExtension.cs @@ -13,8 +13,8 @@ internal partial class MetricData : IExtension public void Serialize(ISerializationWriter serializationWriter) { serializationWriter.WriteProperty("ver", this.ver); - serializationWriter.WriteList("metrics", this.metrics.ToList()); - serializationWriter.WriteDictionary("properties", this.properties); + serializationWriter.WriteProperty("metrics", this.metrics.ToList()); + serializationWriter.WriteProperty("properties", this.properties); } IExtension IExtension.DeepClone() diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/PageViewDataIExtension.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/PageViewDataIExtension.cs index 6f817ebe60..d86ef313d3 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/PageViewDataIExtension.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/PageViewDataIExtension.cs @@ -13,8 +13,8 @@ internal partial class PageViewData : IExtension serializationWriter.WriteProperty("name", this.name); serializationWriter.WriteProperty("url", this.url); serializationWriter.WriteProperty("duration", Utils.ValidateDuration(this.duration)); - serializationWriter.WriteDictionary("properties", this.properties); - serializationWriter.WriteDictionary("measurements", this.measurements); + serializationWriter.WriteProperty("properties", this.properties); + serializationWriter.WriteProperty("measurements", this.measurements); } IExtension IExtension.DeepClone() diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/PageViewPerfDataIExtension.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/PageViewPerfDataIExtension.cs index 2f8c752be6..7a65a25471 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/PageViewPerfDataIExtension.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/PageViewPerfDataIExtension.cs @@ -16,8 +16,8 @@ internal partial class PageViewPerfData : IExtension serializationWriter.WriteProperty("networkConnect", Utils.ValidateDuration(this.networkConnect)); serializationWriter.WriteProperty("sentRequest", Utils.ValidateDuration(this.sentRequest)); serializationWriter.WriteProperty("receivedResponse", Utils.ValidateDuration(this.receivedResponse)); - serializationWriter.WriteDictionary("properties", this.properties); - serializationWriter.WriteDictionary("measurements", this.measurements); + serializationWriter.WriteProperty("properties", this.properties); + serializationWriter.WriteProperty("measurements", this.measurements); } IExtension IExtension.DeepClone() diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/RemoteDependencyDataIExtension.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/RemoteDependencyDataIExtension.cs index 3fa8d67f3f..c5a056d8ec 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/RemoteDependencyDataIExtension.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/RemoteDependencyDataIExtension.cs @@ -20,8 +20,8 @@ public void Serialize(ISerializationWriter serializationWriter) serializationWriter.WriteProperty("success", this.success); serializationWriter.WriteProperty("type", this.type); serializationWriter.WriteProperty("target", this.target); - serializationWriter.WriteDictionary("properties", this.properties); - serializationWriter.WriteDictionary("measurements", this.measurements); + serializationWriter.WriteProperty("properties", this.properties); + serializationWriter.WriteProperty("measurements", this.measurements); } IExtension IExtension.DeepClone() diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/RequestDataIExtension.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/RequestDataIExtension.cs index 0ba1b0ac76..b3255482ea 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/RequestDataIExtension.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/RequestDataIExtension.cs @@ -19,8 +19,8 @@ public void Serialize(ISerializationWriter serializationWriter) serializationWriter.WriteProperty("success", this.success); serializationWriter.WriteProperty("responseCode", this.responseCode); serializationWriter.WriteProperty("url", this.url); - serializationWriter.WriteDictionary("properties", this.properties); - serializationWriter.WriteDictionary("measurements", this.measurements); + serializationWriter.WriteProperty("properties", this.properties); + serializationWriter.WriteProperty("measurements", this.measurements); } IExtension IExtension.DeepClone() diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializationWriter.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializationWriter.cs index 097c7ca784..c5e8419792 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializationWriter.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializationWriter.cs @@ -90,7 +90,7 @@ public void WriteProperty(string name, DateTimeOffset? value) } /// - public void WriteList(string name, IList items) + public void WriteProperty(string name, IList items) { bool commaNeeded = false; if (items != null && items.Count > 0) @@ -115,7 +115,7 @@ public void WriteList(string name, IList items) } /// - public void WriteList(string name, IList items) + public void WriteProperty(string name, IList items) { bool commaNeeded = false; if (items != null && items.Count > 0) @@ -148,7 +148,7 @@ public void WriteProperty(string name, IExtension value) } /// - public void WriteDictionary(string name, IDictionary values) + public void WriteProperty(string name, IDictionary values) { if (values != null && values.Count > 0) { @@ -164,7 +164,7 @@ public void WriteDictionary(string name, IDictionary values) } /// - public void WriteDictionary(string name, IDictionary values) + public void WriteProperty(string name, IDictionary values) { if (values != null && values.Count > 0) { @@ -185,7 +185,7 @@ public void WriteEndObject() this.textWriter.Write('}'); } - private void WritePropertyName(string name) + internal void WritePropertyName(string name) { if (name == null) { @@ -210,27 +210,27 @@ private void WritePropertyName(string name) this.textWriter.Write(':'); } - private void WriteStartArray() + internal void WriteStartArray() { this.textWriter.Write('['); } - private void WriteEndArray() + internal void WriteEndArray() { this.textWriter.Write(']'); } - private void WriteComma() + internal void WriteComma() { this.textWriter.Write(','); } - private void WriteRawValue(object value) + internal void WriteRawValue(object value) { this.textWriter.Write(string.Format(CultureInfo.InvariantCulture, "{0}", value)); - } + } - private void WriteString(string value) + internal void WriteString(string value) { this.textWriter.Write('"'); diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonWriter.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonWriter.cs deleted file mode 100644 index ef9f353dd0..0000000000 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonWriter.cs +++ /dev/null @@ -1,314 +0,0 @@ -namespace Microsoft.ApplicationInsights.Extensibility.Implementation -{ - using System; - using System.Collections.Generic; - using System.Globalization; - using System.IO; - using Microsoft.ApplicationInsights.DataContracts; - - internal class JsonWriter : IJsonWriter - { - private readonly EmptyObjectDetector emptyObjectDetector; - private readonly TextWriter textWriter; - private bool currentObjectHasProperties; - - internal JsonWriter(TextWriter textWriter) - { - this.emptyObjectDetector = new EmptyObjectDetector(); - this.textWriter = textWriter; - } - - public void WriteStartArray() - { - this.textWriter.Write('['); - } - - public void WriteStartObject() - { - this.textWriter.Write('{'); - this.currentObjectHasProperties = false; - } - - public void WriteEndArray() - { - this.textWriter.Write(']'); - } - - public void WriteEndObject() - { - this.textWriter.Write('}'); - } - - public void WriteComma() - { - this.textWriter.Write(','); - } - - public void WriteRawValue(object value) - { - this.textWriter.Write(string.Format(CultureInfo.InvariantCulture, "{0}", value)); - } - - public void WriteProperty(string name, string value) - { - if (!string.IsNullOrEmpty(value)) - { - this.WritePropertyName(name); - this.WriteString(value); - } - } - - public void WriteProperty(string name, bool? value) - { - if (value.HasValue) - { - this.WritePropertyName(name); - this.textWriter.Write(value.Value ? "true" : "false"); - } - } - - public void WriteProperty(string name, int? value) - { - if (value.HasValue) - { - this.WritePropertyName(name); - this.textWriter.Write(value.Value.ToString(CultureInfo.InvariantCulture)); - } - } - - public void WriteProperty(string name, double? value) - { - if (value.HasValue) - { - this.WritePropertyName(name); - this.textWriter.Write(value.Value.ToString(CultureInfo.InvariantCulture)); - } - } - - public void WriteProperty(string name, TimeSpan? value) - { - if (value.HasValue) - { - this.WriteProperty(name, value.Value.ToString(string.Empty, CultureInfo.InvariantCulture)); - } - } - - public void WriteProperty(string name, DateTimeOffset? value) - { - if (value.HasValue) - { - this.WriteProperty(name, value.Value.ToString("o", CultureInfo.InvariantCulture)); - } - } - - public void WriteProperty(string name, IDictionary values) - { - if (values != null && values.Count > 0) - { - this.WritePropertyName(name); - this.WriteStartObject(); - foreach (KeyValuePair item in values) - { - this.WriteProperty(item.Key, item.Value); - } - - this.WriteEndObject(); - } - } - - public void WriteProperty(string name, IDictionary values) - { - if (values != null && values.Count > 0) - { - this.WritePropertyName(name); - this.WriteStartObject(); - foreach (KeyValuePair item in values) - { - this.WriteProperty(item.Key, item.Value); - } - - this.WriteEndObject(); - } - } - - /// - /// Writes the specified property name enclosed in double quotation marks followed by a colon. - /// - /// - /// When this method is called multiple times, the second call after - /// and all subsequent calls will write a coma before the name. - /// - public void WritePropertyName(string name) - { - if (name == null) - { - throw new ArgumentNullException("name"); - } - - if (name.Length == 0) - { - throw new ArgumentException("name"); - } - - if (this.currentObjectHasProperties) - { - this.textWriter.Write(','); - } - else - { - this.currentObjectHasProperties = true; - } - - this.WriteString(name); - this.textWriter.Write(':'); - } - - protected void WriteString(string value) - { - this.textWriter.Write('"'); - - foreach (char c in value) - { - switch (c) - { - case '\\': - this.textWriter.Write("\\\\"); - break; - case '"': - this.textWriter.Write("\\\""); - break; - case '\n': - this.textWriter.Write("\\n"); - break; - case '\b': - this.textWriter.Write("\\b"); - break; - case '\f': - this.textWriter.Write("\\f"); - break; - case '\r': - this.textWriter.Write("\\r"); - break; - case '\t': - this.textWriter.Write("\\t"); - break; - default: - if (!char.IsControl(c)) - { - this.textWriter.Write(c); - } - else - { - this.textWriter.Write(@"\u"); - this.textWriter.Write(((ushort)c).ToString("x4", CultureInfo.InvariantCulture)); - } - - break; - } - } - - this.textWriter.Write('"'); - } - - private sealed class EmptyObjectDetector : IJsonWriter - { - public bool IsEmpty { get; set; } - - public void WriteStartArray() - { - } - - public void WriteStartObject() - { - } - - public void WriteEndArray() - { - } - - public void WriteEndObject() - { - } - - public void WriteComma() - { - } - - public void WriteProperty(string name, string value) - { - if (!string.IsNullOrEmpty(value)) - { - this.IsEmpty = false; - } - } - - public void WriteProperty(string name, bool? value) - { - if (value.HasValue) - { - this.IsEmpty = false; - } - } - - public void WriteProperty(string name, int? value) - { - if (value.HasValue) - { - this.IsEmpty = false; - } - } - - public void WriteProperty(string name, double? value) - { - if (value.HasValue) - { - this.IsEmpty = false; - } - } - - public void WriteProperty(string name, TimeSpan? value) - { - if (value.HasValue) - { - this.IsEmpty = false; - } - } - - public void WriteProperty(string name, DateTimeOffset? value) - { - if (value.HasValue) - { - this.IsEmpty = false; - } - } - - public void WriteProperty(string name, IDictionary value) - { - if (value != null && value.Count > 0) - { - this.IsEmpty = false; - } - } - - public void WriteProperty(string name, IDictionary value) - { - if (value != null && value.Count > 0) - { - this.IsEmpty = false; - } - } - - public void WritePropertyName(string name) - { - } - - public void WriteRawValue(object value) - { - if (value != null) - { - this.IsEmpty = false; - } - } - } - } -} diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Telemetry.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Telemetry.cs index 056d2098fc..0fb91713be 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Telemetry.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Telemetry.cs @@ -58,7 +58,7 @@ public static void WriteTelemetryContext(ISerializationWriter json, TelemetryCon json.WriteProperty("flags", context.Flags); } - json.WriteDictionary("tags", context.SanitizedTags); + json.WriteProperty("tags", context.SanitizedTags); } } From 5b7fb365750f8eb6c023d2e920507b29aac235bc Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Wed, 8 Aug 2018 15:27:00 -0700 Subject: [PATCH 58/74] Modified interfaces to be more correct. IExtension for extensions. ISerializableWithWriter for classes emitting serialization info. --- .../JsonSerializationWriterTests.cs | 71 ++----------------- .../DataContracts/AvailabilityTelemetry.cs | 10 +-- .../DataContracts/DependencyTelemetry.cs | 10 +-- .../DataContracts/EventTelemetry.cs | 10 +-- .../DataContracts/ExceptionTelemetry.cs | 10 +-- .../DataContracts/MetricTelemetry.cs | 10 +-- .../PageViewPerformanceTelemetry.cs | 10 +-- .../DataContracts/PageViewTelemetry.cs | 10 +-- .../PerformanceCounterTelemetry.cs | 10 +-- .../DataContracts/RequestTelemetry.cs | 10 +-- .../DataContracts/SessionStateTelemetry.cs | 10 +-- .../DataContracts/TraceTelemetry.cs | 10 +-- .../Extensibility/ICloneable.cs | 13 ++++ .../Extensibility/IExtension.cs | 11 +-- .../Extensibility/ISerializableWithWriter.cs | 13 ++++ .../Extensibility/ISerializationWriter.cs | 8 +-- ...vailabilityDataISerializableWithWriter.cs} | 9 +-- .../External/DataPointIExtension.cs | 9 +-- ...cs => EventDataISerializableWithWriter.cs} | 9 +-- ...> ExceptionDataISerializableWithWriter.cs} | 11 +-- ...xceptionDetailsISerializableWithWriter.cs} | 11 +-- .../External/MessageDataIExtension.cs | 9 +-- ...s => MetricDataISerializableWithWriter.cs} | 11 +-- .../External/PageViewDataIExtension.cs | 9 +-- .../External/PageViewPerfDataIExtension.cs | 9 +-- ...eDependencyDataISerializableWithWriter.cs} | 9 +-- ... => RequestDataISerializableWithWriter.cs} | 9 +-- ...s => StackFrameISerializableWithWriter.cs} | 9 +-- .../Implementation/JsonSerializationWriter.cs | 4 +- .../Implementation/JsonSerializer.cs | 4 +- 30 files changed, 79 insertions(+), 269 deletions(-) create mode 100644 src/Microsoft.ApplicationInsights/Extensibility/ICloneable.cs create mode 100644 src/Microsoft.ApplicationInsights/Extensibility/ISerializableWithWriter.cs rename src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/{AvailabilityDataIExtension.cs => AvailabilityDataISerializableWithWriter.cs} (83%) rename src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/{EventDataIExtension.cs => EventDataISerializableWithWriter.cs} (76%) rename src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/{ExceptionDataIExtension.cs => ExceptionDataISerializableWithWriter.cs} (79%) rename src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/{ExceptionDetailsIExtension.cs => ExceptionDetailsISerializableWithWriter.cs} (76%) rename src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/{MetricDataIExtension.cs => MetricDataISerializableWithWriter.cs} (72%) rename src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/{RemoteDependencyDataIExtension.cs => RemoteDependencyDataISerializableWithWriter.cs} (84%) rename src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/{RequestDataIExtension.cs => RequestDataISerializableWithWriter.cs} (84%) rename src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/{StackFrameIExtension.cs => StackFrameISerializableWithWriter.cs} (71%) diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/Extensibility/Implementation/JsonSerializationWriterTests.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/Extensibility/Implementation/JsonSerializationWriterTests.cs index 1436bb41a0..d3d0bebf8f 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/Extensibility/Implementation/JsonSerializationWriterTests.cs +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/Extensibility/Implementation/JsonSerializationWriterTests.cs @@ -107,7 +107,7 @@ public void SerializeComplexObject() } } - public class ComplexExtension : IExtension + public class ComplexExtension : ISerializableWithWriter { public string MyStringField; public int MyIntField; @@ -119,49 +119,7 @@ public class ComplexExtension : IExtension public IList MyStringListField; public IList MyExtensionListField; public IDictionary MyStringDictionaryField; - public IDictionary MyDoubleDictionaryField; - - public IExtension DeepClone() - { - ComplexExtension other = new ComplexExtension(); - other.MyStringField = this.MyStringField; - other.MyIntField = this.MyIntField; - other.MyDoubleField = this.MyDoubleField; - other.MyBoolField = this.MyBoolField; - other.MyTimeSpanField = this.MyTimeSpanField; - other.MyDateTimeOffsetField = this.MyDateTimeOffsetField; - other.MySubExtensionField = (MySubExtension) this.MySubExtensionField.DeepClone(); - - IList otherString = new List(); - foreach(var item in this.MyStringListField) - { - otherString.Add(item); - } - other.MyStringListField = otherString; - - IList others = new List(); - foreach(var item in this.MyExtensionListField) - { - others.Add((MySubExtension) item.DeepClone()); - } - other.MyExtensionListField = others; - - IDictionary otherStringDic = new Dictionary(); - foreach (var item in this.MyStringDictionaryField) - { - otherStringDic.Add(item.Key, item.Value); - } - other.MyStringDictionaryField = otherStringDic; - - IDictionary otherDoubleDic = new Dictionary(); - foreach (var item in this.MyDoubleDictionaryField) - { - otherDoubleDic.Add(item.Key, item.Value); - } - other.MyDoubleDictionaryField = otherDoubleDic; - - return other; - } + public IDictionary MyDoubleDictionaryField; public void Serialize(ISerializationWriter serializationWriter) { @@ -173,26 +131,17 @@ public void Serialize(ISerializationWriter serializationWriter) serializationWriter.WriteProperty("MyDateTimeOffsetField", MyDateTimeOffsetField); serializationWriter.WriteProperty("MySubExtensionField", MySubExtensionField); serializationWriter.WriteProperty("MyStringListField", MyStringListField); - serializationWriter.WriteProperty("MyExtensionListField", MyExtensionListField.ToList()); + serializationWriter.WriteProperty("MyExtensionListField", MyExtensionListField.ToList()); serializationWriter.WriteProperty("MyStringDictionaryField", MyStringDictionaryField); serializationWriter.WriteProperty("MyDoubleDictionaryField", MyDoubleDictionaryField); } } - public class MySubExtension : IExtension + public class MySubExtension : ISerializableWithWriter { public string Field1; public int Field2; - public IExtension MySubSubExtension; - - public IExtension DeepClone() - { - MySubExtension other = new MySubExtension(); - other.Field1 = this.Field1; - other.Field2 = this.Field2; - other.MySubSubExtension = this.MySubSubExtension.DeepClone(); - return other; - } + public ISerializableWithWriter MySubSubExtension; public void Serialize(ISerializationWriter serializationWriter) { @@ -202,19 +151,11 @@ public void Serialize(ISerializationWriter serializationWriter) } } - public class MySubSubExtension : IExtension + public class MySubSubExtension : ISerializableWithWriter { public string Field3; public double Field4; - public IExtension DeepClone() - { - MySubSubExtension other = new MySubSubExtension(); - other.Field3 = this.Field3; - other.Field4 = this.Field4; - return other; - } - public void Serialize(ISerializationWriter serializationWriter) { serializationWriter.WriteProperty("Field3", Field3); diff --git a/src/Microsoft.ApplicationInsights/DataContracts/AvailabilityTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/AvailabilityTelemetry.cs index f866c379f6..ba77ebcc4f 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/AvailabilityTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/AvailabilityTelemetry.cs @@ -13,7 +13,7 @@ /// Contains a time and message and optionally some additional metadata. /// Learn more /// - public sealed class AvailabilityTelemetry : ITelemetry, ISupportProperties, ISupportMetrics, IExtension + public sealed class AvailabilityTelemetry : ITelemetry, ISupportProperties, ISupportMetrics, ISerializableWithWriter { internal const string TelemetryName = "Availability"; @@ -178,14 +178,6 @@ public ITelemetry DeepClone() return new AvailabilityTelemetry(this); } - /// - /// Deeply clones the Extension of object. - /// - IExtension IExtension.DeepClone() - { - return new AvailabilityTelemetry(this); - } - /// public void Serialize(ISerializationWriter serializationWriter) { diff --git a/src/Microsoft.ApplicationInsights/DataContracts/DependencyTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/DependencyTelemetry.cs index ccc543a996..7b4dae9c44 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/DependencyTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/DependencyTelemetry.cs @@ -16,7 +16,7 @@ namespace Microsoft.ApplicationInsights.DataContracts /// The class that represents information about the collected dependency. /// Learn more. /// - public sealed class DependencyTelemetry : OperationTelemetry, ITelemetry, ISupportProperties, ISupportSampling, ISupportMetrics, IExtension + public sealed class DependencyTelemetry : OperationTelemetry, ITelemetry, ISupportProperties, ISupportSampling, ISupportMetrics, ISerializableWithWriter { internal new const string TelemetryName = "RemoteDependency"; @@ -368,14 +368,6 @@ void ITelemetry.Sanitize() this.Properties.SanitizeProperties(); } - /// - /// Deeply clones the Extension of object. - /// - IExtension IExtension.DeepClone() - { - return new DependencyTelemetry(this); - } - /// /// Clears any stored operational data for the dependency operation, if any. /// diff --git a/src/Microsoft.ApplicationInsights/DataContracts/EventTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/EventTelemetry.cs index 63793772e0..c1ee406de1 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/EventTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/EventTelemetry.cs @@ -13,7 +13,7 @@ /// Telemetry type used to track custom events. /// Learn more /// - public sealed class EventTelemetry : ITelemetry, ISupportProperties, ISupportSampling, ISupportMetrics, IExtension + public sealed class EventTelemetry : ITelemetry, ISupportProperties, ISupportSampling, ISupportMetrics, ISerializableWithWriter { internal const string TelemetryName = "Event"; @@ -135,14 +135,6 @@ void ITelemetry.Sanitize() this.Metrics.SanitizeMeasurements(); } - /// - /// Deeply clones the Extension of object. - /// - IExtension IExtension.DeepClone() - { - return new EventTelemetry(this); - } - /// public void Serialize(ISerializationWriter serializationWriter) { diff --git a/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs index a1fbe9336e..b60fefdb81 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs @@ -13,7 +13,7 @@ /// Telemetry type used to track exceptions. /// Learn more /// - public sealed class ExceptionTelemetry : ITelemetry, ISupportProperties, ISupportSampling, ISupportMetrics, IExtension + public sealed class ExceptionTelemetry : ITelemetry, ISupportProperties, ISupportSampling, ISupportMetrics, ISerializableWithWriter { internal const string TelemetryName = "Exception"; internal readonly string BaseType = typeof(ExceptionData).Name; @@ -277,14 +277,6 @@ public ITelemetry DeepClone() return new ExceptionTelemetry(this); } - /// - /// Deeply clones the Extension of object. - /// - IExtension IExtension.DeepClone() - { - return new ExceptionTelemetry(this); - } - /// public void Serialize(ISerializationWriter serializationWriter) { diff --git a/src/Microsoft.ApplicationInsights/DataContracts/MetricTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/MetricTelemetry.cs index 79eba9c06a..b1782a65f4 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/MetricTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/MetricTelemetry.cs @@ -13,7 +13,7 @@ /// Telemetry type used to track metrics. Represents a sample set of values with a specified count, sum, max, min, and standard deviation. /// Learn more /// - public sealed class MetricTelemetry : ITelemetry, ISupportProperties, IExtension + public sealed class MetricTelemetry : ITelemetry, ISupportProperties, ISerializableWithWriter { internal const string TelemetryName = "Metric"; @@ -251,14 +251,6 @@ public ITelemetry DeepClone() return new MetricTelemetry(this); } - /// - /// Deeply clones the Extension of object. - /// - IExtension IExtension.DeepClone() - { - return new MetricTelemetry(this); - } - /// public void Serialize(ISerializationWriter serializationWriter) { diff --git a/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs index 24d6474137..ef1ce9c5a6 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs @@ -11,7 +11,7 @@ /// /// Telemetry type used to track page load performance. /// - public sealed class PageViewPerformanceTelemetry : ITelemetry, ISupportProperties, ISupportSampling, IExtension + public sealed class PageViewPerformanceTelemetry : ITelemetry, ISupportProperties, ISupportSampling, ISerializableWithWriter { internal const string TelemetryName = "PageViewPerformance"; @@ -225,14 +225,6 @@ void ITelemetry.Sanitize() this.Id.SanitizeName(); } - /// - /// Deeply clones the Extension of object. - /// - IExtension IExtension.DeepClone() - { - return new PageViewPerformanceTelemetry(this); - } - /// public void Serialize(ISerializationWriter serializationWriter) { diff --git a/src/Microsoft.ApplicationInsights/DataContracts/PageViewTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/PageViewTelemetry.cs index 16dbaae4e5..abe23ea466 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/PageViewTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/PageViewTelemetry.cs @@ -18,7 +18,7 @@ /// method. /// Learn more /// - public sealed class PageViewTelemetry : ITelemetry, ISupportProperties, ISupportSampling, IExtension + public sealed class PageViewTelemetry : ITelemetry, ISupportProperties, ISupportSampling, ISerializableWithWriter { internal const string TelemetryName = "PageView"; @@ -178,14 +178,6 @@ public ITelemetry DeepClone() return new PageViewTelemetry(this); } - /// - /// Deeply clones the Extension of object. - /// - IExtension IExtension.DeepClone() - { - return new PageViewTelemetry(this); - } - /// public void Serialize(ISerializationWriter serializationWriter) { diff --git a/src/Microsoft.ApplicationInsights/DataContracts/PerformanceCounterTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/PerformanceCounterTelemetry.cs index d94cdb77b2..5fc1470b36 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/PerformanceCounterTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/PerformanceCounterTelemetry.cs @@ -10,7 +10,7 @@ /// The class that represents information about performance counters. /// [Obsolete("Use MetricTelemetry instead.")] - public sealed class PerformanceCounterTelemetry : ITelemetry, ISupportProperties, IExtension + public sealed class PerformanceCounterTelemetry : ITelemetry, ISupportProperties, ISerializableWithWriter { internal readonly MetricTelemetry Data; private string categoryName = string.Empty; @@ -192,14 +192,6 @@ public ITelemetry DeepClone() return new PerformanceCounterTelemetry(this); } - /// - /// Deeply clones the Extension of object. - /// - IExtension IExtension.DeepClone() - { - return new PerformanceCounterTelemetry(this); - } - /// public void Serialize(ISerializationWriter serializationWriter) { diff --git a/src/Microsoft.ApplicationInsights/DataContracts/RequestTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/RequestTelemetry.cs index fa962e4a78..30c8204709 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/RequestTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/RequestTelemetry.cs @@ -17,7 +17,7 @@ /// method. /// Learn more /// - public sealed class RequestTelemetry : OperationTelemetry, ITelemetry, ISupportProperties, ISupportMetrics, ISupportSampling, IExtension + public sealed class RequestTelemetry : OperationTelemetry, ITelemetry, ISupportProperties, ISupportMetrics, ISupportSampling, ISerializableWithWriter { internal new const string TelemetryName = "Request"; @@ -268,13 +268,5 @@ void ITelemetry.Sanitize() this.Success = true; } } - - /// - /// Deeply clones the Extension of object. - /// - IExtension IExtension.DeepClone() - { - return new RequestTelemetry(this); - } } } \ No newline at end of file diff --git a/src/Microsoft.ApplicationInsights/DataContracts/SessionStateTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/SessionStateTelemetry.cs index 58d40ef454..841b206678 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/SessionStateTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/SessionStateTelemetry.cs @@ -8,7 +8,7 @@ /// Telemetry type used to track user sessions. /// [Obsolete("Session state events are no longer used. This telemetry item will be sent as EventTelemetry.")] - public sealed class SessionStateTelemetry : ITelemetry, IExtension + public sealed class SessionStateTelemetry : ITelemetry, ISerializableWithWriter { internal readonly EventTelemetry Data; @@ -132,14 +132,6 @@ public ITelemetry DeepClone() return new SessionStateTelemetry(this); } - /// - /// Deeply clones the Extension of object. - /// - IExtension IExtension.DeepClone() - { - return new SessionStateTelemetry(this); - } - /// /// Sanitizes this telemetry instance to ensure it can be accepted by the Application Insights. /// diff --git a/src/Microsoft.ApplicationInsights/DataContracts/TraceTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/TraceTelemetry.cs index fee5ddeafb..8c0fc0a057 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/TraceTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/TraceTelemetry.cs @@ -13,7 +13,7 @@ /// Contains a time and message and optionally some additional metadata. /// Learn more /// - public sealed class TraceTelemetry : ITelemetry, ISupportProperties, ISupportSampling, IExtension + public sealed class TraceTelemetry : ITelemetry, ISupportProperties, ISupportSampling, ISerializableWithWriter { internal const string TelemetryName = "Message"; @@ -136,14 +136,6 @@ public ITelemetry DeepClone() return new TraceTelemetry(this); } - /// - /// Deeply clones the Extension of object. - /// - IExtension IExtension.DeepClone() - { - return new TraceTelemetry(this); - } - /// public void Serialize(ISerializationWriter serializationWriter) { diff --git a/src/Microsoft.ApplicationInsights/Extensibility/ICloneable.cs b/src/Microsoft.ApplicationInsights/Extensibility/ICloneable.cs new file mode 100644 index 0000000000..a33a584bc6 --- /dev/null +++ b/src/Microsoft.ApplicationInsights/Extensibility/ICloneable.cs @@ -0,0 +1,13 @@ +namespace Microsoft.ApplicationInsights.Extensibility +{ + /// + /// Interface for defining method to Deeply clone the members. + /// + public interface ICloneable + { + /// + /// Deep clones the members of the class. + /// + IExtension DeepClone(); + } +} diff --git a/src/Microsoft.ApplicationInsights/Extensibility/IExtension.cs b/src/Microsoft.ApplicationInsights/Extensibility/IExtension.cs index 5b922b9725..aeda336048 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/IExtension.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/IExtension.cs @@ -3,16 +3,7 @@ /// /// Interface for defining strongly typed extensions to telemetry types. /// - public interface IExtension + public interface IExtension : ISerializableWithWriter, ICloneable { - /// - /// Writes serialization info about the class using the given - /// - void Serialize(ISerializationWriter serializationWriter); - - /// - /// Deep clones the members of the class. - /// - IExtension DeepClone(); } } diff --git a/src/Microsoft.ApplicationInsights/Extensibility/ISerializableWithWriter.cs b/src/Microsoft.ApplicationInsights/Extensibility/ISerializableWithWriter.cs new file mode 100644 index 0000000000..9e99ecee25 --- /dev/null +++ b/src/Microsoft.ApplicationInsights/Extensibility/ISerializableWithWriter.cs @@ -0,0 +1,13 @@ +namespace Microsoft.ApplicationInsights.Extensibility +{ + /// + /// Interface for defining objects which can be serialized with a given + public interface ISerializableWithWriter + { + /// + /// Writes serialization info about the class using the given + /// + void Serialize(ISerializationWriter serializationWriter); + } +} diff --git a/src/Microsoft.ApplicationInsights/Extensibility/ISerializationWriter.cs b/src/Microsoft.ApplicationInsights/Extensibility/ISerializationWriter.cs index 4822c973d9..58294aabac 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/ISerializationWriter.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/ISerializationWriter.cs @@ -39,9 +39,9 @@ public interface ISerializationWriter void WriteProperty(string name, DateTimeOffset? value); /// - /// Writes name and value for a IExtension field + /// Writes name and value for a ISerializableWithWriter field /// - void WriteProperty(string name, IExtension value); + void WriteProperty(string name, ISerializableWithWriter value); /// /// Writes name and values for a IList field of strings @@ -49,9 +49,9 @@ public interface ISerializationWriter void WriteProperty(string name, IList items); /// - /// Writes name and values for a IList field of objects implementing IExtension + /// Writes name and values for a IList field of objects implementing ISerializableWithWriter /// - void WriteProperty(string name, IList items); + void WriteProperty(string name, IList items); /// /// Writes name and value for a IDictionary field with string,string as key,value diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/AvailabilityDataIExtension.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/AvailabilityDataISerializableWithWriter.cs similarity index 83% rename from src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/AvailabilityDataIExtension.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/AvailabilityDataISerializableWithWriter.cs index 432d93f02a..5bde401a42 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/AvailabilityDataIExtension.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/AvailabilityDataISerializableWithWriter.cs @@ -5,9 +5,9 @@ using Microsoft.ApplicationInsights.DataContracts; /// - /// Partial class to implement IExtension + /// Partial class to implement ISerializableWithWriter /// - internal partial class AvailabilityData : IExtension + internal partial class AvailabilityData : ISerializableWithWriter { public void Serialize(ISerializationWriter serializationWriter) { @@ -21,10 +21,5 @@ public void Serialize(ISerializationWriter serializationWriter) serializationWriter.WriteProperty("properties", this.properties); serializationWriter.WriteProperty("measurements", this.measurements); } - - IExtension IExtension.DeepClone() - { - return this.DeepClone(); - } } } diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/DataPointIExtension.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/DataPointIExtension.cs index cabd3c5bbb..bd654095a7 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/DataPointIExtension.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/DataPointIExtension.cs @@ -3,9 +3,9 @@ using Microsoft.ApplicationInsights.DataContracts; /// - /// Partial class to implement IExtension + /// Partial class to implement ISerializableWithWriter /// - internal partial class DataPoint : IExtension + internal partial class DataPoint : ISerializableWithWriter { public void Serialize(ISerializationWriter serializationWriter) { @@ -18,10 +18,5 @@ public void Serialize(ISerializationWriter serializationWriter) serializationWriter.WriteProperty("max", this.max); serializationWriter.WriteProperty("stdDev", this.stdDev); } - - IExtension IExtension.DeepClone() - { - return this.DeepClone(); - } } } diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/EventDataIExtension.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/EventDataISerializableWithWriter.cs similarity index 76% rename from src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/EventDataIExtension.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/EventDataISerializableWithWriter.cs index 8dd371c53a..1820667ae9 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/EventDataIExtension.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/EventDataISerializableWithWriter.cs @@ -5,9 +5,9 @@ using Microsoft.ApplicationInsights.DataContracts; /// - /// Partial class to implement IExtension + /// Partial class to implement ISerializableWithWriter /// - internal partial class EventData : IExtension + internal partial class EventData : ISerializableWithWriter { public void Serialize(ISerializationWriter serializationWriter) { @@ -17,10 +17,5 @@ public void Serialize(ISerializationWriter serializationWriter) serializationWriter.WriteProperty("properties", this.properties); serializationWriter.WriteProperty("measurements", this.measurements); } - - IExtension IExtension.DeepClone() - { - return this.DeepClone(); - } } } diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/ExceptionDataIExtension.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/ExceptionDataISerializableWithWriter.cs similarity index 79% rename from src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/ExceptionDataIExtension.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/ExceptionDataISerializableWithWriter.cs index 594a106aee..c385f58564 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/ExceptionDataIExtension.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/ExceptionDataISerializableWithWriter.cs @@ -7,20 +7,15 @@ using Microsoft.ApplicationInsights.DataContracts; /// - /// Additional implementation for ExceptionDetails. + /// Partial class to implement ISerializableWithWriter /// - internal partial class ExceptionData : IExtension + internal partial class ExceptionData : ISerializableWithWriter { - IExtension IExtension.DeepClone() - { - return this.DeepClone(); - } - public void Serialize(ISerializationWriter serializationWriter) { serializationWriter.WriteProperty("ver", this.ver); serializationWriter.WriteProperty("problemId", this.problemId); - serializationWriter.WriteProperty("exceptions", this.exceptions.ToList()); + serializationWriter.WriteProperty("exceptions", this.exceptions.ToList()); serializationWriter.WriteProperty("severityLevel", this.severityLevel.TranslateSeverityLevel().HasValue ? this.severityLevel.TranslateSeverityLevel().Value.ToString() : null); serializationWriter.WriteProperty("properties", this.properties); diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/ExceptionDetailsIExtension.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/ExceptionDetailsISerializableWithWriter.cs similarity index 76% rename from src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/ExceptionDetailsIExtension.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/ExceptionDetailsISerializableWithWriter.cs index 49933ee01f..5e2e918d33 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/ExceptionDetailsIExtension.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/ExceptionDetailsISerializableWithWriter.cs @@ -4,15 +4,10 @@ using System.Linq; /// - /// Additional implementation for ExceptionDetails. + /// Partial class to implement ISerializableWithWriter. /// - internal partial class ExceptionDetails : IExtension + internal partial class ExceptionDetails : ISerializableWithWriter { - public IExtension DeepClone() - { - return null; - } - public void Serialize(ISerializationWriter serializationWriter) { serializationWriter.WriteProperty("id", this.id); @@ -21,7 +16,7 @@ public void Serialize(ISerializationWriter serializationWriter) serializationWriter.WriteProperty("message", this.message); serializationWriter.WriteProperty("hasFullStack", this.hasFullStack); serializationWriter.WriteProperty("stack", this.stack); - serializationWriter.WriteProperty("parsedStack", this.parsedStack.ToList()); + serializationWriter.WriteProperty("parsedStack", this.parsedStack.ToList()); } } } \ No newline at end of file diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/MessageDataIExtension.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/MessageDataIExtension.cs index dc451a9ab2..592fe1e6af 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/MessageDataIExtension.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/MessageDataIExtension.cs @@ -6,9 +6,9 @@ using Microsoft.ApplicationInsights.DataContracts; /// - /// Partial class to implement IExtension + /// Partial class to implement ISerializableWithWriter /// - internal partial class MessageData : IExtension + internal partial class MessageData : ISerializableWithWriter { public void Serialize(ISerializationWriter serializationWriter) { @@ -18,10 +18,5 @@ public void Serialize(ISerializationWriter serializationWriter) serializationWriter.WriteProperty("properties", this.properties); serializationWriter.WriteProperty("measurements", this.measurements); } - - IExtension IExtension.DeepClone() - { - return this.DeepClone(); - } } } diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/MetricDataIExtension.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/MetricDataISerializableWithWriter.cs similarity index 72% rename from src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/MetricDataIExtension.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/MetricDataISerializableWithWriter.cs index 6da0ee9d26..89eb5e72a7 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/MetricDataIExtension.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/MetricDataISerializableWithWriter.cs @@ -6,20 +6,15 @@ using Microsoft.ApplicationInsights.DataContracts; /// - /// Partial class to implement IExtension + /// Partial class to implement ISerializableWithWriter /// - internal partial class MetricData : IExtension + internal partial class MetricData : ISerializableWithWriter { public void Serialize(ISerializationWriter serializationWriter) { serializationWriter.WriteProperty("ver", this.ver); - serializationWriter.WriteProperty("metrics", this.metrics.ToList()); + serializationWriter.WriteProperty("metrics", this.metrics.ToList()); serializationWriter.WriteProperty("properties", this.properties); } - - IExtension IExtension.DeepClone() - { - return this.DeepClone(); - } } } \ No newline at end of file diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/PageViewDataIExtension.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/PageViewDataIExtension.cs index d86ef313d3..f1eadb1a53 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/PageViewDataIExtension.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/PageViewDataIExtension.cs @@ -3,9 +3,9 @@ using Microsoft.ApplicationInsights.DataContracts; /// - /// Partial class to implement IExtension + /// Partial class to implement ISerializableWithWriter /// - internal partial class PageViewData : IExtension + internal partial class PageViewData : ISerializableWithWriter { public new void Serialize(ISerializationWriter serializationWriter) { @@ -16,10 +16,5 @@ internal partial class PageViewData : IExtension serializationWriter.WriteProperty("properties", this.properties); serializationWriter.WriteProperty("measurements", this.measurements); } - - IExtension IExtension.DeepClone() - { - return this.DeepClone(); - } } } \ No newline at end of file diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/PageViewPerfDataIExtension.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/PageViewPerfDataIExtension.cs index 7a65a25471..7417ff207c 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/PageViewPerfDataIExtension.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/PageViewPerfDataIExtension.cs @@ -1,9 +1,9 @@ namespace Microsoft.ApplicationInsights.Extensibility.Implementation.External { /// - /// Partial class to implement IExtension + /// Partial class to implement ISerializableWithWriter /// - internal partial class PageViewPerfData : IExtension + internal partial class PageViewPerfData : ISerializableWithWriter { public new void Serialize(ISerializationWriter serializationWriter) { @@ -19,10 +19,5 @@ internal partial class PageViewPerfData : IExtension serializationWriter.WriteProperty("properties", this.properties); serializationWriter.WriteProperty("measurements", this.measurements); } - - IExtension IExtension.DeepClone() - { - return this.DeepClone(); - } } } \ No newline at end of file diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/RemoteDependencyDataIExtension.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/RemoteDependencyDataISerializableWithWriter.cs similarity index 84% rename from src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/RemoteDependencyDataIExtension.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/RemoteDependencyDataISerializableWithWriter.cs index c5a056d8ec..87b4c96f3b 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/RemoteDependencyDataIExtension.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/RemoteDependencyDataISerializableWithWriter.cs @@ -5,9 +5,9 @@ using Microsoft.ApplicationInsights.DataContracts; /// - /// Partial class to implement IExtension + /// Partial class to implement ISerializableWithWriter /// - internal partial class RemoteDependencyData : IExtension + internal partial class RemoteDependencyData : ISerializableWithWriter { public void Serialize(ISerializationWriter serializationWriter) { @@ -23,10 +23,5 @@ public void Serialize(ISerializationWriter serializationWriter) serializationWriter.WriteProperty("properties", this.properties); serializationWriter.WriteProperty("measurements", this.measurements); } - - IExtension IExtension.DeepClone() - { - return this.DeepClone(); - } } } \ No newline at end of file diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/RequestDataIExtension.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/RequestDataISerializableWithWriter.cs similarity index 84% rename from src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/RequestDataIExtension.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/RequestDataISerializableWithWriter.cs index b3255482ea..1da9c3a024 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/RequestDataIExtension.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/RequestDataISerializableWithWriter.cs @@ -5,9 +5,9 @@ using Microsoft.ApplicationInsights.DataContracts; /// - /// Partial class to implement IExtension + /// Partial class to implement ISerializableWithWriter /// - internal partial class RequestData : IExtension + internal partial class RequestData : ISerializableWithWriter { public void Serialize(ISerializationWriter serializationWriter) { @@ -22,10 +22,5 @@ public void Serialize(ISerializationWriter serializationWriter) serializationWriter.WriteProperty("properties", this.properties); serializationWriter.WriteProperty("measurements", this.measurements); } - - IExtension IExtension.DeepClone() - { - return this.DeepClone(); - } } } \ No newline at end of file diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/StackFrameIExtension.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/StackFrameISerializableWithWriter.cs similarity index 71% rename from src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/StackFrameIExtension.cs rename to src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/StackFrameISerializableWithWriter.cs index 3e245ef533..4e00b4e532 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/StackFrameIExtension.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/External/StackFrameISerializableWithWriter.cs @@ -3,15 +3,10 @@ using System; /// - /// Partial class to add the EventData attribute and any additional customizations to the generated type. + /// Partial class to impelement ISerializableWithWriter /// - internal partial class StackFrame : IExtension + internal partial class StackFrame : ISerializableWithWriter { - public IExtension DeepClone() - { - return null; - } - public void Serialize(ISerializationWriter serializationWriter) { serializationWriter.WriteProperty("level", this.level); diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializationWriter.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializationWriter.cs index c5e8419792..ea679959b2 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializationWriter.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializationWriter.cs @@ -115,7 +115,7 @@ public void WriteProperty(string name, IList items) } /// - public void WriteProperty(string name, IList items) + public void WriteProperty(string name, IList items) { bool commaNeeded = false; if (items != null && items.Count > 0) @@ -140,7 +140,7 @@ public void WriteProperty(string name, IList items) } /// - public void WriteProperty(string name, IExtension value) + public void WriteProperty(string name, ISerializableWithWriter value) { this.WriteStartObject(name); value.Serialize(this); diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs index e473bf0700..102ec97334 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs @@ -155,9 +155,9 @@ private static Stream CreateCompressedStream(Stream stream) private static void SerializeTelemetryItem(ITelemetry telemetryItem, JsonSerializationWriter jsonSerializationWriter) { - if (telemetryItem is IExtension) + if (telemetryItem is ISerializableWithWriter) { - IExtension telemetry = telemetryItem as IExtension; + ISerializableWithWriter telemetry = telemetryItem as ISerializableWithWriter; jsonSerializationWriter.WriteStartObject(); telemetry.Serialize(jsonSerializationWriter); jsonSerializationWriter.WriteEndObject(); From 2fec31ee303ee68a4e3394a87e750116a04b5773 Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Wed, 8 Aug 2018 15:51:52 -0700 Subject: [PATCH 59/74] ITelemetry contains a Serialize method. Though same signature as ISerializableWithWriter, ITelemetry dont implement the interface to avoid conufsion with the IExtension in ITelemetry --- Test/TestFramework/Shared/StubTelemetry.cs | 5 +++++ src/Microsoft.ApplicationInsights/Channel/ITelemetry.cs | 5 +++++ .../DataContracts/AvailabilityTelemetry.cs | 2 +- .../DataContracts/DependencyTelemetry.cs | 4 ++-- .../DataContracts/EventTelemetry.cs | 2 +- .../DataContracts/ExceptionTelemetry.cs | 2 +- .../DataContracts/MetricTelemetry.cs | 2 +- .../DataContracts/PageViewPerformanceTelemetry.cs | 2 +- .../DataContracts/PageViewTelemetry.cs | 2 +- .../DataContracts/PerformanceCounterTelemetry.cs | 2 +- .../DataContracts/RequestTelemetry.cs | 4 ++-- .../DataContracts/SessionStateTelemetry.cs | 2 +- .../DataContracts/TraceTelemetry.cs | 2 +- .../Extensibility/Implementation/OperationTelemetry.cs | 3 +++ 14 files changed, 26 insertions(+), 13 deletions(-) diff --git a/Test/TestFramework/Shared/StubTelemetry.cs b/Test/TestFramework/Shared/StubTelemetry.cs index 8e958132cf..16fd37a430 100644 --- a/Test/TestFramework/Shared/StubTelemetry.cs +++ b/Test/TestFramework/Shared/StubTelemetry.cs @@ -46,5 +46,10 @@ public void SendEvent(object writer) { this.OnSendEvent(writer); } + + public void Serialize(ISerializationWriter serializationWriter) + { + throw new NotImplementedException(); + } } } diff --git a/src/Microsoft.ApplicationInsights/Channel/ITelemetry.cs b/src/Microsoft.ApplicationInsights/Channel/ITelemetry.cs index 6d9cf3aafa..4eb97ecf5f 100644 --- a/src/Microsoft.ApplicationInsights/Channel/ITelemetry.cs +++ b/src/Microsoft.ApplicationInsights/Channel/ITelemetry.cs @@ -49,5 +49,10 @@ public interface ITelemetry /// /// The cloned object. ITelemetry DeepClone(); + + /// + /// Writes serialization info about the class using the given + /// + void Serialize(ISerializationWriter serializationWriter); } } diff --git a/src/Microsoft.ApplicationInsights/DataContracts/AvailabilityTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/AvailabilityTelemetry.cs index ba77ebcc4f..22a6a7b132 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/AvailabilityTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/AvailabilityTelemetry.cs @@ -13,7 +13,7 @@ /// Contains a time and message and optionally some additional metadata. /// Learn more /// - public sealed class AvailabilityTelemetry : ITelemetry, ISupportProperties, ISupportMetrics, ISerializableWithWriter + public sealed class AvailabilityTelemetry : ITelemetry, ISupportProperties, ISupportMetrics { internal const string TelemetryName = "Availability"; diff --git a/src/Microsoft.ApplicationInsights/DataContracts/DependencyTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/DependencyTelemetry.cs index 7b4dae9c44..9e2d43a9cc 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/DependencyTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/DependencyTelemetry.cs @@ -16,7 +16,7 @@ namespace Microsoft.ApplicationInsights.DataContracts /// The class that represents information about the collected dependency. /// Learn more. /// - public sealed class DependencyTelemetry : OperationTelemetry, ITelemetry, ISupportProperties, ISupportSampling, ISupportMetrics, ISerializableWithWriter + public sealed class DependencyTelemetry : OperationTelemetry, ITelemetry, ISupportProperties, ISupportSampling, ISupportMetrics { internal new const string TelemetryName = "RemoteDependency"; @@ -342,7 +342,7 @@ public void SetOperationDetail(string key, object detail) } /// - public void Serialize(ISerializationWriter serializationWriter) + public override void Serialize(ISerializationWriter serializationWriter) { serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName)); this.WriteEnvelopeProperties(serializationWriter); diff --git a/src/Microsoft.ApplicationInsights/DataContracts/EventTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/EventTelemetry.cs index c1ee406de1..744ec8f068 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/EventTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/EventTelemetry.cs @@ -13,7 +13,7 @@ /// Telemetry type used to track custom events. /// Learn more /// - public sealed class EventTelemetry : ITelemetry, ISupportProperties, ISupportSampling, ISupportMetrics, ISerializableWithWriter + public sealed class EventTelemetry : ITelemetry, ISupportProperties, ISupportSampling, ISupportMetrics { internal const string TelemetryName = "Event"; diff --git a/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs index b60fefdb81..9ae338cd20 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs @@ -13,7 +13,7 @@ /// Telemetry type used to track exceptions. /// Learn more /// - public sealed class ExceptionTelemetry : ITelemetry, ISupportProperties, ISupportSampling, ISupportMetrics, ISerializableWithWriter + public sealed class ExceptionTelemetry : ITelemetry, ISupportProperties, ISupportSampling, ISupportMetrics { internal const string TelemetryName = "Exception"; internal readonly string BaseType = typeof(ExceptionData).Name; diff --git a/src/Microsoft.ApplicationInsights/DataContracts/MetricTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/MetricTelemetry.cs index b1782a65f4..2cc0298df7 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/MetricTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/MetricTelemetry.cs @@ -13,7 +13,7 @@ /// Telemetry type used to track metrics. Represents a sample set of values with a specified count, sum, max, min, and standard deviation. /// Learn more /// - public sealed class MetricTelemetry : ITelemetry, ISupportProperties, ISerializableWithWriter + public sealed class MetricTelemetry : ITelemetry, ISupportProperties { internal const string TelemetryName = "Metric"; diff --git a/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs index ef1ce9c5a6..1b2625efd1 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs @@ -11,7 +11,7 @@ /// /// Telemetry type used to track page load performance. /// - public sealed class PageViewPerformanceTelemetry : ITelemetry, ISupportProperties, ISupportSampling, ISerializableWithWriter + public sealed class PageViewPerformanceTelemetry : ITelemetry, ISupportProperties, ISupportSampling { internal const string TelemetryName = "PageViewPerformance"; diff --git a/src/Microsoft.ApplicationInsights/DataContracts/PageViewTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/PageViewTelemetry.cs index abe23ea466..b9c8fa8916 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/PageViewTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/PageViewTelemetry.cs @@ -18,7 +18,7 @@ /// method. /// Learn more /// - public sealed class PageViewTelemetry : ITelemetry, ISupportProperties, ISupportSampling, ISerializableWithWriter + public sealed class PageViewTelemetry : ITelemetry, ISupportProperties, ISupportSampling { internal const string TelemetryName = "PageView"; diff --git a/src/Microsoft.ApplicationInsights/DataContracts/PerformanceCounterTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/PerformanceCounterTelemetry.cs index 5fc1470b36..afe8efe791 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/PerformanceCounterTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/PerformanceCounterTelemetry.cs @@ -10,7 +10,7 @@ /// The class that represents information about performance counters. /// [Obsolete("Use MetricTelemetry instead.")] - public sealed class PerformanceCounterTelemetry : ITelemetry, ISupportProperties, ISerializableWithWriter + public sealed class PerformanceCounterTelemetry : ITelemetry, ISupportProperties { internal readonly MetricTelemetry Data; private string categoryName = string.Empty; diff --git a/src/Microsoft.ApplicationInsights/DataContracts/RequestTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/RequestTelemetry.cs index 30c8204709..8d689012b5 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/RequestTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/RequestTelemetry.cs @@ -17,7 +17,7 @@ /// method. /// Learn more /// - public sealed class RequestTelemetry : OperationTelemetry, ITelemetry, ISupportProperties, ISupportMetrics, ISupportSampling, ISerializableWithWriter + public sealed class RequestTelemetry : OperationTelemetry, ITelemetry, ISupportProperties, ISupportMetrics, ISupportSampling { internal new const string TelemetryName = "Request"; @@ -236,7 +236,7 @@ public override ITelemetry DeepClone() } /// - public void Serialize(ISerializationWriter serializationWriter) + public override void Serialize(ISerializationWriter serializationWriter) { serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName)); this.WriteEnvelopeProperties(serializationWriter); diff --git a/src/Microsoft.ApplicationInsights/DataContracts/SessionStateTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/SessionStateTelemetry.cs index 841b206678..5d8dcd1897 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/SessionStateTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/SessionStateTelemetry.cs @@ -8,7 +8,7 @@ /// Telemetry type used to track user sessions. /// [Obsolete("Session state events are no longer used. This telemetry item will be sent as EventTelemetry.")] - public sealed class SessionStateTelemetry : ITelemetry, ISerializableWithWriter + public sealed class SessionStateTelemetry : ITelemetry { internal readonly EventTelemetry Data; diff --git a/src/Microsoft.ApplicationInsights/DataContracts/TraceTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/TraceTelemetry.cs index 8c0fc0a057..c2fb46f07e 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/TraceTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/TraceTelemetry.cs @@ -13,7 +13,7 @@ /// Contains a time and message and optionally some additional metadata. /// Learn more /// - public sealed class TraceTelemetry : ITelemetry, ISupportProperties, ISupportSampling, ISerializableWithWriter + public sealed class TraceTelemetry : ITelemetry, ISupportProperties, ISupportSampling { internal const string TelemetryName = "Message"; diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/OperationTelemetry.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/OperationTelemetry.cs index bd87c0e7a4..949b8f93a0 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/OperationTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/OperationTelemetry.cs @@ -99,6 +99,9 @@ void ITelemetry.Sanitize() /// A cloned instance. public abstract ITelemetry DeepClone(); + /// + public abstract void Serialize(ISerializationWriter writer); + /// /// Sets operation Id. /// From 1f19af8c8e301459326c6787d9e3b24ef23c6c67 Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Wed, 8 Aug 2018 16:10:45 -0700 Subject: [PATCH 60/74] Copying TC.GlobalProperties to Item.Properties is done outside serialize method to follow the practise of NOT modifying data within serialize method. --- .../DataContracts/AvailabilityTelemetry.cs | 3 +- .../DataContracts/DependencyTelemetry.cs | 4 +- .../DataContracts/EventTelemetry.cs | 3 +- .../DataContracts/ExceptionTelemetry.cs | 3 +- .../DataContracts/MetricTelemetry.cs | 3 +- .../PageViewPerformanceTelemetry.cs | 3 +- .../DataContracts/PageViewTelemetry.cs | 3 +- .../DataContracts/RequestTelemetry.cs | 1 - .../DataContracts/TraceTelemetry.cs | 1 - .../Implementation/JsonSerializer.cs | 59 +++++++++++++++++++ 10 files changed, 66 insertions(+), 17 deletions(-) diff --git a/src/Microsoft.ApplicationInsights/DataContracts/AvailabilityTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/AvailabilityTelemetry.cs index 22a6a7b132..d41063481a 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/AvailabilityTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/AvailabilityTelemetry.cs @@ -182,8 +182,7 @@ public ITelemetry DeepClone() public void Serialize(ISerializationWriter serializationWriter) { serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName)); - this.WriteEnvelopeProperties(serializationWriter); - Utils.CopyDictionary(this.Context.GlobalProperties, this.Data.properties); + this.WriteEnvelopeProperties(serializationWriter); serializationWriter.WriteStartObject("data"); serializationWriter.WriteProperty("baseType", this.BaseType); serializationWriter.WriteProperty("baseData", this.Data); diff --git a/src/Microsoft.ApplicationInsights/DataContracts/DependencyTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/DependencyTelemetry.cs index 9e2d43a9cc..74e1a71a17 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/DependencyTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/DependencyTelemetry.cs @@ -345,9 +345,7 @@ public void SetOperationDetail(string key, object detail) public override void Serialize(ISerializationWriter serializationWriter) { serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName)); - this.WriteEnvelopeProperties(serializationWriter); - - Utils.CopyDictionary(this.Context.GlobalProperties, this.InternalData.properties); + this.WriteEnvelopeProperties(serializationWriter); serializationWriter.WriteStartObject("data"); serializationWriter.WriteProperty("baseType", this.BaseType); serializationWriter.WriteProperty("baseData", this.InternalData); diff --git a/src/Microsoft.ApplicationInsights/DataContracts/EventTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/EventTelemetry.cs index 744ec8f068..67c6d77601 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/EventTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/EventTelemetry.cs @@ -139,8 +139,7 @@ void ITelemetry.Sanitize() public void Serialize(ISerializationWriter serializationWriter) { serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName)); - this.WriteEnvelopeProperties(serializationWriter); - Utils.CopyDictionary(this.Context.GlobalProperties, this.Data.properties); + this.WriteEnvelopeProperties(serializationWriter); serializationWriter.WriteStartObject("data"); serializationWriter.WriteProperty("baseType", this.BaseType); serializationWriter.WriteProperty("baseData", this.Data); diff --git a/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs index 9ae338cd20..87fd96bedf 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs @@ -281,8 +281,7 @@ public ITelemetry DeepClone() public void Serialize(ISerializationWriter serializationWriter) { serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName)); - this.WriteEnvelopeProperties(serializationWriter); - Utils.CopyDictionary(this.Context.GlobalProperties, this.Data.Data.properties); + this.WriteEnvelopeProperties(serializationWriter); serializationWriter.WriteStartObject("data"); serializationWriter.WriteProperty("baseType", this.BaseType); serializationWriter.WriteProperty("baseData", this.Data.Data); diff --git a/src/Microsoft.ApplicationInsights/DataContracts/MetricTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/MetricTelemetry.cs index 2cc0298df7..78c5bf6b11 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/MetricTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/MetricTelemetry.cs @@ -255,8 +255,7 @@ public ITelemetry DeepClone() public void Serialize(ISerializationWriter serializationWriter) { serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName)); - this.WriteEnvelopeProperties(serializationWriter); - Utils.CopyDictionary(this.Context.GlobalProperties, this.Data.properties); + this.WriteEnvelopeProperties(serializationWriter); serializationWriter.WriteStartObject("data"); serializationWriter.WriteProperty("baseType", this.BaseType); serializationWriter.WriteProperty("baseData", this.Data); diff --git a/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs index 1b2625efd1..032f8eed67 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs @@ -229,8 +229,7 @@ void ITelemetry.Sanitize() public void Serialize(ISerializationWriter serializationWriter) { serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName)); - this.WriteEnvelopeProperties(serializationWriter); - Utils.CopyDictionary(this.Context.GlobalProperties, this.Data.properties); + this.WriteEnvelopeProperties(serializationWriter); serializationWriter.WriteStartObject("data"); serializationWriter.WriteProperty("baseType", BaseType); serializationWriter.WriteProperty("baseData", this.Data); diff --git a/src/Microsoft.ApplicationInsights/DataContracts/PageViewTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/PageViewTelemetry.cs index b9c8fa8916..b905a9c22b 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/PageViewTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/PageViewTelemetry.cs @@ -182,8 +182,7 @@ public ITelemetry DeepClone() public void Serialize(ISerializationWriter serializationWriter) { serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName)); - this.WriteEnvelopeProperties(serializationWriter); - Utils.CopyDictionary(this.Context.GlobalProperties, this.Data.properties); + this.WriteEnvelopeProperties(serializationWriter); serializationWriter.WriteStartObject("data"); serializationWriter.WriteProperty("baseType", this.BaseType); serializationWriter.WriteProperty("baseData", this.Data); diff --git a/src/Microsoft.ApplicationInsights/DataContracts/RequestTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/RequestTelemetry.cs index 8d689012b5..ca2199964f 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/RequestTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/RequestTelemetry.cs @@ -240,7 +240,6 @@ public override void Serialize(ISerializationWriter serializationWriter) { serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName)); this.WriteEnvelopeProperties(serializationWriter); - Utils.CopyDictionary(this.Context.GlobalProperties, this.Data.properties); serializationWriter.WriteStartObject("data"); serializationWriter.WriteProperty("baseType", this.BaseType); serializationWriter.WriteProperty("baseData", this.Data); diff --git a/src/Microsoft.ApplicationInsights/DataContracts/TraceTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/TraceTelemetry.cs index c2fb46f07e..f1061623f3 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/TraceTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/TraceTelemetry.cs @@ -141,7 +141,6 @@ public void Serialize(ISerializationWriter serializationWriter) { serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName)); this.WriteEnvelopeProperties(serializationWriter); - Utils.CopyDictionary(this.Context.GlobalProperties, this.Data.properties); serializationWriter.WriteStartObject("data"); serializationWriter.WriteProperty("baseType", this.BaseType); serializationWriter.WriteProperty("baseData", this.Data); diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs index 102ec97334..0782e67c05 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs @@ -9,6 +9,7 @@ using System.IO.Compression; using System.Text; using Microsoft.ApplicationInsights.Channel; + using Microsoft.ApplicationInsights.DataContracts; using Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing; /// @@ -157,6 +158,64 @@ private static void SerializeTelemetryItem(ITelemetry telemetryItem, JsonSeriali { if (telemetryItem is ISerializableWithWriter) { + if (telemetryItem is EventTelemetry) + { + EventTelemetry eventTelemetry = telemetryItem as EventTelemetry; + Utils.CopyDictionary(telemetryItem.Context.GlobalProperties, eventTelemetry.Data.properties); + } + else if (telemetryItem is ExceptionTelemetry) + { + ExceptionTelemetry exTelemetry = telemetryItem as ExceptionTelemetry; + Utils.CopyDictionary(telemetryItem.Context.GlobalProperties, exTelemetry.Data.Data.properties); + } + else if (telemetryItem is MetricTelemetry) + { + MetricTelemetry mTelemetry = telemetryItem as MetricTelemetry; + Utils.CopyDictionary(telemetryItem.Context.GlobalProperties, mTelemetry.Data.properties); + } + else if (telemetryItem is PageViewTelemetry) + { + PageViewTelemetry pvTelemetry = telemetryItem as PageViewTelemetry; + Utils.CopyDictionary(telemetryItem.Context.GlobalProperties, pvTelemetry.Data.pvTelemetry); + } + else if (telemetryItem is PageViewPerformanceTelemetry) + { + PageViewPerformanceTelemetry pvptelemetry = telemetryItem as PageViewPerformanceTelemetry; + Utils.CopyDictionary(telemetryItem.Context.GlobalProperties, pvptelemetry.Data.properties); + } + else if (telemetryItem is DependencyTelemetry) + { + DependencyTelemetry depTelemetry = telemetryItem as DependencyTelemetry; + Utils.CopyDictionary(telemetryItem.Context.GlobalProperties, depTelemetry.Data.properties); + } + else if (telemetryItem is RequestTelemetry) + { + RequestTelemetry reqTelemetry = telemetryItem as RequestTelemetry; + Utils.CopyDictionary(telemetryItem.Context.GlobalProperties, reqTelemetry.Data.properties); + } +#pragma warning disable 618 + else if (telemetryItem is SessionStateTelemetry) + { + SessionStateTelemetry sessionTelemetry = telemetryItem as SessionStateTelemetry; + Utils.CopyDictionary(telemetryItem.Context.GlobalProperties, sessionTelemetry.Data.properties); + } + else if (telemetryItem is PerformanceCounterTelemetry) + { + PerformanceCounterTelemetry pcTelemetry = telemetryItem as PerformanceCounterTelemetry; + Utils.CopyDictionary(telemetryItem.Context.GlobalProperties, pcTelemetry.Data.properties); + } +#pragma warning restore 618 + else if (telemetryItem is TraceTelemetry) + { + TraceTelemetry traceTelemetry = telemetryItem as TraceTelemetry; + Utils.CopyDictionary(telemetryItem.Context.GlobalProperties, traceTelemetry.Data.properties); + } + else if (telemetryItem is AvailabilityTelemetry) + { + AvailabilityTelemetry availabilityTelemetry = telemetryItem as AvailabilityTelemetry; + Utils.CopyDictionary(telemetryItem.Context.GlobalProperties, availabilityTelemetry.Data.properties); + } + ISerializableWithWriter telemetry = telemetryItem as ISerializableWithWriter; jsonSerializationWriter.WriteStartObject(); telemetry.Serialize(jsonSerializationWriter); From 360931b95953725cf3038aba0bea4d58e3916ec2 Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Wed, 8 Aug 2018 16:15:12 -0700 Subject: [PATCH 61/74] Fix typos comments --- .../Extensibility/ISerializableWithWriter.cs | 2 +- .../Extensibility/Implementation/JsonSerializer.cs | 11 +++-------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/Microsoft.ApplicationInsights/Extensibility/ISerializableWithWriter.cs b/src/Microsoft.ApplicationInsights/Extensibility/ISerializableWithWriter.cs index 9e99ecee25..a1e4ab5064 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/ISerializableWithWriter.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/ISerializableWithWriter.cs @@ -1,7 +1,7 @@ namespace Microsoft.ApplicationInsights.Extensibility { /// - /// Interface for defining objects which can be serialized with a given /// public interface ISerializableWithWriter { diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs index 0782e67c05..77444e8232 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs @@ -176,7 +176,7 @@ private static void SerializeTelemetryItem(ITelemetry telemetryItem, JsonSeriali else if (telemetryItem is PageViewTelemetry) { PageViewTelemetry pvTelemetry = telemetryItem as PageViewTelemetry; - Utils.CopyDictionary(telemetryItem.Context.GlobalProperties, pvTelemetry.Data.pvTelemetry); + Utils.CopyDictionary(telemetryItem.Context.GlobalProperties, pvTelemetry.Data.properties); } else if (telemetryItem is PageViewPerformanceTelemetry) { @@ -186,7 +186,7 @@ private static void SerializeTelemetryItem(ITelemetry telemetryItem, JsonSeriali else if (telemetryItem is DependencyTelemetry) { DependencyTelemetry depTelemetry = telemetryItem as DependencyTelemetry; - Utils.CopyDictionary(telemetryItem.Context.GlobalProperties, depTelemetry.Data.properties); + Utils.CopyDictionary(telemetryItem.Context.GlobalProperties, depTelemetry.InternalData.properties); } else if (telemetryItem is RequestTelemetry) { @@ -194,15 +194,10 @@ private static void SerializeTelemetryItem(ITelemetry telemetryItem, JsonSeriali Utils.CopyDictionary(telemetryItem.Context.GlobalProperties, reqTelemetry.Data.properties); } #pragma warning disable 618 - else if (telemetryItem is SessionStateTelemetry) - { - SessionStateTelemetry sessionTelemetry = telemetryItem as SessionStateTelemetry; - Utils.CopyDictionary(telemetryItem.Context.GlobalProperties, sessionTelemetry.Data.properties); - } else if (telemetryItem is PerformanceCounterTelemetry) { PerformanceCounterTelemetry pcTelemetry = telemetryItem as PerformanceCounterTelemetry; - Utils.CopyDictionary(telemetryItem.Context.GlobalProperties, pcTelemetry.Data.properties); + Utils.CopyDictionary(telemetryItem.Context.GlobalProperties, pcTelemetry.Properties); } #pragma warning restore 618 else if (telemetryItem is TraceTelemetry) From f2a412abab8e1eb58abffc835753dd5dc0f445f6 Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Wed, 8 Aug 2018 16:28:49 -0700 Subject: [PATCH 62/74] ITelemetry has serialize so JsonSerializer dont need to cast to anything before calling seiralize --- .../Implementation/JsonSerializer.cs | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs index 77444e8232..bb07e9eec6 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs @@ -156,8 +156,6 @@ private static Stream CreateCompressedStream(Stream stream) private static void SerializeTelemetryItem(ITelemetry telemetryItem, JsonSerializationWriter jsonSerializationWriter) { - if (telemetryItem is ISerializableWithWriter) - { if (telemetryItem is EventTelemetry) { EventTelemetry eventTelemetry = telemetryItem as EventTelemetry; @@ -210,17 +208,10 @@ private static void SerializeTelemetryItem(ITelemetry telemetryItem, JsonSeriali AvailabilityTelemetry availabilityTelemetry = telemetryItem as AvailabilityTelemetry; Utils.CopyDictionary(telemetryItem.Context.GlobalProperties, availabilityTelemetry.Data.properties); } - - ISerializableWithWriter telemetry = telemetryItem as ISerializableWithWriter; + jsonSerializationWriter.WriteStartObject(); - telemetry.Serialize(jsonSerializationWriter); - jsonSerializationWriter.WriteEndObject(); - } - else - { - string msg = string.Format(CultureInfo.InvariantCulture, "Unable to serialize. Unknown telemetry type: {0}", telemetryItem.GetType()); - CoreEventSource.Log.LogVerbose(msg); - } + telemetryItem.Serialize(jsonSerializationWriter); + jsonSerializationWriter.WriteEndObject(); } /// From 9a8bd60653aa2cf97e5723dd758b97901d7cf052 Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Wed, 8 Aug 2018 16:31:03 -0700 Subject: [PATCH 63/74] Removed ICloneable as clone can be defined in IExtension itelf. --- .../Extensibility/ICloneable.cs | 13 ------------- .../Extensibility/IExtension.cs | 6 +++++- 2 files changed, 5 insertions(+), 14 deletions(-) delete mode 100644 src/Microsoft.ApplicationInsights/Extensibility/ICloneable.cs diff --git a/src/Microsoft.ApplicationInsights/Extensibility/ICloneable.cs b/src/Microsoft.ApplicationInsights/Extensibility/ICloneable.cs deleted file mode 100644 index a33a584bc6..0000000000 --- a/src/Microsoft.ApplicationInsights/Extensibility/ICloneable.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace Microsoft.ApplicationInsights.Extensibility -{ - /// - /// Interface for defining method to Deeply clone the members. - /// - public interface ICloneable - { - /// - /// Deep clones the members of the class. - /// - IExtension DeepClone(); - } -} diff --git a/src/Microsoft.ApplicationInsights/Extensibility/IExtension.cs b/src/Microsoft.ApplicationInsights/Extensibility/IExtension.cs index aeda336048..8681097cfe 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/IExtension.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/IExtension.cs @@ -3,7 +3,11 @@ /// /// Interface for defining strongly typed extensions to telemetry types. /// - public interface IExtension : ISerializableWithWriter, ICloneable + public interface IExtension : ISerializableWithWriter { + /// + /// Deep clones the members of the class. + /// + IExtension DeepClone(); } } From c84fdc16a153a52a4ef0b421daaeeb8320ad65f1 Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Wed, 8 Aug 2018 17:13:31 -0700 Subject: [PATCH 64/74] All types to serialzie their Extension --- src/Microsoft.ApplicationInsights/Channel/ITelemetry.cs | 3 ++- .../DataContracts/AvailabilityTelemetry.cs | 1 + .../DataContracts/DependencyTelemetry.cs | 3 ++- .../DataContracts/EventTelemetry.cs | 1 + .../DataContracts/ExceptionTelemetry.cs | 3 ++- .../DataContracts/MetricTelemetry.cs | 1 + .../DataContracts/PageViewPerformanceTelemetry.cs | 1 + .../DataContracts/PageViewTelemetry.cs | 3 ++- .../DataContracts/RequestTelemetry.cs | 3 ++- .../DataContracts/TraceTelemetry.cs | 3 ++- .../Implementation/JsonSerializationWriter.cs | 9 ++++++--- 11 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/Microsoft.ApplicationInsights/Channel/ITelemetry.cs b/src/Microsoft.ApplicationInsights/Channel/ITelemetry.cs index 4eb97ecf5f..80bf49a0fb 100644 --- a/src/Microsoft.ApplicationInsights/Channel/ITelemetry.cs +++ b/src/Microsoft.ApplicationInsights/Channel/ITelemetry.cs @@ -20,7 +20,8 @@ public interface ITelemetry TelemetryContext Context { get; } /// - /// Gets or sets gets the extension used to extend this telemetry instance using new strongly typed object. + /// Gets or sets gets the extension used to extend this telemetry instance using new strongly + /// typed object. /// IExtension Extension { get; set; } diff --git a/src/Microsoft.ApplicationInsights/DataContracts/AvailabilityTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/AvailabilityTelemetry.cs index d41063481a..951ff7f5d8 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/AvailabilityTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/AvailabilityTelemetry.cs @@ -186,6 +186,7 @@ public void Serialize(ISerializationWriter serializationWriter) serializationWriter.WriteStartObject("data"); serializationWriter.WriteProperty("baseType", this.BaseType); serializationWriter.WriteProperty("baseData", this.Data); + serializationWriter.WriteProperty("extension", this.Extension); serializationWriter.WriteEndObject(); // data } diff --git a/src/Microsoft.ApplicationInsights/DataContracts/DependencyTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/DependencyTelemetry.cs index 74e1a71a17..5cc5b36c6b 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/DependencyTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/DependencyTelemetry.cs @@ -348,7 +348,8 @@ public override void Serialize(ISerializationWriter serializationWriter) this.WriteEnvelopeProperties(serializationWriter); serializationWriter.WriteStartObject("data"); serializationWriter.WriteProperty("baseType", this.BaseType); - serializationWriter.WriteProperty("baseData", this.InternalData); + serializationWriter.WriteProperty("baseData", this.InternalData); + serializationWriter.WriteProperty("extension", this.Extension); serializationWriter.WriteEndObject(); // data } diff --git a/src/Microsoft.ApplicationInsights/DataContracts/EventTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/EventTelemetry.cs index 67c6d77601..beb8df2eed 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/EventTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/EventTelemetry.cs @@ -143,6 +143,7 @@ public void Serialize(ISerializationWriter serializationWriter) serializationWriter.WriteStartObject("data"); serializationWriter.WriteProperty("baseType", this.BaseType); serializationWriter.WriteProperty("baseData", this.Data); + serializationWriter.WriteProperty("extension", this.Extension); serializationWriter.WriteEndObject(); // data } } diff --git a/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs index 87fd96bedf..0265423a56 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs @@ -284,7 +284,8 @@ public void Serialize(ISerializationWriter serializationWriter) this.WriteEnvelopeProperties(serializationWriter); serializationWriter.WriteStartObject("data"); serializationWriter.WriteProperty("baseType", this.BaseType); - serializationWriter.WriteProperty("baseData", this.Data.Data); + serializationWriter.WriteProperty("baseData", this.Data.Data); + serializationWriter.WriteProperty("extension", this.Extension); serializationWriter.WriteEndObject(); // data } diff --git a/src/Microsoft.ApplicationInsights/DataContracts/MetricTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/MetricTelemetry.cs index 78c5bf6b11..5f24c08c7d 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/MetricTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/MetricTelemetry.cs @@ -259,6 +259,7 @@ public void Serialize(ISerializationWriter serializationWriter) serializationWriter.WriteStartObject("data"); serializationWriter.WriteProperty("baseType", this.BaseType); serializationWriter.WriteProperty("baseData", this.Data); + serializationWriter.WriteProperty("extension", this.Extension); serializationWriter.WriteEndObject(); // data } diff --git a/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs index 032f8eed67..56e0b0c67a 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs @@ -233,6 +233,7 @@ public void Serialize(ISerializationWriter serializationWriter) serializationWriter.WriteStartObject("data"); serializationWriter.WriteProperty("baseType", BaseType); serializationWriter.WriteProperty("baseData", this.Data); + serializationWriter.WriteProperty("extension", this.Extension); serializationWriter.WriteEndObject(); // data } } diff --git a/src/Microsoft.ApplicationInsights/DataContracts/PageViewTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/PageViewTelemetry.cs index b905a9c22b..4048214146 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/PageViewTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/PageViewTelemetry.cs @@ -185,7 +185,8 @@ public void Serialize(ISerializationWriter serializationWriter) this.WriteEnvelopeProperties(serializationWriter); serializationWriter.WriteStartObject("data"); serializationWriter.WriteProperty("baseType", this.BaseType); - serializationWriter.WriteProperty("baseData", this.Data); + serializationWriter.WriteProperty("baseData", this.Data); + serializationWriter.WriteProperty("extension", this.Extension); serializationWriter.WriteEndObject(); // data } diff --git a/src/Microsoft.ApplicationInsights/DataContracts/RequestTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/RequestTelemetry.cs index ca2199964f..35ce76d6cf 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/RequestTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/RequestTelemetry.cs @@ -242,7 +242,8 @@ public override void Serialize(ISerializationWriter serializationWriter) this.WriteEnvelopeProperties(serializationWriter); serializationWriter.WriteStartObject("data"); serializationWriter.WriteProperty("baseType", this.BaseType); - serializationWriter.WriteProperty("baseData", this.Data); + serializationWriter.WriteProperty("baseData", this.Data); + serializationWriter.WriteProperty("extension", this.Extension); serializationWriter.WriteEndObject(); // data } diff --git a/src/Microsoft.ApplicationInsights/DataContracts/TraceTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/TraceTelemetry.cs index f1061623f3..b436cb14bd 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/TraceTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/TraceTelemetry.cs @@ -143,7 +143,8 @@ public void Serialize(ISerializationWriter serializationWriter) this.WriteEnvelopeProperties(serializationWriter); serializationWriter.WriteStartObject("data"); serializationWriter.WriteProperty("baseType", this.BaseType); - serializationWriter.WriteProperty("baseData", this.Data); + serializationWriter.WriteProperty("baseData", this.Data); + serializationWriter.WriteProperty("extension", this.Extension); serializationWriter.WriteEndObject(); // data } diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializationWriter.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializationWriter.cs index ea679959b2..8bbf8b4994 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializationWriter.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializationWriter.cs @@ -142,9 +142,12 @@ public void WriteProperty(string name, IList items) /// public void WriteProperty(string name, ISerializableWithWriter value) { - this.WriteStartObject(name); - value.Serialize(this); - this.WriteEndObject(); + if (value != null) + { + this.WriteStartObject(name); + value.Serialize(this); + this.WriteEndObject(); + } } /// From f2b693659169218752c6798f0cdc48534b2ad155 Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Wed, 8 Aug 2018 17:19:58 -0700 Subject: [PATCH 65/74] Re-enable public api analyzer --- .../net45/PublicAPI.Unshipped.txt | 22 ++++++++++--------- .../net46/PublicAPI.Unshipped.txt | 22 ++++++++++--------- .../netstandard1.3/PublicAPI.Unshipped.txt | 22 ++++++++++--------- .../Microsoft.ApplicationInsights.csproj | 8 +++---- 4 files changed, 40 insertions(+), 34 deletions(-) diff --git a/PublicAPI/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Unshipped.txt b/PublicAPI/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Unshipped.txt index 0ee44e5cb6..c732961393 100644 --- a/PublicAPI/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Unshipped.txt +++ b/PublicAPI/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Unshipped.txt @@ -322,16 +322,18 @@ abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTel abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTelemetry.Extension.set -> void Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.Extensibility.IExtension.DeepClone() -> Microsoft.ApplicationInsights.Extensibility.IExtension -Microsoft.ApplicationInsights.Extensibility.IExtension.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.Extensibility.ISerializationWriter -Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteDictionary(string name, System.Collections.Generic.IDictionary items) -> void -Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteDictionary(string name, System.Collections.Generic.IDictionary items) -> void -Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteEndObject(string name) -> void -Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteList(string name, System.Collections.Generic.IList items) -> void -Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, System.TimeSpan? value) -> void -Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, System.DateTimeOffset? value) -> void -Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, bool? value) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, string value) -> void Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, double? value) -> void Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, int? value) -> void -Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, string value) -> void -Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteStartObject(string name) -> void \ No newline at end of file +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, bool? value) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, System.TimeSpan? value) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, System.DateTimeOffset? value) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, Microsoft.ApplicationInsights.Extensibility.ISerializableWithWriter value) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, System.Collections.Generic.IList items) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, System.Collections.Generic.IList items) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, System.Collections.Generic.IDictionary items) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, System.Collections.Generic.IDictionary items) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteStartObject(string name) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteStartObject() -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteEndObject() -> void \ No newline at end of file diff --git a/PublicAPI/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Unshipped.txt b/PublicAPI/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Unshipped.txt index 0ee44e5cb6..c732961393 100644 --- a/PublicAPI/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Unshipped.txt +++ b/PublicAPI/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Unshipped.txt @@ -322,16 +322,18 @@ abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTel abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTelemetry.Extension.set -> void Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.Extensibility.IExtension.DeepClone() -> Microsoft.ApplicationInsights.Extensibility.IExtension -Microsoft.ApplicationInsights.Extensibility.IExtension.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.Extensibility.ISerializationWriter -Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteDictionary(string name, System.Collections.Generic.IDictionary items) -> void -Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteDictionary(string name, System.Collections.Generic.IDictionary items) -> void -Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteEndObject(string name) -> void -Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteList(string name, System.Collections.Generic.IList items) -> void -Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, System.TimeSpan? value) -> void -Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, System.DateTimeOffset? value) -> void -Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, bool? value) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, string value) -> void Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, double? value) -> void Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, int? value) -> void -Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, string value) -> void -Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteStartObject(string name) -> void \ No newline at end of file +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, bool? value) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, System.TimeSpan? value) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, System.DateTimeOffset? value) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, Microsoft.ApplicationInsights.Extensibility.ISerializableWithWriter value) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, System.Collections.Generic.IList items) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, System.Collections.Generic.IList items) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, System.Collections.Generic.IDictionary items) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, System.Collections.Generic.IDictionary items) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteStartObject(string name) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteStartObject() -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteEndObject() -> void \ No newline at end of file diff --git a/PublicAPI/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Unshipped.txt b/PublicAPI/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Unshipped.txt index e28308f2d4..e469eed3a6 100644 --- a/PublicAPI/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Unshipped.txt +++ b/PublicAPI/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Unshipped.txt @@ -323,16 +323,18 @@ abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTel abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTelemetry.Extension.set -> void Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.Extensibility.IExtension.DeepClone() -> Microsoft.ApplicationInsights.Extensibility.IExtension -Microsoft.ApplicationInsights.Extensibility.IExtension.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.Extensibility.ISerializationWriter -Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteDictionary(string name, System.Collections.Generic.IDictionary items) -> void -Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteDictionary(string name, System.Collections.Generic.IDictionary items) -> void -Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteEndObject(string name) -> void -Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteList(string name, System.Collections.Generic.IList items) -> void -Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, System.TimeSpan? value) -> void -Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, System.DateTimeOffset? value) -> void -Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, bool? value) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, string value) -> void Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, double? value) -> void Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, int? value) -> void -Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, string value) -> void -Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteStartObject(string name) -> void \ No newline at end of file +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, bool? value) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, System.TimeSpan? value) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, System.DateTimeOffset? value) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, Microsoft.ApplicationInsights.Extensibility.ISerializableWithWriter value) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, System.Collections.Generic.IList items) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, System.Collections.Generic.IList items) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, System.Collections.Generic.IDictionary items) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, System.Collections.Generic.IDictionary items) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteStartObject(string name) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteStartObject() -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteEndObject() -> void \ No newline at end of file diff --git a/src/Microsoft.ApplicationInsights/Microsoft.ApplicationInsights.csproj b/src/Microsoft.ApplicationInsights/Microsoft.ApplicationInsights.csproj index 0c70fffc9c..8e62f5ffb8 100644 --- a/src/Microsoft.ApplicationInsights/Microsoft.ApplicationInsights.csproj +++ b/src/Microsoft.ApplicationInsights/Microsoft.ApplicationInsights.csproj @@ -52,11 +52,11 @@ All - + All @@ -68,7 +68,7 @@ - + \ No newline at end of file From 74b83e1c56296779e584386641bb293bd12d6993 Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Wed, 8 Aug 2018 17:53:31 -0700 Subject: [PATCH 66/74] Public API files added --- .../net45/PublicAPI.Unshipped.txt | 15 +++++++++++++++ .../net46/PublicAPI.Unshipped.txt | 15 +++++++++++++++ .../netstandard1.3/PublicAPI.Unshipped.txt | 15 +++++++++++++++ .../Implementation/OperationTelemetry.cs | 2 +- 4 files changed, 46 insertions(+), 1 deletion(-) diff --git a/PublicAPI/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Unshipped.txt b/PublicAPI/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Unshipped.txt index c732961393..303c1b1eef 100644 --- a/PublicAPI/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Unshipped.txt +++ b/PublicAPI/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Unshipped.txt @@ -296,30 +296,45 @@ Microsoft.ApplicationInsights.DataContracts.TelemetryContext.Flags.set -> void const Microsoft.ApplicationInsights.DataContracts.TelemetryContext.FlagDropIdentifiers = 2097152 -> long Microsoft.ApplicationInsights.Channel.ITelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.Channel.ITelemetry.Extension.set -> void +Microsoft.ApplicationInsights.Channel.ITelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.AvailabilityTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.AvailabilityTelemetry.Extension.set -> void +Microsoft.ApplicationInsights.DataContracts.AvailabilityTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.EventTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.EventTelemetry.Extension.set -> void +Microsoft.ApplicationInsights.DataContracts.EventTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Extension.set -> void +Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.MetricTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.MetricTelemetry.Extension.set -> void +Microsoft.ApplicationInsights.DataContracts.MetricTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Extension.set -> void +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.PageViewTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.PageViewTelemetry.Extension.set -> void +Microsoft.ApplicationInsights.DataContracts.PageViewTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.PerformanceCounterTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.PerformanceCounterTelemetry.Extension.set -> void +Microsoft.ApplicationInsights.DataContracts.PerformanceCounterTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.SessionStateTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.SessionStateTelemetry.Extension.set -> void +Microsoft.ApplicationInsights.DataContracts.SessionStateTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.TraceTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.TraceTelemetry.Extension.set -> void +Microsoft.ApplicationInsights.DataContracts.TraceTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void override Microsoft.ApplicationInsights.DataContracts.DependencyTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension override Microsoft.ApplicationInsights.DataContracts.DependencyTelemetry.Extension.set -> void +override Microsoft.ApplicationInsights.DataContracts.DependencyTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void override Microsoft.ApplicationInsights.DataContracts.RequestTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension override Microsoft.ApplicationInsights.DataContracts.RequestTelemetry.Extension.set -> void +override Microsoft.ApplicationInsights.DataContracts.RequestTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTelemetry.Extension.set -> void +abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializableWithWriter +Microsoft.ApplicationInsights.Extensibility.ISerializableWithWriter.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.Extensibility.IExtension.DeepClone() -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.Extensibility.ISerializationWriter diff --git a/PublicAPI/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Unshipped.txt b/PublicAPI/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Unshipped.txt index c732961393..303c1b1eef 100644 --- a/PublicAPI/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Unshipped.txt +++ b/PublicAPI/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Unshipped.txt @@ -296,30 +296,45 @@ Microsoft.ApplicationInsights.DataContracts.TelemetryContext.Flags.set -> void const Microsoft.ApplicationInsights.DataContracts.TelemetryContext.FlagDropIdentifiers = 2097152 -> long Microsoft.ApplicationInsights.Channel.ITelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.Channel.ITelemetry.Extension.set -> void +Microsoft.ApplicationInsights.Channel.ITelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.AvailabilityTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.AvailabilityTelemetry.Extension.set -> void +Microsoft.ApplicationInsights.DataContracts.AvailabilityTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.EventTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.EventTelemetry.Extension.set -> void +Microsoft.ApplicationInsights.DataContracts.EventTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Extension.set -> void +Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.MetricTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.MetricTelemetry.Extension.set -> void +Microsoft.ApplicationInsights.DataContracts.MetricTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Extension.set -> void +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.PageViewTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.PageViewTelemetry.Extension.set -> void +Microsoft.ApplicationInsights.DataContracts.PageViewTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.PerformanceCounterTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.PerformanceCounterTelemetry.Extension.set -> void +Microsoft.ApplicationInsights.DataContracts.PerformanceCounterTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.SessionStateTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.SessionStateTelemetry.Extension.set -> void +Microsoft.ApplicationInsights.DataContracts.SessionStateTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.TraceTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.TraceTelemetry.Extension.set -> void +Microsoft.ApplicationInsights.DataContracts.TraceTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void override Microsoft.ApplicationInsights.DataContracts.DependencyTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension override Microsoft.ApplicationInsights.DataContracts.DependencyTelemetry.Extension.set -> void +override Microsoft.ApplicationInsights.DataContracts.DependencyTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void override Microsoft.ApplicationInsights.DataContracts.RequestTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension override Microsoft.ApplicationInsights.DataContracts.RequestTelemetry.Extension.set -> void +override Microsoft.ApplicationInsights.DataContracts.RequestTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTelemetry.Extension.set -> void +abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializableWithWriter +Microsoft.ApplicationInsights.Extensibility.ISerializableWithWriter.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.Extensibility.IExtension.DeepClone() -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.Extensibility.ISerializationWriter diff --git a/PublicAPI/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Unshipped.txt b/PublicAPI/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Unshipped.txt index e469eed3a6..f0d0132216 100644 --- a/PublicAPI/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Unshipped.txt +++ b/PublicAPI/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Unshipped.txt @@ -297,30 +297,45 @@ Microsoft.ApplicationInsights.DataContracts.TelemetryContext.Flags.set -> void const Microsoft.ApplicationInsights.DataContracts.TelemetryContext.FlagDropIdentifiers = 2097152 -> long Microsoft.ApplicationInsights.Channel.ITelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.Channel.ITelemetry.Extension.set -> void +Microsoft.ApplicationInsights.Channel.ITelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.AvailabilityTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.AvailabilityTelemetry.Extension.set -> void +Microsoft.ApplicationInsights.DataContracts.AvailabilityTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.EventTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.EventTelemetry.Extension.set -> void +Microsoft.ApplicationInsights.DataContracts.EventTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Extension.set -> void +Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.MetricTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.MetricTelemetry.Extension.set -> void +Microsoft.ApplicationInsights.DataContracts.MetricTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Extension.set -> void +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.PageViewTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.PageViewTelemetry.Extension.set -> void +Microsoft.ApplicationInsights.DataContracts.PageViewTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.PerformanceCounterTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.PerformanceCounterTelemetry.Extension.set -> void +Microsoft.ApplicationInsights.DataContracts.PerformanceCounterTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.SessionStateTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.SessionStateTelemetry.Extension.set -> void +Microsoft.ApplicationInsights.DataContracts.SessionStateTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.TraceTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.TraceTelemetry.Extension.set -> void +Microsoft.ApplicationInsights.DataContracts.TraceTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void override Microsoft.ApplicationInsights.DataContracts.DependencyTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension override Microsoft.ApplicationInsights.DataContracts.DependencyTelemetry.Extension.set -> void +override Microsoft.ApplicationInsights.DataContracts.DependencyTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void override Microsoft.ApplicationInsights.DataContracts.RequestTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension override Microsoft.ApplicationInsights.DataContracts.RequestTelemetry.Extension.set -> void +override Microsoft.ApplicationInsights.DataContracts.RequestTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTelemetry.Extension.set -> void +abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializableWithWriter +Microsoft.ApplicationInsights.Extensibility.ISerializableWithWriter.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.Extensibility.IExtension.DeepClone() -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.Extensibility.ISerializationWriter diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/OperationTelemetry.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/OperationTelemetry.cs index 949b8f93a0..206d84a9b6 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/OperationTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/OperationTelemetry.cs @@ -100,7 +100,7 @@ void ITelemetry.Sanitize() public abstract ITelemetry DeepClone(); /// - public abstract void Serialize(ISerializationWriter writer); + public abstract void Serialize(ISerializationWriter serializationWriter); /// /// Sets operation Id. From 95f3307a1e74d0766b6513c5c87d2c8102968ee8 Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Wed, 8 Aug 2018 17:56:57 -0700 Subject: [PATCH 67/74] remove bad comment --- src/Microsoft.ApplicationInsights/Channel/ITelemetry.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.ApplicationInsights/Channel/ITelemetry.cs b/src/Microsoft.ApplicationInsights/Channel/ITelemetry.cs index 80bf49a0fb..3389786582 100644 --- a/src/Microsoft.ApplicationInsights/Channel/ITelemetry.cs +++ b/src/Microsoft.ApplicationInsights/Channel/ITelemetry.cs @@ -21,7 +21,7 @@ public interface ITelemetry /// /// Gets or sets gets the extension used to extend this telemetry instance using new strongly - /// typed object. + /// typed object. /// IExtension Extension { get; set; } From 35197ed4515711edeff772b303042265363b588c Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Wed, 8 Aug 2018 20:04:59 -0700 Subject: [PATCH 68/74] Test fix --- Test/TestFramework/Shared/StubTelemetry.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Test/TestFramework/Shared/StubTelemetry.cs b/Test/TestFramework/Shared/StubTelemetry.cs index 16fd37a430..73944252f4 100644 --- a/Test/TestFramework/Shared/StubTelemetry.cs +++ b/Test/TestFramework/Shared/StubTelemetry.cs @@ -49,7 +49,7 @@ public void SendEvent(object writer) public void Serialize(ISerializationWriter serializationWriter) { - throw new NotImplementedException(); + } } } From f7f98d7437d8f5809c188c4f638b75d56d6ec2a2 Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Wed, 8 Aug 2018 20:42:59 -0700 Subject: [PATCH 69/74] Test fix --- .../Shared.Tests/Implementation/TelemetrySerializerTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Test/ServerTelemetryChannel.Test/Shared.Tests/Implementation/TelemetrySerializerTest.cs b/Test/ServerTelemetryChannel.Test/Shared.Tests/Implementation/TelemetrySerializerTest.cs index 58ff199930..7080b04227 100644 --- a/Test/ServerTelemetryChannel.Test/Shared.Tests/Implementation/TelemetrySerializerTest.cs +++ b/Test/ServerTelemetryChannel.Test/Shared.Tests/Implementation/TelemetrySerializerTest.cs @@ -101,7 +101,7 @@ public void EnqueuesTransmissionWithExpectedProperties() Assert.AreEqual(serializer.EndpointAddress, transmission.EndpointAddress); Assert.AreEqual("application/x-json-stream", transmission.ContentType); Assert.AreEqual("gzip", transmission.ContentEncoding); - Assert.AreEqual(string.Empty, Unzip(transmission.Content)); + Assert.AreEqual("{}", Unzip(transmission.Content)); } [TestMethod] From 92597d81b50f8f900654fffab149888b7195b8b1 Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Fri, 10 Aug 2018 10:30:31 -0700 Subject: [PATCH 70/74] Added new method SerializeData on ITelemetry which serialize only the data part about the telemetry. No global level info is emitted. --- .../net45/PublicAPI.Unshipped.txt | 13 +++++++++++++ .../net46/PublicAPI.Unshipped.txt | 13 +++++++++++++ .../netstandard1.3/PublicAPI.Unshipped.txt | 13 +++++++++++++ .../Extensibility/Implementation/MyTestExtension.cs | 4 ++-- Test/TestFramework/Shared/StubTelemetry.cs | 5 +++++ .../Channel/ITelemetry.cs | 5 +++++ .../DataContracts/AvailabilityTelemetry.cs | 8 +++++++- .../DataContracts/DependencyTelemetry.cs | 8 +++++++- .../DataContracts/EventTelemetry.cs | 8 +++++++- .../DataContracts/ExceptionTelemetry.cs | 8 +++++++- .../DataContracts/MetricTelemetry.cs | 8 +++++++- .../DataContracts/PageViewPerformanceTelemetry.cs | 8 +++++++- .../DataContracts/PageViewTelemetry.cs | 8 +++++++- .../DataContracts/PerformanceCounterTelemetry.cs | 6 ++++++ .../DataContracts/RequestTelemetry.cs | 10 ++++++++-- .../DataContracts/SessionStateTelemetry.cs | 6 ++++++ .../DataContracts/TraceTelemetry.cs | 8 +++++++- .../Implementation/OperationTelemetry.cs | 3 +++ 18 files changed, 130 insertions(+), 12 deletions(-) diff --git a/PublicAPI/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Unshipped.txt b/PublicAPI/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Unshipped.txt index 303c1b1eef..51cfb05bd3 100644 --- a/PublicAPI/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Unshipped.txt +++ b/PublicAPI/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Unshipped.txt @@ -297,42 +297,55 @@ const Microsoft.ApplicationInsights.DataContracts.TelemetryContext.FlagDropIdent Microsoft.ApplicationInsights.Channel.ITelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.Channel.ITelemetry.Extension.set -> void Microsoft.ApplicationInsights.Channel.ITelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void +Microsoft.ApplicationInsights.Channel.ITelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.AvailabilityTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.AvailabilityTelemetry.Extension.set -> void Microsoft.ApplicationInsights.DataContracts.AvailabilityTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void +Microsoft.ApplicationInsights.DataContracts.AvailabilityTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.EventTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.EventTelemetry.Extension.set -> void Microsoft.ApplicationInsights.DataContracts.EventTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void +Microsoft.ApplicationInsights.DataContracts.EventTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Extension.set -> void Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void +Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.MetricTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.MetricTelemetry.Extension.set -> void Microsoft.ApplicationInsights.DataContracts.MetricTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void +Microsoft.ApplicationInsights.DataContracts.MetricTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Extension.set -> void Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.PageViewTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.PageViewTelemetry.Extension.set -> void Microsoft.ApplicationInsights.DataContracts.PageViewTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void +Microsoft.ApplicationInsights.DataContracts.PageViewTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.PerformanceCounterTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.PerformanceCounterTelemetry.Extension.set -> void Microsoft.ApplicationInsights.DataContracts.PerformanceCounterTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void +Microsoft.ApplicationInsights.DataContracts.PerformanceCounterTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.SessionStateTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.SessionStateTelemetry.Extension.set -> void Microsoft.ApplicationInsights.DataContracts.SessionStateTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void +Microsoft.ApplicationInsights.DataContracts.SessionStateTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.TraceTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.TraceTelemetry.Extension.set -> void Microsoft.ApplicationInsights.DataContracts.TraceTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void +Microsoft.ApplicationInsights.DataContracts.TraceTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void override Microsoft.ApplicationInsights.DataContracts.DependencyTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension override Microsoft.ApplicationInsights.DataContracts.DependencyTelemetry.Extension.set -> void override Microsoft.ApplicationInsights.DataContracts.DependencyTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void +override Microsoft.ApplicationInsights.DataContracts.DependencyTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void override Microsoft.ApplicationInsights.DataContracts.RequestTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension override Microsoft.ApplicationInsights.DataContracts.RequestTelemetry.Extension.set -> void override Microsoft.ApplicationInsights.DataContracts.RequestTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void +override Microsoft.ApplicationInsights.DataContracts.RequestTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTelemetry.Extension.set -> void abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void +abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.Extensibility.ISerializableWithWriter Microsoft.ApplicationInsights.Extensibility.ISerializableWithWriter.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.Extensibility.IExtension diff --git a/PublicAPI/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Unshipped.txt b/PublicAPI/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Unshipped.txt index 303c1b1eef..51cfb05bd3 100644 --- a/PublicAPI/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Unshipped.txt +++ b/PublicAPI/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Unshipped.txt @@ -297,42 +297,55 @@ const Microsoft.ApplicationInsights.DataContracts.TelemetryContext.FlagDropIdent Microsoft.ApplicationInsights.Channel.ITelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.Channel.ITelemetry.Extension.set -> void Microsoft.ApplicationInsights.Channel.ITelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void +Microsoft.ApplicationInsights.Channel.ITelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.AvailabilityTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.AvailabilityTelemetry.Extension.set -> void Microsoft.ApplicationInsights.DataContracts.AvailabilityTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void +Microsoft.ApplicationInsights.DataContracts.AvailabilityTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.EventTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.EventTelemetry.Extension.set -> void Microsoft.ApplicationInsights.DataContracts.EventTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void +Microsoft.ApplicationInsights.DataContracts.EventTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Extension.set -> void Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void +Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.MetricTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.MetricTelemetry.Extension.set -> void Microsoft.ApplicationInsights.DataContracts.MetricTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void +Microsoft.ApplicationInsights.DataContracts.MetricTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Extension.set -> void Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.PageViewTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.PageViewTelemetry.Extension.set -> void Microsoft.ApplicationInsights.DataContracts.PageViewTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void +Microsoft.ApplicationInsights.DataContracts.PageViewTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.PerformanceCounterTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.PerformanceCounterTelemetry.Extension.set -> void Microsoft.ApplicationInsights.DataContracts.PerformanceCounterTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void +Microsoft.ApplicationInsights.DataContracts.PerformanceCounterTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.SessionStateTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.SessionStateTelemetry.Extension.set -> void Microsoft.ApplicationInsights.DataContracts.SessionStateTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void +Microsoft.ApplicationInsights.DataContracts.SessionStateTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.TraceTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.TraceTelemetry.Extension.set -> void Microsoft.ApplicationInsights.DataContracts.TraceTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void +Microsoft.ApplicationInsights.DataContracts.TraceTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void override Microsoft.ApplicationInsights.DataContracts.DependencyTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension override Microsoft.ApplicationInsights.DataContracts.DependencyTelemetry.Extension.set -> void override Microsoft.ApplicationInsights.DataContracts.DependencyTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void +override Microsoft.ApplicationInsights.DataContracts.DependencyTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void override Microsoft.ApplicationInsights.DataContracts.RequestTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension override Microsoft.ApplicationInsights.DataContracts.RequestTelemetry.Extension.set -> void override Microsoft.ApplicationInsights.DataContracts.RequestTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void +override Microsoft.ApplicationInsights.DataContracts.RequestTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTelemetry.Extension.set -> void abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void +abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.Extensibility.ISerializableWithWriter Microsoft.ApplicationInsights.Extensibility.ISerializableWithWriter.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.Extensibility.IExtension diff --git a/PublicAPI/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Unshipped.txt b/PublicAPI/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Unshipped.txt index f0d0132216..90872e718e 100644 --- a/PublicAPI/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Unshipped.txt +++ b/PublicAPI/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Unshipped.txt @@ -298,42 +298,55 @@ const Microsoft.ApplicationInsights.DataContracts.TelemetryContext.FlagDropIdent Microsoft.ApplicationInsights.Channel.ITelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.Channel.ITelemetry.Extension.set -> void Microsoft.ApplicationInsights.Channel.ITelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void +Microsoft.ApplicationInsights.Channel.ITelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.AvailabilityTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.AvailabilityTelemetry.Extension.set -> void Microsoft.ApplicationInsights.DataContracts.AvailabilityTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void +Microsoft.ApplicationInsights.DataContracts.AvailabilityTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.EventTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.EventTelemetry.Extension.set -> void Microsoft.ApplicationInsights.DataContracts.EventTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void +Microsoft.ApplicationInsights.DataContracts.EventTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Extension.set -> void Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void +Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.MetricTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.MetricTelemetry.Extension.set -> void Microsoft.ApplicationInsights.DataContracts.MetricTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void +Microsoft.ApplicationInsights.DataContracts.MetricTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Extension.set -> void Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void +Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.PageViewTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.PageViewTelemetry.Extension.set -> void Microsoft.ApplicationInsights.DataContracts.PageViewTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void +Microsoft.ApplicationInsights.DataContracts.PageViewTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.PerformanceCounterTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.PerformanceCounterTelemetry.Extension.set -> void Microsoft.ApplicationInsights.DataContracts.PerformanceCounterTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void +Microsoft.ApplicationInsights.DataContracts.PerformanceCounterTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.SessionStateTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.SessionStateTelemetry.Extension.set -> void Microsoft.ApplicationInsights.DataContracts.SessionStateTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void +Microsoft.ApplicationInsights.DataContracts.SessionStateTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.TraceTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.TraceTelemetry.Extension.set -> void Microsoft.ApplicationInsights.DataContracts.TraceTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void +Microsoft.ApplicationInsights.DataContracts.TraceTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void override Microsoft.ApplicationInsights.DataContracts.DependencyTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension override Microsoft.ApplicationInsights.DataContracts.DependencyTelemetry.Extension.set -> void override Microsoft.ApplicationInsights.DataContracts.DependencyTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void +override Microsoft.ApplicationInsights.DataContracts.DependencyTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void override Microsoft.ApplicationInsights.DataContracts.RequestTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension override Microsoft.ApplicationInsights.DataContracts.RequestTelemetry.Extension.set -> void override Microsoft.ApplicationInsights.DataContracts.RequestTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void +override Microsoft.ApplicationInsights.DataContracts.RequestTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTelemetry.Extension.set -> void abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void +abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.Extensibility.ISerializableWithWriter Microsoft.ApplicationInsights.Extensibility.ISerializableWithWriter.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.Extensibility.IExtension diff --git a/Test/Microsoft.ApplicationInsights.Test/Shared/Extensibility/Implementation/MyTestExtension.cs b/Test/Microsoft.ApplicationInsights.Test/Shared/Extensibility/Implementation/MyTestExtension.cs index b44ceb3716..dcf4851579 100644 --- a/Test/Microsoft.ApplicationInsights.Test/Shared/Extensibility/Implementation/MyTestExtension.cs +++ b/Test/Microsoft.ApplicationInsights.Test/Shared/Extensibility/Implementation/MyTestExtension.cs @@ -6,8 +6,8 @@ namespace Microsoft.ApplicationInsights.Extensibility.Implementation { public class MyTestExtension : IExtension { - int myIntField; - string myStringField; + public int myIntField; + public string myStringField; public IExtension DeepClone() { diff --git a/Test/TestFramework/Shared/StubTelemetry.cs b/Test/TestFramework/Shared/StubTelemetry.cs index 73944252f4..c18b02a892 100644 --- a/Test/TestFramework/Shared/StubTelemetry.cs +++ b/Test/TestFramework/Shared/StubTelemetry.cs @@ -51,5 +51,10 @@ public void Serialize(ISerializationWriter serializationWriter) { } + + public void SerializeData(ISerializationWriter serializationWriter) + { + + } } } diff --git a/src/Microsoft.ApplicationInsights/Channel/ITelemetry.cs b/src/Microsoft.ApplicationInsights/Channel/ITelemetry.cs index 3389786582..b31ab52af1 100644 --- a/src/Microsoft.ApplicationInsights/Channel/ITelemetry.cs +++ b/src/Microsoft.ApplicationInsights/Channel/ITelemetry.cs @@ -55,5 +55,10 @@ public interface ITelemetry /// Writes serialization info about the class using the given /// void Serialize(ISerializationWriter serializationWriter); + + /// + /// Writes serialization info about the data class of the implementing type using the given + /// + void SerializeData(ISerializationWriter serializationWriter); } } diff --git a/src/Microsoft.ApplicationInsights/DataContracts/AvailabilityTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/AvailabilityTelemetry.cs index 951ff7f5d8..f9dc8abcf2 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/AvailabilityTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/AvailabilityTelemetry.cs @@ -185,9 +185,15 @@ public void Serialize(ISerializationWriter serializationWriter) this.WriteEnvelopeProperties(serializationWriter); serializationWriter.WriteStartObject("data"); serializationWriter.WriteProperty("baseType", this.BaseType); + this.SerializeData(serializationWriter); + serializationWriter.WriteEndObject(); // data + } + + /// + public void SerializeData(ISerializationWriter serializationWriter) + { serializationWriter.WriteProperty("baseData", this.Data); serializationWriter.WriteProperty("extension", this.Extension); - serializationWriter.WriteEndObject(); // data } /// diff --git a/src/Microsoft.ApplicationInsights/DataContracts/DependencyTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/DependencyTelemetry.cs index 5cc5b36c6b..5ca3b93cf7 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/DependencyTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/DependencyTelemetry.cs @@ -348,9 +348,15 @@ public override void Serialize(ISerializationWriter serializationWriter) this.WriteEnvelopeProperties(serializationWriter); serializationWriter.WriteStartObject("data"); serializationWriter.WriteProperty("baseType", this.BaseType); + this.SerializeData(serializationWriter); + serializationWriter.WriteEndObject(); // data + } + + /// + public override void SerializeData(ISerializationWriter serializationWriter) + { serializationWriter.WriteProperty("baseData", this.InternalData); serializationWriter.WriteProperty("extension", this.Extension); - serializationWriter.WriteEndObject(); // data } /// diff --git a/src/Microsoft.ApplicationInsights/DataContracts/EventTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/EventTelemetry.cs index beb8df2eed..a8f24ba44f 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/EventTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/EventTelemetry.cs @@ -142,9 +142,15 @@ public void Serialize(ISerializationWriter serializationWriter) this.WriteEnvelopeProperties(serializationWriter); serializationWriter.WriteStartObject("data"); serializationWriter.WriteProperty("baseType", this.BaseType); + this.SerializeData(serializationWriter); + serializationWriter.WriteEndObject(); // data + } + + /// + public void SerializeData(ISerializationWriter serializationWriter) + { serializationWriter.WriteProperty("baseData", this.Data); serializationWriter.WriteProperty("extension", this.Extension); - serializationWriter.WriteEndObject(); // data } } } diff --git a/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs index 0265423a56..6454720990 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs @@ -284,9 +284,15 @@ public void Serialize(ISerializationWriter serializationWriter) this.WriteEnvelopeProperties(serializationWriter); serializationWriter.WriteStartObject("data"); serializationWriter.WriteProperty("baseType", this.BaseType); + this.SerializeData(serializationWriter); + serializationWriter.WriteEndObject(); // data + } + + /// + public void SerializeData(ISerializationWriter serializationWriter) + { serializationWriter.WriteProperty("baseData", this.Data.Data); serializationWriter.WriteProperty("extension", this.Extension); - serializationWriter.WriteEndObject(); // data } /// diff --git a/src/Microsoft.ApplicationInsights/DataContracts/MetricTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/MetricTelemetry.cs index 5f24c08c7d..91ad18aa84 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/MetricTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/MetricTelemetry.cs @@ -258,9 +258,15 @@ public void Serialize(ISerializationWriter serializationWriter) this.WriteEnvelopeProperties(serializationWriter); serializationWriter.WriteStartObject("data"); serializationWriter.WriteProperty("baseType", this.BaseType); + this.SerializeData(serializationWriter); + serializationWriter.WriteEndObject(); // data + } + + /// + public void SerializeData(ISerializationWriter serializationWriter) + { serializationWriter.WriteProperty("baseData", this.Data); serializationWriter.WriteProperty("extension", this.Extension); - serializationWriter.WriteEndObject(); // data } /// diff --git a/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs index 56e0b0c67a..a1a6e31bcb 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs @@ -232,9 +232,15 @@ public void Serialize(ISerializationWriter serializationWriter) this.WriteEnvelopeProperties(serializationWriter); serializationWriter.WriteStartObject("data"); serializationWriter.WriteProperty("baseType", BaseType); + this.SerializeData(serializationWriter); + serializationWriter.WriteEndObject(); // data + } + + /// + public void SerializeData(ISerializationWriter serializationWriter) + { serializationWriter.WriteProperty("baseData", this.Data); serializationWriter.WriteProperty("extension", this.Extension); - serializationWriter.WriteEndObject(); // data } } } diff --git a/src/Microsoft.ApplicationInsights/DataContracts/PageViewTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/PageViewTelemetry.cs index 4048214146..4b6ae50a76 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/PageViewTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/PageViewTelemetry.cs @@ -185,9 +185,15 @@ public void Serialize(ISerializationWriter serializationWriter) this.WriteEnvelopeProperties(serializationWriter); serializationWriter.WriteStartObject("data"); serializationWriter.WriteProperty("baseType", this.BaseType); + this.SerializeData(serializationWriter); + serializationWriter.WriteEndObject(); // data + } + + /// + public void SerializeData(ISerializationWriter serializationWriter) + { serializationWriter.WriteProperty("baseData", this.Data); serializationWriter.WriteProperty("extension", this.Extension); - serializationWriter.WriteEndObject(); // data } /// diff --git a/src/Microsoft.ApplicationInsights/DataContracts/PerformanceCounterTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/PerformanceCounterTelemetry.cs index afe8efe791..d6f7f11439 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/PerformanceCounterTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/PerformanceCounterTelemetry.cs @@ -198,6 +198,12 @@ public void Serialize(ISerializationWriter serializationWriter) this.Data.Serialize(serializationWriter); } + /// + public void SerializeData(ISerializationWriter serializationWriter) + { + this.Data.SerializeData(serializationWriter); + } + /// /// Sanitizes the properties based on constraints. /// diff --git a/src/Microsoft.ApplicationInsights/DataContracts/RequestTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/RequestTelemetry.cs index 35ce76d6cf..0dee3ef4e2 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/RequestTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/RequestTelemetry.cs @@ -242,11 +242,17 @@ public override void Serialize(ISerializationWriter serializationWriter) this.WriteEnvelopeProperties(serializationWriter); serializationWriter.WriteStartObject("data"); serializationWriter.WriteProperty("baseType", this.BaseType); - serializationWriter.WriteProperty("baseData", this.Data); - serializationWriter.WriteProperty("extension", this.Extension); + this.SerializeData(serializationWriter); serializationWriter.WriteEndObject(); // data } + /// + public override void SerializeData(ISerializationWriter serializationWriter) + { + serializationWriter.WriteProperty("baseData", this.Data); + serializationWriter.WriteProperty("extension", this.Extension); + } + /// /// Sanitizes the properties based on constraints. /// diff --git a/src/Microsoft.ApplicationInsights/DataContracts/SessionStateTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/SessionStateTelemetry.cs index 5d8dcd1897..12bd6a6738 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/SessionStateTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/SessionStateTelemetry.cs @@ -145,5 +145,11 @@ public void Serialize(ISerializationWriter serializationWriter) { this.Data.Serialize(serializationWriter); } + + /// + public void SerializeData(ISerializationWriter serializationWriter) + { + this.Data.SerializeData(serializationWriter); + } } } \ No newline at end of file diff --git a/src/Microsoft.ApplicationInsights/DataContracts/TraceTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/TraceTelemetry.cs index b436cb14bd..6ebd1e63ec 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/TraceTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/TraceTelemetry.cs @@ -143,9 +143,15 @@ public void Serialize(ISerializationWriter serializationWriter) this.WriteEnvelopeProperties(serializationWriter); serializationWriter.WriteStartObject("data"); serializationWriter.WriteProperty("baseType", this.BaseType); + this.SerializeData(serializationWriter); + serializationWriter.WriteEndObject(); // data + } + + /// + public void SerializeData(ISerializationWriter serializationWriter) + { serializationWriter.WriteProperty("baseData", this.Data); serializationWriter.WriteProperty("extension", this.Extension); - serializationWriter.WriteEndObject(); // data } /// diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/OperationTelemetry.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/OperationTelemetry.cs index 206d84a9b6..72fde57cae 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/OperationTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/OperationTelemetry.cs @@ -102,6 +102,9 @@ void ITelemetry.Sanitize() /// public abstract void Serialize(ISerializationWriter serializationWriter); + /// + public abstract void SerializeData(ISerializationWriter serializationWriter); + /// /// Sets operation Id. /// From abc8ffe14ee461adb2b099def86b64c5fd427aac Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Tue, 14 Aug 2018 09:30:03 -0700 Subject: [PATCH 71/74] Make ITelemetry implement SerializeData instead of Serialize, as only Data part need to be serialized. Rest of the content are known within ITelemetry itself and hence require no explicit serialization call. --- .../net45/PublicAPI.Unshipped.txt | 14 +- .../net46/PublicAPI.Unshipped.txt | 14 +- .../netstandard1.3/PublicAPI.Unshipped.txt | 14 +- .../Channel/ITelemetry.cs | 7 +- .../DataContracts/AvailabilityTelemetry.cs | 14 +- .../DataContracts/DependencyTelemetry.cs | 14 +- .../DataContracts/EventTelemetry.cs | 14 +- .../DataContracts/ExceptionTelemetry.cs | 14 +- .../DataContracts/MetricTelemetry.cs | 14 +- .../PageViewPerformanceTelemetry.cs | 14 +- .../DataContracts/PageViewTelemetry.cs | 14 +- .../PerformanceCounterTelemetry.cs | 6 - .../DataContracts/RequestTelemetry.cs | 14 +- .../DataContracts/SessionStateTelemetry.cs | 6 - .../DataContracts/TraceTelemetry.cs | 14 +- .../Extensibility/ISerializationWriter.cs | 5 + .../Implementation/JsonSerializationWriter.cs | 11 ++ .../Implementation/JsonSerializer.cs | 126 +++++++++++++++++- .../Implementation/OperationTelemetry.cs | 3 - 19 files changed, 149 insertions(+), 183 deletions(-) diff --git a/PublicAPI/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Unshipped.txt b/PublicAPI/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Unshipped.txt index 51cfb05bd3..35653d4cce 100644 --- a/PublicAPI/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Unshipped.txt +++ b/PublicAPI/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Unshipped.txt @@ -296,55 +296,42 @@ Microsoft.ApplicationInsights.DataContracts.TelemetryContext.Flags.set -> void const Microsoft.ApplicationInsights.DataContracts.TelemetryContext.FlagDropIdentifiers = 2097152 -> long Microsoft.ApplicationInsights.Channel.ITelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.Channel.ITelemetry.Extension.set -> void -Microsoft.ApplicationInsights.Channel.ITelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.Channel.ITelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.AvailabilityTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.AvailabilityTelemetry.Extension.set -> void -Microsoft.ApplicationInsights.DataContracts.AvailabilityTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.AvailabilityTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.EventTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.EventTelemetry.Extension.set -> void -Microsoft.ApplicationInsights.DataContracts.EventTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.EventTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Extension.set -> void -Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.MetricTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.MetricTelemetry.Extension.set -> void -Microsoft.ApplicationInsights.DataContracts.MetricTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.MetricTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Extension.set -> void -Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.PageViewTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.PageViewTelemetry.Extension.set -> void -Microsoft.ApplicationInsights.DataContracts.PageViewTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.PageViewTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.PerformanceCounterTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.PerformanceCounterTelemetry.Extension.set -> void -Microsoft.ApplicationInsights.DataContracts.PerformanceCounterTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.PerformanceCounterTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.SessionStateTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.SessionStateTelemetry.Extension.set -> void -Microsoft.ApplicationInsights.DataContracts.SessionStateTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.SessionStateTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.TraceTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.TraceTelemetry.Extension.set -> void -Microsoft.ApplicationInsights.DataContracts.TraceTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.TraceTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void override Microsoft.ApplicationInsights.DataContracts.DependencyTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension override Microsoft.ApplicationInsights.DataContracts.DependencyTelemetry.Extension.set -> void -override Microsoft.ApplicationInsights.DataContracts.DependencyTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void override Microsoft.ApplicationInsights.DataContracts.DependencyTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void override Microsoft.ApplicationInsights.DataContracts.RequestTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension override Microsoft.ApplicationInsights.DataContracts.RequestTelemetry.Extension.set -> void -override Microsoft.ApplicationInsights.DataContracts.RequestTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void override Microsoft.ApplicationInsights.DataContracts.RequestTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTelemetry.Extension.set -> void -abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.Extensibility.ISerializableWithWriter Microsoft.ApplicationInsights.Extensibility.ISerializableWithWriter.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void @@ -358,6 +345,7 @@ Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(s Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, System.TimeSpan? value) -> void Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, System.DateTimeOffset? value) -> void Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, Microsoft.ApplicationInsights.Extensibility.ISerializableWithWriter value) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(Microsoft.ApplicationInsights.Extensibility.ISerializableWithWriter value) -> void Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, System.Collections.Generic.IList items) -> void Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, System.Collections.Generic.IList items) -> void Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, System.Collections.Generic.IDictionary items) -> void diff --git a/PublicAPI/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Unshipped.txt b/PublicAPI/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Unshipped.txt index 51cfb05bd3..35653d4cce 100644 --- a/PublicAPI/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Unshipped.txt +++ b/PublicAPI/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Unshipped.txt @@ -296,55 +296,42 @@ Microsoft.ApplicationInsights.DataContracts.TelemetryContext.Flags.set -> void const Microsoft.ApplicationInsights.DataContracts.TelemetryContext.FlagDropIdentifiers = 2097152 -> long Microsoft.ApplicationInsights.Channel.ITelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.Channel.ITelemetry.Extension.set -> void -Microsoft.ApplicationInsights.Channel.ITelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.Channel.ITelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.AvailabilityTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.AvailabilityTelemetry.Extension.set -> void -Microsoft.ApplicationInsights.DataContracts.AvailabilityTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.AvailabilityTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.EventTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.EventTelemetry.Extension.set -> void -Microsoft.ApplicationInsights.DataContracts.EventTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.EventTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Extension.set -> void -Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.MetricTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.MetricTelemetry.Extension.set -> void -Microsoft.ApplicationInsights.DataContracts.MetricTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.MetricTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Extension.set -> void -Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.PageViewTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.PageViewTelemetry.Extension.set -> void -Microsoft.ApplicationInsights.DataContracts.PageViewTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.PageViewTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.PerformanceCounterTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.PerformanceCounterTelemetry.Extension.set -> void -Microsoft.ApplicationInsights.DataContracts.PerformanceCounterTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.PerformanceCounterTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.SessionStateTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.SessionStateTelemetry.Extension.set -> void -Microsoft.ApplicationInsights.DataContracts.SessionStateTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.SessionStateTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.TraceTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.TraceTelemetry.Extension.set -> void -Microsoft.ApplicationInsights.DataContracts.TraceTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.TraceTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void override Microsoft.ApplicationInsights.DataContracts.DependencyTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension override Microsoft.ApplicationInsights.DataContracts.DependencyTelemetry.Extension.set -> void -override Microsoft.ApplicationInsights.DataContracts.DependencyTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void override Microsoft.ApplicationInsights.DataContracts.DependencyTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void override Microsoft.ApplicationInsights.DataContracts.RequestTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension override Microsoft.ApplicationInsights.DataContracts.RequestTelemetry.Extension.set -> void -override Microsoft.ApplicationInsights.DataContracts.RequestTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void override Microsoft.ApplicationInsights.DataContracts.RequestTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTelemetry.Extension.set -> void -abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.Extensibility.ISerializableWithWriter Microsoft.ApplicationInsights.Extensibility.ISerializableWithWriter.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void @@ -358,6 +345,7 @@ Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(s Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, System.TimeSpan? value) -> void Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, System.DateTimeOffset? value) -> void Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, Microsoft.ApplicationInsights.Extensibility.ISerializableWithWriter value) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(Microsoft.ApplicationInsights.Extensibility.ISerializableWithWriter value) -> void Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, System.Collections.Generic.IList items) -> void Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, System.Collections.Generic.IList items) -> void Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, System.Collections.Generic.IDictionary items) -> void diff --git a/PublicAPI/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Unshipped.txt b/PublicAPI/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Unshipped.txt index 90872e718e..19c24ee0d5 100644 --- a/PublicAPI/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Unshipped.txt +++ b/PublicAPI/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Unshipped.txt @@ -297,55 +297,42 @@ Microsoft.ApplicationInsights.DataContracts.TelemetryContext.Flags.set -> void const Microsoft.ApplicationInsights.DataContracts.TelemetryContext.FlagDropIdentifiers = 2097152 -> long Microsoft.ApplicationInsights.Channel.ITelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.Channel.ITelemetry.Extension.set -> void -Microsoft.ApplicationInsights.Channel.ITelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.Channel.ITelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.AvailabilityTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.AvailabilityTelemetry.Extension.set -> void -Microsoft.ApplicationInsights.DataContracts.AvailabilityTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.AvailabilityTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.EventTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.EventTelemetry.Extension.set -> void -Microsoft.ApplicationInsights.DataContracts.EventTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.EventTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Extension.set -> void -Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.MetricTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.MetricTelemetry.Extension.set -> void -Microsoft.ApplicationInsights.DataContracts.MetricTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.MetricTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Extension.set -> void -Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.PageViewPerformanceTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.PageViewTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.PageViewTelemetry.Extension.set -> void -Microsoft.ApplicationInsights.DataContracts.PageViewTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.PageViewTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.PerformanceCounterTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.PerformanceCounterTelemetry.Extension.set -> void -Microsoft.ApplicationInsights.DataContracts.PerformanceCounterTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.PerformanceCounterTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.SessionStateTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.SessionStateTelemetry.Extension.set -> void -Microsoft.ApplicationInsights.DataContracts.SessionStateTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.SessionStateTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.TraceTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension Microsoft.ApplicationInsights.DataContracts.TraceTelemetry.Extension.set -> void -Microsoft.ApplicationInsights.DataContracts.TraceTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.DataContracts.TraceTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void override Microsoft.ApplicationInsights.DataContracts.DependencyTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension override Microsoft.ApplicationInsights.DataContracts.DependencyTelemetry.Extension.set -> void -override Microsoft.ApplicationInsights.DataContracts.DependencyTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void override Microsoft.ApplicationInsights.DataContracts.DependencyTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void override Microsoft.ApplicationInsights.DataContracts.RequestTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension override Microsoft.ApplicationInsights.DataContracts.RequestTelemetry.Extension.set -> void -override Microsoft.ApplicationInsights.DataContracts.RequestTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void override Microsoft.ApplicationInsights.DataContracts.RequestTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTelemetry.Extension.get -> Microsoft.ApplicationInsights.Extensibility.IExtension abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTelemetry.Extension.set -> void -abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTelemetry.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void abstract Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTelemetry.SerializeData(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void Microsoft.ApplicationInsights.Extensibility.ISerializableWithWriter Microsoft.ApplicationInsights.Extensibility.ISerializableWithWriter.Serialize(Microsoft.ApplicationInsights.Extensibility.ISerializationWriter serializationWriter) -> void @@ -359,6 +346,7 @@ Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(s Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, System.TimeSpan? value) -> void Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, System.DateTimeOffset? value) -> void Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, Microsoft.ApplicationInsights.Extensibility.ISerializableWithWriter value) -> void +Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(Microsoft.ApplicationInsights.Extensibility.ISerializableWithWriter value) -> void Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, System.Collections.Generic.IList items) -> void Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, System.Collections.Generic.IList items) -> void Microsoft.ApplicationInsights.Extensibility.ISerializationWriter.WriteProperty(string name, System.Collections.Generic.IDictionary items) -> void diff --git a/src/Microsoft.ApplicationInsights/Channel/ITelemetry.cs b/src/Microsoft.ApplicationInsights/Channel/ITelemetry.cs index b31ab52af1..a33e48e4e4 100644 --- a/src/Microsoft.ApplicationInsights/Channel/ITelemetry.cs +++ b/src/Microsoft.ApplicationInsights/Channel/ITelemetry.cs @@ -50,12 +50,7 @@ public interface ITelemetry /// /// The cloned object. ITelemetry DeepClone(); - - /// - /// Writes serialization info about the class using the given - /// - void Serialize(ISerializationWriter serializationWriter); - + /// /// Writes serialization info about the data class of the implementing type using the given /// diff --git a/src/Microsoft.ApplicationInsights/DataContracts/AvailabilityTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/AvailabilityTelemetry.cs index f9dc8abcf2..188a0caac1 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/AvailabilityTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/AvailabilityTelemetry.cs @@ -178,22 +178,10 @@ public ITelemetry DeepClone() return new AvailabilityTelemetry(this); } - /// - public void Serialize(ISerializationWriter serializationWriter) - { - serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName)); - this.WriteEnvelopeProperties(serializationWriter); - serializationWriter.WriteStartObject("data"); - serializationWriter.WriteProperty("baseType", this.BaseType); - this.SerializeData(serializationWriter); - serializationWriter.WriteEndObject(); // data - } - /// public void SerializeData(ISerializationWriter serializationWriter) { - serializationWriter.WriteProperty("baseData", this.Data); - serializationWriter.WriteProperty("extension", this.Extension); + serializationWriter.WriteProperty(this.Data); } /// diff --git a/src/Microsoft.ApplicationInsights/DataContracts/DependencyTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/DependencyTelemetry.cs index 5ca3b93cf7..1f60edeab4 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/DependencyTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/DependencyTelemetry.cs @@ -341,22 +341,10 @@ public void SetOperationDetail(string key, object detail) this.OperationDetails[key] = detail; } - /// - public override void Serialize(ISerializationWriter serializationWriter) - { - serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName)); - this.WriteEnvelopeProperties(serializationWriter); - serializationWriter.WriteStartObject("data"); - serializationWriter.WriteProperty("baseType", this.BaseType); - this.SerializeData(serializationWriter); - serializationWriter.WriteEndObject(); // data - } - /// public override void SerializeData(ISerializationWriter serializationWriter) { - serializationWriter.WriteProperty("baseData", this.InternalData); - serializationWriter.WriteProperty("extension", this.Extension); + serializationWriter.WriteProperty(this.InternalData); } /// diff --git a/src/Microsoft.ApplicationInsights/DataContracts/EventTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/EventTelemetry.cs index a8f24ba44f..2eea99a979 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/EventTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/EventTelemetry.cs @@ -135,22 +135,10 @@ void ITelemetry.Sanitize() this.Metrics.SanitizeMeasurements(); } - /// - public void Serialize(ISerializationWriter serializationWriter) - { - serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName)); - this.WriteEnvelopeProperties(serializationWriter); - serializationWriter.WriteStartObject("data"); - serializationWriter.WriteProperty("baseType", this.BaseType); - this.SerializeData(serializationWriter); - serializationWriter.WriteEndObject(); // data - } - /// public void SerializeData(ISerializationWriter serializationWriter) { - serializationWriter.WriteProperty("baseData", this.Data); - serializationWriter.WriteProperty("extension", this.Extension); + serializationWriter.WriteProperty(this.Data); } } } diff --git a/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs index 6454720990..ae762674aa 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/ExceptionTelemetry.cs @@ -277,22 +277,10 @@ public ITelemetry DeepClone() return new ExceptionTelemetry(this); } - /// - public void Serialize(ISerializationWriter serializationWriter) - { - serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName)); - this.WriteEnvelopeProperties(serializationWriter); - serializationWriter.WriteStartObject("data"); - serializationWriter.WriteProperty("baseType", this.BaseType); - this.SerializeData(serializationWriter); - serializationWriter.WriteEndObject(); // data - } - /// public void SerializeData(ISerializationWriter serializationWriter) { - serializationWriter.WriteProperty("baseData", this.Data.Data); - serializationWriter.WriteProperty("extension", this.Extension); + serializationWriter.WriteProperty(this.Data.Data); } /// diff --git a/src/Microsoft.ApplicationInsights/DataContracts/MetricTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/MetricTelemetry.cs index 91ad18aa84..d62d5331a9 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/MetricTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/MetricTelemetry.cs @@ -251,22 +251,10 @@ public ITelemetry DeepClone() return new MetricTelemetry(this); } - /// - public void Serialize(ISerializationWriter serializationWriter) - { - serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName)); - this.WriteEnvelopeProperties(serializationWriter); - serializationWriter.WriteStartObject("data"); - serializationWriter.WriteProperty("baseType", this.BaseType); - this.SerializeData(serializationWriter); - serializationWriter.WriteEndObject(); // data - } - /// public void SerializeData(ISerializationWriter serializationWriter) { - serializationWriter.WriteProperty("baseData", this.Data); - serializationWriter.WriteProperty("extension", this.Extension); + serializationWriter.WriteProperty(this.Data); } /// diff --git a/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs index a1a6e31bcb..ee0f9995b7 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/PageViewPerformanceTelemetry.cs @@ -225,22 +225,10 @@ void ITelemetry.Sanitize() this.Id.SanitizeName(); } - /// - public void Serialize(ISerializationWriter serializationWriter) - { - serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName)); - this.WriteEnvelopeProperties(serializationWriter); - serializationWriter.WriteStartObject("data"); - serializationWriter.WriteProperty("baseType", BaseType); - this.SerializeData(serializationWriter); - serializationWriter.WriteEndObject(); // data - } - /// public void SerializeData(ISerializationWriter serializationWriter) { - serializationWriter.WriteProperty("baseData", this.Data); - serializationWriter.WriteProperty("extension", this.Extension); + serializationWriter.WriteProperty(this.Data); } } } diff --git a/src/Microsoft.ApplicationInsights/DataContracts/PageViewTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/PageViewTelemetry.cs index 4b6ae50a76..fd7fc7c654 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/PageViewTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/PageViewTelemetry.cs @@ -178,22 +178,10 @@ public ITelemetry DeepClone() return new PageViewTelemetry(this); } - /// - public void Serialize(ISerializationWriter serializationWriter) - { - serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName)); - this.WriteEnvelopeProperties(serializationWriter); - serializationWriter.WriteStartObject("data"); - serializationWriter.WriteProperty("baseType", this.BaseType); - this.SerializeData(serializationWriter); - serializationWriter.WriteEndObject(); // data - } - /// public void SerializeData(ISerializationWriter serializationWriter) { - serializationWriter.WriteProperty("baseData", this.Data); - serializationWriter.WriteProperty("extension", this.Extension); + serializationWriter.WriteProperty(this.Data); } /// diff --git a/src/Microsoft.ApplicationInsights/DataContracts/PerformanceCounterTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/PerformanceCounterTelemetry.cs index d6f7f11439..62854cf869 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/PerformanceCounterTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/PerformanceCounterTelemetry.cs @@ -192,12 +192,6 @@ public ITelemetry DeepClone() return new PerformanceCounterTelemetry(this); } - /// - public void Serialize(ISerializationWriter serializationWriter) - { - this.Data.Serialize(serializationWriter); - } - /// public void SerializeData(ISerializationWriter serializationWriter) { diff --git a/src/Microsoft.ApplicationInsights/DataContracts/RequestTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/RequestTelemetry.cs index 0dee3ef4e2..76192ac44d 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/RequestTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/RequestTelemetry.cs @@ -235,22 +235,10 @@ public override ITelemetry DeepClone() return new RequestTelemetry(this); } - /// - public override void Serialize(ISerializationWriter serializationWriter) - { - serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName)); - this.WriteEnvelopeProperties(serializationWriter); - serializationWriter.WriteStartObject("data"); - serializationWriter.WriteProperty("baseType", this.BaseType); - this.SerializeData(serializationWriter); - serializationWriter.WriteEndObject(); // data - } - /// public override void SerializeData(ISerializationWriter serializationWriter) { - serializationWriter.WriteProperty("baseData", this.Data); - serializationWriter.WriteProperty("extension", this.Extension); + serializationWriter.WriteProperty(this.Data); } /// diff --git a/src/Microsoft.ApplicationInsights/DataContracts/SessionStateTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/SessionStateTelemetry.cs index 12bd6a6738..ff23946a4d 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/SessionStateTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/SessionStateTelemetry.cs @@ -140,12 +140,6 @@ void ITelemetry.Sanitize() ((ITelemetry)this.Data).Sanitize(); } - /// - public void Serialize(ISerializationWriter serializationWriter) - { - this.Data.Serialize(serializationWriter); - } - /// public void SerializeData(ISerializationWriter serializationWriter) { diff --git a/src/Microsoft.ApplicationInsights/DataContracts/TraceTelemetry.cs b/src/Microsoft.ApplicationInsights/DataContracts/TraceTelemetry.cs index 6ebd1e63ec..4282760fa1 100644 --- a/src/Microsoft.ApplicationInsights/DataContracts/TraceTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/DataContracts/TraceTelemetry.cs @@ -136,22 +136,10 @@ public ITelemetry DeepClone() return new TraceTelemetry(this); } - /// - public void Serialize(ISerializationWriter serializationWriter) - { - serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName)); - this.WriteEnvelopeProperties(serializationWriter); - serializationWriter.WriteStartObject("data"); - serializationWriter.WriteProperty("baseType", this.BaseType); - this.SerializeData(serializationWriter); - serializationWriter.WriteEndObject(); // data - } - /// public void SerializeData(ISerializationWriter serializationWriter) { - serializationWriter.WriteProperty("baseData", this.Data); - serializationWriter.WriteProperty("extension", this.Extension); + serializationWriter.WriteProperty(this.Data); } /// diff --git a/src/Microsoft.ApplicationInsights/Extensibility/ISerializationWriter.cs b/src/Microsoft.ApplicationInsights/Extensibility/ISerializationWriter.cs index 58294aabac..83f5591e05 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/ISerializationWriter.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/ISerializationWriter.cs @@ -43,6 +43,11 @@ public interface ISerializationWriter /// void WriteProperty(string name, ISerializableWithWriter value); + /// + /// Writes value ISerializableWithWriter field + /// + void WriteProperty(ISerializableWithWriter value); + /// /// Writes name and values for a IList field of strings /// diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializationWriter.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializationWriter.cs index 8bbf8b4994..37f02ef054 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializationWriter.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializationWriter.cs @@ -150,6 +150,17 @@ public void WriteProperty(string name, ISerializableWithWriter value) } } + /// + public void WriteProperty(ISerializableWithWriter value) + { + if (value != null) + { + this.WriteStartObject(); + value.Serialize(this); + this.WriteEndObject(); + } + } + /// public void WriteProperty(string name, IDictionary values) { diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs index bb07e9eec6..b17b565b63 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs @@ -155,62 +155,176 @@ private static Stream CreateCompressedStream(Stream stream) } private static void SerializeTelemetryItem(ITelemetry telemetryItem, JsonSerializationWriter jsonSerializationWriter) - { - if (telemetryItem is EventTelemetry) + { + jsonSerializationWriter.WriteStartObject(); + + if (telemetryItem is EventTelemetry) { EventTelemetry eventTelemetry = telemetryItem as EventTelemetry; Utils.CopyDictionary(telemetryItem.Context.GlobalProperties, eventTelemetry.Data.properties); + + jsonSerializationWriter.WriteProperty("name", telemetryItem.WriteTelemetryName(EventTelemetry.TelemetryName)); + telemetryItem.WriteEnvelopeProperties(jsonSerializationWriter); + jsonSerializationWriter.WriteStartObject("data"); + jsonSerializationWriter.WriteProperty("baseType", eventTelemetry.BaseType); + jsonSerializationWriter.WriteStartObject("baseData"); + telemetryItem.SerializeData(jsonSerializationWriter); + jsonSerializationWriter.WriteEndObject(); // baseData + jsonSerializationWriter.WriteProperty("extension", telemetryItem.Extension); + jsonSerializationWriter.WriteEndObject(); // data } else if (telemetryItem is ExceptionTelemetry) { ExceptionTelemetry exTelemetry = telemetryItem as ExceptionTelemetry; Utils.CopyDictionary(telemetryItem.Context.GlobalProperties, exTelemetry.Data.Data.properties); + + jsonSerializationWriter.WriteProperty("name", telemetryItem.WriteTelemetryName(ExceptionTelemetry.TelemetryName)); + telemetryItem.WriteEnvelopeProperties(jsonSerializationWriter); + jsonSerializationWriter.WriteStartObject("data"); + jsonSerializationWriter.WriteProperty("baseType", exTelemetry.BaseType); + jsonSerializationWriter.WriteStartObject("baseData"); + telemetryItem.SerializeData(jsonSerializationWriter); + jsonSerializationWriter.WriteEndObject(); // baseData + jsonSerializationWriter.WriteProperty("extension", telemetryItem.Extension); + jsonSerializationWriter.WriteEndObject(); // data } else if (telemetryItem is MetricTelemetry) { MetricTelemetry mTelemetry = telemetryItem as MetricTelemetry; Utils.CopyDictionary(telemetryItem.Context.GlobalProperties, mTelemetry.Data.properties); + + jsonSerializationWriter.WriteProperty("name", telemetryItem.WriteTelemetryName(MetricTelemetry.TelemetryName)); + telemetryItem.WriteEnvelopeProperties(jsonSerializationWriter); + jsonSerializationWriter.WriteStartObject("data"); + jsonSerializationWriter.WriteProperty("baseType", mTelemetry.BaseType); + jsonSerializationWriter.WriteStartObject("baseData"); + telemetryItem.SerializeData(jsonSerializationWriter); + jsonSerializationWriter.WriteEndObject(); // baseData + jsonSerializationWriter.WriteProperty("extension", telemetryItem.Extension); + jsonSerializationWriter.WriteEndObject(); // data } else if (telemetryItem is PageViewTelemetry) { PageViewTelemetry pvTelemetry = telemetryItem as PageViewTelemetry; Utils.CopyDictionary(telemetryItem.Context.GlobalProperties, pvTelemetry.Data.properties); + + jsonSerializationWriter.WriteProperty("name", telemetryItem.WriteTelemetryName(PageViewTelemetry.TelemetryName)); + telemetryItem.WriteEnvelopeProperties(jsonSerializationWriter); + jsonSerializationWriter.WriteStartObject("data"); + jsonSerializationWriter.WriteProperty("baseType", pvTelemetry.BaseType); + jsonSerializationWriter.WriteStartObject("baseData"); + telemetryItem.SerializeData(jsonSerializationWriter); + jsonSerializationWriter.WriteEndObject(); // baseData + jsonSerializationWriter.WriteProperty("extension", telemetryItem.Extension); + jsonSerializationWriter.WriteEndObject(); // data } else if (telemetryItem is PageViewPerformanceTelemetry) { PageViewPerformanceTelemetry pvptelemetry = telemetryItem as PageViewPerformanceTelemetry; Utils.CopyDictionary(telemetryItem.Context.GlobalProperties, pvptelemetry.Data.properties); + + jsonSerializationWriter.WriteProperty("name", telemetryItem.WriteTelemetryName(PageViewPerformanceTelemetry.TelemetryName)); + telemetryItem.WriteEnvelopeProperties(jsonSerializationWriter); + jsonSerializationWriter.WriteStartObject("data"); + jsonSerializationWriter.WriteProperty("baseType", PageViewPerformanceTelemetry.BaseType); + jsonSerializationWriter.WriteStartObject("baseData"); + telemetryItem.SerializeData(jsonSerializationWriter); + jsonSerializationWriter.WriteEndObject(); // baseData + jsonSerializationWriter.WriteProperty("extension", telemetryItem.Extension); + jsonSerializationWriter.WriteEndObject(); // data } else if (telemetryItem is DependencyTelemetry) { DependencyTelemetry depTelemetry = telemetryItem as DependencyTelemetry; Utils.CopyDictionary(telemetryItem.Context.GlobalProperties, depTelemetry.InternalData.properties); + + jsonSerializationWriter.WriteProperty("name", telemetryItem.WriteTelemetryName(DependencyTelemetry.TelemetryName)); + telemetryItem.WriteEnvelopeProperties(jsonSerializationWriter); + jsonSerializationWriter.WriteStartObject("data"); + jsonSerializationWriter.WriteProperty("baseType", depTelemetry.BaseType); + jsonSerializationWriter.WriteStartObject("baseData"); + telemetryItem.SerializeData(jsonSerializationWriter); + jsonSerializationWriter.WriteEndObject(); // baseData + jsonSerializationWriter.WriteProperty("extension", telemetryItem.Extension); + jsonSerializationWriter.WriteEndObject(); // data } else if (telemetryItem is RequestTelemetry) { RequestTelemetry reqTelemetry = telemetryItem as RequestTelemetry; Utils.CopyDictionary(telemetryItem.Context.GlobalProperties, reqTelemetry.Data.properties); + + jsonSerializationWriter.WriteProperty("name", telemetryItem.WriteTelemetryName(RequestTelemetry.TelemetryName)); + telemetryItem.WriteEnvelopeProperties(jsonSerializationWriter); + jsonSerializationWriter.WriteStartObject("data"); + jsonSerializationWriter.WriteProperty("baseType", reqTelemetry.BaseType); + jsonSerializationWriter.WriteStartObject("baseData"); + telemetryItem.SerializeData(jsonSerializationWriter); + jsonSerializationWriter.WriteEndObject(); // baseData + jsonSerializationWriter.WriteProperty("extension", telemetryItem.Extension); + jsonSerializationWriter.WriteEndObject(); // data } #pragma warning disable 618 else if (telemetryItem is PerformanceCounterTelemetry) { PerformanceCounterTelemetry pcTelemetry = telemetryItem as PerformanceCounterTelemetry; Utils.CopyDictionary(telemetryItem.Context.GlobalProperties, pcTelemetry.Properties); + + jsonSerializationWriter.WriteProperty("name", telemetryItem.WriteTelemetryName(MetricTelemetry.TelemetryName)); + telemetryItem.WriteEnvelopeProperties(jsonSerializationWriter); + jsonSerializationWriter.WriteStartObject("data"); + jsonSerializationWriter.WriteProperty("baseType", pcTelemetry.Data.BaseType); + jsonSerializationWriter.WriteStartObject("baseData"); + telemetryItem.SerializeData(jsonSerializationWriter); + jsonSerializationWriter.WriteEndObject(); // baseData + jsonSerializationWriter.WriteProperty("extension", telemetryItem.Extension); + jsonSerializationWriter.WriteEndObject(); // data + } + else if (telemetryItem is SessionStateTelemetry) + { + SessionStateTelemetry ssTelemetry = telemetryItem as SessionStateTelemetry; + + jsonSerializationWriter.WriteProperty("name", telemetryItem.WriteTelemetryName(EventTelemetry.TelemetryName)); + telemetryItem.WriteEnvelopeProperties(jsonSerializationWriter); + jsonSerializationWriter.WriteStartObject("data"); + jsonSerializationWriter.WriteProperty("baseType", ssTelemetry.Data.BaseType); + jsonSerializationWriter.WriteStartObject("baseData"); + telemetryItem.SerializeData(jsonSerializationWriter); + jsonSerializationWriter.WriteEndObject(); // baseData + jsonSerializationWriter.WriteProperty("extension", telemetryItem.Extension); + jsonSerializationWriter.WriteEndObject(); // data } #pragma warning restore 618 - else if (telemetryItem is TraceTelemetry) + else if (telemetryItem is TraceTelemetry) { TraceTelemetry traceTelemetry = telemetryItem as TraceTelemetry; Utils.CopyDictionary(telemetryItem.Context.GlobalProperties, traceTelemetry.Data.properties); + + jsonSerializationWriter.WriteProperty("name", telemetryItem.WriteTelemetryName(TraceTelemetry.TelemetryName)); + telemetryItem.WriteEnvelopeProperties(jsonSerializationWriter); + jsonSerializationWriter.WriteStartObject("data"); + jsonSerializationWriter.WriteProperty("baseType", traceTelemetry.BaseType); + jsonSerializationWriter.WriteStartObject("baseData"); + telemetryItem.SerializeData(jsonSerializationWriter); + jsonSerializationWriter.WriteEndObject(); // baseData + jsonSerializationWriter.WriteProperty("extension", telemetryItem.Extension); + jsonSerializationWriter.WriteEndObject(); // data } else if (telemetryItem is AvailabilityTelemetry) { AvailabilityTelemetry availabilityTelemetry = telemetryItem as AvailabilityTelemetry; Utils.CopyDictionary(telemetryItem.Context.GlobalProperties, availabilityTelemetry.Data.properties); + + jsonSerializationWriter.WriteProperty("name", telemetryItem.WriteTelemetryName(AvailabilityTelemetry.TelemetryName)); + telemetryItem.WriteEnvelopeProperties(jsonSerializationWriter); + jsonSerializationWriter.WriteStartObject("data"); + jsonSerializationWriter.WriteProperty("baseType", availabilityTelemetry.BaseType); + jsonSerializationWriter.WriteStartObject("baseData"); + telemetryItem.SerializeData(jsonSerializationWriter); + jsonSerializationWriter.WriteEndObject(); // baseData + jsonSerializationWriter.WriteProperty("extension", telemetryItem.Extension); + jsonSerializationWriter.WriteEndObject(); // data } - - jsonSerializationWriter.WriteStartObject(); - telemetryItem.Serialize(jsonSerializationWriter); + jsonSerializationWriter.WriteEndObject(); } diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/OperationTelemetry.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/OperationTelemetry.cs index 72fde57cae..c5c5e5189c 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/OperationTelemetry.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/OperationTelemetry.cs @@ -99,9 +99,6 @@ void ITelemetry.Sanitize() /// A cloned instance. public abstract ITelemetry DeepClone(); - /// - public abstract void Serialize(ISerializationWriter serializationWriter); - /// public abstract void SerializeData(ISerializationWriter serializationWriter); From ca64affe2c07d7ecc796e3bcbebeefb8de7ceff8 Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Tue, 14 Aug 2018 09:48:06 -0700 Subject: [PATCH 72/74] Small refactoring to move duplicated code to common method --- .../Implementation/JsonSerializer.cs | 232 ++++++------------ 1 file changed, 78 insertions(+), 154 deletions(-) diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs index b17b565b63..0fd4dc7911 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs @@ -159,173 +159,97 @@ private static void SerializeTelemetryItem(ITelemetry telemetryItem, JsonSeriali jsonSerializationWriter.WriteStartObject(); if (telemetryItem is EventTelemetry) - { - EventTelemetry eventTelemetry = telemetryItem as EventTelemetry; - Utils.CopyDictionary(telemetryItem.Context.GlobalProperties, eventTelemetry.Data.properties); + { + EventTelemetry eventTelemetry = telemetryItem as EventTelemetry; + Utils.CopyDictionary(telemetryItem.Context.GlobalProperties, eventTelemetry.Data.properties); - jsonSerializationWriter.WriteProperty("name", telemetryItem.WriteTelemetryName(EventTelemetry.TelemetryName)); - telemetryItem.WriteEnvelopeProperties(jsonSerializationWriter); - jsonSerializationWriter.WriteStartObject("data"); - jsonSerializationWriter.WriteProperty("baseType", eventTelemetry.BaseType); - jsonSerializationWriter.WriteStartObject("baseData"); - telemetryItem.SerializeData(jsonSerializationWriter); - jsonSerializationWriter.WriteEndObject(); // baseData - jsonSerializationWriter.WriteProperty("extension", telemetryItem.Extension); - jsonSerializationWriter.WriteEndObject(); // data - } - else if (telemetryItem is ExceptionTelemetry) - { - ExceptionTelemetry exTelemetry = telemetryItem as ExceptionTelemetry; - Utils.CopyDictionary(telemetryItem.Context.GlobalProperties, exTelemetry.Data.Data.properties); + SerializeHelper(telemetryItem, jsonSerializationWriter, eventTelemetry.BaseType, EventTelemetry.TelemetryName); + } + else if (telemetryItem is ExceptionTelemetry) + { + ExceptionTelemetry exTelemetry = telemetryItem as ExceptionTelemetry; + Utils.CopyDictionary(telemetryItem.Context.GlobalProperties, exTelemetry.Data.Data.properties); - jsonSerializationWriter.WriteProperty("name", telemetryItem.WriteTelemetryName(ExceptionTelemetry.TelemetryName)); - telemetryItem.WriteEnvelopeProperties(jsonSerializationWriter); - jsonSerializationWriter.WriteStartObject("data"); - jsonSerializationWriter.WriteProperty("baseType", exTelemetry.BaseType); - jsonSerializationWriter.WriteStartObject("baseData"); - telemetryItem.SerializeData(jsonSerializationWriter); - jsonSerializationWriter.WriteEndObject(); // baseData - jsonSerializationWriter.WriteProperty("extension", telemetryItem.Extension); - jsonSerializationWriter.WriteEndObject(); // data - } - else if (telemetryItem is MetricTelemetry) - { - MetricTelemetry mTelemetry = telemetryItem as MetricTelemetry; - Utils.CopyDictionary(telemetryItem.Context.GlobalProperties, mTelemetry.Data.properties); + SerializeHelper(telemetryItem, jsonSerializationWriter, exTelemetry.BaseType, ExceptionTelemetry.TelemetryName); + } + else if (telemetryItem is MetricTelemetry) + { + MetricTelemetry mTelemetry = telemetryItem as MetricTelemetry; + Utils.CopyDictionary(telemetryItem.Context.GlobalProperties, mTelemetry.Data.properties); - jsonSerializationWriter.WriteProperty("name", telemetryItem.WriteTelemetryName(MetricTelemetry.TelemetryName)); - telemetryItem.WriteEnvelopeProperties(jsonSerializationWriter); - jsonSerializationWriter.WriteStartObject("data"); - jsonSerializationWriter.WriteProperty("baseType", mTelemetry.BaseType); - jsonSerializationWriter.WriteStartObject("baseData"); - telemetryItem.SerializeData(jsonSerializationWriter); - jsonSerializationWriter.WriteEndObject(); // baseData - jsonSerializationWriter.WriteProperty("extension", telemetryItem.Extension); - jsonSerializationWriter.WriteEndObject(); // data - } - else if (telemetryItem is PageViewTelemetry) - { - PageViewTelemetry pvTelemetry = telemetryItem as PageViewTelemetry; - Utils.CopyDictionary(telemetryItem.Context.GlobalProperties, pvTelemetry.Data.properties); + SerializeHelper(telemetryItem, jsonSerializationWriter, mTelemetry.BaseType, MetricTelemetry.TelemetryName); + } + else if (telemetryItem is PageViewTelemetry) + { + PageViewTelemetry pvTelemetry = telemetryItem as PageViewTelemetry; + Utils.CopyDictionary(telemetryItem.Context.GlobalProperties, pvTelemetry.Data.properties); - jsonSerializationWriter.WriteProperty("name", telemetryItem.WriteTelemetryName(PageViewTelemetry.TelemetryName)); - telemetryItem.WriteEnvelopeProperties(jsonSerializationWriter); - jsonSerializationWriter.WriteStartObject("data"); - jsonSerializationWriter.WriteProperty("baseType", pvTelemetry.BaseType); - jsonSerializationWriter.WriteStartObject("baseData"); - telemetryItem.SerializeData(jsonSerializationWriter); - jsonSerializationWriter.WriteEndObject(); // baseData - jsonSerializationWriter.WriteProperty("extension", telemetryItem.Extension); - jsonSerializationWriter.WriteEndObject(); // data - } - else if (telemetryItem is PageViewPerformanceTelemetry) - { - PageViewPerformanceTelemetry pvptelemetry = telemetryItem as PageViewPerformanceTelemetry; - Utils.CopyDictionary(telemetryItem.Context.GlobalProperties, pvptelemetry.Data.properties); + SerializeHelper(telemetryItem, jsonSerializationWriter, pvTelemetry.BaseType, PageViewTelemetry.TelemetryName); + } + else if (telemetryItem is PageViewPerformanceTelemetry) + { + PageViewPerformanceTelemetry pvptelemetry = telemetryItem as PageViewPerformanceTelemetry; + Utils.CopyDictionary(telemetryItem.Context.GlobalProperties, pvptelemetry.Data.properties); - jsonSerializationWriter.WriteProperty("name", telemetryItem.WriteTelemetryName(PageViewPerformanceTelemetry.TelemetryName)); - telemetryItem.WriteEnvelopeProperties(jsonSerializationWriter); - jsonSerializationWriter.WriteStartObject("data"); - jsonSerializationWriter.WriteProperty("baseType", PageViewPerformanceTelemetry.BaseType); - jsonSerializationWriter.WriteStartObject("baseData"); - telemetryItem.SerializeData(jsonSerializationWriter); - jsonSerializationWriter.WriteEndObject(); // baseData - jsonSerializationWriter.WriteProperty("extension", telemetryItem.Extension); - jsonSerializationWriter.WriteEndObject(); // data - } - else if (telemetryItem is DependencyTelemetry) - { - DependencyTelemetry depTelemetry = telemetryItem as DependencyTelemetry; - Utils.CopyDictionary(telemetryItem.Context.GlobalProperties, depTelemetry.InternalData.properties); + SerializeHelper(telemetryItem, jsonSerializationWriter, PageViewPerformanceTelemetry.BaseType, PageViewPerformanceTelemetry.TelemetryName); + } + else if (telemetryItem is DependencyTelemetry) + { + DependencyTelemetry depTelemetry = telemetryItem as DependencyTelemetry; + Utils.CopyDictionary(telemetryItem.Context.GlobalProperties, depTelemetry.InternalData.properties); - jsonSerializationWriter.WriteProperty("name", telemetryItem.WriteTelemetryName(DependencyTelemetry.TelemetryName)); - telemetryItem.WriteEnvelopeProperties(jsonSerializationWriter); - jsonSerializationWriter.WriteStartObject("data"); - jsonSerializationWriter.WriteProperty("baseType", depTelemetry.BaseType); - jsonSerializationWriter.WriteStartObject("baseData"); - telemetryItem.SerializeData(jsonSerializationWriter); - jsonSerializationWriter.WriteEndObject(); // baseData - jsonSerializationWriter.WriteProperty("extension", telemetryItem.Extension); - jsonSerializationWriter.WriteEndObject(); // data - } - else if (telemetryItem is RequestTelemetry) - { - RequestTelemetry reqTelemetry = telemetryItem as RequestTelemetry; - Utils.CopyDictionary(telemetryItem.Context.GlobalProperties, reqTelemetry.Data.properties); + SerializeHelper(telemetryItem, jsonSerializationWriter, depTelemetry.BaseType, DependencyTelemetry.TelemetryName); + } + else if (telemetryItem is RequestTelemetry) + { + RequestTelemetry reqTelemetry = telemetryItem as RequestTelemetry; + Utils.CopyDictionary(telemetryItem.Context.GlobalProperties, reqTelemetry.Data.properties); - jsonSerializationWriter.WriteProperty("name", telemetryItem.WriteTelemetryName(RequestTelemetry.TelemetryName)); - telemetryItem.WriteEnvelopeProperties(jsonSerializationWriter); - jsonSerializationWriter.WriteStartObject("data"); - jsonSerializationWriter.WriteProperty("baseType", reqTelemetry.BaseType); - jsonSerializationWriter.WriteStartObject("baseData"); - telemetryItem.SerializeData(jsonSerializationWriter); - jsonSerializationWriter.WriteEndObject(); // baseData - jsonSerializationWriter.WriteProperty("extension", telemetryItem.Extension); - jsonSerializationWriter.WriteEndObject(); // data - } + SerializeHelper(telemetryItem, jsonSerializationWriter, reqTelemetry.BaseType, RequestTelemetry.TelemetryName); + } #pragma warning disable 618 - else if (telemetryItem is PerformanceCounterTelemetry) - { - PerformanceCounterTelemetry pcTelemetry = telemetryItem as PerformanceCounterTelemetry; - Utils.CopyDictionary(telemetryItem.Context.GlobalProperties, pcTelemetry.Properties); - - jsonSerializationWriter.WriteProperty("name", telemetryItem.WriteTelemetryName(MetricTelemetry.TelemetryName)); - telemetryItem.WriteEnvelopeProperties(jsonSerializationWriter); - jsonSerializationWriter.WriteStartObject("data"); - jsonSerializationWriter.WriteProperty("baseType", pcTelemetry.Data.BaseType); - jsonSerializationWriter.WriteStartObject("baseData"); - telemetryItem.SerializeData(jsonSerializationWriter); - jsonSerializationWriter.WriteEndObject(); // baseData - jsonSerializationWriter.WriteProperty("extension", telemetryItem.Extension); - jsonSerializationWriter.WriteEndObject(); // data - } - else if (telemetryItem is SessionStateTelemetry) - { - SessionStateTelemetry ssTelemetry = telemetryItem as SessionStateTelemetry; + else if (telemetryItem is PerformanceCounterTelemetry) + { + PerformanceCounterTelemetry pcTelemetry = telemetryItem as PerformanceCounterTelemetry; + Utils.CopyDictionary(telemetryItem.Context.GlobalProperties, pcTelemetry.Properties); - jsonSerializationWriter.WriteProperty("name", telemetryItem.WriteTelemetryName(EventTelemetry.TelemetryName)); - telemetryItem.WriteEnvelopeProperties(jsonSerializationWriter); - jsonSerializationWriter.WriteStartObject("data"); - jsonSerializationWriter.WriteProperty("baseType", ssTelemetry.Data.BaseType); - jsonSerializationWriter.WriteStartObject("baseData"); - telemetryItem.SerializeData(jsonSerializationWriter); - jsonSerializationWriter.WriteEndObject(); // baseData - jsonSerializationWriter.WriteProperty("extension", telemetryItem.Extension); - jsonSerializationWriter.WriteEndObject(); // data - } + SerializeHelper(telemetryItem, jsonSerializationWriter, pcTelemetry.Data.BaseType, MetricTelemetry.TelemetryName); + } + else if (telemetryItem is SessionStateTelemetry) + { + SessionStateTelemetry ssTelemetry = telemetryItem as SessionStateTelemetry; + SerializeHelper(telemetryItem, jsonSerializationWriter, ssTelemetry.Data.BaseType, EventTelemetry.TelemetryName); + } #pragma warning restore 618 - else if (telemetryItem is TraceTelemetry) - { - TraceTelemetry traceTelemetry = telemetryItem as TraceTelemetry; - Utils.CopyDictionary(telemetryItem.Context.GlobalProperties, traceTelemetry.Data.properties); + else if (telemetryItem is TraceTelemetry) + { + TraceTelemetry traceTelemetry = telemetryItem as TraceTelemetry; + Utils.CopyDictionary(telemetryItem.Context.GlobalProperties, traceTelemetry.Data.properties); - jsonSerializationWriter.WriteProperty("name", telemetryItem.WriteTelemetryName(TraceTelemetry.TelemetryName)); - telemetryItem.WriteEnvelopeProperties(jsonSerializationWriter); - jsonSerializationWriter.WriteStartObject("data"); - jsonSerializationWriter.WriteProperty("baseType", traceTelemetry.BaseType); - jsonSerializationWriter.WriteStartObject("baseData"); - telemetryItem.SerializeData(jsonSerializationWriter); - jsonSerializationWriter.WriteEndObject(); // baseData - jsonSerializationWriter.WriteProperty("extension", telemetryItem.Extension); - jsonSerializationWriter.WriteEndObject(); // data - } - else if (telemetryItem is AvailabilityTelemetry) - { - AvailabilityTelemetry availabilityTelemetry = telemetryItem as AvailabilityTelemetry; - Utils.CopyDictionary(telemetryItem.Context.GlobalProperties, availabilityTelemetry.Data.properties); + SerializeHelper(telemetryItem, jsonSerializationWriter, traceTelemetry.BaseType, TraceTelemetry.TelemetryName); + } + else if (telemetryItem is AvailabilityTelemetry) + { + AvailabilityTelemetry availabilityTelemetry = telemetryItem as AvailabilityTelemetry; + Utils.CopyDictionary(telemetryItem.Context.GlobalProperties, availabilityTelemetry.Data.properties); - jsonSerializationWriter.WriteProperty("name", telemetryItem.WriteTelemetryName(AvailabilityTelemetry.TelemetryName)); - telemetryItem.WriteEnvelopeProperties(jsonSerializationWriter); - jsonSerializationWriter.WriteStartObject("data"); - jsonSerializationWriter.WriteProperty("baseType", availabilityTelemetry.BaseType); - jsonSerializationWriter.WriteStartObject("baseData"); - telemetryItem.SerializeData(jsonSerializationWriter); - jsonSerializationWriter.WriteEndObject(); // baseData - jsonSerializationWriter.WriteProperty("extension", telemetryItem.Extension); - jsonSerializationWriter.WriteEndObject(); // data - } + SerializeHelper(telemetryItem, jsonSerializationWriter, availabilityTelemetry.BaseType, AvailabilityTelemetry.TelemetryName); + } - jsonSerializationWriter.WriteEndObject(); + jsonSerializationWriter.WriteEndObject(); + } + + private static void SerializeHelper(ITelemetry telemetryItem, JsonSerializationWriter jsonSerializationWriter, string baseType, string telemetryName) + { + jsonSerializationWriter.WriteProperty("name", telemetryItem.WriteTelemetryName(telemetryName)); + telemetryItem.WriteEnvelopeProperties(jsonSerializationWriter); + jsonSerializationWriter.WriteStartObject("data"); + jsonSerializationWriter.WriteProperty("baseType", baseType); + jsonSerializationWriter.WriteStartObject("baseData"); + telemetryItem.SerializeData(jsonSerializationWriter); + jsonSerializationWriter.WriteEndObject(); // baseData + jsonSerializationWriter.WriteProperty("extension", telemetryItem.Extension); + jsonSerializationWriter.WriteEndObject(); // data } /// From f3359cd4d8a8a42054adad07d353ef281fdf93ee Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Tue, 14 Aug 2018 10:47:15 -0700 Subject: [PATCH 73/74] Fixed a bug in WriteProperty which caused invalid json serialization --- .../Extensibility/Implementation/JsonSerializationWriter.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializationWriter.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializationWriter.cs index 37f02ef054..59e6326685 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializationWriter.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializationWriter.cs @@ -154,10 +154,8 @@ public void WriteProperty(string name, ISerializableWithWriter value) public void WriteProperty(ISerializableWithWriter value) { if (value != null) - { - this.WriteStartObject(); - value.Serialize(this); - this.WriteEndObject(); + { + value.Serialize(this); } } From 4f8f53ba7e60c1408c6a93376a793a7af5f3e5c1 Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Tue, 14 Aug 2018 11:29:57 -0700 Subject: [PATCH 74/74] Add verbose trace if unable to serialize a type. Update changelog.md --- CHANGELOG.md | 2 ++ .../Extensibility/Implementation/JsonSerializer.cs | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ba0ca916e..d34d65272b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ This changelog will be used to generate documentation on [release notes page](ht ## Version 2.8.0-beta1 - [Add a new distict properties collection, GlobalProperties, on TelemetryContext, and obsolete the Properties on TelemetryContext.](https://github.com/Microsoft/ApplicationInsights-dotnet/issues/820) - [Added support for strongly typed extensibility for Telemetry types using IExtension.](https://github.com/Microsoft/ApplicationInsights-dotnet/issues/871) +- [New method SerializeData(ISerializationWriter writer) defined in ITelemetry. All existing types implement this method to emit information about it's fields to channels who can serialize this data] + (continuation of https://github.com/Microsoft/ApplicationInsights-dotnet/issues/871) - [Allow to track PageViewPerformance data type](https://github.com/Microsoft/ApplicationInsights-dotnet/issues/673). - Added method `ExceptionDetailsInfoList` on `ExceptionTelemetry` class that gives control to user to update exception message and exception type of underlying `System.Exception` object that user wants to send to telemetry. Related discussion is [here](https://github.com/Microsoft/ApplicationInsights-dotnet/issues/498). diff --git a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs index 0fd4dc7911..ae3c00c991 100644 --- a/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs +++ b/src/Microsoft.ApplicationInsights/Extensibility/Implementation/JsonSerializer.cs @@ -235,7 +235,12 @@ private static void SerializeTelemetryItem(ITelemetry telemetryItem, JsonSeriali SerializeHelper(telemetryItem, jsonSerializationWriter, availabilityTelemetry.BaseType, AvailabilityTelemetry.TelemetryName); } - + else + { + string msg = string.Format(CultureInfo.InvariantCulture, "Unknown telemetry type: {0}", telemetryItem.GetType()); + CoreEventSource.Log.LogVerbose(msg); + } + jsonSerializationWriter.WriteEndObject(); }