diff --git a/src/OpenTelemetry.Exporter.Geneva/MsgPackExporter/Traces/GenevaExporterHelperExtensions.cs b/src/OpenTelemetry.Exporter.Geneva/GenevaExporterHelperExtensions.cs similarity index 100% rename from src/OpenTelemetry.Exporter.Geneva/MsgPackExporter/Traces/GenevaExporterHelperExtensions.cs rename to src/OpenTelemetry.Exporter.Geneva/GenevaExporterHelperExtensions.cs diff --git a/src/OpenTelemetry.Exporter.Geneva/GenevaLogExporter.cs b/src/OpenTelemetry.Exporter.Geneva/GenevaLogExporter.cs new file mode 100644 index 0000000000..b23bd32b10 --- /dev/null +++ b/src/OpenTelemetry.Exporter.Geneva/GenevaLogExporter.cs @@ -0,0 +1,73 @@ +// +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +using System; +using OpenTelemetry.Internal; +using OpenTelemetry.Logs; + +namespace OpenTelemetry.Exporter.Geneva; + +public class GenevaLogExporter : GenevaBaseExporter +{ + internal bool IsUsingUnixDomainSocket; + + private bool isDisposed; + + private delegate ExportResult ExportLogRecordFunc(in Batch batch); + + private readonly ExportLogRecordFunc exportLogRecord; + + private readonly IDisposable exporter; + + public GenevaLogExporter(GenevaExporterOptions options) + { + Guard.ThrowIfNull(options); + Guard.ThrowIfNullOrWhitespace(options.ConnectionString); + + var msgPackExporter = new MsgPackLogExporter(options); + this.IsUsingUnixDomainSocket = msgPackExporter.IsUsingUnixDomainSocket; + this.exportLogRecord = (in Batch batch) => msgPackExporter.Export(in batch); + this.exporter = msgPackExporter; + } + + public override ExportResult Export(in Batch batch) + { + return this.exportLogRecord(batch); + } + + protected override void Dispose(bool disposing) + { + if (this.isDisposed) + { + return; + } + + if (disposing) + { + try + { + this.exporter.Dispose(); + } + catch (Exception ex) + { + ExporterEventSource.Log.ExporterException("GenevaLogExporter Dispose failed.", ex); + } + } + + this.isDisposed = true; + base.Dispose(disposing); + } +} diff --git a/src/OpenTelemetry.Exporter.Geneva/MsgPackExporter/Logs/GenevaLoggingExtensions.cs b/src/OpenTelemetry.Exporter.Geneva/GenevaLoggingExtensions.cs similarity index 100% rename from src/OpenTelemetry.Exporter.Geneva/MsgPackExporter/Logs/GenevaLoggingExtensions.cs rename to src/OpenTelemetry.Exporter.Geneva/GenevaLoggingExtensions.cs diff --git a/src/OpenTelemetry.Exporter.Geneva/GenevaTraceExporter.cs b/src/OpenTelemetry.Exporter.Geneva/GenevaTraceExporter.cs new file mode 100644 index 0000000000..9c37b6db84 --- /dev/null +++ b/src/OpenTelemetry.Exporter.Geneva/GenevaTraceExporter.cs @@ -0,0 +1,73 @@ +// +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +using System; +using System.Diagnostics; +using OpenTelemetry.Internal; + +namespace OpenTelemetry.Exporter.Geneva; + +public class GenevaTraceExporter : GenevaBaseExporter +{ + internal readonly bool IsUsingUnixDomainSocket; + + private bool isDisposed; + + private delegate ExportResult ExportActivityFunc(in Batch batch); + + private readonly ExportActivityFunc exportActivity; + + private readonly IDisposable exporter; + + public GenevaTraceExporter(GenevaExporterOptions options) + { + Guard.ThrowIfNull(options); + Guard.ThrowIfNullOrWhitespace(options.ConnectionString); + + var msgPackExporter = new MsgPackTraceExporter(options); + this.IsUsingUnixDomainSocket = msgPackExporter.IsUsingUnixDomainSocket; + this.exportActivity = (in Batch batch) => msgPackExporter.Export(in batch); + this.exporter = msgPackExporter; + } + + public override ExportResult Export(in Batch batch) + { + return this.exportActivity(batch); + } + + protected override void Dispose(bool disposing) + { + if (this.isDisposed) + { + return; + } + + if (disposing) + { + try + { + this.exporter.Dispose(); + } + catch (Exception ex) + { + ExporterEventSource.Log.ExporterException("GenevaTraceExporter Dispose failed.", ex); + } + } + + this.isDisposed = true; + base.Dispose(disposing); + } +} diff --git a/src/OpenTelemetry.Exporter.Geneva/MsgPackExporter/Logs/GenevaLogExporter.cs b/src/OpenTelemetry.Exporter.Geneva/MsgPackExporter/MsgPackLogExporter.cs similarity index 94% rename from src/OpenTelemetry.Exporter.Geneva/MsgPackExporter/Logs/GenevaLogExporter.cs rename to src/OpenTelemetry.Exporter.Geneva/MsgPackExporter/MsgPackLogExporter.cs index 476836005a..d437ff6c15 100644 --- a/src/OpenTelemetry.Exporter.Geneva/MsgPackExporter/Logs/GenevaLogExporter.cs +++ b/src/OpenTelemetry.Exporter.Geneva/MsgPackExporter/MsgPackLogExporter.cs @@ -1,4 +1,4 @@ -// +// // Copyright The OpenTelemetry Authors // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,12 +21,11 @@ using System.Runtime.InteropServices; using System.Threading; using Microsoft.Extensions.Logging; -using OpenTelemetry.Internal; using OpenTelemetry.Logs; namespace OpenTelemetry.Exporter.Geneva; -public class GenevaLogExporter : GenevaBaseExporter +internal sealed class MsgPackLogExporter : IDisposable { private const int BUFFER_SIZE = 65360; // the maximum ETW payload (inclusive) private const int MaxSanitizedEventNameLength = 50; @@ -46,11 +45,8 @@ public class GenevaLogExporter : GenevaBaseExporter private readonly bool shouldPassThruTableMappings; private bool isDisposed; - public GenevaLogExporter(GenevaExporterOptions options) + public MsgPackLogExporter(GenevaExporterOptions options) { - Guard.ThrowIfNull(options); - Guard.ThrowIfNullOrWhitespace(options.ConnectionString); - // TODO: Validate mappings for reserved tablenames etc. if (options.TableNameMappings != null) { @@ -134,7 +130,7 @@ public GenevaLogExporter(GenevaExporterOptions options) private readonly IReadOnlyDictionary m_tableMappings; - public override ExportResult Export(in Batch batch) + public ExportResult Export(in Batch batch) { var result = ExportResult.Success; foreach (var logRecord in batch) @@ -154,31 +150,6 @@ public override ExportResult Export(in Batch batch) return result; } - protected override void Dispose(bool disposing) - { - if (this.isDisposed) - { - return; - } - - if (disposing) - { - // DO NOT Dispose m_buffer as it is a static type - try - { - (this.m_dataTransport as IDisposable)?.Dispose(); - this.m_prepopulatedFieldKeys.Clear(); - } - catch (Exception ex) - { - ExporterEventSource.Log.ExporterException("GenevaLogExporter Dispose failed.", ex); - } - } - - this.isDisposed = true; - base.Dispose(disposing); - } - internal bool IsUsingUnixDomainSocket { get => this.m_dataTransport is UnixDomainSocketDataTransport; @@ -279,7 +250,7 @@ internal int SerializeLogRecord(LogRecord logRecord) { var key = this.m_prepopulatedFieldKeys[i]; var value = this.m_prepopulatedFields[key]; - cursor = AddPartAField(buffer, cursor, key, value); + cursor = GenevaBaseExporter.AddPartAField(buffer, cursor, key, value); cntFields += 1; } } @@ -287,11 +258,11 @@ internal int SerializeLogRecord(LogRecord logRecord) // Part A - core envelope if (sanitizedEventName.Length != 0) { - cursor = AddPartAField(buffer, cursor, Schema.V40.PartA.Name, sanitizedEventName); + cursor = GenevaBaseExporter.AddPartAField(buffer, cursor, Schema.V40.PartA.Name, sanitizedEventName); } else { - cursor = AddPartAField(buffer, cursor, Schema.V40.PartA.Name, eventName); + cursor = GenevaBaseExporter.AddPartAField(buffer, cursor, Schema.V40.PartA.Name, eventName); } cntFields += 1; @@ -548,4 +519,25 @@ private static int SerializeSanitizedCategoryName(byte[] buffer, int cursor, str return cursor; } + + public void Dispose() + { + if (this.isDisposed) + { + return; + } + + // DO NOT Dispose m_buffer as it is a static type + try + { + (this.m_dataTransport as IDisposable)?.Dispose(); + this.m_prepopulatedFieldKeys.Clear(); + } + catch (Exception ex) + { + ExporterEventSource.Log.ExporterException("MsgPackLogExporter Dispose failed.", ex); + } + + this.isDisposed = true; + } } diff --git a/src/OpenTelemetry.Exporter.Geneva/MsgPackExporter/Traces/GenevaTraceExporter.cs b/src/OpenTelemetry.Exporter.Geneva/MsgPackExporter/MsgPackTraceExporter.cs similarity index 94% rename from src/OpenTelemetry.Exporter.Geneva/MsgPackExporter/Traces/GenevaTraceExporter.cs rename to src/OpenTelemetry.Exporter.Geneva/MsgPackExporter/MsgPackTraceExporter.cs index 5ae7849df1..677fea7d4f 100644 --- a/src/OpenTelemetry.Exporter.Geneva/MsgPackExporter/Traces/GenevaTraceExporter.cs +++ b/src/OpenTelemetry.Exporter.Geneva/MsgPackExporter/MsgPackTraceExporter.cs @@ -1,4 +1,4 @@ -// +// // Copyright The OpenTelemetry Authors // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -20,17 +20,13 @@ using System.Linq; using System.Runtime.InteropServices; using System.Threading; -using OpenTelemetry.Internal; namespace OpenTelemetry.Exporter.Geneva; -public class GenevaTraceExporter : GenevaBaseExporter +internal sealed class MsgPackTraceExporter : IDisposable { - public GenevaTraceExporter(GenevaExporterOptions options) + public MsgPackTraceExporter(GenevaExporterOptions options) { - Guard.ThrowIfNull(options); - Guard.ThrowIfNullOrWhitespace(options.ConnectionString); - var partAName = "Span"; if (options.TableNameMappings != null && options.TableNameMappings.TryGetValue("Span", out var customTableName)) @@ -125,13 +121,13 @@ public GenevaTraceExporter(GenevaExporterOptions options) // TODO: Do we support PartB as well? // Part A - core envelope - cursor = AddPartAField(buffer, cursor, Schema.V40.PartA.Name, partAName); + cursor = GenevaBaseExporter.AddPartAField(buffer, cursor, Schema.V40.PartA.Name, partAName); this.m_cntPrepopulatedFields += 1; foreach (var entry in options.PrepopulatedFields) { var value = entry.Value; - cursor = AddPartAField(buffer, cursor, entry.Key, value); + cursor = GenevaBaseExporter.AddPartAField(buffer, cursor, entry.Key, value); this.m_cntPrepopulatedFields += 1; } @@ -144,7 +140,7 @@ public GenevaTraceExporter(GenevaExporterOptions options) Buffer.BlockCopy(buffer, 0, this.m_bufferEpilogue, 0, cursor - 0); } - public override ExportResult Export(in Batch batch) + public ExportResult Export(in Batch batch) { // Note: The MessagePackSerializer takes way less time / memory than creating the activity itself. // This makes the short-circuit check less useful. @@ -173,30 +169,6 @@ public override ExportResult Export(in Batch batch) return result; } - protected override void Dispose(bool disposing) - { - if (this.isDisposed) - { - return; - } - - if (disposing) - { - try - { - (this.m_dataTransport as IDisposable)?.Dispose(); - this.m_buffer.Dispose(); - } - catch (Exception ex) - { - ExporterEventSource.Log.ExporterException("GenevaTraceExporter Dispose failed.", ex); - } - } - - this.isDisposed = true; - base.Dispose(disposing); - } - internal bool IsUsingUnixDomainSocket { get => this.m_dataTransport is UnixDomainSocketDataTransport; @@ -403,6 +375,26 @@ internal int SerializeActivity(Activity activity) return cursor; } + public void Dispose() + { + if (this.isDisposed) + { + return; + } + + try + { + (this.m_dataTransport as IDisposable)?.Dispose(); + this.m_buffer.Dispose(); + } + catch (Exception ex) + { + ExporterEventSource.Log.ExporterException("MsgPackTraceExporter Dispose failed.", ex); + } + + this.isDisposed = true; + } + private const int BUFFER_SIZE = 65360; // the maximum ETW payload (inclusive) private readonly ThreadLocal m_buffer = new ThreadLocal(() => null); diff --git a/test/OpenTelemetry.Exporter.Geneva.Benchmark/Exporter/LogExporterBenchmarks.cs b/test/OpenTelemetry.Exporter.Geneva.Benchmark/Exporter/LogExporterBenchmarks.cs index b18385afc5..4c6c4bc122 100644 --- a/test/OpenTelemetry.Exporter.Geneva.Benchmark/Exporter/LogExporterBenchmarks.cs +++ b/test/OpenTelemetry.Exporter.Geneva.Benchmark/Exporter/LogExporterBenchmarks.cs @@ -20,42 +20,42 @@ using OpenTelemetry.Logs; /* -BenchmarkDotNet=v0.13.1, OS=Windows 10.0.22000 +BenchmarkDotNet=v0.13.1, OS=Windows 10.0.22621 Intel Core i7-9700 CPU 3.00GHz, 1 CPU, 8 logical and 8 physical cores .NET SDK=7.0.100-preview.6.22352.1 - [Host] : .NET 6.0.8 (6.0.822.36306), X64 RyuJIT - DefaultJob : .NET 6.0.8 (6.0.822.36306), X64 RyuJIT + [Host] : .NET 6.0.9 (6.0.922.41905), X64 RyuJIT + DefaultJob : .NET 6.0.9 (6.0.922.41905), X64 RyuJIT Without Scopes -| Method | IncludeFormattedMessage | Mean | Error | StdDev | Gen 0 | Allocated | -|-------------------------- |------------------------ |---------:|---------:|---------:|-------:|----------:| -| LoggerWithMessageTemplate | False | 823.3 ns | 2.20 ns | 1.84 ns | 0.0362 | 232 B | -| LoggerWithDirectLoggerAPI | False | 749.2 ns | 5.49 ns | 4.87 ns | 0.0582 | 368 B | -| LoggerWithSourceGenerator | False | 798.4 ns | 2.72 ns | 2.41 ns | 0.0305 | 192 B | -| SerializeLogRecord | False | 596.3 ns | 10.69 ns | 10.00 ns | - | - | -| Export | False | 655.1 ns | 12.75 ns | 15.18 ns | - | - | -| LoggerWithMessageTemplate | True | 817.8 ns | 3.04 ns | 2.85 ns | 0.0362 | 232 B | -| LoggerWithDirectLoggerAPI | True | 750.5 ns | 4.73 ns | 4.43 ns | 0.0582 | 368 B | -| LoggerWithSourceGenerator | True | 782.3 ns | 9.26 ns | 8.67 ns | 0.0305 | 192 B | -| SerializeLogRecord | True | 580.3 ns | 3.39 ns | 3.17 ns | - | - | -| Export | True | 640.1 ns | 4.26 ns | 3.98 ns | - | - | +| Method | IncludeFormattedMessage | Mean | Error | StdDev | Gen 0 | Allocated | +|-------------------------- |------------------------ |-----------:|--------:|--------:|-------:|----------:| +| LoggerWithMessageTemplate | False | 1,273.1 ns | 6.09 ns | 5.39 ns | 0.0362 | 232 B | +| LoggerWithDirectLoggerAPI | False | 1,213.0 ns | 9.71 ns | 8.61 ns | 0.0572 | 368 B | +| LoggerWithSourceGenerator | False | 1,243.5 ns | 6.13 ns | 5.44 ns | 0.0305 | 192 B | +| SerializeLogRecord | False | 587.7 ns | 2.71 ns | 2.54 ns | - | - | +| Export | False | 955.0 ns | 5.46 ns | 5.11 ns | - | - | +| LoggerWithMessageTemplate | True | 1,261.1 ns | 6.59 ns | 5.84 ns | 0.0362 | 232 B | +| LoggerWithDirectLoggerAPI | True | 1,214.4 ns | 4.56 ns | 4.27 ns | 0.0572 | 368 B | +| LoggerWithSourceGenerator | True | 1,229.6 ns | 6.84 ns | 6.40 ns | 0.0305 | 192 B | +| SerializeLogRecord | True | 581.6 ns | 2.38 ns | 2.11 ns | - | - | +| Export | True | 958.4 ns | 3.02 ns | 2.52 ns | - | - | With Scopes (https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/545) -| Method | IncludeFormattedMessage | Mean | Error | StdDev | Gen 0 | Allocated | -|-------------------------- |------------------------ |---------:|---------:|---------:|-------:|----------:| -| LoggerWithMessageTemplate | False | 872.5 ns | 5.37 ns | 4.48 ns | 0.0534 | 336 B | -| LoggerWithDirectLoggerAPI | False | 808.6 ns | 12.32 ns | 10.92 ns | 0.0744 | 472 B | -| LoggerWithSourceGenerator | False | 828.1 ns | 4.06 ns | 3.80 ns | 0.0467 | 296 B | -| SerializeLogRecord | False | 607.4 ns | 1.69 ns | 1.50 ns | 0.0162 | 104 B | -| Export | False | 658.8 ns | 2.20 ns | 2.05 ns | 0.0162 | 104 B | -| LoggerWithMessageTemplate | True | 845.7 ns | 3.77 ns | 3.52 ns | 0.0534 | 336 B | -| LoggerWithDirectLoggerAPI | True | 803.4 ns | 5.37 ns | 5.02 ns | 0.0744 | 472 B | -| LoggerWithSourceGenerator | True | 836.9 ns | 7.04 ns | 6.24 ns | 0.0467 | 296 B | -| SerializeLogRecord | True | 605.5 ns | 3.30 ns | 3.09 ns | 0.0162 | 104 B | -| Export | True | 664.1 ns | 2.01 ns | 1.88 ns | 0.0162 | 104 B | +| Method | IncludeFormattedMessage | Mean | Error | StdDev | Gen 0 | Allocated | +|-------------------------- |------------------------ |-----------:|--------:|--------:|-------:|----------:| +| LoggerWithMessageTemplate | False | 1,280.8 ns | 7.45 ns | 6.61 ns | 0.0534 | 336 B | +| LoggerWithDirectLoggerAPI | False | 1,261.5 ns | 6.38 ns | 5.96 ns | 0.0744 | 472 B | +| LoggerWithSourceGenerator | False | 1,309.3 ns | 4.83 ns | 4.52 ns | 0.0458 | 296 B | +| SerializeLogRecord | False | 611.3 ns | 4.63 ns | 4.11 ns | 0.0162 | 104 B | +| Export | False | 1,012.2 ns | 7.56 ns | 7.07 ns | 0.0153 | 104 B | +| LoggerWithMessageTemplate | True | 1,278.3 ns | 6.63 ns | 5.88 ns | 0.0534 | 336 B | +| LoggerWithDirectLoggerAPI | True | 1,263.8 ns | 8.26 ns | 7.73 ns | 0.0744 | 472 B | +| LoggerWithSourceGenerator | True | 1,273.4 ns | 5.57 ns | 5.21 ns | 0.0458 | 296 B | +| SerializeLogRecord | True | 604.3 ns | 2.83 ns | 2.65 ns | 0.0162 | 104 B | +| Export | True | 1,003.6 ns | 9.29 ns | 8.69 ns | 0.0153 | 104 B | */ namespace OpenTelemetry.Exporter.Geneva.Benchmark; @@ -65,7 +65,7 @@ public class LogExporterBenchmarks { private readonly ILogger logger; private readonly ILoggerFactory loggerFactory; - private readonly GenevaLogExporter exporter; + private readonly MsgPackLogExporter exporter; private readonly LogRecord logRecord; private readonly Batch batch; @@ -97,7 +97,7 @@ public LogExporterBenchmarks() // For msgpack serialization + export this.logRecord = GenerateTestLogRecord(); this.batch = GenerateTestLogRecordBatch(); - this.exporter = new GenevaLogExporter(new GenevaExporterOptions + this.exporter = new MsgPackLogExporter(new GenevaExporterOptions { ConnectionString = "EtwSession=OpenTelemetry", PrepopulatedFields = new Dictionary diff --git a/test/OpenTelemetry.Exporter.Geneva.Benchmark/Exporter/TraceExporterBenchmarks.cs b/test/OpenTelemetry.Exporter.Geneva.Benchmark/Exporter/TraceExporterBenchmarks.cs index 3460304ff1..3956343f72 100644 --- a/test/OpenTelemetry.Exporter.Geneva.Benchmark/Exporter/TraceExporterBenchmarks.cs +++ b/test/OpenTelemetry.Exporter.Geneva.Benchmark/Exporter/TraceExporterBenchmarks.cs @@ -14,23 +14,24 @@ // limitations under the License. // +using System; using System.Collections.Generic; using System.Diagnostics; using BenchmarkDotNet.Attributes; using OpenTelemetry.Trace; /* -BenchmarkDotNet=v0.13.1, OS=Windows 10.0.22000 +BenchmarkDotNet=v0.13.1, OS=Windows 10.0.22621 Intel Core i7-9700 CPU 3.00GHz, 1 CPU, 8 logical and 8 physical cores .NET SDK=7.0.100-preview.6.22352.1 - [Host] : .NET 6.0.8 (6.0.822.36306), X64 RyuJIT - DefaultJob : .NET 6.0.8 (6.0.822.36306), X64 RyuJIT + [Host] : .NET 6.0.9 (6.0.922.41905), X64 RyuJIT + DefaultJob : .NET 6.0.9 (6.0.922.41905), X64 RyuJIT | Method | Mean | Error | StdDev | Gen 0 | Allocated | |------------------ |---------:|--------:|--------:|-------:|----------:| -| ExportActivity | 422.0 ns | 8.41 ns | 8.64 ns | 0.0062 | 40 B | -| SerializeActivity | 387.4 ns | 7.22 ns | 7.09 ns | 0.0062 | 40 B | +| ExportActivity | 719.9 ns | 5.83 ns | 5.45 ns | 0.0057 | 40 B | +| SerializeActivity | 361.7 ns | 1.09 ns | 0.97 ns | 0.0062 | 40 B | */ namespace OpenTelemetry.Exporter.Geneva.Benchmark; @@ -40,7 +41,7 @@ public class TraceExporterBenchmarks { private readonly Activity activity; private readonly Batch batch; - private readonly GenevaTraceExporter exporter; + private readonly MsgPackTraceExporter exporter; private readonly ActivitySource activitySource = new ActivitySource("OpenTelemetry.Exporter.Geneva.Benchmark"); public TraceExporterBenchmarks() @@ -67,7 +68,7 @@ public TraceExporterBenchmarks() this.activity?.SetStatus(Status.Error); } - this.exporter = new GenevaTraceExporter(new GenevaExporterOptions + this.exporter = new MsgPackTraceExporter(new GenevaExporterOptions { ConnectionString = "EtwSession=OpenTelemetry", PrepopulatedFields = new Dictionary diff --git a/test/OpenTelemetry.Exporter.Geneva.Tests/GenevaLogExporterTests.cs b/test/OpenTelemetry.Exporter.Geneva.Tests/GenevaLogExporterTests.cs index d86edadca5..383c359519 100644 --- a/test/OpenTelemetry.Exporter.Geneva.Tests/GenevaLogExporterTests.cs +++ b/test/OpenTelemetry.Exporter.Geneva.Tests/GenevaLogExporterTests.cs @@ -171,7 +171,7 @@ public void TableNameMappingTest(params string[] category) .AddFilter("*", LogLevel.Trace)); // Enable all LogLevels // Create a test exporter to get MessagePack byte data to validate if the data was serialized correctly. - using var exporter = new GenevaLogExporter(exporterOptions); + using var exporter = new MsgPackLogExporter(exporterOptions); ILogger logger; ThreadLocal m_buffer; @@ -188,7 +188,7 @@ public void TableNameMappingTest(params string[] category) logger.LogError("this does not matter"); Assert.Single(logRecordList); - m_buffer = typeof(GenevaLogExporter).GetField("m_buffer", BindingFlags.NonPublic | BindingFlags.Static).GetValue(exporter) as ThreadLocal; + m_buffer = typeof(MsgPackLogExporter).GetField("m_buffer", BindingFlags.NonPublic | BindingFlags.Static).GetValue(exporter) as ThreadLocal; _ = exporter.SerializeLogRecord(logRecordList[0]); fluentdData = MessagePack.MessagePackSerializer.Deserialize(m_buffer.Value, MessagePack.Resolvers.ContractlessStandardResolver.Instance); actualTableName = (fluentdData as object[])[0] as string; @@ -206,7 +206,7 @@ public void TableNameMappingTest(params string[] category) logger.LogError("this does not matter"); Assert.Single(logRecordList); - m_buffer = typeof(GenevaLogExporter).GetField("m_buffer", BindingFlags.NonPublic | BindingFlags.Static).GetValue(exporter) as ThreadLocal; + m_buffer = typeof(MsgPackLogExporter).GetField("m_buffer", BindingFlags.NonPublic | BindingFlags.Static).GetValue(exporter) as ThreadLocal; _ = exporter.SerializeLogRecord(logRecordList[0]); fluentdData = MessagePack.MessagePackSerializer.Deserialize(m_buffer.Value, MessagePack.Resolvers.ContractlessStandardResolver.Instance); actualTableName = (fluentdData as object[])[0] as string; @@ -293,13 +293,13 @@ public void PassThruTableMappingsWhenTheRuleIsEnabled() .AddFilter("*", LogLevel.Trace)); // Enable all LogLevels // Create a test exporter to get MessagePack byte data to validate if the data was serialized correctly. - using var exporter = new GenevaLogExporter(exporterOptions); + using var exporter = new MsgPackLogExporter(exporterOptions); ILogger passThruTableMappingsLogger, userInitializedTableMappingsLogger; ThreadLocal m_buffer; object fluentdData; string actualTableName; - m_buffer = typeof(GenevaLogExporter).GetField("m_buffer", BindingFlags.NonPublic | BindingFlags.Static).GetValue(exporter) as ThreadLocal; + m_buffer = typeof(MsgPackLogExporter).GetField("m_buffer", BindingFlags.NonPublic | BindingFlags.Static).GetValue(exporter) as ThreadLocal; // Verify that the category table mappings specified by the users in the Geneva Configuration are mapped correctly. foreach (var mapping in userInitializedCategoryToTableNameMappings) @@ -407,7 +407,7 @@ public void SerializeILoggerScopes() byte[] serializedData; if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - var m_buffer = typeof(GenevaLogExporter).GetField("m_buffer", BindingFlags.NonPublic | BindingFlags.Static).GetValue(exporter) as ThreadLocal; + var m_buffer = typeof(MsgPackLogExporter).GetField("m_buffer", BindingFlags.NonPublic | BindingFlags.Static).GetValue(exporter) as ThreadLocal; serializedData = m_buffer.Value; } else @@ -504,7 +504,7 @@ public void SerializationTestWithILoggerLogMethod(bool includeFormattedMessage) .AddFilter(typeof(GenevaLogExporterTests).FullName, LogLevel.Trace)); // Enable all LogLevels // Create a test exporter to get MessagePack byte data to validate if the data was serialized correctly. - using var exporter = new GenevaLogExporter(exporterOptions); + using var exporter = new MsgPackLogExporter(exporterOptions); // Emit a LogRecord and grab a copy of the LogRecord from the collection passed to InMemoryExporter var logger = loggerFactory.CreateLogger(); @@ -524,7 +524,7 @@ public void SerializationTestWithILoggerLogMethod(bool includeFormattedMessage) // VALIDATE Assert.Single(logRecordList); - var m_buffer = typeof(GenevaLogExporter).GetField("m_buffer", BindingFlags.NonPublic | BindingFlags.Static).GetValue(exporter) as ThreadLocal; + var m_buffer = typeof(MsgPackLogExporter).GetField("m_buffer", BindingFlags.NonPublic | BindingFlags.Static).GetValue(exporter) as ThreadLocal; _ = exporter.SerializeLogRecord(logRecordList[0]); object fluentdData = MessagePack.MessagePackSerializer.Deserialize(m_buffer.Value, MessagePack.Resolvers.ContractlessStandardResolver.Instance); var body = GetField(fluentdData, "body"); @@ -554,7 +554,7 @@ public void SerializationTestWithILoggerLogMethod(bool includeFormattedMessage) // VALIDATE Assert.Single(logRecordList); - m_buffer = typeof(GenevaLogExporter).GetField("m_buffer", BindingFlags.NonPublic | BindingFlags.Static).GetValue(exporter) as ThreadLocal; + m_buffer = typeof(MsgPackLogExporter).GetField("m_buffer", BindingFlags.NonPublic | BindingFlags.Static).GetValue(exporter) as ThreadLocal; _ = exporter.SerializeLogRecord(logRecordList[0]); fluentdData = MessagePack.MessagePackSerializer.Deserialize(m_buffer.Value, MessagePack.Resolvers.ContractlessStandardResolver.Instance); body = GetField(fluentdData, "body"); @@ -581,7 +581,7 @@ public void SerializationTestWithILoggerLogMethod(bool includeFormattedMessage) // VALIDATE Assert.Single(logRecordList); - m_buffer = typeof(GenevaLogExporter).GetField("m_buffer", BindingFlags.NonPublic | BindingFlags.Static).GetValue(exporter) as ThreadLocal; + m_buffer = typeof(MsgPackLogExporter).GetField("m_buffer", BindingFlags.NonPublic | BindingFlags.Static).GetValue(exporter) as ThreadLocal; _ = exporter.SerializeLogRecord(logRecordList[0]); fluentdData = MessagePack.MessagePackSerializer.Deserialize(m_buffer.Value, MessagePack.Resolvers.ContractlessStandardResolver.Instance); body = GetField(fluentdData, "body"); @@ -606,7 +606,7 @@ public void SerializationTestWithILoggerLogMethod(bool includeFormattedMessage) // VALIDATE Assert.Single(logRecordList); - m_buffer = typeof(GenevaLogExporter).GetField("m_buffer", BindingFlags.NonPublic | BindingFlags.Static).GetValue(exporter) as ThreadLocal; + m_buffer = typeof(MsgPackLogExporter).GetField("m_buffer", BindingFlags.NonPublic | BindingFlags.Static).GetValue(exporter) as ThreadLocal; _ = exporter.SerializeLogRecord(logRecordList[0]); fluentdData = MessagePack.MessagePackSerializer.Deserialize(m_buffer.Value, MessagePack.Resolvers.ContractlessStandardResolver.Instance); Assert.Equal("Value1", GetField(fluentdData, "Key1")); @@ -706,7 +706,7 @@ public void SerializationTestWithILoggerLogWithTemplates(bool hasTableNameMappin .AddFilter(typeof(GenevaLogExporterTests).FullName, LogLevel.Trace)); // Enable all LogLevels // Create a test exporter to get MessagePack byte data to validate if the data was serialized correctly. - using var exporter = new GenevaLogExporter(exporterOptions); + using var exporter = new MsgPackLogExporter(exporterOptions); // Emit a LogRecord and grab a copy of the LogRecord from the collection passed to InMemoryExporter var logger = loggerFactory.CreateLogger(); @@ -751,7 +751,7 @@ public void SerializationTestWithILoggerLogWithTemplates(bool hasTableNameMappin // logRecordList should have 14 logRecord entries as there were 14 Log calls Assert.Equal(14, logRecordList.Count); - var m_buffer = typeof(GenevaLogExporter).GetField("m_buffer", BindingFlags.NonPublic | BindingFlags.Static).GetValue(exporter) as ThreadLocal; + var m_buffer = typeof(MsgPackLogExporter).GetField("m_buffer", BindingFlags.NonPublic | BindingFlags.Static).GetValue(exporter) as ThreadLocal; foreach (var logRecord in logRecordList) { @@ -842,7 +842,7 @@ public void SuccessfulExportOnLinux() serverSocket.ReceiveTimeout = 10000; // Create a test exporter to get MessagePack byte data for validation of the data received via Socket. - using var exporter = new GenevaLogExporter(new GenevaExporterOptions + using var exporter = new MsgPackLogExporter(new GenevaExporterOptions { ConnectionString = "Endpoint=unix:" + path, PrepopulatedFields = new Dictionary @@ -938,7 +938,7 @@ public void SerializationTestForException() .AddFilter(typeof(GenevaLogExporterTests).FullName, LogLevel.Trace)); // Enable all LogLevels // Create a test exporter to get MessagePack byte data to validate if the data was serialized correctly. - using var exporter = new GenevaLogExporter(exporterOptions); + using var exporter = new MsgPackLogExporter(exporterOptions); // Emit a LogRecord and grab a copy of the LogRecord from the collection passed to InMemoryExporter var logger = loggerFactory.CreateLogger(); @@ -954,7 +954,7 @@ public void SerializationTestForException() // VALIDATE Assert.Single(logRecordList); - var m_buffer = typeof(GenevaLogExporter).GetField("m_buffer", BindingFlags.NonPublic | BindingFlags.Static).GetValue(exporter) as ThreadLocal; + var m_buffer = typeof(MsgPackLogExporter).GetField("m_buffer", BindingFlags.NonPublic | BindingFlags.Static).GetValue(exporter) as ThreadLocal; _ = exporter.SerializeLogRecord(logRecordList[0]); object fluentdData = MessagePack.MessagePackSerializer.Deserialize(m_buffer.Value, MessagePack.Resolvers.ContractlessStandardResolver.Instance); var exceptionType = GetField(fluentdData, "env_ex_type"); @@ -1012,7 +1012,7 @@ public void SerializationTestForEventId() .AddFilter(typeof(GenevaLogExporterTests).FullName, LogLevel.Trace)); // Enable all LogLevels // Create a test exporter to get MessagePack byte data to validate if the data was serialized correctly. - using var exporter = new GenevaLogExporter(exporterOptions); + using var exporter = new MsgPackLogExporter(exporterOptions); // Emit a LogRecord and grab a copy of the LogRecord from the collection passed to InMemoryExporter var logger = loggerFactory.CreateLogger(); @@ -1028,7 +1028,7 @@ public void SerializationTestForEventId() // VALIDATE Assert.Single(logRecordList); - var m_buffer = typeof(GenevaLogExporter).GetField("m_buffer", BindingFlags.NonPublic | BindingFlags.Static).GetValue(exporter) as ThreadLocal; + var m_buffer = typeof(MsgPackLogExporter).GetField("m_buffer", BindingFlags.NonPublic | BindingFlags.Static).GetValue(exporter) as ThreadLocal; _ = exporter.SerializeLogRecord(logRecordList[0]); object fluentdData = MessagePack.MessagePackSerializer.Deserialize(m_buffer.Value, MessagePack.Resolvers.ContractlessStandardResolver.Instance); diff --git a/test/OpenTelemetry.Exporter.Geneva.Tests/GenevaTraceExporterTests.cs b/test/OpenTelemetry.Exporter.Geneva.Tests/GenevaTraceExporterTests.cs index 0db23b09b7..34ae3c7c61 100644 --- a/test/OpenTelemetry.Exporter.Geneva.Tests/GenevaTraceExporterTests.cs +++ b/test/OpenTelemetry.Exporter.Geneva.Tests/GenevaTraceExporterTests.cs @@ -250,10 +250,10 @@ public void GenevaTraceExporter_Serialization_Success(bool hasTableNameMapping, exporterOptions.CustomFields = new string[] { "clientRequestId" }; } - using var exporter = new GenevaTraceExporter(exporterOptions); - var dedicatedFields = typeof(GenevaTraceExporter).GetField("m_dedicatedFields", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(exporter) as IReadOnlyDictionary; - var CS40_PART_B_MAPPING = typeof(GenevaTraceExporter).GetField("CS40_PART_B_MAPPING", BindingFlags.NonPublic | BindingFlags.Static).GetValue(exporter) as IReadOnlyDictionary; - var m_buffer = typeof(GenevaTraceExporter).GetField("m_buffer", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(exporter) as ThreadLocal; + using var exporter = new MsgPackTraceExporter(exporterOptions); + var dedicatedFields = typeof(MsgPackTraceExporter).GetField("m_dedicatedFields", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(exporter) as IReadOnlyDictionary; + var CS40_PART_B_MAPPING = typeof(MsgPackTraceExporter).GetField("CS40_PART_B_MAPPING", BindingFlags.NonPublic | BindingFlags.Static).GetValue(exporter) as IReadOnlyDictionary; + var m_buffer = typeof(MsgPackTraceExporter).GetField("m_buffer", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(exporter) as ThreadLocal; // Add an ActivityListener to serialize the activity and assert that it was valid on ActivityStopped event @@ -417,7 +417,7 @@ public void GenevaTraceExporter_Success_Linux() serverSocket.ReceiveTimeout = 10000; // Create a test exporter to get MessagePack byte data for validation of the data received via Socket. - var exporter = new GenevaTraceExporter(new GenevaExporterOptions + var exporter = new MsgPackTraceExporter(new GenevaExporterOptions { ConnectionString = "Endpoint=unix:" + path, PrepopulatedFields = new Dictionary