From 74821cf76dab21128b511fffc4016760327467a3 Mon Sep 17 00:00:00 2001 From: Yun-Ting Date: Fri, 26 Jan 2024 14:52:31 -0800 Subject: [PATCH 01/12] initial --- .../OtlpLogRecordTransformer.cs | 10 +++++++ .../OtlpLogExporterTests.cs | 26 +++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs index ad76b1bb7cd..69a6ef94510 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs @@ -156,6 +156,7 @@ internal OtlpLogs.LogRecord ToOtlpLog(LogRecord logRecord) if (logRecord.Attributes != null) { + bool useTemplateFromExtensionMethod = false; foreach (var attribute in logRecord.Attributes) { // Special casing {OriginalFormat} @@ -164,12 +165,21 @@ internal OtlpLogs.LogRecord ToOtlpLog(LogRecord logRecord) if (attribute.Key.Equals("{OriginalFormat}") && !bodyPopulatedFromFormattedMessage) { otlpLogRecord.Body = new OtlpCommon.AnyValue { StringValue = attribute.Value as string }; + useTemplateFromExtensionMethod = true; } else if (OtlpKeyValueTransformer.Instance.TryTransformTag(attribute, out var result, attributeValueLengthLimit)) { AddAttribute(otlpLogRecord, result, attributeCountLimit); } } + + // Supports Body set directly on LogRecord for the Logs Bridge API. + if (!useTemplateFromExtensionMethod && !bodyPopulatedFromFormattedMessage && logRecord.Body != null) + { + // If {OriginalFormat} is not present in the attributes, + // use logRecord.Body if it is set. + otlpLogRecord.Body = new OtlpCommon.AnyValue { StringValue = logRecord.Body }; + } } if (logRecord.TraceId != default && logRecord.SpanId != default) diff --git a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs index 9d338f8ec7a..b657624eda1 100644 --- a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs +++ b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs @@ -589,6 +589,32 @@ public void CheckToOtlpLogRecordBodyIsPopulated(bool includeFormattedMessage) Assert.Equal("state", otlpLogRecord.Body.StringValue); } + [Fact] + public void LogRecordBodyIsExportedWhenUsingBridgeApi() + { + var logRecords = new List(); + + using (var loggerProvider = Sdk.CreateLoggerProviderBuilder() + .AddInMemoryExporter(logRecords) + .Build()) + { + var logger = loggerProvider.GetLogger(); + + logger.EmitLog(new LogRecordData() + { + Body = "Hello world", + }); + } + + Assert.Single(logRecords); + + var otlpLogRecordTransformer = new OtlpLogRecordTransformer(DefaultSdkLimitOptions, new()); + + var otlpLogRecord = otlpLogRecordTransformer.ToOtlpLog(logRecords[0]); + + Assert.Equal("Hello world", otlpLogRecord.Body?.StringValue); + } + [Theory] [InlineData("true")] [InlineData("false")] From 4e4b6a63ae64a14111287fbd56ac3f408c82b1d1 Mon Sep 17 00:00:00 2001 From: Yun-Ting Date: Fri, 26 Jan 2024 15:03:12 -0800 Subject: [PATCH 02/12] fix merge --- .../OtlpLogExporterTests.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs index 3f99ac942e9..db81a8663f0 100644 --- a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs +++ b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs @@ -615,11 +615,8 @@ public void LogRecordBodyIsExportedWhenUsingBridgeApi() Assert.Equal("Hello world", otlpLogRecord.Body?.StringValue); } - [Theory] - [InlineData("true")] - [InlineData("false")] - [InlineData(null)] - public void CheckToOtlpLogRecordExceptionAttributes(string emitExceptionAttributes) + [Fact] + public void CheckToOtlpLogRecordExceptionAttributes() { var logRecords = new List(); using var loggerFactory = LoggerFactory.Create(builder => From 3679052e37834f2719ce45ad99d580e76039717f Mon Sep 17 00:00:00 2001 From: Yun-Ting Date: Fri, 26 Jan 2024 15:19:32 -0800 Subject: [PATCH 03/12] if --- .../OtlpLogExporterTests.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs index db81a8663f0..80ce53c44bd 100644 --- a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs +++ b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs @@ -589,6 +589,7 @@ public void CheckToOtlpLogRecordBodyIsPopulated(bool includeFormattedMessage) Assert.Equal("state", otlpLogRecord.Body.StringValue); } +#if EXPOSE_EXPERIMENTAL_FEATURES && NET8_0_OR_GREATER [Fact] public void LogRecordBodyIsExportedWhenUsingBridgeApi() { @@ -614,6 +615,7 @@ public void LogRecordBodyIsExportedWhenUsingBridgeApi() Assert.Equal("Hello world", otlpLogRecord.Body?.StringValue); } +#endif [Fact] public void CheckToOtlpLogRecordExceptionAttributes() From e00e64e379783b2b397dbbc3b1ea2dde75aedf9d Mon Sep 17 00:00:00 2001 From: Yun-Ting Date: Fri, 26 Jan 2024 15:55:54 -0800 Subject: [PATCH 04/12] comment and changelog --- .../CHANGELOG.md | 4 ++++ .../Implementation/OtlpLogRecordTransformer.cs | 7 +++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md index 4b0d4a32a85..9a4c4762f58 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +* **Experimental (pre-release builds only):** Added + support for `Body` set directly on `LogRecord` via the Logs Bridge API. + [#5268](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5268) + * **Experimental (pre-release builds only):** Added `LoggerProviderBuilder.AddOtlpExporter` registration extensions. [#5103](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5103) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs index da96f64bbc3..c52f217f5b4 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs @@ -156,7 +156,6 @@ internal OtlpLogs.LogRecord ToOtlpLog(LogRecord logRecord) if (logRecord.Attributes != null) { - bool useTemplateFromExtensionMethod = false; foreach (var attribute in logRecord.Attributes) { // Special casing {OriginalFormat} @@ -165,21 +164,21 @@ internal OtlpLogs.LogRecord ToOtlpLog(LogRecord logRecord) if (attribute.Key.Equals("{OriginalFormat}") && !bodyPopulatedFromFormattedMessage) { otlpLogRecord.Body = new OtlpCommon.AnyValue { StringValue = attribute.Value as string }; - useTemplateFromExtensionMethod = true; } else if (OtlpKeyValueTransformer.Instance.TryTransformTag(attribute, out var result, attributeValueLengthLimit)) { AddAttribute(otlpLogRecord, result, attributeCountLimit); } } - +#if EXPOSE_EXPERIMENTAL_FEATURES && NET8_0_OR_GREATER // Supports Body set directly on LogRecord for the Logs Bridge API. - if (!useTemplateFromExtensionMethod && !bodyPopulatedFromFormattedMessage && logRecord.Body != null) + if (otlpLogRecord.Body == null && logRecord.Body != null) { // If {OriginalFormat} is not present in the attributes, // use logRecord.Body if it is set. otlpLogRecord.Body = new OtlpCommon.AnyValue { StringValue = logRecord.Body }; } +#endif } if (logRecord.TraceId != default && logRecord.SpanId != default) From eff653305cc172dc6a13aab5fdc5af32070a93c2 Mon Sep 17 00:00:00 2001 From: Yun-Ting Date: Fri, 26 Jan 2024 16:14:31 -0800 Subject: [PATCH 05/12] addressed comments --- .../Implementation/OtlpLogRecordTransformer.cs | 3 +-- .../OtlpLogExporterTests.cs | 10 ++++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs index c52f217f5b4..6e4f5c074ec 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs @@ -170,7 +170,7 @@ internal OtlpLogs.LogRecord ToOtlpLog(LogRecord logRecord) AddAttribute(otlpLogRecord, result, attributeCountLimit); } } -#if EXPOSE_EXPERIMENTAL_FEATURES && NET8_0_OR_GREATER + // Supports Body set directly on LogRecord for the Logs Bridge API. if (otlpLogRecord.Body == null && logRecord.Body != null) { @@ -178,7 +178,6 @@ internal OtlpLogs.LogRecord ToOtlpLog(LogRecord logRecord) // use logRecord.Body if it is set. otlpLogRecord.Body = new OtlpCommon.AnyValue { StringValue = logRecord.Body }; } -#endif } if (logRecord.TraceId != default && logRecord.SpanId != default) diff --git a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs index 80ce53c44bd..44a4ef241b0 100644 --- a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs +++ b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs @@ -589,14 +589,20 @@ public void CheckToOtlpLogRecordBodyIsPopulated(bool includeFormattedMessage) Assert.Equal("state", otlpLogRecord.Body.StringValue); } -#if EXPOSE_EXPERIMENTAL_FEATURES && NET8_0_OR_GREATER +#if NET8_0_OR_GREATER [Fact] public void LogRecordBodyIsExportedWhenUsingBridgeApi() { var logRecords = new List(); using (var loggerProvider = Sdk.CreateLoggerProviderBuilder() - .AddInMemoryExporter(logRecords) + .ConfigureServices(services => + { + services.AddLogging(builder => builder.AddOpenTelemetry(options => + { + options.AddInMemoryExporter(logRecords); + })); + }) .Build()) { var logger = loggerProvider.GetLogger(); From ed0385f1a72408d6ed84c1c6eaabecdf011c188e Mon Sep 17 00:00:00 2001 From: Yun-Ting Date: Fri, 26 Jan 2024 16:21:34 -0800 Subject: [PATCH 06/12] fix preprocessor --- .../OtlpLogExporterTests.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs index 44a4ef241b0..e03e618a6d1 100644 --- a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs +++ b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs @@ -589,7 +589,6 @@ public void CheckToOtlpLogRecordBodyIsPopulated(bool includeFormattedMessage) Assert.Equal("state", otlpLogRecord.Body.StringValue); } -#if NET8_0_OR_GREATER [Fact] public void LogRecordBodyIsExportedWhenUsingBridgeApi() { @@ -621,7 +620,6 @@ public void LogRecordBodyIsExportedWhenUsingBridgeApi() Assert.Equal("Hello world", otlpLogRecord.Body?.StringValue); } -#endif [Fact] public void CheckToOtlpLogRecordExceptionAttributes() From 47dc823ec2c68abd95cdba5327b8305b69abc126 Mon Sep 17 00:00:00 2001 From: Yun-Ting Date: Fri, 26 Jan 2024 16:23:53 -0800 Subject: [PATCH 07/12] convention --- .../CHANGELOG.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md index 9a4c4762f58..ec40a1527f1 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md @@ -2,10 +2,6 @@ ## Unreleased -* **Experimental (pre-release builds only):** Added - support for `Body` set directly on `LogRecord` via the Logs Bridge API. - [#5268](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5268) - * **Experimental (pre-release builds only):** Added `LoggerProviderBuilder.AddOtlpExporter` registration extensions. [#5103](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5103) @@ -19,6 +15,10 @@ will be automatically included in exports. ([#5258](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5258)) +* **Experimental (pre-release builds only):** Added + support for `Body` set directly on `LogRecord` via the Logs Bridge API. + [#5268](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5268) + ## 1.7.0 Released 2023-Dec-08 From 97eaf0a48ae7cd162e435d7f1136df337dedc6b1 Mon Sep 17 00:00:00 2001 From: Mikel Blanchard Date: Mon, 29 Jan 2024 09:39:38 -0800 Subject: [PATCH 08/12] Code review. --- .../AssemblyInfo.cs | 20 +++++++++++++++++++ .../OtlpLogExporterTests.cs | 8 +------- 2 files changed, 21 insertions(+), 7 deletions(-) create mode 100644 src/OpenTelemetry.Exporter.InMemory/AssemblyInfo.cs diff --git a/src/OpenTelemetry.Exporter.InMemory/AssemblyInfo.cs b/src/OpenTelemetry.Exporter.InMemory/AssemblyInfo.cs new file mode 100644 index 00000000000..f7775c1b9b8 --- /dev/null +++ b/src/OpenTelemetry.Exporter.InMemory/AssemblyInfo.cs @@ -0,0 +1,20 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#if !EXPOSE_EXPERIMENTAL_FEATURES +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests" + AssemblyInfo.PublicKey)] +#endif + +#if SIGNED +file static class AssemblyInfo +{ + public const string PublicKey = ", PublicKey=002400000480000094000000060200000024000052534131000400000100010051C1562A090FB0C9F391012A32198B5E5D9A60E9B80FA2D7B434C9E5CCB7259BD606E66F9660676AFC6692B8CDC6793D190904551D2103B7B22FA636DCBB8208839785BA402EA08FC00C8F1500CCEF28BBF599AA64FFB1E1D5DC1BF3420A3777BADFE697856E9D52070A50C3EA5821C80BEF17CA3ACFFA28F89DD413F096F898"; +} +#else +file static class AssemblyInfo +{ + public const string PublicKey = ""; +} +#endif diff --git a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs index e03e618a6d1..db81a8663f0 100644 --- a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs +++ b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs @@ -595,13 +595,7 @@ public void LogRecordBodyIsExportedWhenUsingBridgeApi() var logRecords = new List(); using (var loggerProvider = Sdk.CreateLoggerProviderBuilder() - .ConfigureServices(services => - { - services.AddLogging(builder => builder.AddOpenTelemetry(options => - { - options.AddInMemoryExporter(logRecords); - })); - }) + .AddInMemoryExporter(logRecords) .Build()) { var logger = loggerProvider.GetLogger(); From 367ff23bf4346470ec09f784e33430e808f11c69 Mon Sep 17 00:00:00 2001 From: Yun-Ting Lin Date: Tue, 30 Jan 2024 14:24:21 -0800 Subject: [PATCH 09/12] comment --- .../OtlpLogExporterTests.cs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs index db81a8663f0..9c8558dd2c9 100644 --- a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs +++ b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs @@ -589,8 +589,10 @@ public void CheckToOtlpLogRecordBodyIsPopulated(bool includeFormattedMessage) Assert.Equal("state", otlpLogRecord.Body.StringValue); } - [Fact] - public void LogRecordBodyIsExportedWhenUsingBridgeApi() + [Theory] + [InlineData(true)] + [InlineData(false)] + public void LogRecordBodyIsExportedWhenUsingBridgeApi(bool isBodySet) { var logRecords = new List(); @@ -602,7 +604,7 @@ public void LogRecordBodyIsExportedWhenUsingBridgeApi() logger.EmitLog(new LogRecordData() { - Body = "Hello world", + Body = isBodySet ? "Hello world" : null, }); } @@ -612,7 +614,14 @@ public void LogRecordBodyIsExportedWhenUsingBridgeApi() var otlpLogRecord = otlpLogRecordTransformer.ToOtlpLog(logRecords[0]); - Assert.Equal("Hello world", otlpLogRecord.Body?.StringValue); + if (isBodySet) + { + Assert.Equal("Hello world", otlpLogRecord.Body?.StringValue); + } + else + { + Assert.Null(otlpLogRecord.Body); + } } [Fact] From eef83a402970c5be47442d873c4623167fb36181 Mon Sep 17 00:00:00 2001 From: Yun-Ting Date: Wed, 31 Jan 2024 10:43:54 -0800 Subject: [PATCH 10/12] addressed a comment --- .../OtlpLogExporterTests.cs | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs index 9c8558dd2c9..3656dda54aa 100644 --- a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs +++ b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs @@ -594,6 +594,11 @@ public void CheckToOtlpLogRecordBodyIsPopulated(bool includeFormattedMessage) [InlineData(false)] public void LogRecordBodyIsExportedWhenUsingBridgeApi(bool isBodySet) { + LogRecordAttributeList attributes = default; + attributes.Add("name", "tomato"); + attributes.Add("price", 2.99); + attributes.Add("{OriginalFormat}", "Hello from {name} {price}."); + var logRecords = new List(); using (var loggerProvider = Sdk.CreateLoggerProviderBuilder() @@ -606,9 +611,11 @@ public void LogRecordBodyIsExportedWhenUsingBridgeApi(bool isBodySet) { Body = isBodySet ? "Hello world" : null, }); + + logger.EmitLog(new LogRecordData(), attributes); } - Assert.Single(logRecords); + Assert.Equal(2, logRecords.Count); var otlpLogRecordTransformer = new OtlpLogRecordTransformer(DefaultSdkLimitOptions, new()); @@ -622,6 +629,21 @@ public void LogRecordBodyIsExportedWhenUsingBridgeApi(bool isBodySet) { Assert.Null(otlpLogRecord.Body); } + + otlpLogRecord = otlpLogRecordTransformer.ToOtlpLog(logRecords[1]); + + Assert.Equal(2, otlpLogRecord.Attributes.Count); + + var index = 0; + var attribute = otlpLogRecord.Attributes[index]; + Assert.Equal("name", attribute.Key); + Assert.Equal("tomato", attribute.Value.StringValue); + + attribute = otlpLogRecord.Attributes[++index]; + Assert.Equal("price", attribute.Key); + Assert.Equal(2.99, attribute.Value.DoubleValue); + + Assert.Equal("Hello from {name} {price}.", otlpLogRecord.Body.StringValue); } [Fact] From 57599fef017be16f0afb1060255075e85b4fd27e Mon Sep 17 00:00:00 2001 From: Yun-Ting Lin Date: Wed, 31 Jan 2024 12:21:55 -0800 Subject: [PATCH 11/12] Apply suggestions from code review Co-authored-by: Vishwesh Bankwar --- src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md | 2 +- .../Implementation/OtlpLogRecordTransformer.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md index ec40a1527f1..da819796285 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md @@ -16,7 +16,7 @@ ([#5258](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5258)) * **Experimental (pre-release builds only):** Added - support for `Body` set directly on `LogRecord` via the Logs Bridge API. + support for setting `Body` directly on `LogRecord` via the Logs Bridge API. [#5268](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5268) ## 1.7.0 diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs index 6e4f5c074ec..607f8fa5584 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs @@ -171,7 +171,7 @@ internal OtlpLogs.LogRecord ToOtlpLog(LogRecord logRecord) } } - // Supports Body set directly on LogRecord for the Logs Bridge API. + // Supports setting Body directly on LogRecord for the Logs Bridge API. if (otlpLogRecord.Body == null && logRecord.Body != null) { // If {OriginalFormat} is not present in the attributes, From f4de1f56bc979a8615a23bd2382f487a5b99b2be Mon Sep 17 00:00:00 2001 From: Mikel Blanchard Date: Thu, 1 Feb 2024 09:59:39 -0800 Subject: [PATCH 12/12] CHANGELOG tweak. --- .../CHANGELOG.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md index da819796285..dcd24114fd1 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md @@ -15,9 +15,11 @@ will be automatically included in exports. ([#5258](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5258)) -* **Experimental (pre-release builds only):** Added - support for setting `Body` directly on `LogRecord` via the Logs Bridge API. - [#5268](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5268) +* Updated `OtlpLogExporter` to set `body` on the data model from + `LogRecord.Body` if `{OriginalFormat}` attribute is NOT found and + `FormattedMessage` is `null`. This is typically the case when using the + experimental Logs Bridge API. + ([#5268](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5268)) ## 1.7.0