diff --git a/README.md b/README.md index 56b1865780c..2581334477d 100644 --- a/README.md +++ b/README.md @@ -104,6 +104,23 @@ extension scenarios: * Building a custom sampler for [traces](./docs/trace/extending-the-sdk/README.md#sampler). +## Experimental Features + +Various experimental features are available by the components of OpenTelemetry +.NET. + +Experimental features are enabled in a variety of different ways. Some features +are only available in pre-release builds while others may be available in +stable builds gated by a feature flag. Feature flags are implemented using +environment variables (e.g., `OTEL_DOTNET_EXPERIMENTAL_SOME_FEATURE`). + +Experimental features are subject to breaking changes. Typically, they are +works-in-progress that we intend to eventually provide in a stable release. +However, this is not guaranteed and they may be removed entirely. + +The README of a each component will contain information for any available +experimental features and how to use them. + ## Contributing See [CONTRIBUTING.md](CONTRIBUTING.md) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md index fc9afc5e825..9f4a449b422 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md @@ -12,6 +12,11 @@ exporter. [specification](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.23.0/specification/metrics/sdk_exporters/otlp.md#additional-configuration). ([#4667](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4667)) +* **[Experimental feature](./README.md#experimental-features)** + Exporting the following fields from `LogRecord` is now considered + an experimental feature: `CategoryName`, `EventId`, and `Exception`. + Refer to the documentation for more details. + ## 1.6.0-alpha.1 Released 2023-Jul-12 @@ -34,20 +39,18 @@ Released 2023-Jul-12 for more details. ([#4647](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4647)) -* **Experimental (pre-release builds only):** - - * Note: See - [#4735](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4735) - for the introduction of experimental api support. - - * Add back support for Exemplars. See - [exemplars](../../docs/metrics/customizing-the-sdk/README.md#exemplars) for - instructions to enable exemplars. - ([#4553](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4553)) - - * Updated to support `Severity` and `SeverityText` when exporting - `LogRecord`s. - ([#4568](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4568)) +* **[Experimental feature](./README.md#experimental-features)** + Add back support for Exemplars which is now treated as an experimental + feature available only in pre-release builds. See + [exemplars](../../docs/metrics/customizing-the-sdk/README.md#exemplars) for + instructions to enable exemplars. + ([#4553](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4553)) + +* **[Experimental feature](./README.md#experimental-features)** + The `Severity` and `SeverityText` fields on `LogRecord` are only available in + pre-release builds of the SDK. Pre-release builds of the OTLP exporter will + export these fields. + ([#4568](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4568)) ## 1.5.1 diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/LogRecordExtensions.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/LogRecordExtensions.cs index 294ce6454f2..0b330bfd938 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/LogRecordExtensions.cs +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/LogRecordExtensions.cs @@ -16,9 +16,13 @@ using System.Runtime.CompilerServices; using Google.Protobuf; +#if EXPOSE_EXPERIMENTAL_FEATURES using OpenTelemetry.Internal; +#endif using OpenTelemetry.Logs; +#if EXPOSE_EXPERIMENTAL_FEATURES using OpenTelemetry.Trace; +#endif using OtlpCollector = OpenTelemetry.Proto.Collector.Logs.V1; using OtlpCommon = OpenTelemetry.Proto.Common.V1; using OtlpLogs = OpenTelemetry.Proto.Logs.V1; @@ -79,7 +83,7 @@ internal static OtlpLogs.LogRecord ToOtlpLog(this LogRecord logRecord, SdkLimitO var attributeValueLengthLimit = sdkLimitOptions.AttributeValueLengthLimit; var attributeCountLimit = sdkLimitOptions.AttributeCountLimit ?? int.MaxValue; - +#if EXPOSE_EXPERIMENTAL_FEATURES // First add the generic attributes like Category, EventId and Exception, // so they are less likely being dropped because of AttributeCountLimit. @@ -109,7 +113,7 @@ internal static OtlpLogs.LogRecord ToOtlpLog(this LogRecord logRecord, SdkLimitO otlpLogRecord.AddStringAttribute(SemanticConventions.AttributeExceptionMessage, logRecord.Exception.Message, attributeValueLengthLimit, attributeCountLimit); otlpLogRecord.AddStringAttribute(SemanticConventions.AttributeExceptionStacktrace, logRecord.Exception.ToInvariantString(), attributeValueLengthLimit, attributeCountLimit); } - +#endif bool bodyPopulatedFromFormattedMessage = false; if (logRecord.FormattedMessage != null) { diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md index 59b511d0187..b03552f6a05 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md @@ -233,6 +233,31 @@ services.AddHttpClient( Note: The single instance returned by `HttpClientFactory` is reused by all export requests. +## Experimental features + +The OTLP exporter contains the following +[experimental features](../../README.md#experimental-features): + +* The + [exemplar specification](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#exemplar) + is not yet stable. Pre-release builds of the OpenTelemetry .NET SDK and the + OTLP exporter support sampling and exporting exemplars. +* Support for exporting the following fields on `LogRecord`: `CategoryName`, + `EventId`, and `Exception`. These fields are unique to OpenTelemetry .NET's + data model (i.e., they are not reflected in the + [standard data model](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/data-model.md#log-and-event-record-definition)). + Therefore, the conventions + for exporting these fields is not yet stable. In pre-release builds, these + fields are exported as attributes mapped as follows: + * `CategoryName` maps to `dotnet.ilogger.category_name`. + * `EventId` maps to two attributes `Id` and `Name` representing + `Event.Id` and `EventId.Name`, respectively. + * `Exception` maps to the attributes defined by the experimental + [exception semantic conventions](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/exceptions/exceptions-logs.md#attributes). +* In pre-release builds of the OpenTelemetry .NET SDK `LogRecord` contains new + fields: `Severity` and `SeverityText`, and they will be exported by the OTLP + exporter. + ## Troubleshooting This component uses an diff --git a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs index ed1aa8f5fc1..a02df0f1498 100644 --- a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs +++ b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs @@ -23,7 +23,9 @@ using Moq; using OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation; using OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation.ExportClient; +#if EXPOSE_EXPERIMENTAL_FEATURES using OpenTelemetry.Internal; +#endif using OpenTelemetry.Logs; using OpenTelemetry.Tests; using OpenTelemetry.Trace; @@ -184,25 +186,32 @@ public void OtlpLogRecordTestWhenStateValuesArePopulated() Assert.NotNull(otlpLogRecord); Assert.Equal("Hello from tomato 2.99.", otlpLogRecord.Body.StringValue); +#if EXPOSE_EXPERIMENTAL_FEATURES Assert.Equal(4, otlpLogRecord.Attributes.Count); - - var attribute = otlpLogRecord.Attributes[0]; +#else + Assert.Equal(3, otlpLogRecord.Attributes.Count); +#endif + var index = 0; + var attribute = otlpLogRecord.Attributes[index]; +#if EXPOSE_EXPERIMENTAL_FEATURES Assert.Equal("dotnet.ilogger.category", attribute.Key); Assert.Equal("OtlpLogExporterTests", attribute.Value.StringValue); - attribute = otlpLogRecord.Attributes[1]; + attribute = otlpLogRecord.Attributes[++index]; +#endif Assert.Equal("name", attribute.Key); Assert.Equal("tomato", attribute.Value.StringValue); - attribute = otlpLogRecord.Attributes[2]; + attribute = otlpLogRecord.Attributes[++index]; Assert.Equal("price", attribute.Key); Assert.Equal(2.99, attribute.Value.DoubleValue); - attribute = otlpLogRecord.Attributes[3]; + attribute = otlpLogRecord.Attributes[++index]; Assert.Equal("{OriginalFormat}", attribute.Key); Assert.Equal("Hello from {name} {price}.", attribute.Value.StringValue); } +#if EXPOSE_EXPERIMENTAL_FEATURES [Fact] public void CheckToOtlpLogRecordLoggerCategory() { @@ -287,6 +296,7 @@ public void CheckToOtlpLogRecordEventId() Assert.Contains("Name", otlpLogRecordAttributes); Assert.Contains("MyEvent10", otlpLogRecordAttributes); } +#endif [Fact] public void CheckToOtlpLogRecordTimestamps() @@ -485,6 +495,7 @@ public void CheckToOtlpLogRecordBodyIsPopulated(bool includeFormattedMessage) Assert.Equal("state", otlpLogRecord.Body.StringValue); } +#if EXPOSE_EXPERIMENTAL_FEATURES [Fact] public void CheckToOtlpLogRecordExceptionAttributes() { @@ -515,13 +526,14 @@ public void CheckToOtlpLogRecordExceptionAttributes() Assert.Contains(SemanticConventions.AttributeExceptionStacktrace, otlpLogRecordAttributes); Assert.Contains(logRecord.Exception.ToInvariantString(), otlpLogRecordAttributes); } +#endif [Fact] public void CheckToOtlpLogRecordRespectsAttributeLimits() { var sdkLimitOptions = new SdkLimitOptions { - AttributeCountLimit = 3, // 3 => LogCategory, exception.type and exception.message + AttributeCountLimit = 2, AttributeValueLengthLimit = 8, }; @@ -530,12 +542,13 @@ public void CheckToOtlpLogRecordRespectsAttributeLimits() { builder.AddOpenTelemetry(options => { + options.ParseStateValues = true; options.AddInMemoryExporter(logRecords); }); }); - var logger = loggerFactory.CreateLogger("OtlpLogExporterTests"); - logger.LogInformation(new NotSupportedException("I'm the exception message."), "Exception Occurred"); + var logger = loggerFactory.CreateLogger(string.Empty); + logger.LogInformation("OpenTelemetry {AttributeOne} {AttributeTwo} {AttributeThree}!", "I'm an attribute", "I too am an attribute", "I get dropped :("); var logRecord = logRecords[0]; var otlpLogRecord = logRecord.ToOtlpLog(sdkLimitOptions); @@ -543,19 +556,19 @@ public void CheckToOtlpLogRecordRespectsAttributeLimits() Assert.NotNull(otlpLogRecord); Assert.Equal(1u, otlpLogRecord.DroppedAttributesCount); - var exceptionTypeAtt = TryGetAttribute(otlpLogRecord, SemanticConventions.AttributeExceptionType); - Assert.NotNull(exceptionTypeAtt); + var attribute = TryGetAttribute(otlpLogRecord, "AttributeOne"); + Assert.NotNull(attribute); - // "NotSuppo" == first 8 chars from the exception typename "NotSupportedException" - Assert.Equal("NotSuppo", exceptionTypeAtt.Value.StringValue); - var exceptionMessageAtt = TryGetAttribute(otlpLogRecord, SemanticConventions.AttributeExceptionMessage); - Assert.NotNull(exceptionMessageAtt); + // "I'm an a" == first 8 chars from the first attribute "I'm an attribute" + Assert.Equal("I'm an a", attribute.Value.StringValue); + attribute = TryGetAttribute(otlpLogRecord, "AttributeTwo"); + Assert.NotNull(attribute); - // "I'm the " == first 8 chars from the exception message - Assert.Equal("I'm the ", exceptionMessageAtt.Value.StringValue); + // "I too am" == first 8 chars from the second attribute "I too am an attribute" + Assert.Equal("I too am", attribute.Value.StringValue); - var exceptionStackTraceAtt = TryGetAttribute(otlpLogRecord, SemanticConventions.AttributeExceptionStacktrace); - Assert.Null(exceptionStackTraceAtt); + attribute = TryGetAttribute(otlpLogRecord, "AttributeThree"); + Assert.Null(attribute); } [Fact] @@ -670,7 +683,7 @@ public void ToOtlpLog_WhenOptionsIncludeScopesIsTrue_ContainsScopeAttributeStrin options.AddInMemoryExporter(logRecords); }); }); - var logger = loggerFactory.CreateLogger(nameof(OtlpLogExporterTests)); + var logger = loggerFactory.CreateLogger(string.Empty); const string scopeKey = "Some scope key"; @@ -686,7 +699,7 @@ public void ToOtlpLog_WhenOptionsIncludeScopesIsTrue_ContainsScopeAttributeStrin // Assert. var logRecord = logRecords.Single(); var otlpLogRecord = logRecord.ToOtlpLog(DefaultSdkLimitOptions); - Assert.Equal(2, otlpLogRecord.Attributes.Count); + Assert.Single(otlpLogRecord.Attributes); var actualScope = TryGetAttribute(otlpLogRecord, scopeKey); Assert.NotNull(actualScope); Assert.Equal(scopeKey, actualScope.Key); @@ -709,7 +722,7 @@ public void ToOtlpLog_WhenOptionsIncludeScopesIsTrue_ContainsScopeAttributeBoolV options.AddInMemoryExporter(logRecords); }); }); - var logger = loggerFactory.CreateLogger(nameof(OtlpLogExporterTests)); + var logger = loggerFactory.CreateLogger(string.Empty); const string scopeKey = "Some scope key"; @@ -725,7 +738,7 @@ public void ToOtlpLog_WhenOptionsIncludeScopesIsTrue_ContainsScopeAttributeBoolV // Assert. var logRecord = logRecords.Single(); var otlpLogRecord = logRecord.ToOtlpLog(DefaultSdkLimitOptions); - Assert.Equal(2, otlpLogRecord.Attributes.Count); + Assert.Single(otlpLogRecord.Attributes); var actualScope = TryGetAttribute(otlpLogRecord, scopeKey); Assert.NotNull(actualScope); Assert.Equal(scopeKey, actualScope.Key); @@ -760,7 +773,7 @@ public void ToOtlpLog_WhenOptionsIncludeScopesIsTrue_ContainsScopeAttributeIntVa options.AddInMemoryExporter(logRecords); }); }); - var logger = loggerFactory.CreateLogger(nameof(OtlpLogExporterTests)); + var logger = loggerFactory.CreateLogger(string.Empty); const string scopeKey = "Some scope key"; @@ -776,7 +789,7 @@ public void ToOtlpLog_WhenOptionsIncludeScopesIsTrue_ContainsScopeAttributeIntVa // Assert. var logRecord = logRecords.Single(); var otlpLogRecord = logRecord.ToOtlpLog(DefaultSdkLimitOptions); - Assert.Equal(2, otlpLogRecord.Attributes.Count); + Assert.Single(otlpLogRecord.Attributes); var actualScope = TryGetAttribute(otlpLogRecord, scopeKey); Assert.NotNull(actualScope); Assert.Equal(scopeKey, actualScope.Key); @@ -799,7 +812,7 @@ public void ToOtlpLog_WhenOptionsIncludeScopesIsTrue_ContainsScopeAttributeDoubl options.AddInMemoryExporter(logRecords); }); }); - var logger = loggerFactory.CreateLogger(nameof(OtlpLogExporterTests)); + var logger = loggerFactory.CreateLogger(string.Empty); const string scopeKey = "Some scope key"; @@ -815,7 +828,7 @@ public void ToOtlpLog_WhenOptionsIncludeScopesIsTrue_ContainsScopeAttributeDoubl // Assert. var logRecord = logRecords.Single(); var otlpLogRecord = logRecord.ToOtlpLog(DefaultSdkLimitOptions); - Assert.Equal(2, otlpLogRecord.Attributes.Count); + Assert.Single(otlpLogRecord.Attributes); var actualScope = TryGetAttribute(otlpLogRecord, scopeKey); Assert.NotNull(actualScope); Assert.Equal(scopeKey, actualScope.Key); @@ -838,7 +851,7 @@ public void ToOtlpLog_WhenOptionsIncludeScopesIsTrue_ContainsScopeAttributeDoubl options.AddInMemoryExporter(logRecords); }); }); - var logger = loggerFactory.CreateLogger(nameof(OtlpLogExporterTests)); + var logger = loggerFactory.CreateLogger(string.Empty); const string scopeKey = "Some scope key"; @@ -854,7 +867,7 @@ public void ToOtlpLog_WhenOptionsIncludeScopesIsTrue_ContainsScopeAttributeDoubl // Assert. var logRecord = logRecords.Single(); var otlpLogRecord = logRecord.ToOtlpLog(DefaultSdkLimitOptions); - Assert.Equal(2, otlpLogRecord.Attributes.Count); + Assert.Single(otlpLogRecord.Attributes); var actualScope = TryGetAttribute(otlpLogRecord, scopeKey); Assert.NotNull(actualScope); Assert.Equal(scopeKey, actualScope.Key); @@ -874,7 +887,7 @@ public void ToOtlpLog_WhenOptionsIncludeScopesIsTrue_AndScopeStateIsOfTypeString options.AddInMemoryExporter(logRecords); }); }); - var logger = loggerFactory.CreateLogger(nameof(OtlpLogExporterTests)); + var logger = loggerFactory.CreateLogger(string.Empty); const string scopeState = "Some scope state"; @@ -888,7 +901,7 @@ public void ToOtlpLog_WhenOptionsIncludeScopesIsTrue_AndScopeStateIsOfTypeString var logRecord = logRecords.Single(); var otlpLogRecord = logRecord.ToOtlpLog(DefaultSdkLimitOptions); Assert.NotNull(otlpLogRecord); - Assert.Single(otlpLogRecord.Attributes); + Assert.Empty(otlpLogRecord.Attributes); } [Theory] @@ -909,7 +922,7 @@ public void ToOtlpLog_WhenOptionsIncludeScopesIsTrue_AndScopeStateIsOfPrimitiveT options.AddInMemoryExporter(logRecords); }); }); - var logger = loggerFactory.CreateLogger(nameof(OtlpLogExporterTests)); + var logger = loggerFactory.CreateLogger(string.Empty); var scopeState = Activator.CreateInstance(typeOfScopeState); @@ -923,7 +936,7 @@ public void ToOtlpLog_WhenOptionsIncludeScopesIsTrue_AndScopeStateIsOfPrimitiveT var logRecord = logRecords.Single(); var otlpLogRecord = logRecord.ToOtlpLog(DefaultSdkLimitOptions); Assert.NotNull(otlpLogRecord); - Assert.Single(otlpLogRecord.Attributes); + Assert.Empty(otlpLogRecord.Attributes); } [Fact] @@ -939,7 +952,7 @@ public void ToOtlpLog_WhenOptionsIncludeScopesIsTrue_AndScopeStateIsOfDictionary options.AddInMemoryExporter(logRecords); }); }); - var logger = loggerFactory.CreateLogger(nameof(OtlpLogExporterTests)); + var logger = loggerFactory.CreateLogger(string.Empty); const string scopeKey = "Some scope key"; const string scopeValue = "Some scope value"; @@ -954,7 +967,7 @@ public void ToOtlpLog_WhenOptionsIncludeScopesIsTrue_AndScopeStateIsOfDictionary // Assert. var logRecord = logRecords.Single(); var otlpLogRecord = logRecord.ToOtlpLog(DefaultSdkLimitOptions); - Assert.Equal(2, otlpLogRecord.Attributes.Count); + Assert.Single(otlpLogRecord.Attributes); var actualScope = TryGetAttribute(otlpLogRecord, scopeKey); Assert.NotNull(actualScope); Assert.Equal(scopeKey, actualScope.Key); @@ -977,7 +990,7 @@ public void ToOtlpLog_WhenOptionsIncludeScopesIsTrue_AndScopeStateIsOfEnumerable options.AddInMemoryExporter(logRecords); }); }); - var logger = loggerFactory.CreateLogger(nameof(OtlpLogExporterTests)); + var logger = loggerFactory.CreateLogger(string.Empty); const string scopeKey = "Some scope key"; const string scopeValue = "Some scope value"; @@ -993,7 +1006,7 @@ public void ToOtlpLog_WhenOptionsIncludeScopesIsTrue_AndScopeStateIsOfEnumerable // Assert. var logRecord = logRecords.Single(); var otlpLogRecord = logRecord.ToOtlpLog(DefaultSdkLimitOptions); - Assert.Equal(2, otlpLogRecord.Attributes.Count); + Assert.Single(otlpLogRecord.Attributes); var actualScope = TryGetAttribute(otlpLogRecord, scopeKey); Assert.NotNull(actualScope); Assert.Equal(scopeKey, actualScope.Key); @@ -1015,7 +1028,7 @@ public void ToOtlpLog_WhenOptionsIncludeScopesIsTrue_AndMultipleScopesAreAdded_C options.AddInMemoryExporter(logRecords); }); }); - var logger = loggerFactory.CreateLogger(nameof(OtlpLogExporterTests)); + var logger = loggerFactory.CreateLogger(string.Empty); const string scopeValue1 = "Some scope value"; const string scopeValue2 = "Some other scope value"; @@ -1036,7 +1049,7 @@ public void ToOtlpLog_WhenOptionsIncludeScopesIsTrue_AndMultipleScopesAreAdded_C var allScopeValues = otlpLogRecord.Attributes .Where(_ => _.Key == scopeKey1 || _.Key == scopeKey2) .Select(_ => _.Value.StringValue); - Assert.Equal(3, otlpLogRecord.Attributes.Count); + Assert.Equal(2, otlpLogRecord.Attributes.Count); Assert.Equal(2, allScopeValues.Count()); Assert.Contains(scopeValue1, allScopeValues); Assert.Contains(scopeValue2, allScopeValues); @@ -1057,7 +1070,7 @@ public void ToOtlpLog_WhenOptionsIncludeScopesIsTrue_AndMultipleScopeLevelsAreAd options.AddInMemoryExporter(logRecords); }); }); - var logger = loggerFactory.CreateLogger(nameof(OtlpLogExporterTests)); + var logger = loggerFactory.CreateLogger(string.Empty); const string scopeValue1 = "Some scope value"; const string scopeValue2 = "Some other scope value"; @@ -1077,7 +1090,7 @@ public void ToOtlpLog_WhenOptionsIncludeScopesIsTrue_AndMultipleScopeLevelsAreAd var allScopeValues = otlpLogRecord.Attributes .Where(_ => _.Key == scopeKey1 || _.Key == scopeKey2) .Select(_ => _.Value.StringValue); - Assert.Equal(3, otlpLogRecord.Attributes.Count); + Assert.Equal(2, otlpLogRecord.Attributes.Count); Assert.Equal(2, allScopeValues.Count()); Assert.Contains(scopeValue1, allScopeValues); Assert.Contains(scopeValue2, allScopeValues); @@ -1098,7 +1111,7 @@ public void ToOtlpLog_WhenOptionsIncludeScopesIsTrue_AndScopeIsUsedInLogMethod_C options.AddInMemoryExporter(logRecords); }); }); - var logger = loggerFactory.CreateLogger(nameof(OtlpLogExporterTests)); + var logger = loggerFactory.CreateLogger(string.Empty); const string scopeValue1 = "Some scope value"; const string scopeValue2 = "Some other scope value"; @@ -1111,9 +1124,9 @@ public void ToOtlpLog_WhenOptionsIncludeScopesIsTrue_AndScopeIsUsedInLogMethod_C { logger.Log( LogLevel.Error, - new EventId(1), + default, new List> { new KeyValuePair(scopeKey2, scopeValue2) }, - exception: new Exception("Some exception message"), + exception: null, formatter: (s, e) => string.Empty); } @@ -1123,7 +1136,7 @@ public void ToOtlpLog_WhenOptionsIncludeScopesIsTrue_AndScopeIsUsedInLogMethod_C var allScopeValues = otlpLogRecord.Attributes .Where(_ => _.Key == scopeKey1 || _.Key == scopeKey2) .Select(_ => _.Value.StringValue); - Assert.Equal(7, otlpLogRecord.Attributes.Count); + Assert.Equal(2, otlpLogRecord.Attributes.Count); Assert.Equal(2, allScopeValues.Count()); Assert.Contains(scopeValue1, allScopeValues); Assert.Contains(scopeValue2, allScopeValues);