From b330514f514ff7318353b23ba491c2ca9cb2aa7b Mon Sep 17 00:00:00 2001 From: Rajkumar Rangaraj Date: Thu, 26 Mar 2020 15:25:45 -0700 Subject: [PATCH] Removed MaxTraceSeverityLevelValuesToDiscover --- .../net45/PublicAPI.Unshipped.txt | 2 - .../net46/PublicAPI.Unshipped.txt | 2 - .../netstandard1.3/PublicAPI.Unshipped.txt | 2 - .../netstandard2.0/PublicAPI.Unshipped.txt | 2 - .../AutocollectedMetricsExtractorTest.cs | 63 ------------------- .../AutocollectedMetricsExtractor.cs | 23 ------- .../MetricTerms.cs | 1 + .../TraceSeverityLevelDimensionExtractor.cs | 8 +-- .../TraceMetricsExtractor.cs | 12 +--- 9 files changed, 6 insertions(+), 109 deletions(-) diff --git a/.publicApi/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Unshipped.txt b/.publicApi/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Unshipped.txt index 670a9b299..849e432ac 100644 --- a/.publicApi/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Unshipped.txt +++ b/.publicApi/Microsoft.ApplicationInsights.dll/net45/PublicAPI.Unshipped.txt @@ -2,8 +2,6 @@ Microsoft.ApplicationInsights.Extensibility.AutocollectedMetricsExtractor.MaxTra Microsoft.ApplicationInsights.Extensibility.AutocollectedMetricsExtractor.MaxTraceCloudRoleInstanceValuesToDiscover.set -> void Microsoft.ApplicationInsights.Extensibility.AutocollectedMetricsExtractor.MaxTraceCloudRoleNameValuesToDiscover.get -> int Microsoft.ApplicationInsights.Extensibility.AutocollectedMetricsExtractor.MaxTraceCloudRoleNameValuesToDiscover.set -> void -Microsoft.ApplicationInsights.Extensibility.AutocollectedMetricsExtractor.MaxTraceSeverityLevelValuesToDiscover.get -> int -Microsoft.ApplicationInsights.Extensibility.AutocollectedMetricsExtractor.MaxTraceSeverityLevelValuesToDiscover.set -> void Microsoft.ApplicationInsights.Extensibility.AutocollectedMetricsExtractor.MaxExceptionCloudRoleInstanceValuesToDiscover.get -> int Microsoft.ApplicationInsights.Extensibility.AutocollectedMetricsExtractor.MaxExceptionCloudRoleInstanceValuesToDiscover.set -> void Microsoft.ApplicationInsights.Extensibility.AutocollectedMetricsExtractor.MaxExceptionCloudRoleNameValuesToDiscover.get -> int diff --git a/.publicApi/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Unshipped.txt b/.publicApi/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Unshipped.txt index 670a9b299..849e432ac 100644 --- a/.publicApi/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Unshipped.txt +++ b/.publicApi/Microsoft.ApplicationInsights.dll/net46/PublicAPI.Unshipped.txt @@ -2,8 +2,6 @@ Microsoft.ApplicationInsights.Extensibility.AutocollectedMetricsExtractor.MaxTra Microsoft.ApplicationInsights.Extensibility.AutocollectedMetricsExtractor.MaxTraceCloudRoleInstanceValuesToDiscover.set -> void Microsoft.ApplicationInsights.Extensibility.AutocollectedMetricsExtractor.MaxTraceCloudRoleNameValuesToDiscover.get -> int Microsoft.ApplicationInsights.Extensibility.AutocollectedMetricsExtractor.MaxTraceCloudRoleNameValuesToDiscover.set -> void -Microsoft.ApplicationInsights.Extensibility.AutocollectedMetricsExtractor.MaxTraceSeverityLevelValuesToDiscover.get -> int -Microsoft.ApplicationInsights.Extensibility.AutocollectedMetricsExtractor.MaxTraceSeverityLevelValuesToDiscover.set -> void Microsoft.ApplicationInsights.Extensibility.AutocollectedMetricsExtractor.MaxExceptionCloudRoleInstanceValuesToDiscover.get -> int Microsoft.ApplicationInsights.Extensibility.AutocollectedMetricsExtractor.MaxExceptionCloudRoleInstanceValuesToDiscover.set -> void Microsoft.ApplicationInsights.Extensibility.AutocollectedMetricsExtractor.MaxExceptionCloudRoleNameValuesToDiscover.get -> int diff --git a/.publicApi/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Unshipped.txt b/.publicApi/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Unshipped.txt index 670a9b299..849e432ac 100644 --- a/.publicApi/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Unshipped.txt +++ b/.publicApi/Microsoft.ApplicationInsights.dll/netstandard1.3/PublicAPI.Unshipped.txt @@ -2,8 +2,6 @@ Microsoft.ApplicationInsights.Extensibility.AutocollectedMetricsExtractor.MaxTra Microsoft.ApplicationInsights.Extensibility.AutocollectedMetricsExtractor.MaxTraceCloudRoleInstanceValuesToDiscover.set -> void Microsoft.ApplicationInsights.Extensibility.AutocollectedMetricsExtractor.MaxTraceCloudRoleNameValuesToDiscover.get -> int Microsoft.ApplicationInsights.Extensibility.AutocollectedMetricsExtractor.MaxTraceCloudRoleNameValuesToDiscover.set -> void -Microsoft.ApplicationInsights.Extensibility.AutocollectedMetricsExtractor.MaxTraceSeverityLevelValuesToDiscover.get -> int -Microsoft.ApplicationInsights.Extensibility.AutocollectedMetricsExtractor.MaxTraceSeverityLevelValuesToDiscover.set -> void Microsoft.ApplicationInsights.Extensibility.AutocollectedMetricsExtractor.MaxExceptionCloudRoleInstanceValuesToDiscover.get -> int Microsoft.ApplicationInsights.Extensibility.AutocollectedMetricsExtractor.MaxExceptionCloudRoleInstanceValuesToDiscover.set -> void Microsoft.ApplicationInsights.Extensibility.AutocollectedMetricsExtractor.MaxExceptionCloudRoleNameValuesToDiscover.get -> int diff --git a/.publicApi/Microsoft.ApplicationInsights.dll/netstandard2.0/PublicAPI.Unshipped.txt b/.publicApi/Microsoft.ApplicationInsights.dll/netstandard2.0/PublicAPI.Unshipped.txt index 670a9b299..849e432ac 100644 --- a/.publicApi/Microsoft.ApplicationInsights.dll/netstandard2.0/PublicAPI.Unshipped.txt +++ b/.publicApi/Microsoft.ApplicationInsights.dll/netstandard2.0/PublicAPI.Unshipped.txt @@ -2,8 +2,6 @@ Microsoft.ApplicationInsights.Extensibility.AutocollectedMetricsExtractor.MaxTra Microsoft.ApplicationInsights.Extensibility.AutocollectedMetricsExtractor.MaxTraceCloudRoleInstanceValuesToDiscover.set -> void Microsoft.ApplicationInsights.Extensibility.AutocollectedMetricsExtractor.MaxTraceCloudRoleNameValuesToDiscover.get -> int Microsoft.ApplicationInsights.Extensibility.AutocollectedMetricsExtractor.MaxTraceCloudRoleNameValuesToDiscover.set -> void -Microsoft.ApplicationInsights.Extensibility.AutocollectedMetricsExtractor.MaxTraceSeverityLevelValuesToDiscover.get -> int -Microsoft.ApplicationInsights.Extensibility.AutocollectedMetricsExtractor.MaxTraceSeverityLevelValuesToDiscover.set -> void Microsoft.ApplicationInsights.Extensibility.AutocollectedMetricsExtractor.MaxExceptionCloudRoleInstanceValuesToDiscover.get -> int Microsoft.ApplicationInsights.Extensibility.AutocollectedMetricsExtractor.MaxExceptionCloudRoleInstanceValuesToDiscover.set -> void Microsoft.ApplicationInsights.Extensibility.AutocollectedMetricsExtractor.MaxExceptionCloudRoleNameValuesToDiscover.get -> int diff --git a/BASE/Test/Microsoft.ApplicationInsights.Test/Microsoft.ApplicationInsights.Tests/Metrics/Extensibility/AutocollectedMetricsExtraction/AutocollectedMetricsExtractorTest.cs b/BASE/Test/Microsoft.ApplicationInsights.Test/Microsoft.ApplicationInsights.Tests/Metrics/Extensibility/AutocollectedMetricsExtraction/AutocollectedMetricsExtractorTest.cs index 5669477d6..a673d9ae9 100644 --- a/BASE/Test/Microsoft.ApplicationInsights.Test/Microsoft.ApplicationInsights.Tests/Metrics/Extensibility/AutocollectedMetricsExtraction/AutocollectedMetricsExtractorTest.cs +++ b/BASE/Test/Microsoft.ApplicationInsights.Test/Microsoft.ApplicationInsights.Tests/Metrics/Extensibility/AutocollectedMetricsExtraction/AutocollectedMetricsExtractorTest.cs @@ -1222,68 +1222,6 @@ Assert.AreEqual(4, telemetrySentToChannel.Count); } - [TestMethod] - public void Trace_TelemetryRespectsDimLimitSeverityLevel() - { - List telemetrySentToChannel = new List(); - Func extractorFactory = - (nextProc) => { - var metricExtractor = new AutocollectedMetricsExtractor(nextProc); - metricExtractor.MaxTraceSeverityLevelValuesToDiscover = 0; - return metricExtractor; - }; - - TelemetryConfiguration telemetryConfig = CreateTelemetryConfigWithExtractor(telemetrySentToChannel, extractorFactory); - using (telemetryConfig) - { - TelemetryClient client = new TelemetryClient(telemetryConfig); - // Track 3 traces with 3 different values for Severity Level - Error, Critical, Verbose. - // As MaxTraceSeverityLevelValuesToDiscover = 0, we expect all severity level to be rolled into Other - client.TrackTrace("Test 1", SeverityLevel.Error); - client.TrackTrace("Test 2", SeverityLevel.Critical); - client.TrackTrace("Test 3", SeverityLevel.Verbose); - } - - Assert.AreEqual(4, telemetrySentToChannel.Count); - - AssertEx.IsType(telemetrySentToChannel[0]); - Assert.AreEqual("Test 1", ((TraceTelemetry)telemetrySentToChannel[0]).Message); - Assert.AreEqual(true, ((TraceTelemetry)telemetrySentToChannel[0]).Properties.ContainsKey("_MS.ProcessedByMetricExtractors")); - Assert.AreEqual("(Name:'Traces', Ver:'1.1')", - ((TraceTelemetry)telemetrySentToChannel[0]).Properties["_MS.ProcessedByMetricExtractors"]); - - AssertEx.IsType(telemetrySentToChannel[1]); - Assert.AreEqual("Test 2", ((TraceTelemetry)telemetrySentToChannel[1]).Message); - Assert.AreEqual(true, ((TraceTelemetry)telemetrySentToChannel[1]).Properties.ContainsKey("_MS.ProcessedByMetricExtractors")); - Assert.AreEqual("(Name:'Traces', Ver:'1.1')", - ((TraceTelemetry)telemetrySentToChannel[1]).Properties["_MS.ProcessedByMetricExtractors"]); - - AssertEx.IsType(telemetrySentToChannel[2]); - Assert.AreEqual("Test 3", ((TraceTelemetry)telemetrySentToChannel[2]).Message); - Assert.AreEqual(true, ((TraceTelemetry)telemetrySentToChannel[2]).Properties.ContainsKey("_MS.ProcessedByMetricExtractors")); - Assert.AreEqual("(Name:'Traces', Ver:'1.1')", - ((TraceTelemetry)telemetrySentToChannel[2]).Properties["_MS.ProcessedByMetricExtractors"]); - - AssertEx.IsType(telemetrySentToChannel[3]); - var metricTel = telemetrySentToChannel[3] as MetricTelemetry; - // validate standard fields - Assert.IsTrue(metricTel.Properties.ContainsKey("_MS.AggregationIntervalMs")); - Assert.IsTrue(metricTel.Context.GlobalProperties.ContainsKey("_MS.IsAutocollected")); - Assert.AreEqual("True", metricTel.Context.GlobalProperties["_MS.IsAutocollected"]); - Assert.IsTrue(metricTel.Context.GlobalProperties.ContainsKey("_MS.MetricId")); - Assert.AreEqual("traces/count", metricTel.Context.GlobalProperties["_MS.MetricId"]); - - // validate dimensions exist - Assert.AreEqual(true, metricTel.Properties.ContainsKey("trace/severityLevel")); - Assert.AreEqual(true, metricTel.Properties.ContainsKey("cloud/roleInstance")); - Assert.AreEqual(true, metricTel.Properties.ContainsKey("cloud/roleName")); - Assert.AreEqual(true, metricTel.Properties.ContainsKey("operation/synthetic")); - - var resultCodeDimension = metricTel.Properties["trace/severityLevel"]; - // As MaxTraceSeverityLevelValuesToDiscover = 0, we expect all severity level to be rolled into Other - Assert.AreEqual("Other", resultCodeDimension); - } - [TestMethod] public void Trace_TelemetryRespectsDimLimitCloudRoleInstance() { @@ -1542,7 +1480,6 @@ public void Trace_DefaultDimensionLimitsValidation() { var traceExtractor = new TraceMetricsExtractor(); - Assert.AreEqual(5, traceExtractor.MaxTraceSeverityLevelValuesToDiscover); Assert.AreEqual(2, traceExtractor.MaxCloudRoleNameValuesToDiscover); Assert.AreEqual(2, traceExtractor.MaxCloudRoleInstanceValuesToDiscover); } diff --git a/BASE/src/Microsoft.ApplicationInsights/Metrics/Extensibility/AutocollectedMetricsExtraction/AutocollectedMetricsExtractor.cs b/BASE/src/Microsoft.ApplicationInsights/Metrics/Extensibility/AutocollectedMetricsExtraction/AutocollectedMetricsExtractor.cs index 93ac68dda..cb9b04ad8 100644 --- a/BASE/src/Microsoft.ApplicationInsights/Metrics/Extensibility/AutocollectedMetricsExtraction/AutocollectedMetricsExtractor.cs +++ b/BASE/src/Microsoft.ApplicationInsights/Metrics/Extensibility/AutocollectedMetricsExtraction/AutocollectedMetricsExtractor.cs @@ -290,29 +290,6 @@ } } - /// - /// Gets or sets the maximum distinct values for SeverityLevel for Trace telemetry. - /// Values encountered after this limit is hit will be collapsed into a single value DIMENSION_CAPPED. - /// Setting 0 will all values to be replaced with a single value "Other". - /// - public int MaxTraceSeverityLevelValuesToDiscover - { - get - { - return this.extractorForTraceMetrics.MaxTraceSeverityLevelValuesToDiscover; - } - - set - { - if (value < 0) - { - throw new ArgumentOutOfRangeException(nameof(value), value, "MaxTraceSeverityLevelValuesToDiscover value may not be negative."); - } - - this.extractorForTraceMetrics.MaxTraceSeverityLevelValuesToDiscover = value; - } - } - /// /// Gets or sets the maximum distinct values for CloudRoleInstance for Request telemetry. /// Values encountered after this limit is hit will be collapsed into a single value DIMENSION_CAPPED. diff --git a/BASE/src/Microsoft.ApplicationInsights/Metrics/Implementation/AutocollectedMetricsExtraction/MetricTerms.cs b/BASE/src/Microsoft.ApplicationInsights/Metrics/Implementation/AutocollectedMetricsExtraction/MetricTerms.cs index 79aa4c526..45336cb60 100644 --- a/BASE/src/Microsoft.ApplicationInsights/Metrics/Implementation/AutocollectedMetricsExtraction/MetricTerms.cs +++ b/BASE/src/Microsoft.ApplicationInsights/Metrics/Implementation/AutocollectedMetricsExtraction/MetricTerms.cs @@ -115,6 +115,7 @@ { public const string DimensionCapFallbackValue = "DIMENSION-CAPPED"; public const string Unknown = "Unknown"; + public const string Unspecified = "Unspecified"; public const string Other = "Other"; } } diff --git a/BASE/src/Microsoft.ApplicationInsights/Metrics/Implementation/AutocollectedMetricsExtraction/TraceExtractor/TraceSeverityLevelDimensionExtractor.cs b/BASE/src/Microsoft.ApplicationInsights/Metrics/Implementation/AutocollectedMetricsExtraction/TraceExtractor/TraceSeverityLevelDimensionExtractor.cs index 68a1ab9b2..e3176d5e3 100644 --- a/BASE/src/Microsoft.ApplicationInsights/Metrics/Implementation/AutocollectedMetricsExtraction/TraceExtractor/TraceSeverityLevelDimensionExtractor.cs +++ b/BASE/src/Microsoft.ApplicationInsights/Metrics/Implementation/AutocollectedMetricsExtraction/TraceExtractor/TraceSeverityLevelDimensionExtractor.cs @@ -7,18 +7,18 @@ internal class TraceSeverityLevelDimensionExtractor : IDimensionExtractor { - public int MaxValues { get; set; } + public int MaxValues { get; set; } = 6; - public string DefaultValue { get; set; } = MetricTerms.Autocollection.Common.PropertyValues.Unknown; + public string DefaultValue { get; set; } = MetricTerms.Autocollection.Common.PropertyValues.Unspecified; public string Name { get; set; } = MetricTerms.Autocollection.TraceCount.PropertyNames.SeverityLevel; public string ExtractDimension(ITelemetry item) { var trace = item as TraceTelemetry; - if (trace != null) + if (trace?.SeverityLevel != null) { - var sevLevel = (int)trace.SeverityLevel.GetValueOrDefault(); + var sevLevel = (int)trace.SeverityLevel; return sevLevel.ToString(CultureInfo.InvariantCulture); } else diff --git a/BASE/src/Microsoft.ApplicationInsights/Metrics/Implementation/AutocollectedMetricsExtraction/TraceMetricsExtractor.cs b/BASE/src/Microsoft.ApplicationInsights/Metrics/Implementation/AutocollectedMetricsExtraction/TraceMetricsExtractor.cs index ca52c6809..4c64958f5 100644 --- a/BASE/src/Microsoft.ApplicationInsights/Metrics/Implementation/AutocollectedMetricsExtraction/TraceMetricsExtractor.cs +++ b/BASE/src/Microsoft.ApplicationInsights/Metrics/Implementation/AutocollectedMetricsExtraction/TraceMetricsExtractor.cs @@ -14,11 +14,6 @@ /// internal class TraceMetricsExtractor : ISpecificAutocollectedMetricsExtractor { - /// - /// The default value for the property. - /// - public const int MaxTraceSeverityLevelValuesToDiscoverDefault = 5; - /// /// The default value for the property. /// @@ -46,11 +41,6 @@ public string ExtractorVersion { get; } = "1.1"; - /// - /// Gets or sets the maximum number of auto-discovered trace types. - /// - public int MaxTraceSeverityLevelValuesToDiscover { get; set; } = MaxTraceSeverityLevelValuesToDiscoverDefault; - /// /// Gets or sets the maximum number of auto-discovered Cloud RoleInstance values. /// @@ -76,7 +66,7 @@ if (!this.isInitialized) { this.dimensionExtractors.Add(new TraceMetricIdDimensionExtractor()); - this.dimensionExtractors.Add(new TraceSeverityLevelDimensionExtractor() { MaxValues = this.MaxTraceSeverityLevelValuesToDiscover }); + this.dimensionExtractors.Add(new TraceSeverityLevelDimensionExtractor()); this.dimensionExtractors.Add(new SyntheticDimensionExtractor()); this.dimensionExtractors.Add(new CloudRoleInstanceDimensionExtractor() { MaxValues = this.MaxCloudRoleInstanceValuesToDiscover }); this.dimensionExtractors.Add(new CloudRoleNameDimensionExtractor() { MaxValues = this.MaxCloudRoleNameValuesToDiscover });