From 037cda86d82baffc09d22c74a391c648fac5e308 Mon Sep 17 00:00:00 2001 From: Vishwesh Bankwar Date: Mon, 16 Oct 2023 13:17:38 -0700 Subject: [PATCH 1/4] [OTLP] Export LogRecord.CategoryName as InstrumentationScope name (#4941) --- .../CHANGELOG.md | 6 ++ .../OtlpLogRecordTransformer.cs | 55 ++++++++++++++++- .../OtlpLogExporter.cs | 11 +++- .../OtlpLogExporterTests.cs | 59 +++++++++++++++++++ 4 files changed, 127 insertions(+), 4 deletions(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md index 90f64dd9c0a..09690b7182d 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md @@ -19,6 +19,12 @@ attributes will be exported when variable will be set to `true`. ([#4892](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4892)) +* `LogRecord.CategoryName` will now be exported as +[InstrumentationScope](https://github.com/open-telemetry/opentelemetry-dotnet/blob/3c2bb7c93dd2e697636479a1882f49bb0c4a362e/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/opentelemetry/proto/common/v1/common.proto#L71-L81) +`name` field under +[ScopeLogs](https://github.com/open-telemetry/opentelemetry-dotnet/blob/3c2bb7c93dd2e697636479a1882f49bb0c4a362e/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/opentelemetry/proto/logs/v1/logs.proto#L64-L75). +([#4941](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4941)) + ## 1.6.0 Released 2023-Sep-05 diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs index 3a7be7f04c8..73101b2f4e5 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs @@ -14,6 +14,7 @@ // limitations under the License. // +using System.Collections.Concurrent; using System.Runtime.CompilerServices; using Google.Protobuf; using OpenTelemetry.Internal; @@ -28,6 +29,8 @@ namespace OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation; internal sealed class OtlpLogRecordTransformer { + internal static readonly ConcurrentBag LogListPool = new(); + private readonly SdkLimitOptions sdkLimitOptions; private readonly ExperimentalOptions experimentalOptions; @@ -41,6 +44,9 @@ internal OtlpCollector.ExportLogsServiceRequest BuildExportRequest( OtlpResource.Resource processResource, in Batch logRecordBatch) { + // TODO: https://github.com/open-telemetry/opentelemetry-dotnet/issues/4943 + Dictionary logsByCategory = new Dictionary(); + var request = new OtlpCollector.ExportLogsServiceRequest(); var resourceLogs = new OtlpLogs.ResourceLogs @@ -49,14 +55,18 @@ internal OtlpCollector.ExportLogsServiceRequest BuildExportRequest( }; request.ResourceLogs.Add(resourceLogs); - var scopeLogs = new OtlpLogs.ScopeLogs(); - resourceLogs.ScopeLogs.Add(scopeLogs); - foreach (var logRecord in logRecordBatch) { var otlpLogRecord = this.ToOtlpLog(logRecord); if (otlpLogRecord != null) { + if (!logsByCategory.TryGetValue(logRecord.CategoryName, out var scopeLogs)) + { + scopeLogs = this.GetLogListFromPool(logRecord.CategoryName); + logsByCategory.Add(logRecord.CategoryName, scopeLogs); + resourceLogs.ScopeLogs.Add(scopeLogs); + } + scopeLogs.LogRecords.Add(otlpLogRecord); } } @@ -64,6 +74,45 @@ internal OtlpCollector.ExportLogsServiceRequest BuildExportRequest( return request; } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + internal void Return(OtlpCollector.ExportLogsServiceRequest request) + { + var resourceLogs = request.ResourceLogs.FirstOrDefault(); + if (resourceLogs == null) + { + return; + } + + foreach (var scope in resourceLogs.ScopeLogs) + { + scope.LogRecords.Clear(); + LogListPool.Add(scope); + } + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + internal OtlpLogs.ScopeLogs GetLogListFromPool(string name) + { + if (!LogListPool.TryTake(out var logs)) + { + logs = new OtlpLogs.ScopeLogs + { + Scope = new OtlpCommon.InstrumentationScope + { + Name = name, // Name is enforced to not be null, but it can be empty. + Version = string.Empty, // proto requires this to be non-null. + }, + }; + } + else + { + logs.Scope.Name = name; + logs.Scope.Version = string.Empty; + } + + return logs; + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] internal OtlpLogs.LogRecord ToOtlpLog(LogRecord logRecord) { diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpLogExporter.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpLogExporter.cs index 715ec0de263..757691d1702 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpLogExporter.cs +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpLogExporter.cs @@ -90,9 +90,11 @@ public override ExportResult Export(in Batch logRecordBatch) // Prevents the exporter's gRPC and HTTP operations from being instrumented. using var scope = SuppressInstrumentationScope.Begin(); + OtlpCollector.ExportLogsServiceRequest request = null; + try { - var request = this.otlpLogRecordTransformer.BuildExportRequest(this.ProcessResource, logRecordBatch); + request = this.otlpLogRecordTransformer.BuildExportRequest(this.ProcessResource, logRecordBatch); if (!this.exportClient.SendExportRequest(request)) { @@ -104,6 +106,13 @@ public override ExportResult Export(in Batch logRecordBatch) OpenTelemetryProtocolExporterEventSource.Log.ExportMethodException(ex); return ExportResult.Failure; } + finally + { + if (request != null) + { + this.otlpLogRecordTransformer.Return(request); + } + } return ExportResult.Success; } diff --git a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs index 0c2e6c06f9b..00ba07d96a7 100644 --- a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs +++ b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs @@ -26,6 +26,7 @@ using OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation.ExportClient; using OpenTelemetry.Internal; using OpenTelemetry.Logs; +using OpenTelemetry.Resources; using OpenTelemetry.Tests; using OpenTelemetry.Trace; using Xunit; @@ -1242,6 +1243,64 @@ public void AddOtlpLogExporterLogRecordProcessorOptionsTest(ExportProcessorType } } + [Fact] + public void ValidateInstrumentationScope() + { + var logRecords = new List(); + using var loggerFactory = LoggerFactory.Create(builder => + { + builder + .AddOpenTelemetry(options => options + .AddInMemoryExporter(logRecords)); + }); + + var logger1 = loggerFactory.CreateLogger("OtlpLogExporterTests-A"); + logger1.LogInformation("Hello from red-tomato"); + + var logger2 = loggerFactory.CreateLogger("OtlpLogExporterTests-B"); + logger2.LogInformation("Hello from green-tomato"); + + Assert.Equal(2, logRecords.Count); + + var batch = new Batch(logRecords.ToArray(), logRecords.Count); + var logRecordTransformer = new OtlpLogRecordTransformer(new(), new()); + + var resourceBuilder = ResourceBuilder.CreateEmpty(); + var processResource = resourceBuilder.Build().ToOtlpResource(); + + var request = logRecordTransformer.BuildExportRequest(processResource, batch); + + Assert.Single(request.ResourceLogs); + + var scope1 = request.ResourceLogs[0].ScopeLogs.First(); + var scope2 = request.ResourceLogs[0].ScopeLogs.Last(); + + Assert.Equal("OtlpLogExporterTests-A", scope1.Scope.Name); + Assert.Equal("OtlpLogExporterTests-B", scope2.Scope.Name); + + Assert.Single(scope1.LogRecords); + Assert.Single(scope2.LogRecords); + + var logrecord1 = scope1.LogRecords[0]; + var logrecord2 = scope2.LogRecords[0]; + + Assert.Equal("Hello from red-tomato", logrecord1.Body.StringValue); + + Assert.Equal("Hello from green-tomato", logrecord2.Body.StringValue); + + // Validate LogListPool + Assert.Empty(OtlpLogRecordTransformer.LogListPool); + logRecordTransformer.Return(request); + Assert.Equal(2, OtlpLogRecordTransformer.LogListPool.Count); + + request = logRecordTransformer.BuildExportRequest(processResource, batch); + + Assert.Single(request.ResourceLogs); + + // ScopeLogs will be reused. + Assert.Empty(OtlpLogRecordTransformer.LogListPool); + } + private static OtlpCommon.KeyValue TryGetAttribute(OtlpLogs.LogRecord record, string key) { return record.Attributes.FirstOrDefault(att => att.Key == key); From 33fdd4769a203bf03f61792d9ee33cffa72e53c5 Mon Sep 17 00:00:00 2001 From: Vishwesh Bankwar Date: Mon, 16 Oct 2023 14:05:40 -0700 Subject: [PATCH 2/4] Add ability to export attributes corresponding to `Logrecord.EventId` (#4925) --- .../CHANGELOG.md | 16 ++- .../Implementation/ExperimentalOptions.cs | 20 +++- .../OtlpLogRecordTransformer.cs | 33 ++----- .../README.md | 5 + .../OtlpLogExporterTests.cs | 98 ++++++++----------- 5 files changed, 86 insertions(+), 86 deletions(-) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md index 09690b7182d..f305b56b0a0 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md @@ -17,7 +17,21 @@ 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)) + + **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 +`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 variable mentioned above. + ([#4925](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4925)) * `LogRecord.CategoryName` will now be exported as [InstrumentationScope](https://github.com/open-telemetry/opentelemetry-dotnet/blob/3c2bb7c93dd2e697636479a1882f49bb0c4a362e/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/opentelemetry/proto/common/v1/common.proto#L71-L81) diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ExperimentalOptions.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ExperimentalOptions.cs index 2734ad8a158..2c27b3f9990 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ExperimentalOptions.cs +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ExperimentalOptions.cs @@ -23,7 +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 LogRecordEventNameAttribute = "logrecord.event.name"; + + 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()) @@ -32,14 +38,24 @@ 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(EmitLogEventEnvVar, out var emitLogEventAttributes)) + { + this.EmitLogEventAttributes = emitLogEventAttributes; + } } /// /// 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 attributes should be exported. + /// + 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 73101b2f4e5..c185c24c251 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs @@ -140,33 +140,18 @@ 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.EmitLogEventAttributes) { - // 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 (logRecord.EventId.Id != default) - { - otlpLogRecord.AddIntAttribute(nameof(logRecord.EventId.Id), logRecord.EventId.Id, attributeCountLimit); - } + if (logRecord.EventId.Id != default) + { + AddIntAttribute(otlpLogRecord, ExperimentalOptions.LogRecordEventIdAttribute, 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, ExperimentalOptions.LogRecordEventNameAttribute, logRecord.EventId.Name, attributeValueLengthLimit, attributeCountLimit); + } } - */ if (this.experimentalOptions.EmitLogExceptionAttributes && logRecord.Exception != null) { diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md index 2f53e327ecc..94278f7a3d5 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_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`. + ## Configure HttpClient The `HttpClientFactory` option is provided on `OtlpExporterOptions` for users diff --git a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs index 00ba07d96a7..172ec254566 100644 --- a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs +++ b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs @@ -192,12 +192,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); @@ -210,45 +204,11 @@ public void OtlpLogRecordTestWhenStateValuesArePopulated() Assert.Equal("Hello from {name} {price}.", attribute.Value.StringValue); } - /* - [Fact] - public void CheckToOtlpLogRecordLoggerCategory() - { - 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 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); - - logRecords.Clear(); - var logger2 = loggerFactory.CreateLogger(string.Empty); - logger2.LogInformation("Hello"); - Assert.Single(logRecords); - - logRecord = logRecords[0]; - otlpLogRecord = logRecord.ToOtlpLog(DefaultSdkLimitOptions, new()); - Assert.NotNull(otlpLogRecord); - Assert.Empty(otlpLogRecord.Attributes); - } - - [Fact] - public void CheckToOtlpLogRecordEventId() + [Theory] + [InlineData("true")] + [InlineData("false")] + [InlineData(null)] + public void CheckToOtlpLogRecordEventId(string emitLogEventAttributes) { var logRecords = new List(); using var loggerFactory = LoggerFactory.Create(builder => @@ -265,17 +225,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.EmitLogEventEnvVar] = emitLogEventAttributes }) + .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 (emitLogEventAttributes == "true") + { + Assert.Contains(ExperimentalOptions.LogRecordEventIdAttribute, otlpLogRecordAttributes); + Assert.Contains("10", otlpLogRecordAttributes); + } + else + { + Assert.DoesNotContain(ExperimentalOptions.LogRecordEventIdAttribute, otlpLogRecordAttributes); + } logRecords.Clear(); @@ -283,19 +256,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 (emitLogEventAttributes == "true") + { + Assert.Contains(ExperimentalOptions.LogRecordEventIdAttribute, otlpLogRecordAttributes); + Assert.Contains("10", otlpLogRecordAttributes); + Assert.Contains(ExperimentalOptions.LogRecordEventNameAttribute, otlpLogRecordAttributes); + Assert.Contains("MyEvent10", otlpLogRecordAttributes); + } + else + { + Assert.DoesNotContain(ExperimentalOptions.LogRecordEventIdAttribute, otlpLogRecordAttributes); + Assert.DoesNotContain(ExperimentalOptions.LogRecordEventNameAttribute, otlpLogRecordAttributes); + } } - */ [Fact] public void CheckToOtlpLogRecordTimestamps() @@ -508,6 +487,7 @@ public void CheckToOtlpLogRecordBodyIsPopulated(bool includeFormattedMessage) [Theory] [InlineData("true")] [InlineData("false")] + [InlineData(null)] public void CheckToOtlpLogRecordExceptionAttributes(string emitExceptionAttributes) { var logRecords = new List(); @@ -525,7 +505,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 f63b0adf640d554a686e57dc9d9f52452999972f Mon Sep 17 00:00:00 2001 From: Utkarsh Umesan Pillai <66651184+utpilla@users.noreply.github.com> Date: Mon, 16 Oct 2023 15:05:17 -0700 Subject: [PATCH 3/4] Update CHANGELOG for 1.7.0-alpha.1 (#4952) --- src/OpenTelemetry.Api.ProviderBuilderExtensions/CHANGELOG.md | 4 ++++ src/OpenTelemetry.Api/CHANGELOG.md | 4 ++++ src/OpenTelemetry.Exporter.Console/CHANGELOG.md | 4 ++++ src/OpenTelemetry.Exporter.InMemory/CHANGELOG.md | 4 ++++ src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md | 4 ++++ src/OpenTelemetry.Exporter.Prometheus.AspNetCore/CHANGELOG.md | 4 ++++ .../CHANGELOG.md | 4 ++++ src/OpenTelemetry.Exporter.Zipkin/CHANGELOG.md | 4 ++++ src/OpenTelemetry.Extensions.Hosting/CHANGELOG.md | 4 ++++ src/OpenTelemetry.Extensions.Propagators/CHANGELOG.md | 4 ++++ src/OpenTelemetry/CHANGELOG.md | 4 ++++ 11 files changed, 44 insertions(+) diff --git a/src/OpenTelemetry.Api.ProviderBuilderExtensions/CHANGELOG.md b/src/OpenTelemetry.Api.ProviderBuilderExtensions/CHANGELOG.md index 60142c06b05..8e124c39ecb 100644 --- a/src/OpenTelemetry.Api.ProviderBuilderExtensions/CHANGELOG.md +++ b/src/OpenTelemetry.Api.ProviderBuilderExtensions/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +## 1.7.0-alpha.1 + +Released 2023-Oct-16 + ## 1.6.0 Released 2023-Sep-05 diff --git a/src/OpenTelemetry.Api/CHANGELOG.md b/src/OpenTelemetry.Api/CHANGELOG.md index 6d47071c7e3..4599f1e6790 100644 --- a/src/OpenTelemetry.Api/CHANGELOG.md +++ b/src/OpenTelemetry.Api/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +## 1.7.0-alpha.1 + +Released 2023-Oct-16 + * Fixed a bug which caused `Tracer.StartRootSpan` to generate a child span if a trace was running (`Activity.Current != null`). ([#4890](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4890)) diff --git a/src/OpenTelemetry.Exporter.Console/CHANGELOG.md b/src/OpenTelemetry.Exporter.Console/CHANGELOG.md index 691cec63e16..3255a0371d4 100644 --- a/src/OpenTelemetry.Exporter.Console/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.Console/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +## 1.7.0-alpha.1 + +Released 2023-Oct-16 + ## 1.6.0 Released 2023-Sep-05 diff --git a/src/OpenTelemetry.Exporter.InMemory/CHANGELOG.md b/src/OpenTelemetry.Exporter.InMemory/CHANGELOG.md index 5682213e8af..3890402406a 100644 --- a/src/OpenTelemetry.Exporter.InMemory/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.InMemory/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +## 1.7.0-alpha.1 + +Released 2023-Oct-16 + ## 1.6.0 Released 2023-Sep-05 diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md index f305b56b0a0..f1dfe571404 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +## 1.7.0-alpha.1 + +Released 2023-Oct-16 + * Bumped the version of `Google.Protobuf` used by the project to `3.22.5` so that consuming applications can be published as NativeAOT successfully. Also, a new performance feature can be used instead of reflection emit, which is diff --git a/src/OpenTelemetry.Exporter.Prometheus.AspNetCore/CHANGELOG.md b/src/OpenTelemetry.Exporter.Prometheus.AspNetCore/CHANGELOG.md index 52fc65b6158..adc7f6d701d 100644 --- a/src/OpenTelemetry.Exporter.Prometheus.AspNetCore/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.Prometheus.AspNetCore/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +## 1.7.0-alpha.1 + +Released 2023-Oct-16 + * Fixed writing boolean values to use the JSON representation ([#4823](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4823)) diff --git a/src/OpenTelemetry.Exporter.Prometheus.HttpListener/CHANGELOG.md b/src/OpenTelemetry.Exporter.Prometheus.HttpListener/CHANGELOG.md index 3b2eb78addf..875c9b03841 100644 --- a/src/OpenTelemetry.Exporter.Prometheus.HttpListener/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.Prometheus.HttpListener/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +## 1.7.0-alpha.1 + +Released 2023-Oct-16 + * Fixed writing boolean values to use the JSON representation ([#4823](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4823)) diff --git a/src/OpenTelemetry.Exporter.Zipkin/CHANGELOG.md b/src/OpenTelemetry.Exporter.Zipkin/CHANGELOG.md index f1f3b54d63a..0d957c310ec 100644 --- a/src/OpenTelemetry.Exporter.Zipkin/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.Zipkin/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +## 1.7.0-alpha.1 + +Released 2023-Oct-16 + ## 1.6.0 Released 2023-Sep-05 diff --git a/src/OpenTelemetry.Extensions.Hosting/CHANGELOG.md b/src/OpenTelemetry.Extensions.Hosting/CHANGELOG.md index 0afddcc2d9e..3739a6d6f55 100644 --- a/src/OpenTelemetry.Extensions.Hosting/CHANGELOG.md +++ b/src/OpenTelemetry.Extensions.Hosting/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +## 1.7.0-alpha.1 + +Released 2023-Oct-16 + * Changed the behavior of the `OpenTelemetryBuilder.AddOpenTelemetry` extension to INSERT OpenTelemetry services at the beginning of the `IServiceCollection` in an attempt to provide a better experience for end users capturing telemetry diff --git a/src/OpenTelemetry.Extensions.Propagators/CHANGELOG.md b/src/OpenTelemetry.Extensions.Propagators/CHANGELOG.md index c4b82968461..f5838c552a7 100644 --- a/src/OpenTelemetry.Extensions.Propagators/CHANGELOG.md +++ b/src/OpenTelemetry.Extensions.Propagators/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +## 1.7.0-alpha.1 + +Released 2023-Oct-16 + ## 1.6.0 Released 2023-Sep-05 diff --git a/src/OpenTelemetry/CHANGELOG.md b/src/OpenTelemetry/CHANGELOG.md index 6b4bf62cef6..b044a5bc1d8 100644 --- a/src/OpenTelemetry/CHANGELOG.md +++ b/src/OpenTelemetry/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +## 1.7.0-alpha.1 + +Released 2023-Oct-16 + * Update `AggregatorStore` to reclaim unused MetricPoints for Delta aggregation temporality. ([#4486](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4486)) From e66f4f3bf78bb1ab4e7a465333604b9459bdec8e Mon Sep 17 00:00:00 2001 From: Utkarsh Umesan Pillai <66651184+utpilla@users.noreply.github.com> Date: Mon, 16 Oct 2023 17:04:10 -0700 Subject: [PATCH 4/4] Fix publish package workflow (#4954) --- OpenTelemetry.proj | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/OpenTelemetry.proj b/OpenTelemetry.proj index 4db5f7a0642..fe6a7a130c7 100644 --- a/OpenTelemetry.proj +++ b/OpenTelemetry.proj @@ -7,12 +7,15 @@ + + - - - + + + +