From a40eb9bd3040d6689cab0e366c4a1ed8d0b63a78 Mon Sep 17 00:00:00 2001 From: Vishwesh Bankwar Date: Thu, 5 Oct 2023 13:15:51 -0700 Subject: [PATCH 01/10] draft --- .../Implementation/ExperimentalOptions.cs | 12 +++ .../OtlpLogRecordTransformer.cs | 41 ++++----- .../OtlpLogExporterTests.cs | 91 ++++++++++++++----- 3 files changed, 96 insertions(+), 48 deletions(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ExperimentalOptions.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ExperimentalOptions.cs index 2734ad8a158..caa2af689fd 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ExperimentalOptions.cs +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ExperimentalOptions.cs @@ -25,6 +25,8 @@ internal sealed class ExperimentalOptions { public const string EMITLOGEXCEPTIONATTRIBUTES = "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES"; + public const string EMITCATEGORYANDEVENTATTRIBUTES = "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_CATEGORY_AND_EVENT_LOG_ATTRIBUTES"; + public ExperimentalOptions() : this(new ConfigurationBuilder().AddEnvironmentVariables().Build()) { @@ -36,10 +38,20 @@ public ExperimentalOptions(IConfiguration configuration) { this.EmitLogExceptionAttributes = emitLogExceptionAttributes; } + + if (configuration.TryGetBoolValue(EMITCATEGORYANDEVENTATTRIBUTES, out var emitLogEventAndCategoryAttributes)) + { + this.EmitLogEventAndCategoryAttributes = emitLogEventAndCategoryAttributes; + } } /// /// Gets or sets a value indicating whether log exception attributes should be exported. /// public bool EmitLogExceptionAttributes { get; set; } = false; + + /// + /// Gets or sets a value indicating whether log event and category attributes should be exported. + /// + public bool EmitLogEventAndCategoryAttributes { get; set; } = false; } diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs index 3a7be7f04c8..52f462fb04e 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs @@ -91,33 +91,28 @@ internal OtlpLogs.LogRecord ToOtlpLog(LogRecord logRecord) var attributeValueLengthLimit = this.sdkLimitOptions.LogRecordAttributeValueLengthLimit; var attributeCountLimit = this.sdkLimitOptions.LogRecordAttributeCountLimit ?? int.MaxValue; - /* - // Removing this temporarily for stable release - // https://github.com/open-telemetry/opentelemetry-dotnet/issues/4776 - // https://github.com/open-telemetry/opentelemetry-dotnet/issues/3491 - // First add the generic attributes like Category, EventId and Exception, - // so they are less likely being dropped because of AttributeCountLimit. - - if (!string.IsNullOrEmpty(logRecord.CategoryName)) + if (this.experimentalOptions.EmitLogEventAndCategoryAttributes) { - // TODO: - // 1. Track the following issue, and map CategoryName to Name - // if it makes it to log data model. - // https://github.com/open-telemetry/opentelemetry-specification/issues/2398 - // 2. Confirm if this name for attribute is good. - otlpLogRecord.AddStringAttribute("dotnet.ilogger.category", logRecord.CategoryName, attributeValueLengthLimit, attributeCountLimit); - } + if (!string.IsNullOrEmpty(logRecord.CategoryName)) + { + // TODO: + // 1. Track the following issue, and map CategoryName to Name + // if it makes it to log data model. + // https://github.com/open-telemetry/opentelemetry-specification/issues/2398 + // 2. Confirm if this name for attribute is good. + AddStringAttribute(otlpLogRecord, "dotnet.ilogger.category", logRecord.CategoryName, attributeValueLengthLimit, attributeCountLimit); + } - if (logRecord.EventId.Id != default) - { - otlpLogRecord.AddIntAttribute(nameof(logRecord.EventId.Id), logRecord.EventId.Id, attributeCountLimit); - } + if (logRecord.EventId.Id != default) + { + AddIntAttribute(otlpLogRecord, "event.id", logRecord.EventId.Id, attributeCountLimit); + } - if (!string.IsNullOrEmpty(logRecord.EventId.Name)) - { - otlpLogRecord.AddStringAttribute(nameof(logRecord.EventId.Name), logRecord.EventId.Name, attributeValueLengthLimit, attributeCountLimit); + if (!string.IsNullOrEmpty(logRecord.EventId.Name)) + { + AddStringAttribute(otlpLogRecord, "event.name", logRecord.EventId.Name, attributeValueLengthLimit, attributeCountLimit); + } } - */ if (this.experimentalOptions.EmitLogExceptionAttributes && logRecord.Exception != null) { diff --git a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs index 0c2e6c06f9b..f03d34801c2 100644 --- a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs +++ b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs @@ -14,6 +14,7 @@ // limitations under the License. // +using System; using System.Collections.ObjectModel; using System.Diagnostics; using System.Reflection; @@ -209,9 +210,11 @@ public void OtlpLogRecordTestWhenStateValuesArePopulated() Assert.Equal("Hello from {name} {price}.", attribute.Value.StringValue); } - /* - [Fact] - public void CheckToOtlpLogRecordLoggerCategory() + [Theory] + [InlineData("true")] + [InlineData("false")] + [InlineData(null)] + public void CheckToOtlpLogRecordLoggerCategory(string emitLogEventAndCategoryAttributes) { var logRecords = new List(); using var loggerFactory = LoggerFactory.Create(builder => @@ -227,13 +230,29 @@ public void CheckToOtlpLogRecordLoggerCategory() Assert.Single(logRecords); var logRecord = logRecords[0]; - var otlpLogRecord = logRecord.ToOtlpLog(DefaultSdkLimitOptions, new()); - Assert.NotNull(otlpLogRecord); - Assert.Single(otlpLogRecord.Attributes); - var attribute = otlpLogRecord.Attributes[0]; - Assert.Equal("dotnet.ilogger.category", attribute.Key); - Assert.Equal("CategoryA", attribute.Value.StringValue); + var configuration = new ConfigurationBuilder() + .AddInMemoryCollection(new Dictionary { [ExperimentalOptions.EMITCATEGORYANDEVENTATTRIBUTES] = emitLogEventAndCategoryAttributes }) + .Build(); + + var otlpLogRecordTransformer = new OtlpLogRecordTransformer(DefaultSdkLimitOptions, new(configuration)); + + var otlpLogRecord = otlpLogRecordTransformer.ToOtlpLog(logRecord); + + if (emitLogEventAndCategoryAttributes == "true") + { + Assert.NotNull(otlpLogRecord); + Assert.Single(otlpLogRecord.Attributes); + + var attribute = otlpLogRecord.Attributes[0]; + Assert.Equal("dotnet.ilogger.category", attribute.Key); + Assert.Equal("CategoryA", attribute.Value.StringValue); + } + else + { + Assert.NotNull(otlpLogRecord); + Assert.Empty(otlpLogRecord.Attributes); + } logRecords.Clear(); var logger2 = loggerFactory.CreateLogger(string.Empty); @@ -241,13 +260,16 @@ public void CheckToOtlpLogRecordLoggerCategory() Assert.Single(logRecords); logRecord = logRecords[0]; - otlpLogRecord = logRecord.ToOtlpLog(DefaultSdkLimitOptions, new()); + otlpLogRecord = otlpLogRecordTransformer.ToOtlpLog(logRecord); Assert.NotNull(otlpLogRecord); Assert.Empty(otlpLogRecord.Attributes); } - [Fact] - public void CheckToOtlpLogRecordEventId() + [Theory] + [InlineData("true")] + [InlineData("false")] + [InlineData(null)] + public void CheckToOtlpLogRecordEventId(string emitLogEventAndCategoryAttributes) { var logRecords = new List(); using var loggerFactory = LoggerFactory.Create(builder => @@ -264,17 +286,30 @@ public void CheckToOtlpLogRecordEventId() logger.LogInformation(new EventId(10, null), "Hello from {name} {price}.", "tomato", 2.99); Assert.Single(logRecords); + var configuration = new ConfigurationBuilder() + .AddInMemoryCollection(new Dictionary { [ExperimentalOptions.EMITCATEGORYANDEVENTATTRIBUTES] = emitLogEventAndCategoryAttributes }) + .Build(); + + var otlpLogRecordTransformer = new OtlpLogRecordTransformer(DefaultSdkLimitOptions, new(configuration)); + var logRecord = logRecords[0]; - var otlpLogRecord = logRecord.ToOtlpLog(DefaultSdkLimitOptions, new()); + + var otlpLogRecord = otlpLogRecordTransformer.ToOtlpLog(logRecord); Assert.NotNull(otlpLogRecord); Assert.Equal("Hello from tomato 2.99.", otlpLogRecord.Body.StringValue); - var otlpLogRecordAttributes = otlpLogRecord.Attributes.ToString(); - // Event - Assert.Contains("Id", otlpLogRecordAttributes); - Assert.Contains("10", otlpLogRecordAttributes); + var otlpLogRecordAttributes = otlpLogRecord.Attributes.ToString(); + if (emitLogEventAndCategoryAttributes == "true") + { + Assert.Contains("event.id", otlpLogRecordAttributes); + Assert.Contains("10", otlpLogRecordAttributes); + } + else + { + Assert.DoesNotContain("event.id", otlpLogRecordAttributes); + } logRecords.Clear(); @@ -282,19 +317,25 @@ public void CheckToOtlpLogRecordEventId() Assert.Single(logRecords); logRecord = logRecords[0]; - otlpLogRecord = logRecord.ToOtlpLog(DefaultSdkLimitOptions, new()); + otlpLogRecord = otlpLogRecordTransformer.ToOtlpLog(logRecord); Assert.NotNull(otlpLogRecord); Assert.Equal("Hello from tomato 2.99.", otlpLogRecord.Body.StringValue); - otlpLogRecordAttributes = otlpLogRecord.Attributes.ToString(); - // Event - Assert.Contains("Id", otlpLogRecordAttributes); - Assert.Contains("10", otlpLogRecordAttributes); - Assert.Contains("Name", otlpLogRecordAttributes); - Assert.Contains("MyEvent10", otlpLogRecordAttributes); + otlpLogRecordAttributes = otlpLogRecord.Attributes.ToString(); + if (emitLogEventAndCategoryAttributes == "true") + { + Assert.Contains("event.id", otlpLogRecordAttributes); + Assert.Contains("10", otlpLogRecordAttributes); + Assert.Contains("event.name", otlpLogRecordAttributes); + Assert.Contains("MyEvent10", otlpLogRecordAttributes); + } + else + { + Assert.DoesNotContain("event.id", otlpLogRecordAttributes); + Assert.DoesNotContain("event.name", otlpLogRecordAttributes); + } } - */ [Fact] public void CheckToOtlpLogRecordTimestamps() From 0f4b254da1daf34d35108fb018e1fbf6898e375b Mon Sep 17 00:00:00 2001 From: Vishwesh Bankwar Date: Thu, 5 Oct 2023 17:46:50 -0700 Subject: [PATCH 02/10] changelog --- .../CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md index 90f64dd9c0a..010bc2e29c7 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md @@ -19,6 +19,13 @@ attributes will be exported when variable will be set to `true`. ([#4892](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4892)) +* Added ability to export attributes corresponding to `LogRecord.EventId` as +`event.id` and `event.name` and `LogRecord.Category` as +`dotnet.ilogger.category`. These attributes will be exported when +`OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_CATEGORY_AND_EVENT_LOG_ATTRIBUTES` will be +set to `true`. +([#]()) + ## 1.6.0 Released 2023-Sep-05 From e021b585c4b77cae9d44496a96f0133200b31ae3 Mon Sep 17 00:00:00 2001 From: Vishwesh Bankwar Date: Thu, 5 Oct 2023 17:49:11 -0700 Subject: [PATCH 03/10] typo --- src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md index 010bc2e29c7..3ca9f2f0d41 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md @@ -20,7 +20,7 @@ variable will be set to `true`. ([#4892](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4892)) * Added ability to export attributes corresponding to `LogRecord.EventId` as -`event.id` and `event.name` and `LogRecord.Category` as +`event.id` and `event.name` and `LogRecord.CategoryName` as `dotnet.ilogger.category`. These attributes will be exported when `OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_CATEGORY_AND_EVENT_LOG_ATTRIBUTES` will be set to `true`. From 05b7556a0c08a785fec6deea46d2b86a5ee90c49 Mon Sep 17 00:00:00 2001 From: Vishwesh Bankwar Date: Thu, 5 Oct 2023 17:58:36 -0700 Subject: [PATCH 04/10] changelog --- src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md index 3ca9f2f0d41..08b0d3d1c0d 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md @@ -24,7 +24,7 @@ variable will be set to `true`. `dotnet.ilogger.category`. These attributes will be exported when `OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_CATEGORY_AND_EVENT_LOG_ATTRIBUTES` will be set to `true`. -([#]()) +([#4925](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4925)) ## 1.6.0 From a9c75705f0f627ee54ce67084d07dbff62087c91 Mon Sep 17 00:00:00 2001 From: Vishwesh Bankwar Date: Thu, 5 Oct 2023 18:04:58 -0700 Subject: [PATCH 05/10] remove using --- .../OtlpLogExporterTests.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs index f03d34801c2..b174942bdde 100644 --- a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs +++ b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs @@ -14,7 +14,6 @@ // limitations under the License. // -using System; using System.Collections.ObjectModel; using System.Diagnostics; using System.Reflection; From f7cee62696a785e5326f4b1e44649c9a4c36e560 Mon Sep 17 00:00:00 2001 From: Vishwesh Bankwar Date: Thu, 5 Oct 2023 18:09:40 -0700 Subject: [PATCH 06/10] update readme --- src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md index 2f53e327ecc..8ec64280f55 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md @@ -229,6 +229,11 @@ When set to `true`, it enables export of attributes corresponding to `exception.stacktrace` are defined in [specification](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/exceptions/exceptions-logs.md#attributes). +* `OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_CATEGORY_AND_EVENT_LOG_ATTRIBUTES` + +When set to `true`, it enables export of `LogRecord.EventId` as `event.id` and +`event.name` and `LogRecord.CategoryName` as `dotnet.ilogger.category`. + ## Configure HttpClient The `HttpClientFactory` option is provided on `OtlpExporterOptions` for users From 8976d3f7a5e7e5afb020e3c3407ff064edc058a5 Mon Sep 17 00:00:00 2001 From: Vishwesh Bankwar Date: Fri, 6 Oct 2023 13:16:14 -0700 Subject: [PATCH 07/10] pr feedback --- .../CHANGELOG.md | 30 ++++++++++++++----- .../Implementation/ExperimentalOptions.cs | 22 ++++++++++---- .../OtlpLogRecordTransformer.cs | 11 +++---- .../README.md | 11 +++++-- .../OtlpLogExporterTests.cs | 14 ++++----- 5 files changed, 60 insertions(+), 28 deletions(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md index 08b0d3d1c0d..36899c72d8f 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md @@ -17,14 +17,28 @@ attributes will be exported when `OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES` environment variable will be set to `true`. -([#4892](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4892)) - -* Added ability to export attributes corresponding to `LogRecord.EventId` as -`event.id` and `event.name` and `LogRecord.CategoryName` as -`dotnet.ilogger.category`. These attributes will be exported when -`OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_CATEGORY_AND_EVENT_LOG_ATTRIBUTES` will be -set to `true`. -([#4925](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4925)) + + **NOTE**: These attributes were removed in [1.6.0-rc.1](#160-rc1) release in + order to support stable release of OTLP Log Exporter. The attributes will now be + available via environment variable mentioned above. + ([#4892](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4892)) + +* Added ability to export attributes corresponding to `LogRecord.EventId.Id` as +`event.id`, `LogRecord.EventId.Name` as `event.name` and +`LogRecord.CategoryName` as `dotnet.ilogger.category`. + + * The attributes for `LogRecord.EventId.Id` and `LogRecord.EventId.Name` will +be exported when `OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES` will +be set to `true`. + + * The attribute for `LogRecord.CategoryName` will be exported when +`OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_CATEGORY_LOG_ATTRIBUTE` will be set to +`true`. + + **NOTE**: These attributes were removed in [1.6.0-rc.1](#160-rc1) release in + order to support stable release of OTLP Log Exporter. The attributes will now be + available via environment variables mentioned above. + ([#4925](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4925)) ## 1.6.0 diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ExperimentalOptions.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ExperimentalOptions.cs index caa2af689fd..06b0b5c0513 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ExperimentalOptions.cs +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ExperimentalOptions.cs @@ -25,7 +25,9 @@ internal sealed class ExperimentalOptions { public const string EMITLOGEXCEPTIONATTRIBUTES = "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES"; - public const string EMITCATEGORYANDEVENTATTRIBUTES = "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_CATEGORY_AND_EVENT_LOG_ATTRIBUTES"; + public const string EMITLOGCATEGORYATTRIBUTE = "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_CATEGORY_LOG_ATTRIBUTE"; + + public const string EMITLOGEVENTATTRIBUTES = "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES"; public ExperimentalOptions() : this(new ConfigurationBuilder().AddEnvironmentVariables().Build()) @@ -39,9 +41,14 @@ public ExperimentalOptions(IConfiguration configuration) this.EmitLogExceptionAttributes = emitLogExceptionAttributes; } - if (configuration.TryGetBoolValue(EMITCATEGORYANDEVENTATTRIBUTES, out var emitLogEventAndCategoryAttributes)) + if (configuration.TryGetBoolValue(EMITLOGCATEGORYATTRIBUTE, out var emitLogCategoryAttribute)) + { + this.EmitLogCategoryAttribute = emitLogCategoryAttribute; + } + + if (configuration.TryGetBoolValue(EMITLOGEVENTATTRIBUTES, out var emitLogEventAttributes)) { - this.EmitLogEventAndCategoryAttributes = emitLogEventAndCategoryAttributes; + this.EmitLogEventAttributes = emitLogEventAttributes; } } @@ -51,7 +58,12 @@ public ExperimentalOptions(IConfiguration configuration) public bool EmitLogExceptionAttributes { get; set; } = false; /// - /// Gets or sets a value indicating whether log event and category attributes should be exported. + /// Gets or sets a value indicating whether log category attribute should be exported. + /// + public bool EmitLogCategoryAttribute { get; set; } = false; + + /// + /// Gets or sets a value indicating whether log event attributes should be exported. /// - public bool EmitLogEventAndCategoryAttributes { get; set; } = false; + public bool EmitLogEventAttributes { get; set; } = false; } diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs index 52f462fb04e..0cb64d40abd 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs @@ -91,18 +91,19 @@ internal OtlpLogs.LogRecord ToOtlpLog(LogRecord logRecord) var attributeValueLengthLimit = this.sdkLimitOptions.LogRecordAttributeValueLengthLimit; var attributeCountLimit = this.sdkLimitOptions.LogRecordAttributeCountLimit ?? int.MaxValue; - if (this.experimentalOptions.EmitLogEventAndCategoryAttributes) + if (this.experimentalOptions.EmitLogCategoryAttribute) { if (!string.IsNullOrEmpty(logRecord.CategoryName)) { // TODO: - // 1. Track the following issue, and map CategoryName to Name - // if it makes it to log data model. - // https://github.com/open-telemetry/opentelemetry-specification/issues/2398 - // 2. Confirm if this name for attribute is good. + // Decide how to handle CategoryName + // https://github.com/open-telemetry/opentelemetry-dotnet/issues/3491 AddStringAttribute(otlpLogRecord, "dotnet.ilogger.category", logRecord.CategoryName, attributeValueLengthLimit, attributeCountLimit); } + } + if (this.experimentalOptions.EmitLogEventAttributes) + { if (logRecord.EventId.Id != default) { AddIntAttribute(otlpLogRecord, "event.id", logRecord.EventId.Id, attributeCountLimit); diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md index 8ec64280f55..4f49a9e686c 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md @@ -229,10 +229,15 @@ When set to `true`, it enables export of attributes corresponding to `exception.stacktrace` are defined in [specification](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/exceptions/exceptions-logs.md#attributes). -* `OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_CATEGORY_AND_EVENT_LOG_ATTRIBUTES` +* `OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_CATEGORY_LOG_ATTRIBUTE` -When set to `true`, it enables export of `LogRecord.EventId` as `event.id` and -`event.name` and `LogRecord.CategoryName` as `dotnet.ilogger.category`. +When set to `true`, it enables export `LogRecord.CategoryName` as +`dotnet.ilogger.category`. + +* `OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_CATEGORY_EVENT_ATTRIBUTES + +When set to `true`, it enables export of `LogRecord.EventId.Id` as `event.id` +and `LogRecord.EventId.Name` to `event.name`. ## Configure HttpClient diff --git a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs index b174942bdde..4a89e8b6451 100644 --- a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs +++ b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs @@ -213,7 +213,7 @@ public void OtlpLogRecordTestWhenStateValuesArePopulated() [InlineData("true")] [InlineData("false")] [InlineData(null)] - public void CheckToOtlpLogRecordLoggerCategory(string emitLogEventAndCategoryAttributes) + public void CheckToOtlpLogRecordLoggerCategory(string emitLogCategoryAttribute) { var logRecords = new List(); using var loggerFactory = LoggerFactory.Create(builder => @@ -231,14 +231,14 @@ public void CheckToOtlpLogRecordLoggerCategory(string emitLogEventAndCategoryAtt var logRecord = logRecords[0]; var configuration = new ConfigurationBuilder() - .AddInMemoryCollection(new Dictionary { [ExperimentalOptions.EMITCATEGORYANDEVENTATTRIBUTES] = emitLogEventAndCategoryAttributes }) + .AddInMemoryCollection(new Dictionary { [ExperimentalOptions.EMITLOGCATEGORYATTRIBUTE] = emitLogCategoryAttribute }) .Build(); var otlpLogRecordTransformer = new OtlpLogRecordTransformer(DefaultSdkLimitOptions, new(configuration)); var otlpLogRecord = otlpLogRecordTransformer.ToOtlpLog(logRecord); - if (emitLogEventAndCategoryAttributes == "true") + if (emitLogCategoryAttribute == "true") { Assert.NotNull(otlpLogRecord); Assert.Single(otlpLogRecord.Attributes); @@ -268,7 +268,7 @@ public void CheckToOtlpLogRecordLoggerCategory(string emitLogEventAndCategoryAtt [InlineData("true")] [InlineData("false")] [InlineData(null)] - public void CheckToOtlpLogRecordEventId(string emitLogEventAndCategoryAttributes) + public void CheckToOtlpLogRecordEventId(string emitLogEventAttributes) { var logRecords = new List(); using var loggerFactory = LoggerFactory.Create(builder => @@ -286,7 +286,7 @@ public void CheckToOtlpLogRecordEventId(string emitLogEventAndCategoryAttributes Assert.Single(logRecords); var configuration = new ConfigurationBuilder() - .AddInMemoryCollection(new Dictionary { [ExperimentalOptions.EMITCATEGORYANDEVENTATTRIBUTES] = emitLogEventAndCategoryAttributes }) + .AddInMemoryCollection(new Dictionary { [ExperimentalOptions.EMITLOGEVENTATTRIBUTES] = emitLogEventAttributes }) .Build(); var otlpLogRecordTransformer = new OtlpLogRecordTransformer(DefaultSdkLimitOptions, new(configuration)); @@ -300,7 +300,7 @@ public void CheckToOtlpLogRecordEventId(string emitLogEventAndCategoryAttributes // Event var otlpLogRecordAttributes = otlpLogRecord.Attributes.ToString(); - if (emitLogEventAndCategoryAttributes == "true") + if (emitLogEventAttributes == "true") { Assert.Contains("event.id", otlpLogRecordAttributes); Assert.Contains("10", otlpLogRecordAttributes); @@ -322,7 +322,7 @@ public void CheckToOtlpLogRecordEventId(string emitLogEventAndCategoryAttributes // Event otlpLogRecordAttributes = otlpLogRecord.Attributes.ToString(); - if (emitLogEventAndCategoryAttributes == "true") + if (emitLogEventAttributes == "true") { Assert.Contains("event.id", otlpLogRecordAttributes); Assert.Contains("10", otlpLogRecordAttributes); From d5c9e658344ca90f186d8475dd1db9789a5a1326 Mon Sep 17 00:00:00 2001 From: Vishwesh Bankwar Date: Thu, 12 Oct 2023 15:09:26 -0700 Subject: [PATCH 08/10] update attribute names --- .../CHANGELOG.md | 17 ++-- .../Implementation/ExperimentalOptions.cs | 22 ++---- .../OtlpLogRecordTransformer.cs | 15 +--- .../README.md | 9 +-- .../OtlpLogExporterTests.cs | 78 +++---------------- 5 files changed, 25 insertions(+), 116 deletions(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md index 36899c72d8f..a9d7b07b5f7 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md @@ -24,20 +24,13 @@ variable will be set to `true`. ([#4892](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4892)) * Added ability to export attributes corresponding to `LogRecord.EventId.Id` as -`event.id`, `LogRecord.EventId.Name` as `event.name` and -`LogRecord.CategoryName` as `dotnet.ilogger.category`. - - * The attributes for `LogRecord.EventId.Id` and `LogRecord.EventId.Name` will -be exported when `OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES` will -be set to `true`. - - * The attribute for `LogRecord.CategoryName` will be exported when -`OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_CATEGORY_LOG_ATTRIBUTE` will be set to -`true`. +`logrecord.event.id` and `LogRecord.EventId.Name` as `logrecord.event.name`. The +attributes will be exported when +`OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES` will be set to `true`. **NOTE**: These attributes were removed in [1.6.0-rc.1](#160-rc1) release in - order to support stable release of OTLP Log Exporter. The attributes will now be - available via environment variables mentioned above. + order to support stable release of OTLP Log Exporter. The attributes will now + be available via environment variable mentioned above. ([#4925](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4925)) ## 1.6.0 diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ExperimentalOptions.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ExperimentalOptions.cs index 06b0b5c0513..5c5cf8ec1e6 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ExperimentalOptions.cs +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ExperimentalOptions.cs @@ -23,11 +23,13 @@ namespace OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation; internal sealed class ExperimentalOptions { - public const string EMITLOGEXCEPTIONATTRIBUTES = "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES"; + public const string LogRecordEventIdAttribute = "logrecord.event.id"; - public const string EMITLOGCATEGORYATTRIBUTE = "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_CATEGORY_LOG_ATTRIBUTE"; + public const string LogRecordEventNameAttribute = "logrecord.evenet.name"; - public const string EMITLOGEVENTATTRIBUTES = "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES"; + public const string EmitLogExceptionEnvVar = "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES"; + + public const string EmitLogEventEnvVar = "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES"; public ExperimentalOptions() : this(new ConfigurationBuilder().AddEnvironmentVariables().Build()) @@ -36,17 +38,12 @@ public ExperimentalOptions() public ExperimentalOptions(IConfiguration configuration) { - if (configuration.TryGetBoolValue(EMITLOGEXCEPTIONATTRIBUTES, out var emitLogExceptionAttributes)) + if (configuration.TryGetBoolValue(EmitLogExceptionEnvVar, out var emitLogExceptionAttributes)) { this.EmitLogExceptionAttributes = emitLogExceptionAttributes; } - if (configuration.TryGetBoolValue(EMITLOGCATEGORYATTRIBUTE, out var emitLogCategoryAttribute)) - { - this.EmitLogCategoryAttribute = emitLogCategoryAttribute; - } - - if (configuration.TryGetBoolValue(EMITLOGEVENTATTRIBUTES, out var emitLogEventAttributes)) + if (configuration.TryGetBoolValue(EmitLogEventEnvVar, out var emitLogEventAttributes)) { this.EmitLogEventAttributes = emitLogEventAttributes; } @@ -57,11 +54,6 @@ public ExperimentalOptions(IConfiguration configuration) /// public bool EmitLogExceptionAttributes { get; set; } = false; - /// - /// Gets or sets a value indicating whether log category attribute should be exported. - /// - public bool EmitLogCategoryAttribute { get; set; } = false; - /// /// Gets or sets a value indicating whether log event attributes should be exported. /// diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs index 0cb64d40abd..1c7933e4fae 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs @@ -91,27 +91,16 @@ internal OtlpLogs.LogRecord ToOtlpLog(LogRecord logRecord) var attributeValueLengthLimit = this.sdkLimitOptions.LogRecordAttributeValueLengthLimit; var attributeCountLimit = this.sdkLimitOptions.LogRecordAttributeCountLimit ?? int.MaxValue; - if (this.experimentalOptions.EmitLogCategoryAttribute) - { - if (!string.IsNullOrEmpty(logRecord.CategoryName)) - { - // TODO: - // Decide how to handle CategoryName - // https://github.com/open-telemetry/opentelemetry-dotnet/issues/3491 - AddStringAttribute(otlpLogRecord, "dotnet.ilogger.category", logRecord.CategoryName, attributeValueLengthLimit, attributeCountLimit); - } - } - if (this.experimentalOptions.EmitLogEventAttributes) { if (logRecord.EventId.Id != default) { - AddIntAttribute(otlpLogRecord, "event.id", logRecord.EventId.Id, attributeCountLimit); + AddIntAttribute(otlpLogRecord, ExperimentalOptions.LogRecordEventIdAttribute, logRecord.EventId.Id, attributeCountLimit); } if (!string.IsNullOrEmpty(logRecord.EventId.Name)) { - AddStringAttribute(otlpLogRecord, "event.name", logRecord.EventId.Name, attributeValueLengthLimit, attributeCountLimit); + AddStringAttribute(otlpLogRecord, ExperimentalOptions.LogRecordEventNameAttribute, logRecord.EventId.Name, attributeValueLengthLimit, attributeCountLimit); } } diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md index 4f49a9e686c..c8e52220f3a 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md @@ -229,15 +229,10 @@ When set to `true`, it enables export of attributes corresponding to `exception.stacktrace` are defined in [specification](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/exceptions/exceptions-logs.md#attributes). -* `OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_CATEGORY_LOG_ATTRIBUTE` - -When set to `true`, it enables export `LogRecord.CategoryName` as -`dotnet.ilogger.category`. - * `OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_CATEGORY_EVENT_ATTRIBUTES -When set to `true`, it enables export of `LogRecord.EventId.Id` as `event.id` -and `LogRecord.EventId.Name` to `event.name`. +When set to `true`, it enables export of `LogRecord.EventId.Id` as +`logrecord.event.id` and `LogRecord.EventId.Name` to `logrecord.event.name`. ## Configure HttpClient diff --git a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs index 4a89e8b6451..a5b42956e4f 100644 --- a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs +++ b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs @@ -191,12 +191,6 @@ public void OtlpLogRecordTestWhenStateValuesArePopulated() var index = 0; var attribute = otlpLogRecord.Attributes[index]; - /* - Assert.Equal("dotnet.ilogger.category", attribute.Key); - Assert.Equal("OtlpLogExporterTests", attribute.Value.StringValue); - attribute = otlpLogRecord.Attributes[++index]; - */ - Assert.Equal("name", attribute.Key); Assert.Equal("tomato", attribute.Value.StringValue); @@ -209,61 +203,6 @@ public void OtlpLogRecordTestWhenStateValuesArePopulated() Assert.Equal("Hello from {name} {price}.", attribute.Value.StringValue); } - [Theory] - [InlineData("true")] - [InlineData("false")] - [InlineData(null)] - public void CheckToOtlpLogRecordLoggerCategory(string emitLogCategoryAttribute) - { - var logRecords = new List(); - using var loggerFactory = LoggerFactory.Create(builder => - { - builder.AddOpenTelemetry(options => - { - options.AddInMemoryExporter(logRecords); - }); - }); - - var logger1 = loggerFactory.CreateLogger("CategoryA"); - logger1.LogInformation("Hello"); - Assert.Single(logRecords); - - var logRecord = logRecords[0]; - - var configuration = new ConfigurationBuilder() - .AddInMemoryCollection(new Dictionary { [ExperimentalOptions.EMITLOGCATEGORYATTRIBUTE] = emitLogCategoryAttribute }) - .Build(); - - var otlpLogRecordTransformer = new OtlpLogRecordTransformer(DefaultSdkLimitOptions, new(configuration)); - - var otlpLogRecord = otlpLogRecordTransformer.ToOtlpLog(logRecord); - - if (emitLogCategoryAttribute == "true") - { - Assert.NotNull(otlpLogRecord); - Assert.Single(otlpLogRecord.Attributes); - - var attribute = otlpLogRecord.Attributes[0]; - Assert.Equal("dotnet.ilogger.category", attribute.Key); - Assert.Equal("CategoryA", attribute.Value.StringValue); - } - else - { - Assert.NotNull(otlpLogRecord); - Assert.Empty(otlpLogRecord.Attributes); - } - - logRecords.Clear(); - var logger2 = loggerFactory.CreateLogger(string.Empty); - logger2.LogInformation("Hello"); - Assert.Single(logRecords); - - logRecord = logRecords[0]; - otlpLogRecord = otlpLogRecordTransformer.ToOtlpLog(logRecord); - Assert.NotNull(otlpLogRecord); - Assert.Empty(otlpLogRecord.Attributes); - } - [Theory] [InlineData("true")] [InlineData("false")] @@ -286,7 +225,7 @@ public void CheckToOtlpLogRecordEventId(string emitLogEventAttributes) Assert.Single(logRecords); var configuration = new ConfigurationBuilder() - .AddInMemoryCollection(new Dictionary { [ExperimentalOptions.EMITLOGEVENTATTRIBUTES] = emitLogEventAttributes }) + .AddInMemoryCollection(new Dictionary { [ExperimentalOptions.EmitLogEventEnvVar] = emitLogEventAttributes }) .Build(); var otlpLogRecordTransformer = new OtlpLogRecordTransformer(DefaultSdkLimitOptions, new(configuration)); @@ -302,12 +241,12 @@ public void CheckToOtlpLogRecordEventId(string emitLogEventAttributes) var otlpLogRecordAttributes = otlpLogRecord.Attributes.ToString(); if (emitLogEventAttributes == "true") { - Assert.Contains("event.id", otlpLogRecordAttributes); + Assert.Contains(ExperimentalOptions.LogRecordEventIdAttribute, otlpLogRecordAttributes); Assert.Contains("10", otlpLogRecordAttributes); } else { - Assert.DoesNotContain("event.id", otlpLogRecordAttributes); + Assert.DoesNotContain(ExperimentalOptions.LogRecordEventIdAttribute, otlpLogRecordAttributes); } logRecords.Clear(); @@ -324,15 +263,15 @@ public void CheckToOtlpLogRecordEventId(string emitLogEventAttributes) otlpLogRecordAttributes = otlpLogRecord.Attributes.ToString(); if (emitLogEventAttributes == "true") { - Assert.Contains("event.id", otlpLogRecordAttributes); + Assert.Contains(ExperimentalOptions.LogRecordEventIdAttribute, otlpLogRecordAttributes); Assert.Contains("10", otlpLogRecordAttributes); - Assert.Contains("event.name", otlpLogRecordAttributes); + Assert.Contains(ExperimentalOptions.LogRecordEventNameAttribute, otlpLogRecordAttributes); Assert.Contains("MyEvent10", otlpLogRecordAttributes); } else { - Assert.DoesNotContain("event.id", otlpLogRecordAttributes); - Assert.DoesNotContain("event.name", otlpLogRecordAttributes); + Assert.DoesNotContain(ExperimentalOptions.LogRecordEventIdAttribute, otlpLogRecordAttributes); + Assert.DoesNotContain(ExperimentalOptions.LogRecordEventNameAttribute, otlpLogRecordAttributes); } } @@ -547,6 +486,7 @@ public void CheckToOtlpLogRecordBodyIsPopulated(bool includeFormattedMessage) [Theory] [InlineData("true")] [InlineData("false")] + [InlineData(null)] public void CheckToOtlpLogRecordExceptionAttributes(string emitExceptionAttributes) { var logRecords = new List(); @@ -564,7 +504,7 @@ public void CheckToOtlpLogRecordExceptionAttributes(string emitExceptionAttribut var logRecord = logRecords[0]; var loggedException = logRecord.Exception; var configuration = new ConfigurationBuilder() - .AddInMemoryCollection(new Dictionary { [ExperimentalOptions.EMITLOGEXCEPTIONATTRIBUTES] = emitExceptionAttributes }) + .AddInMemoryCollection(new Dictionary { [ExperimentalOptions.EmitLogExceptionEnvVar] = emitExceptionAttributes }) .Build(); var otlpLogRecordTransformer = new OtlpLogRecordTransformer(DefaultSdkLimitOptions, new(configuration)); From 235732d14335ce36c88d1cba0298c76b96b14bdf Mon Sep 17 00:00:00 2001 From: Vishwesh Bankwar Date: Thu, 12 Oct 2023 15:10:10 -0700 Subject: [PATCH 09/10] fix md --- src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md index c8e52220f3a..94278f7a3d5 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md @@ -229,7 +229,7 @@ When set to `true`, it enables export of attributes corresponding to `exception.stacktrace` are defined in [specification](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/exceptions/exceptions-logs.md#attributes). -* `OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_CATEGORY_EVENT_ATTRIBUTES +* `OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_CATEGORY_EVENT_ATTRIBUTES` When set to `true`, it enables export of `LogRecord.EventId.Id` as `logrecord.event.id` and `LogRecord.EventId.Name` to `logrecord.event.name`. From 505fd0566c858b5d7ad5b6d0799ddd0e4f9f1d9b Mon Sep 17 00:00:00 2001 From: Vishwesh Bankwar Date: Thu, 12 Oct 2023 15:15:08 -0700 Subject: [PATCH 10/10] typo --- .../Implementation/ExperimentalOptions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ExperimentalOptions.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ExperimentalOptions.cs index 5c5cf8ec1e6..2c27b3f9990 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ExperimentalOptions.cs +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ExperimentalOptions.cs @@ -25,7 +25,7 @@ internal sealed class ExperimentalOptions { public const string LogRecordEventIdAttribute = "logrecord.event.id"; - public const string LogRecordEventNameAttribute = "logrecord.evenet.name"; + public const string LogRecordEventNameAttribute = "logrecord.event.name"; public const string EmitLogExceptionEnvVar = "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES";