diff --git a/src/Libraries/Microsoft.Extensions.Telemetry.Abstractions/Enrichment/EnricherExtensions.cs b/src/Libraries/Microsoft.Extensions.Telemetry.Abstractions/Enrichment/EnricherExtensions.cs index 5c682834270..651f8af35ac 100644 --- a/src/Libraries/Microsoft.Extensions.Telemetry.Abstractions/Enrichment/EnricherExtensions.cs +++ b/src/Libraries/Microsoft.Extensions.Telemetry.Abstractions/Enrichment/EnricherExtensions.cs @@ -4,6 +4,7 @@ using System; using System.Diagnostics.CodeAnalysis; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Shared.DiagnosticIds; using Microsoft.Shared.Diagnostics; namespace Microsoft.Extensions.Telemetry.Enrichment; @@ -50,7 +51,7 @@ public static IServiceCollection AddLogEnricher(this IServiceCollection services /// Enricher type. /// The value of . /// is . - [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] + [Experimental(diagnosticId: Experiments.Telemetry, UrlFormat = Experiments.UrlFormat)] public static IServiceCollection AddStaticLogEnricher(this IServiceCollection services) where T : class, IStaticLogEnricher { @@ -66,7 +67,7 @@ public static IServiceCollection AddStaticLogEnricher(this IServiceCollection /// The enricher instance to add. /// The value of . /// or are . - [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] + [Experimental(diagnosticId: Experiments.Telemetry, UrlFormat = Experiments.UrlFormat)] public static IServiceCollection AddStaticLogEnricher(this IServiceCollection services, IStaticLogEnricher enricher) { _ = Throw.IfNull(services); diff --git a/src/Libraries/Microsoft.Extensions.Telemetry.Abstractions/Enrichment/IStaticLogEnricher.cs b/src/Libraries/Microsoft.Extensions.Telemetry.Abstractions/Enrichment/IStaticLogEnricher.cs index ba5e3c35d8f..137a12a3222 100644 --- a/src/Libraries/Microsoft.Extensions.Telemetry.Abstractions/Enrichment/IStaticLogEnricher.cs +++ b/src/Libraries/Microsoft.Extensions.Telemetry.Abstractions/Enrichment/IStaticLogEnricher.cs @@ -2,13 +2,14 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics.CodeAnalysis; +using Microsoft.Shared.DiagnosticIds; namespace Microsoft.Extensions.Telemetry.Enrichment; /// /// A component that augments log records with additional properties which are unchanging over the life of the object. /// -[Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] +[Experimental(diagnosticId: Experiments.Telemetry, UrlFormat = Experiments.UrlFormat)] public interface IStaticLogEnricher { /// diff --git a/src/Libraries/Microsoft.Extensions.Telemetry.Abstractions/Logging/ILogPropertyCollector.cs b/src/Libraries/Microsoft.Extensions.Telemetry.Abstractions/Logging/ILogPropertyCollector.cs index 4b112770dfe..5e82849e854 100644 --- a/src/Libraries/Microsoft.Extensions.Telemetry.Abstractions/Logging/ILogPropertyCollector.cs +++ b/src/Libraries/Microsoft.Extensions.Telemetry.Abstractions/Logging/ILogPropertyCollector.cs @@ -4,6 +4,7 @@ using System; using System.Diagnostics.CodeAnalysis; using Microsoft.Extensions.Compliance.Classification; +using Microsoft.Shared.DiagnosticIds; namespace Microsoft.Extensions.Telemetry.Logging; @@ -36,6 +37,6 @@ public interface ILogPropertyCollector /// is empty or contains exclusively whitespace, /// or when a property of the same name has already been added. /// - [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] + [Experimental(diagnosticId: Experiments.Telemetry, UrlFormat = Experiments.UrlFormat)] void Add(string propertyName, object? propertyValue, DataClassification classification); } diff --git a/src/Libraries/Microsoft.Extensions.Telemetry.Abstractions/Logging/LogMethodHelper.cs b/src/Libraries/Microsoft.Extensions.Telemetry.Abstractions/Logging/LogMethodHelper.cs index c00059c146c..6846867a935 100644 --- a/src/Libraries/Microsoft.Extensions.Telemetry.Abstractions/Logging/LogMethodHelper.cs +++ b/src/Libraries/Microsoft.Extensions.Telemetry.Abstractions/Logging/LogMethodHelper.cs @@ -10,6 +10,7 @@ using Microsoft.Extensions.Logging; using Microsoft.Extensions.ObjectPool; using Microsoft.Extensions.Telemetry.Enrichment; +using Microsoft.Shared.DiagnosticIds; using Microsoft.Shared.Diagnostics; using Microsoft.Shared.Pools; @@ -37,7 +38,7 @@ public void Add(string propertyName, object? propertyValue) } /// - [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] + [Experimental(diagnosticId: Experiments.Telemetry, UrlFormat = Experiments.UrlFormat)] public void Add(string propertyName, object? propertyValue, DataClassification classification) => Add(propertyName, propertyValue); /// diff --git a/src/Libraries/Microsoft.Extensions.Telemetry.Abstractions/Logging/LoggerMessageHelper.cs b/src/Libraries/Microsoft.Extensions.Telemetry.Abstractions/Logging/LoggerMessageHelper.cs index d5c28de9268..8920d63caf5 100644 --- a/src/Libraries/Microsoft.Extensions.Telemetry.Abstractions/Logging/LoggerMessageHelper.cs +++ b/src/Libraries/Microsoft.Extensions.Telemetry.Abstractions/Logging/LoggerMessageHelper.cs @@ -7,6 +7,7 @@ using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using Microsoft.Extensions.ObjectPool; +using Microsoft.Shared.DiagnosticIds; using Microsoft.Shared.Pools; namespace Microsoft.Extensions.Telemetry.Logging; @@ -15,7 +16,7 @@ namespace Microsoft.Extensions.Telemetry.Logging; /// Utility type to support generated logging methods. /// [EditorBrowsable(EditorBrowsableState.Never)] -[Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] +[Experimental(diagnosticId: Experiments.Telemetry, UrlFormat = Experiments.UrlFormat)] public static class LoggerMessageHelper { [ThreadStatic] diff --git a/src/Libraries/Microsoft.Extensions.Telemetry.Abstractions/Logging/LoggerMessageState.cs b/src/Libraries/Microsoft.Extensions.Telemetry.Abstractions/Logging/LoggerMessageState.cs index ce1a0a8f42a..ac86bd9d9db 100644 --- a/src/Libraries/Microsoft.Extensions.Telemetry.Abstractions/Logging/LoggerMessageState.cs +++ b/src/Libraries/Microsoft.Extensions.Telemetry.Abstractions/Logging/LoggerMessageState.cs @@ -6,6 +6,7 @@ using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using Microsoft.Extensions.Logging; +using Microsoft.Shared.DiagnosticIds; using Microsoft.Shared.Pools; namespace Microsoft.Extensions.Telemetry.Logging; @@ -13,19 +14,25 @@ namespace Microsoft.Extensions.Telemetry.Logging; /// /// Additional state to use with . /// -[Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] +[Experimental(diagnosticId: Experiments.Telemetry, UrlFormat = Experiments.UrlFormat)] [EditorBrowsable(EditorBrowsableState.Never)] public sealed partial class LoggerMessageState { private KeyValuePair[] _properties = Array.Empty>(); + private KeyValuePair[] _redactedProperties = Array.Empty>(); private ClassifiedProperty[] _classifiedProperties = Array.Empty(); +#pragma warning disable CA1819 // Properties should not return arrays /// /// Gets the array of properties. /// -#pragma warning disable CA1819 // Properties should not return arrays public KeyValuePair[] PropertyArray => _properties; + /// + /// Gets the array of properties. + /// + public KeyValuePair[] RedactedPropertyArray => _redactedProperties; + /// /// Gets the array of classified properties. /// @@ -51,6 +58,25 @@ public int EnsurePropertySpace(int count) return index; } + /// + /// Allocates some room to put some redacted properties. + /// + /// The amount of space to allocate. + /// The index in the where to store the properties. + public int EnsureRedactedPropertySpace(int count) + { + int avail = _redactedProperties.Length - NumRedactedProperties; + if (count > avail) + { + var need = _redactedProperties.Length + (count - avail); + Array.Resize(ref _redactedProperties, need); + } + + var index = NumRedactedProperties; + NumRedactedProperties += count; + return index; + } + /// /// Allocates some room to put some properties. /// @@ -76,8 +102,10 @@ public int EnsureClassifiedPropertySpace(int count) public void Clear() { Array.Clear(_properties, 0, NumProperties); + Array.Clear(_redactedProperties, 0, NumRedactedProperties); Array.Clear(_classifiedProperties, 0, NumClassifiedProperties); NumProperties = 0; + NumRedactedProperties = 0; NumClassifiedProperties = 0; PropertyNamePrefix = string.Empty; } @@ -87,6 +115,11 @@ public void Clear() /// public int NumProperties { get; private set; } + /// + /// Gets a value indicating the number of redacted properties currently in this instance. + /// + public int NumRedactedProperties { get; private set; } + /// /// Gets a value indicating the number of classified properties currently in this instance. /// diff --git a/src/Libraries/Microsoft.Extensions.Telemetry.Abstractions/Microsoft.Extensions.Telemetry.Abstractions.csproj b/src/Libraries/Microsoft.Extensions.Telemetry.Abstractions/Microsoft.Extensions.Telemetry.Abstractions.csproj index c8185eaad15..c4ae2b597a4 100644 --- a/src/Libraries/Microsoft.Extensions.Telemetry.Abstractions/Microsoft.Extensions.Telemetry.Abstractions.csproj +++ b/src/Libraries/Microsoft.Extensions.Telemetry.Abstractions/Microsoft.Extensions.Telemetry.Abstractions.csproj @@ -14,7 +14,7 @@ normal - 99 + 100 100 diff --git a/src/Libraries/Microsoft.Extensions.Telemetry/Logging/ExtendedLogger.ModernPropertyJoiner.cs b/src/Libraries/Microsoft.Extensions.Telemetry/Logging/ExtendedLogger.ModernPropertyJoiner.cs index 2ac70a0ac17..15dbffdbf25 100644 --- a/src/Libraries/Microsoft.Extensions.Telemetry/Logging/ExtendedLogger.ModernPropertyJoiner.cs +++ b/src/Libraries/Microsoft.Extensions.Telemetry/Logging/ExtendedLogger.ModernPropertyJoiner.cs @@ -22,7 +22,9 @@ internal sealed class ModernPropertyJoiner : IReadOnlyList> _extraProperties = new(PropCapacity); private KeyValuePair[]? _incomingProperties; + private KeyValuePair[]? _redactedProperties; private int _incomingPropertiesCount; + private int _redactedPropertiesCount; public ModernPropertyJoiner() { @@ -35,6 +37,7 @@ public void Clear() { _extraProperties.Clear(); _incomingProperties = null; + _redactedProperties = null; State = null; Formatter = null; } @@ -44,6 +47,9 @@ public void SetIncomingProperties(LoggerMessageState value) { _incomingProperties = value.PropertyArray; _incomingPropertiesCount = value.NumProperties; + + _redactedProperties = value.RedactedPropertyArray; + _redactedPropertiesCount = value.NumRedactedProperties; } public KeyValuePair this[int index] @@ -54,18 +60,22 @@ public void SetIncomingProperties(LoggerMessageState value) { return _incomingProperties![index]; } - else if (index < _incomingPropertiesCount + _extraProperties.Count) + else if (index < _incomingPropertiesCount + _redactedPropertiesCount) + { + return _redactedProperties![index - _incomingPropertiesCount]; + } + else if (index < _incomingPropertiesCount + _redactedPropertiesCount + _extraProperties.Count) { - return _extraProperties[index - _incomingPropertiesCount]; + return _extraProperties[index - _incomingPropertiesCount - _redactedPropertiesCount]; } else { - return StaticProperties![index - _incomingPropertiesCount - _extraProperties.Count]; + return StaticProperties![index - _incomingPropertiesCount - _redactedPropertiesCount - _extraProperties.Count]; } } } - public int Count => _incomingPropertiesCount + _extraProperties.Count + StaticProperties!.Length; + public int Count => _incomingPropertiesCount + _redactedPropertiesCount + _extraProperties.Count + StaticProperties!.Length; public IEnumerator> GetEnumerator() { diff --git a/src/Libraries/Microsoft.Extensions.Telemetry/Logging/ExtendedLogger.cs b/src/Libraries/Microsoft.Extensions.Telemetry/Logging/ExtendedLogger.cs index 64579180f7d..cf07f3dfd15 100644 --- a/src/Libraries/Microsoft.Extensions.Telemetry/Logging/ExtendedLogger.cs +++ b/src/Libraries/Microsoft.Extensions.Telemetry/Logging/ExtendedLogger.cs @@ -190,11 +190,6 @@ private void ModernPath(LogLevel logLevel, EventId eventId, LoggerMessageState m var loggers = MessageLoggers; var config = _factory.Config; - var joiner = ModernJoiner; - joiner.StaticProperties = config.StaticProperties; - joiner.Formatter = formatter; - joiner.SetIncomingProperties(msgState); - List? exceptions = null; // redact @@ -210,7 +205,8 @@ private void ModernPath(LogLevel logLevel, EventId eventId, LoggerMessageState m jr.Next = jitRedactors; jitRedactors = jr; - joiner.PropertyBag.Add(cp.Name, jr); + var index = msgState.EnsureRedactedPropertySpace(1); + msgState.RedactedPropertyArray[index] = new(cp.Name, jr); } catch (Exception ex) { @@ -219,6 +215,11 @@ private void ModernPath(LogLevel logLevel, EventId eventId, LoggerMessageState m } } + var joiner = ModernJoiner; + joiner.StaticProperties = config.StaticProperties; + joiner.Formatter = formatter; + joiner.SetIncomingProperties(msgState); + // enrich foreach (var enricher in config.Enrichers) { diff --git a/src/Libraries/Microsoft.Extensions.Telemetry/Logging/LoggingEnrichmentExtensions.cs b/src/Libraries/Microsoft.Extensions.Telemetry/Logging/LoggingEnrichmentExtensions.cs index ad41aeeb81a..0089e7cb7c6 100644 --- a/src/Libraries/Microsoft.Extensions.Telemetry/Logging/LoggingEnrichmentExtensions.cs +++ b/src/Libraries/Microsoft.Extensions.Telemetry/Logging/LoggingEnrichmentExtensions.cs @@ -8,6 +8,7 @@ using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options.Validation; +using Microsoft.Shared.DiagnosticIds; using Microsoft.Shared.Diagnostics; namespace Microsoft.Extensions.Telemetry.Logging; @@ -15,7 +16,7 @@ namespace Microsoft.Extensions.Telemetry.Logging; /// /// Extensions for configuring logging enrichment features. /// -[Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] +[Experimental(diagnosticId: Experiments.Telemetry, UrlFormat = Experiments.UrlFormat)] public static class LoggingEnrichmentExtensions { /// diff --git a/src/Libraries/Microsoft.Extensions.Telemetry/Logging/LoggingRedactionExtensions.cs b/src/Libraries/Microsoft.Extensions.Telemetry/Logging/LoggingRedactionExtensions.cs index 7bdf7685595..76f33f8e29f 100644 --- a/src/Libraries/Microsoft.Extensions.Telemetry/Logging/LoggingRedactionExtensions.cs +++ b/src/Libraries/Microsoft.Extensions.Telemetry/Logging/LoggingRedactionExtensions.cs @@ -5,6 +5,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Logging; +using Microsoft.Shared.DiagnosticIds; using Microsoft.Shared.Diagnostics; namespace Microsoft.Extensions.Telemetry.Logging; @@ -12,7 +13,7 @@ namespace Microsoft.Extensions.Telemetry.Logging; /// /// Extensions for configuring logging redaction features. /// -[Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] +[Experimental(diagnosticId: Experiments.Telemetry, UrlFormat = Experiments.UrlFormat)] public static class LoggingRedactionExtensions { /// diff --git a/test/Libraries/Microsoft.AspNetCore.Telemetry.Tests/Enrichment.RequestHeaders.Tests/RequestHeadersEnricherTests.cs b/test/Libraries/Microsoft.AspNetCore.Telemetry.Tests/Enrichment.RequestHeaders.Tests/RequestHeadersEnricherTests.cs index b98b449e9e6..b6889d927f8 100644 --- a/test/Libraries/Microsoft.AspNetCore.Telemetry.Tests/Enrichment.RequestHeaders.Tests/RequestHeadersEnricherTests.cs +++ b/test/Libraries/Microsoft.AspNetCore.Telemetry.Tests/Enrichment.RequestHeaders.Tests/RequestHeadersEnricherTests.cs @@ -8,7 +8,6 @@ using Microsoft.Extensions.Compliance.Classification; using Microsoft.Extensions.Compliance.Redaction; using Microsoft.Extensions.Compliance.Testing; -using Microsoft.Extensions.Telemetry.Enrichment.Test; using Moq; using Xunit; diff --git a/test/Libraries/Microsoft.Extensions.Telemetry.Abstractions.Tests/Enrichment/TestLogEnrichmentPropertyBag.cs b/test/Libraries/Microsoft.AspNetCore.Telemetry.Tests/Enrichment.RequestHeaders.Tests/TestLogEnrichmentPropertyBag.cs similarity index 91% rename from test/Libraries/Microsoft.Extensions.Telemetry.Abstractions.Tests/Enrichment/TestLogEnrichmentPropertyBag.cs rename to test/Libraries/Microsoft.AspNetCore.Telemetry.Tests/Enrichment.RequestHeaders.Tests/TestLogEnrichmentPropertyBag.cs index eef49f70063..4e7e4a8fc9f 100644 --- a/test/Libraries/Microsoft.Extensions.Telemetry.Abstractions.Tests/Enrichment/TestLogEnrichmentPropertyBag.cs +++ b/test/Libraries/Microsoft.AspNetCore.Telemetry.Tests/Enrichment.RequestHeaders.Tests/TestLogEnrichmentPropertyBag.cs @@ -3,8 +3,9 @@ using System; using System.Collections.Generic; +using Microsoft.Extensions.Telemetry.Enrichment; -namespace Microsoft.Extensions.Telemetry.Enrichment.Test; +namespace Microsoft.AspNetCore.Telemetry.RequestHeaders.Test; public class TestLogEnrichmentPropertyBag : IEnrichmentPropertyBag { diff --git a/test/Libraries/Microsoft.Extensions.Telemetry.Abstractions.Tests/Enrichment/TestMetricEnrichmentPropertyBag.cs b/test/Libraries/Microsoft.AspNetCore.Telemetry.Tests/Enrichment.RequestHeaders.Tests/TestMetricEnrichmentPropertyBag.cs similarity index 91% rename from test/Libraries/Microsoft.Extensions.Telemetry.Abstractions.Tests/Enrichment/TestMetricEnrichmentPropertyBag.cs rename to test/Libraries/Microsoft.AspNetCore.Telemetry.Tests/Enrichment.RequestHeaders.Tests/TestMetricEnrichmentPropertyBag.cs index 2796acfd823..f87b7dd259b 100644 --- a/test/Libraries/Microsoft.Extensions.Telemetry.Abstractions.Tests/Enrichment/TestMetricEnrichmentPropertyBag.cs +++ b/test/Libraries/Microsoft.AspNetCore.Telemetry.Tests/Enrichment.RequestHeaders.Tests/TestMetricEnrichmentPropertyBag.cs @@ -3,8 +3,9 @@ using System; using System.Collections.Generic; +using Microsoft.Extensions.Telemetry.Enrichment; -namespace Microsoft.Extensions.Telemetry.Enrichment.Test; +namespace Microsoft.AspNetCore.Telemetry.Test.Enrichment.RequestHeaders.Tests; public class TestMetricEnrichmentPropertyBag : IEnrichmentPropertyBag { diff --git a/test/Libraries/Microsoft.AspNetCore.Telemetry.Tests/Microsoft.AspNetCore.Telemetry.Tests.csproj b/test/Libraries/Microsoft.AspNetCore.Telemetry.Tests/Microsoft.AspNetCore.Telemetry.Tests.csproj index 61eb8395f6d..0de018933d7 100644 --- a/test/Libraries/Microsoft.AspNetCore.Telemetry.Tests/Microsoft.AspNetCore.Telemetry.Tests.csproj +++ b/test/Libraries/Microsoft.AspNetCore.Telemetry.Tests/Microsoft.AspNetCore.Telemetry.Tests.csproj @@ -14,7 +14,6 @@ - diff --git a/test/Libraries/Microsoft.Extensions.Telemetry.Abstractions.Tests/Enrichment/EnricherExtensionsTests.cs b/test/Libraries/Microsoft.Extensions.Telemetry.Abstractions.Tests/Enrichment/EnricherExtensionsTests.cs index 1b70b6c2f4b..7f2c34e5948 100644 --- a/test/Libraries/Microsoft.Extensions.Telemetry.Abstractions.Tests/Enrichment/EnricherExtensionsTests.cs +++ b/test/Libraries/Microsoft.Extensions.Telemetry.Abstractions.Tests/Enrichment/EnricherExtensionsTests.cs @@ -45,7 +45,7 @@ public void ServiceCollection_GivenNullArguments_Throws() } [Fact] - public void ServiceCollection_AddMultipleEnrichersSuccessfully() + public void ServiceCollection_AddMultipleMetricEnrichersSuccessfully() { var services = new ServiceCollection(); services.AddMetricEnricher(); @@ -63,7 +63,45 @@ public void ServiceCollection_AddMultipleEnrichersSuccessfully() Assert.Equal(2, enricherCount); } - internal class EmptyEnricher : IMetricEnricher, ILogEnricher + [Fact] + public void AddLogEnricher() + { + var services = new ServiceCollection(); + services.AddLogEnricher(); + services.AddLogEnricher(new TestEnricher()); + + using var provider = services.BuildServiceProvider(); + var enrichersCollection = provider.GetServices(); + + var enricherCount = 0; + foreach (var enricher in enrichersCollection) + { + enricherCount++; + } + + Assert.Equal(2, enricherCount); + } + + [Fact] + public void AddStaticLogEnricher() + { + var services = new ServiceCollection(); + services.AddStaticLogEnricher(); + services.AddStaticLogEnricher(new TestEnricher()); + + using var provider = services.BuildServiceProvider(); + var enrichersCollection = provider.GetServices(); + + var enricherCount = 0; + foreach (var enricher in enrichersCollection) + { + enricherCount++; + } + + Assert.Equal(2, enricherCount); + } + + internal class EmptyEnricher : IMetricEnricher, ILogEnricher, IStaticLogEnricher { public void Enrich(IEnrichmentPropertyBag enrichmentBag) { @@ -71,7 +109,7 @@ public void Enrich(IEnrichmentPropertyBag enrichmentBag) } } - internal class TestEnricher : IMetricEnricher, ILogEnricher + internal class TestEnricher : IMetricEnricher, ILogEnricher, IStaticLogEnricher { public void Enrich(IEnrichmentPropertyBag enrichmentBag) { diff --git a/test/Libraries/Microsoft.Extensions.Telemetry.Abstractions.Tests/Latency/LatencyRegistryExtensionsTest.cs b/test/Libraries/Microsoft.Extensions.Telemetry.Abstractions.Tests/Latency/LatencyRegistryExtensionsTest.cs index 7014a356649..101b1cec663 100644 --- a/test/Libraries/Microsoft.Extensions.Telemetry.Abstractions.Tests/Latency/LatencyRegistryExtensionsTest.cs +++ b/test/Libraries/Microsoft.Extensions.Telemetry.Abstractions.Tests/Latency/LatencyRegistryExtensionsTest.cs @@ -27,6 +27,14 @@ public void LatencyRegistryExtension_NullArguments() () => LatencyRegistryExtensions.RegisterTagNames(new ServiceCollection(), null!)); } + [Fact] + public void LatencyRegistryExtension_EmptyNames() + { + Assert.Throws(() => LatencyRegistryExtensions.RegisterCheckpointNames(new ServiceCollection(), "")); + Assert.Throws(() => LatencyRegistryExtensions.RegisterMeasureNames(new ServiceCollection(), "")); + Assert.Throws(() => LatencyRegistryExtensions.RegisterTagNames(new ServiceCollection(), "")); + } + [Fact] public void LatencyRegistryExtension_BasicFunctionality() { diff --git a/test/Libraries/Microsoft.Extensions.Telemetry.Abstractions.Tests/Logging/LogMethodHelperTests.cs b/test/Libraries/Microsoft.Extensions.Telemetry.Abstractions.Tests/Logging/LogMethodHelperTests.cs index 23d75c14fc5..ab07cc493ec 100644 --- a/test/Libraries/Microsoft.Extensions.Telemetry.Abstractions.Tests/Logging/LogMethodHelperTests.cs +++ b/test/Libraries/Microsoft.Extensions.Telemetry.Abstractions.Tests/Logging/LogMethodHelperTests.cs @@ -4,6 +4,7 @@ using System; using System.Collections; using System.Collections.Generic; +using Microsoft.Extensions.Compliance.Classification; using Microsoft.Extensions.Telemetry.Enrichment; using Microsoft.Extensions.Telemetry.Logging; using Xunit; @@ -34,7 +35,7 @@ public static void CollectorContract() Assert.Empty(list); Assert.Equal(string.Empty, list.ParameterName); - list.Add(PropName, Value); + list.Add(PropName, Value, DataClassification.None); Assert.Single(list); Assert.Equal(PropName, list[0].Key); Assert.Equal(Value, list[0].Value);