diff --git a/.github/component_owners.yml b/.github/component_owners.yml index acf4632141..5cee7a9e64 100644 --- a/.github/component_owners.yml +++ b/.github/component_owners.yml @@ -11,7 +11,6 @@ components: src/OpenTelemetry.Exporter.Geneva/: - cijothomas - codeblanch - - mic-max - reyang - utpilla - Yun-Ting @@ -75,21 +74,18 @@ components: test/OpenTelemetry.Exporter.Geneva.Benchmark/: - cijothomas - codeblanch - - mic-max - reyang - utpilla - Yun-Ting test/OpenTelemetry.Exporter.Geneva.Stress/: - cijothomas - codeblanch - - mic-max - reyang - utpilla - Yun-Ting test/OpenTelemetry.Exporter.Geneva.Tests/: - cijothomas - codeblanch - - mic-max - reyang - utpilla - Yun-Ting diff --git a/.github/workflows/dotnet-core-cov.yml b/.github/workflows/dotnet-core-cov.yml index 1f71a5119c..5c60677a4c 100644 --- a/.github/workflows/dotnet-core-cov.yml +++ b/.github/workflows/dotnet-core-cov.yml @@ -48,7 +48,7 @@ jobs: - name: Merging test results run: reportgenerator -reports:TestResults/**/*.xml -targetdir:TestResults -reporttypes:Cobertura - - uses: codecov/codecov-action@v3.1.2 + - uses: codecov/codecov-action@v3.1.3 with: file: TestResults/Cobertura.xml env_vars: OS diff --git a/build/Common.props b/build/Common.props index 78f7845324..07c8eaae50 100644 --- a/build/Common.props +++ b/build/Common.props @@ -55,20 +55,20 @@ - + - - - - - - - - - - + + + + + + + + + + diff --git a/opentelemetry-dotnet-contrib.sln b/opentelemetry-dotnet-contrib.sln index 994981773d..b8556d00c5 100644 --- a/opentelemetry-dotnet-contrib.sln +++ b/opentelemetry-dotnet-contrib.sln @@ -13,7 +13,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution items", "Solution global.json = global.json NuGet.config = NuGet.config opentelemetry-dotnet-contrib.proj = opentelemetry-dotnet-contrib.proj - examples\process-instrumentation\process-instrumentation.csproj = examples\process-instrumentation\process-instrumentation.csproj README.md = README.md EndProjectSection EndProject @@ -120,8 +119,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Contrib.Instr EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Contrib.Instrumentation.AWS.Tests", "test\OpenTelemetry.Contrib.Instrumentation.AWS.Tests\OpenTelemetry.Contrib.Instrumentation.AWS.Tests.csproj", "{CAB66B50-DAB6-49B8-83F9-6CCF520C4A36}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Contrib.Shared", "src\OpenTelemetry.Contrib.Shared\OpenTelemetry.Contrib.Shared.csproj", "{F52B9D81-2155-433A-B6F2-4CD7CBBEC7E6}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Instrumentation.Wcf.Tests", "test\OpenTelemetry.Instrumentation.Wcf.Tests\OpenTelemetry.Instrumentation.Wcf.Tests.csproj", "{76BAB24F-85DB-4FCE-89D0-EFB4185004C9}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "grpc.core", "grpc.core", "{58D1DE55-B0A5-4BC4-AB37-09B1C7B26752}" @@ -263,10 +260,30 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Sampler.AWS.T EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Exporter.OneCollector.Benchmarks", "test\OpenTelemetry.Exporter.OneCollector.Benchmarks\OpenTelemetry.Exporter.OneCollector.Benchmarks.csproj", "{C42868C8-968A-473F-AC39-AC97C5D47E84}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Examples.Enrichment", "examples\enrichment\Examples.Enrichment\Examples.Enrichment.csproj", "{9B7F7605-ADFF-4A47-9B64-FFF3E2EC9DEA}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Examples.Enrichment", "examples\enrichment\Examples.Enrichment\Examples.Enrichment.csproj", "{9B7F7605-ADFF-4A47-9B64-FFF3E2EC9DEA}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "enrichment", "enrichment", "{93503FAF-D43D-48C0-818C-92EB90F7606B}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Shared", "Shared", "{1FCC8EEC-9E75-4FEA-AFCF-363DD33FF0B9}" + ProjectSection(SolutionItems) = preProject + src\Shared\ActivityInstrumentationHelper.cs = src\Shared\ActivityInstrumentationHelper.cs + src\Shared\DiagnosticSourceListener.cs = src\Shared\DiagnosticSourceListener.cs + src\Shared\DiagnosticSourceSubscriber.cs = src\Shared\DiagnosticSourceSubscriber.cs + src\Shared\ExceptionExtensions.cs = src\Shared\ExceptionExtensions.cs + src\Shared\Guard.cs = src\Shared\Guard.cs + src\Shared\InstrumentationEventSource.cs = src\Shared\InstrumentationEventSource.cs + src\Shared\IsExternalInit.cs = src\Shared\IsExternalInit.cs + src\Shared\ListenerHandler.cs = src\Shared\ListenerHandler.cs + src\Shared\MultiTypePropertyFetcher.cs = src\Shared\MultiTypePropertyFetcher.cs + src\Shared\NullableAttributes.cs = src\Shared\NullableAttributes.cs + src\Shared\PropertyFetcher.cs = src\Shared\PropertyFetcher.cs + src\Shared\ResourceSemanticConventions.cs = src\Shared\ResourceSemanticConventions.cs + src\Shared\SemanticConventions.cs = src\Shared\SemanticConventions.cs + src\Shared\ServiceProviderExtensions.cs = src\Shared\ServiceProviderExtensions.cs + src\Shared\SpanAttributeConstants.cs = src\Shared\SpanAttributeConstants.cs + src\Shared\SpanHelper.cs = src\Shared\SpanHelper.cs + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -309,10 +326,6 @@ Global {CAB66B50-DAB6-49B8-83F9-6CCF520C4A36}.Debug|Any CPU.Build.0 = Debug|Any CPU {CAB66B50-DAB6-49B8-83F9-6CCF520C4A36}.Release|Any CPU.ActiveCfg = Release|Any CPU {CAB66B50-DAB6-49B8-83F9-6CCF520C4A36}.Release|Any CPU.Build.0 = Release|Any CPU - {F52B9D81-2155-433A-B6F2-4CD7CBBEC7E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F52B9D81-2155-433A-B6F2-4CD7CBBEC7E6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F52B9D81-2155-433A-B6F2-4CD7CBBEC7E6}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F52B9D81-2155-433A-B6F2-4CD7CBBEC7E6}.Release|Any CPU.Build.0 = Release|Any CPU {76BAB24F-85DB-4FCE-89D0-EFB4185004C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {76BAB24F-85DB-4FCE-89D0-EFB4185004C9}.Debug|Any CPU.Build.0 = Debug|Any CPU {76BAB24F-85DB-4FCE-89D0-EFB4185004C9}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -595,7 +608,6 @@ Global {9CE513AC-CFC5-4DD1-9F16-8719EDCE9BF9} = {2097345F-4DD3-477D-BC54-A922F9B2B402} {970673DA-F308-4960-A58D-ECCEA44CEF6B} = {22DF5DC0-1290-4E83-A9D8-6BB7DE3B3E63} {CAB66B50-DAB6-49B8-83F9-6CCF520C4A36} = {2097345F-4DD3-477D-BC54-A922F9B2B402} - {F52B9D81-2155-433A-B6F2-4CD7CBBEC7E6} = {22DF5DC0-1290-4E83-A9D8-6BB7DE3B3E63} {76BAB24F-85DB-4FCE-89D0-EFB4185004C9} = {2097345F-4DD3-477D-BC54-A922F9B2B402} {58D1DE55-B0A5-4BC4-AB37-09B1C7B26752} = {B75EE478-97F7-4E9F-9A5A-DB3D0988EDEA} {F1591DEE-79C0-4161-85C2-1477B261D274} = {58D1DE55-B0A5-4BC4-AB37-09B1C7B26752} @@ -667,6 +679,7 @@ Global {C42868C8-968A-473F-AC39-AC97C5D47E84} = {2097345F-4DD3-477D-BC54-A922F9B2B402} {9B7F7605-ADFF-4A47-9B64-FFF3E2EC9DEA} = {93503FAF-D43D-48C0-818C-92EB90F7606B} {93503FAF-D43D-48C0-818C-92EB90F7606B} = {B75EE478-97F7-4E9F-9A5A-DB3D0988EDEA} + {1FCC8EEC-9E75-4FEA-AFCF-363DD33FF0B9} = {22DF5DC0-1290-4E83-A9D8-6BB7DE3B3E63} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {B0816796-CDB3-47D7-8C3C-946434DE3B66} diff --git a/src/OpenTelemetry.Contrib.Extensions.AWSXRay/OpenTelemetry.Contrib.Extensions.AWSXRay.csproj b/src/OpenTelemetry.Contrib.Extensions.AWSXRay/OpenTelemetry.Contrib.Extensions.AWSXRay.csproj index d06b9eb9ca..17a1720792 100644 --- a/src/OpenTelemetry.Contrib.Extensions.AWSXRay/OpenTelemetry.Contrib.Extensions.AWSXRay.csproj +++ b/src/OpenTelemetry.Contrib.Extensions.AWSXRay/OpenTelemetry.Contrib.Extensions.AWSXRay.csproj @@ -26,7 +26,7 @@ - + diff --git a/src/OpenTelemetry.Contrib.Instrumentation.AWS/OpenTelemetry.Contrib.Instrumentation.AWS.csproj b/src/OpenTelemetry.Contrib.Instrumentation.AWS/OpenTelemetry.Contrib.Instrumentation.AWS.csproj index 1d908482c2..8a63f31667 100644 --- a/src/OpenTelemetry.Contrib.Instrumentation.AWS/OpenTelemetry.Contrib.Instrumentation.AWS.csproj +++ b/src/OpenTelemetry.Contrib.Instrumentation.AWS/OpenTelemetry.Contrib.Instrumentation.AWS.csproj @@ -14,7 +14,7 @@ - - + + diff --git a/src/OpenTelemetry.Contrib.Shared/.publicApi/netstandard2.0/PublicAPI.Shipped.txt b/src/OpenTelemetry.Contrib.Shared/.publicApi/netstandard2.0/PublicAPI.Shipped.txt deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/OpenTelemetry.Contrib.Shared/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Contrib.Shared/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/OpenTelemetry.Contrib.Shared/OpenTelemetry.Contrib.Shared.csproj b/src/OpenTelemetry.Contrib.Shared/OpenTelemetry.Contrib.Shared.csproj deleted file mode 100644 index 2525d8bf35..0000000000 --- a/src/OpenTelemetry.Contrib.Shared/OpenTelemetry.Contrib.Shared.csproj +++ /dev/null @@ -1,16 +0,0 @@ - - - - netstandard2.0 - - - - - - - - - - - - diff --git a/src/OpenTelemetry.Exporter.Geneva/.publicApi/net462/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.Geneva/.publicApi/net462/PublicAPI.Unshipped.txt index e69de29bb2..1fd2dcd539 100644 --- a/src/OpenTelemetry.Exporter.Geneva/.publicApi/net462/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.Exporter.Geneva/.publicApi/net462/PublicAPI.Unshipped.txt @@ -0,0 +1,5 @@ +OpenTelemetry.Exporter.Geneva.EventNameExportMode +OpenTelemetry.Exporter.Geneva.EventNameExportMode.ExportAsPartAName = 1 -> OpenTelemetry.Exporter.Geneva.EventNameExportMode +OpenTelemetry.Exporter.Geneva.EventNameExportMode.None = 0 -> OpenTelemetry.Exporter.Geneva.EventNameExportMode +OpenTelemetry.Exporter.Geneva.GenevaExporterOptions.EventNameExportMode.get -> OpenTelemetry.Exporter.Geneva.EventNameExportMode +OpenTelemetry.Exporter.Geneva.GenevaExporterOptions.EventNameExportMode.set -> void diff --git a/src/OpenTelemetry.Exporter.Geneva/.publicApi/net6.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.Geneva/.publicApi/net6.0/PublicAPI.Unshipped.txt index e69de29bb2..4ca0ea2c19 100644 --- a/src/OpenTelemetry.Exporter.Geneva/.publicApi/net6.0/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.Exporter.Geneva/.publicApi/net6.0/PublicAPI.Unshipped.txt @@ -0,0 +1,5 @@ +OpenTelemetry.Exporter.Geneva.EventNameExportMode +OpenTelemetry.Exporter.Geneva.EventNameExportMode.ExportAsPartAName = 1 -> OpenTelemetry.Exporter.Geneva.EventNameExportMode +OpenTelemetry.Exporter.Geneva.EventNameExportMode.None = 0 -> OpenTelemetry.Exporter.Geneva.EventNameExportMode +OpenTelemetry.Exporter.Geneva.GenevaExporterOptions.EventNameExportMode.get -> OpenTelemetry.Exporter.Geneva.EventNameExportMode +OpenTelemetry.Exporter.Geneva.GenevaExporterOptions.EventNameExportMode.set -> void \ No newline at end of file diff --git a/src/OpenTelemetry.Exporter.Geneva/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.Geneva/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt index e69de29bb2..1fd2dcd539 100644 --- a/src/OpenTelemetry.Exporter.Geneva/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.Exporter.Geneva/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt @@ -0,0 +1,5 @@ +OpenTelemetry.Exporter.Geneva.EventNameExportMode +OpenTelemetry.Exporter.Geneva.EventNameExportMode.ExportAsPartAName = 1 -> OpenTelemetry.Exporter.Geneva.EventNameExportMode +OpenTelemetry.Exporter.Geneva.EventNameExportMode.None = 0 -> OpenTelemetry.Exporter.Geneva.EventNameExportMode +OpenTelemetry.Exporter.Geneva.GenevaExporterOptions.EventNameExportMode.get -> OpenTelemetry.Exporter.Geneva.EventNameExportMode +OpenTelemetry.Exporter.Geneva.GenevaExporterOptions.EventNameExportMode.set -> void diff --git a/src/OpenTelemetry.Exporter.Geneva/CHANGELOG.md b/src/OpenTelemetry.Exporter.Geneva/CHANGELOG.md index 3592898456..7ce77b5913 100644 --- a/src/OpenTelemetry.Exporter.Geneva/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.Geneva/CHANGELOG.md @@ -2,10 +2,19 @@ ## Unreleased +## 1.5.0-alpha.3 + +Released 2023-Apr-19 + * TldLogExporter to export `eventId.Id` as a Part B field instead of Part C field. ([#1134](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1134)) +* Update GenevaLogExporter to export `eventId.Name` as the value for Part A + `name` field when the `EventNameExportMode` option is set to + `ExportAsPartAName`. + ([#1135](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1135)) + ## 1.4.1 Released 2023-Mar-29 diff --git a/src/OpenTelemetry.Exporter.Geneva/EventNameExportMode.cs b/src/OpenTelemetry.Exporter.Geneva/EventNameExportMode.cs new file mode 100644 index 0000000000..7e9e18528f --- /dev/null +++ b/src/OpenTelemetry.Exporter.Geneva/EventNameExportMode.cs @@ -0,0 +1,43 @@ +// +// 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; + +namespace OpenTelemetry.Exporter.Geneva; + +[Flags] +public enum EventNameExportMode +{ + /// + /// GenevaExporter will not export eventId.Name + /// if the enum instance has no other flag selected. + /// + None = 0, + + /// + /// GenevaExporter will export eventId.Name + /// as Part A name field when this flag is selected. + /// + ExportAsPartAName = 1, + + /* Note: This might be added in future. + /// + /// GenevaExporter will export eventId.Name + /// as the table name when this flag is selected. + /// + ExportAsTableName = 2, + */ +} diff --git a/src/OpenTelemetry.Exporter.Geneva/GenevaExporterOptions.cs b/src/OpenTelemetry.Exporter.Geneva/GenevaExporterOptions.cs index 5d781ec8ac..82cdb3a3ac 100644 --- a/src/OpenTelemetry.Exporter.Geneva/GenevaExporterOptions.cs +++ b/src/OpenTelemetry.Exporter.Geneva/GenevaExporterOptions.cs @@ -36,6 +36,8 @@ public class GenevaExporterOptions public ExceptionStackExportMode ExceptionStackExportMode { get; set; } + public EventNameExportMode EventNameExportMode { get; set; } + public IReadOnlyDictionary TableNameMappings { get => this._tableNameMappings; diff --git a/src/OpenTelemetry.Exporter.Geneva/MsgPackExporter/MsgPackLogExporter.cs b/src/OpenTelemetry.Exporter.Geneva/MsgPackExporter/MsgPackLogExporter.cs index b8c9534796..2c353b8337 100644 --- a/src/OpenTelemetry.Exporter.Geneva/MsgPackExporter/MsgPackLogExporter.cs +++ b/src/OpenTelemetry.Exporter.Geneva/MsgPackExporter/MsgPackLogExporter.cs @@ -36,6 +36,7 @@ internal sealed class MsgPackLogExporter : MsgPackExporter, IDisposable "Trace", "Debug", "Information", "Warning", "Error", "Critical", "None", }; + private readonly bool m_shouldExportEventName; private readonly TableNameSerializer m_tableNameSerializer; private readonly Dictionary m_customFields; private readonly Dictionary m_prepopulatedFields; @@ -53,6 +54,8 @@ public MsgPackLogExporter(GenevaExporterOptions options) this.m_tableNameSerializer = new(options, defaultTableName: "Log"); this.m_exportExceptionStack = options.ExceptionStackExportMode; + this.m_shouldExportEventName = (options.EventNameExportMode & EventNameExportMode.ExportAsPartAName) != 0; + var connectionStringBuilder = new ConnectionStringBuilder(options.ConnectionString); switch (connectionStringBuilder.Protocol) { @@ -202,9 +205,22 @@ internal int SerializeLogRecord(LogRecord logRecord) } // Part A - core envelope - cursor = AddPartAField(buffer, cursor, Schema.V40.PartA.Name, eventName); - cntFields += 1; + var eventId = logRecord.EventId; + bool hasEventId = eventId != default; + + if (hasEventId && this.m_shouldExportEventName && !string.IsNullOrWhiteSpace(eventId.Name)) + { + // Export `eventId.Name` as the value for `env_name` + cursor = AddPartAField(buffer, cursor, Schema.V40.PartA.Name, eventId.Name); + cntFields += 1; + } + else + { + // Export the table name as the value for `env_name` + cursor = AddPartAField(buffer, cursor, Schema.V40.PartA.Name, eventName); + cntFields += 1; + } cursor = MessagePackSerializer.SerializeAsciiString(buffer, cursor, "env_time"); cursor = MessagePackSerializer.SerializeUtcDateTime(buffer, cursor, timestamp); // LogRecord.Timestamp should already be converted to UTC format in the SDK @@ -343,8 +359,7 @@ internal int SerializeLogRecord(LogRecord logRecord) MessagePackSerializer.WriteUInt16(buffer, idxMapSizeEnvPropertiesPatch, envPropertiesCount); } - var eventId = logRecord.EventId; - if (eventId != default) + if (hasEventId) { cursor = MessagePackSerializer.SerializeAsciiString(buffer, cursor, "eventId"); cursor = MessagePackSerializer.SerializeInt32(buffer, cursor, eventId.Id); diff --git a/src/OpenTelemetry.Exporter.Geneva/OpenTelemetry.Exporter.Geneva.csproj b/src/OpenTelemetry.Exporter.Geneva/OpenTelemetry.Exporter.Geneva.csproj index 4478d94496..93599774e7 100644 --- a/src/OpenTelemetry.Exporter.Geneva/OpenTelemetry.Exporter.Geneva.csproj +++ b/src/OpenTelemetry.Exporter.Geneva/OpenTelemetry.Exporter.Geneva.csproj @@ -18,7 +18,7 @@ - + diff --git a/src/OpenTelemetry.Exporter.OneCollector/OpenTelemetry.Exporter.OneCollector.csproj b/src/OpenTelemetry.Exporter.OneCollector/OpenTelemetry.Exporter.OneCollector.csproj index cd6db1ff7d..2990eb9ae4 100644 --- a/src/OpenTelemetry.Exporter.OneCollector/OpenTelemetry.Exporter.OneCollector.csproj +++ b/src/OpenTelemetry.Exporter.OneCollector/OpenTelemetry.Exporter.OneCollector.csproj @@ -19,8 +19,8 @@ - - + + diff --git a/src/OpenTelemetry.Exporter.Stackdriver/OpenTelemetry.Exporter.Stackdriver.csproj b/src/OpenTelemetry.Exporter.Stackdriver/OpenTelemetry.Exporter.Stackdriver.csproj index e818a64c9d..515cde9d2a 100644 --- a/src/OpenTelemetry.Exporter.Stackdriver/OpenTelemetry.Exporter.Stackdriver.csproj +++ b/src/OpenTelemetry.Exporter.Stackdriver/OpenTelemetry.Exporter.Stackdriver.csproj @@ -15,6 +15,6 @@ - + diff --git a/src/OpenTelemetry.Extensions.AzureMonitor/OpenTelemetry.Extensions.AzureMonitor.csproj b/src/OpenTelemetry.Extensions.AzureMonitor/OpenTelemetry.Extensions.AzureMonitor.csproj index 761d805b1f..fe20b5c2f7 100644 --- a/src/OpenTelemetry.Extensions.AzureMonitor/OpenTelemetry.Extensions.AzureMonitor.csproj +++ b/src/OpenTelemetry.Extensions.AzureMonitor/OpenTelemetry.Extensions.AzureMonitor.csproj @@ -15,7 +15,7 @@ - + diff --git a/src/OpenTelemetry.Extensions.Enrichment/OpenTelemetry.Extensions.Enrichment.csproj b/src/OpenTelemetry.Extensions.Enrichment/OpenTelemetry.Extensions.Enrichment.csproj index 3b41bba5e1..ffab6b1f36 100644 --- a/src/OpenTelemetry.Extensions.Enrichment/OpenTelemetry.Extensions.Enrichment.csproj +++ b/src/OpenTelemetry.Extensions.Enrichment/OpenTelemetry.Extensions.Enrichment.csproj @@ -14,8 +14,8 @@ - - + + diff --git a/src/OpenTelemetry.Extensions/OpenTelemetry.Extensions.csproj b/src/OpenTelemetry.Extensions/OpenTelemetry.Extensions.csproj index 6518979045..a8f69a0230 100644 --- a/src/OpenTelemetry.Extensions/OpenTelemetry.Extensions.csproj +++ b/src/OpenTelemetry.Extensions/OpenTelemetry.Extensions.csproj @@ -12,7 +12,7 @@ - + diff --git a/src/OpenTelemetry.Instrumentation.AWSLambda/OpenTelemetry.Instrumentation.AWSLambda.csproj b/src/OpenTelemetry.Instrumentation.AWSLambda/OpenTelemetry.Instrumentation.AWSLambda.csproj index 14a98b2675..28929ee4b4 100644 --- a/src/OpenTelemetry.Instrumentation.AWSLambda/OpenTelemetry.Instrumentation.AWSLambda.csproj +++ b/src/OpenTelemetry.Instrumentation.AWSLambda/OpenTelemetry.Instrumentation.AWSLambda.csproj @@ -15,8 +15,8 @@ - - + + diff --git a/src/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.csproj b/src/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.csproj index a084f11f68..395a6adc25 100644 --- a/src/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.csproj +++ b/src/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.csproj @@ -9,7 +9,7 @@ - + diff --git a/src/OpenTelemetry.Instrumentation.AspNet/OpenTelemetry.Instrumentation.AspNet.csproj b/src/OpenTelemetry.Instrumentation.AspNet/OpenTelemetry.Instrumentation.AspNet.csproj index f0eec1af27..3072fd37da 100644 --- a/src/OpenTelemetry.Instrumentation.AspNet/OpenTelemetry.Instrumentation.AspNet.csproj +++ b/src/OpenTelemetry.Instrumentation.AspNet/OpenTelemetry.Instrumentation.AspNet.csproj @@ -14,9 +14,9 @@ - - - + + + diff --git a/src/OpenTelemetry.Instrumentation.Cassandra/OpenTelemetry.Instrumentation.Cassandra.csproj b/src/OpenTelemetry.Instrumentation.Cassandra/OpenTelemetry.Instrumentation.Cassandra.csproj index ae8b086b9e..fb51ba0d92 100644 --- a/src/OpenTelemetry.Instrumentation.Cassandra/OpenTelemetry.Instrumentation.Cassandra.csproj +++ b/src/OpenTelemetry.Instrumentation.Cassandra/OpenTelemetry.Instrumentation.Cassandra.csproj @@ -14,7 +14,7 @@ - + diff --git a/src/OpenTelemetry.Instrumentation.ElasticsearchClient/OpenTelemetry.Instrumentation.ElasticsearchClient.csproj b/src/OpenTelemetry.Instrumentation.ElasticsearchClient/OpenTelemetry.Instrumentation.ElasticsearchClient.csproj index e8560eac26..167a22babb 100644 --- a/src/OpenTelemetry.Instrumentation.ElasticsearchClient/OpenTelemetry.Instrumentation.ElasticsearchClient.csproj +++ b/src/OpenTelemetry.Instrumentation.ElasticsearchClient/OpenTelemetry.Instrumentation.ElasticsearchClient.csproj @@ -14,6 +14,6 @@ - + diff --git a/src/OpenTelemetry.Instrumentation.EntityFrameworkCore/OpenTelemetry.Instrumentation.EntityFrameworkCore.csproj b/src/OpenTelemetry.Instrumentation.EntityFrameworkCore/OpenTelemetry.Instrumentation.EntityFrameworkCore.csproj index f4d574d930..96eaf37e4f 100644 --- a/src/OpenTelemetry.Instrumentation.EntityFrameworkCore/OpenTelemetry.Instrumentation.EntityFrameworkCore.csproj +++ b/src/OpenTelemetry.Instrumentation.EntityFrameworkCore/OpenTelemetry.Instrumentation.EntityFrameworkCore.csproj @@ -14,7 +14,7 @@ - + diff --git a/src/OpenTelemetry.Instrumentation.EventCounters/OpenTelemetry.Instrumentation.EventCounters.csproj b/src/OpenTelemetry.Instrumentation.EventCounters/OpenTelemetry.Instrumentation.EventCounters.csproj index ec5f3e960a..a92edeb866 100644 --- a/src/OpenTelemetry.Instrumentation.EventCounters/OpenTelemetry.Instrumentation.EventCounters.csproj +++ b/src/OpenTelemetry.Instrumentation.EventCounters/OpenTelemetry.Instrumentation.EventCounters.csproj @@ -12,6 +12,6 @@ - + diff --git a/src/OpenTelemetry.Instrumentation.GrpcCore/OpenTelemetry.Instrumentation.GrpcCore.csproj b/src/OpenTelemetry.Instrumentation.GrpcCore/OpenTelemetry.Instrumentation.GrpcCore.csproj index 6133308c08..f00e38357f 100644 --- a/src/OpenTelemetry.Instrumentation.GrpcCore/OpenTelemetry.Instrumentation.GrpcCore.csproj +++ b/src/OpenTelemetry.Instrumentation.GrpcCore/OpenTelemetry.Instrumentation.GrpcCore.csproj @@ -12,6 +12,6 @@ - + diff --git a/src/OpenTelemetry.Instrumentation.Hangfire/OpenTelemetry.Instrumentation.Hangfire.csproj b/src/OpenTelemetry.Instrumentation.Hangfire/OpenTelemetry.Instrumentation.Hangfire.csproj index 33a91b03ee..d842b71a81 100644 --- a/src/OpenTelemetry.Instrumentation.Hangfire/OpenTelemetry.Instrumentation.Hangfire.csproj +++ b/src/OpenTelemetry.Instrumentation.Hangfire/OpenTelemetry.Instrumentation.Hangfire.csproj @@ -11,6 +11,6 @@ - + diff --git a/src/OpenTelemetry.Instrumentation.MySqlData/OpenTelemetry.Instrumentation.MySqlData.csproj b/src/OpenTelemetry.Instrumentation.MySqlData/OpenTelemetry.Instrumentation.MySqlData.csproj index 5397712c47..2c721cafb6 100644 --- a/src/OpenTelemetry.Instrumentation.MySqlData/OpenTelemetry.Instrumentation.MySqlData.csproj +++ b/src/OpenTelemetry.Instrumentation.MySqlData/OpenTelemetry.Instrumentation.MySqlData.csproj @@ -14,9 +14,9 @@ - - - + + + diff --git a/src/OpenTelemetry.Instrumentation.Owin/OpenTelemetry.Instrumentation.Owin.csproj b/src/OpenTelemetry.Instrumentation.Owin/OpenTelemetry.Instrumentation.Owin.csproj index de6e33c97f..47748d2105 100644 --- a/src/OpenTelemetry.Instrumentation.Owin/OpenTelemetry.Instrumentation.Owin.csproj +++ b/src/OpenTelemetry.Instrumentation.Owin/OpenTelemetry.Instrumentation.Owin.csproj @@ -1,4 +1,4 @@ - + $(NetFrameworkMinimumSupportedVersion) true @@ -9,9 +9,9 @@ - - - + + + diff --git a/src/OpenTelemetry.Instrumentation.Process/OpenTelemetry.Instrumentation.Process.csproj b/src/OpenTelemetry.Instrumentation.Process/OpenTelemetry.Instrumentation.Process.csproj index 4f7202a8f8..49e32f3588 100644 --- a/src/OpenTelemetry.Instrumentation.Process/OpenTelemetry.Instrumentation.Process.csproj +++ b/src/OpenTelemetry.Instrumentation.Process/OpenTelemetry.Instrumentation.Process.csproj @@ -13,7 +13,7 @@ - + diff --git a/src/OpenTelemetry.Instrumentation.Quartz/OpenTelemetry.Instrumentation.Quartz.csproj b/src/OpenTelemetry.Instrumentation.Quartz/OpenTelemetry.Instrumentation.Quartz.csproj index 0b271ac9da..c794f15c85 100644 --- a/src/OpenTelemetry.Instrumentation.Quartz/OpenTelemetry.Instrumentation.Quartz.csproj +++ b/src/OpenTelemetry.Instrumentation.Quartz/OpenTelemetry.Instrumentation.Quartz.csproj @@ -12,6 +12,6 @@ - + diff --git a/src/OpenTelemetry.Instrumentation.Runtime/OpenTelemetry.Instrumentation.Runtime.csproj b/src/OpenTelemetry.Instrumentation.Runtime/OpenTelemetry.Instrumentation.Runtime.csproj index dc81b9be78..06adbebe66 100644 --- a/src/OpenTelemetry.Instrumentation.Runtime/OpenTelemetry.Instrumentation.Runtime.csproj +++ b/src/OpenTelemetry.Instrumentation.Runtime/OpenTelemetry.Instrumentation.Runtime.csproj @@ -14,6 +14,6 @@ - + diff --git a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/OpenTelemetry.Instrumentation.StackExchangeRedis.csproj b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/OpenTelemetry.Instrumentation.StackExchangeRedis.csproj index 29b7e82417..45aa8b140d 100644 --- a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/OpenTelemetry.Instrumentation.StackExchangeRedis.csproj +++ b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/OpenTelemetry.Instrumentation.StackExchangeRedis.csproj @@ -10,8 +10,8 @@ - - + + diff --git a/src/OpenTelemetry.Instrumentation.Wcf/OpenTelemetry.Instrumentation.Wcf.csproj b/src/OpenTelemetry.Instrumentation.Wcf/OpenTelemetry.Instrumentation.Wcf.csproj index cc6da9eac8..7b01ca3fb1 100644 --- a/src/OpenTelemetry.Instrumentation.Wcf/OpenTelemetry.Instrumentation.Wcf.csproj +++ b/src/OpenTelemetry.Instrumentation.Wcf/OpenTelemetry.Instrumentation.Wcf.csproj @@ -23,7 +23,7 @@ - + diff --git a/src/OpenTelemetry.PersistentStorage.Abstractions/OpenTelemetry.PersistentStorage.Abstractions.csproj b/src/OpenTelemetry.PersistentStorage.Abstractions/OpenTelemetry.PersistentStorage.Abstractions.csproj index b33f879639..bd71e8127b 100644 --- a/src/OpenTelemetry.PersistentStorage.Abstractions/OpenTelemetry.PersistentStorage.Abstractions.csproj +++ b/src/OpenTelemetry.PersistentStorage.Abstractions/OpenTelemetry.PersistentStorage.Abstractions.csproj @@ -14,7 +14,7 @@ - + diff --git a/src/OpenTelemetry.PersistentStorage.FileSystem/OpenTelemetry.PersistentStorage.FileSystem.csproj b/src/OpenTelemetry.PersistentStorage.FileSystem/OpenTelemetry.PersistentStorage.FileSystem.csproj index 5b86be8b0a..7dffd68dec 100644 --- a/src/OpenTelemetry.PersistentStorage.FileSystem/OpenTelemetry.PersistentStorage.FileSystem.csproj +++ b/src/OpenTelemetry.PersistentStorage.FileSystem/OpenTelemetry.PersistentStorage.FileSystem.csproj @@ -16,8 +16,8 @@ - - + + diff --git a/src/OpenTelemetry.ResourceDetectors.Azure/CHANGELOG.md b/src/OpenTelemetry.ResourceDetectors.Azure/CHANGELOG.md index ef8912a5bc..32baee3f54 100644 --- a/src/OpenTelemetry.ResourceDetectors.Azure/CHANGELOG.md +++ b/src/OpenTelemetry.ResourceDetectors.Azure/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +## 1.0.0-alpha.1 + +Released 2023-Apr-19 + * Add AppService resource detector. ([#989](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/989)) diff --git a/src/OpenTelemetry.ResourceDetectors.Azure/OpenTelemetry.ResourceDetectors.Azure.csproj b/src/OpenTelemetry.ResourceDetectors.Azure/OpenTelemetry.ResourceDetectors.Azure.csproj index cb303071bf..19c0f3f377 100644 --- a/src/OpenTelemetry.ResourceDetectors.Azure/OpenTelemetry.ResourceDetectors.Azure.csproj +++ b/src/OpenTelemetry.ResourceDetectors.Azure/OpenTelemetry.ResourceDetectors.Azure.csproj @@ -1,4 +1,4 @@ - + netstandard2.0 OpenTelemetry Resource Detectors for Azure cloud environments @@ -13,7 +13,7 @@ - - + + diff --git a/src/OpenTelemetry.ResourceDetectors.Azure/README.md b/src/OpenTelemetry.ResourceDetectors.Azure/README.md index 3389bf6c6a..660d6b595b 100644 --- a/src/OpenTelemetry.ResourceDetectors.Azure/README.md +++ b/src/OpenTelemetry.ResourceDetectors.Azure/README.md @@ -1,3 +1,30 @@ # Resource Detectors for Azure cloud environments -TODO +This package contains [Resource +Detectors](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/sdk.md#detecting-resource-information-from-the-environment) +for applications running in Azure environment. + +## Installation + +```shell +dotnet add package --prerelease OpenTelemetry.ResourceDetectors.Azure +``` + +## Appservice Resource Detector + +Adds resource attributes for the applications running in Appservice. The +following example shows how to add `AppServiceResourceDetector` to +`TracerProvider` configuration: + +```csharp +using OpenTelemetry; +using OpenTelemetry.ResourceDetectors.Azure; +using OpenTelemetry.Resources; + +var tracerProvider = Sdk.CreateTracerProviderBuilder() + // other configurations + .SetResourceBuilder(ResourceBuilder + .CreateDefault() + .AddDetector(new AppServiceResourceDetector())) + .Build(); +``` diff --git a/src/OpenTelemetry.Sampler.AWS/OpenTelemetry.Sampler.AWS.csproj b/src/OpenTelemetry.Sampler.AWS/OpenTelemetry.Sampler.AWS.csproj index ed94f96cc4..341fabd468 100644 --- a/src/OpenTelemetry.Sampler.AWS/OpenTelemetry.Sampler.AWS.csproj +++ b/src/OpenTelemetry.Sampler.AWS/OpenTelemetry.Sampler.AWS.csproj @@ -18,7 +18,7 @@ - + diff --git a/src/OpenTelemetry.Contrib.Shared/DiagnosticSourceInstrumentation/ActivityInstrumentationHelper.cs b/src/Shared/ActivityInstrumentationHelper.cs similarity index 100% rename from src/OpenTelemetry.Contrib.Shared/DiagnosticSourceInstrumentation/ActivityInstrumentationHelper.cs rename to src/Shared/ActivityInstrumentationHelper.cs diff --git a/src/OpenTelemetry.Contrib.Shared/DiagnosticSourceInstrumentation/DiagnosticSourceListener.cs b/src/Shared/DiagnosticSourceListener.cs similarity index 100% rename from src/OpenTelemetry.Contrib.Shared/DiagnosticSourceInstrumentation/DiagnosticSourceListener.cs rename to src/Shared/DiagnosticSourceListener.cs diff --git a/src/OpenTelemetry.Contrib.Shared/DiagnosticSourceInstrumentation/DiagnosticSourceSubscriber.cs b/src/Shared/DiagnosticSourceSubscriber.cs similarity index 100% rename from src/OpenTelemetry.Contrib.Shared/DiagnosticSourceInstrumentation/DiagnosticSourceSubscriber.cs rename to src/Shared/DiagnosticSourceSubscriber.cs diff --git a/src/OpenTelemetry.Contrib.Shared/Api/ExceptionExtensions.cs b/src/Shared/ExceptionExtensions.cs similarity index 100% rename from src/OpenTelemetry.Contrib.Shared/Api/ExceptionExtensions.cs rename to src/Shared/ExceptionExtensions.cs diff --git a/src/OpenTelemetry.Internal/Guard.cs b/src/Shared/Guard.cs similarity index 100% rename from src/OpenTelemetry.Internal/Guard.cs rename to src/Shared/Guard.cs diff --git a/src/OpenTelemetry.Contrib.Shared/DiagnosticSourceInstrumentation/InstrumentationEventSource.cs b/src/Shared/InstrumentationEventSource.cs similarity index 100% rename from src/OpenTelemetry.Contrib.Shared/DiagnosticSourceInstrumentation/InstrumentationEventSource.cs rename to src/Shared/InstrumentationEventSource.cs diff --git a/src/OpenTelemetry.Internal/IsExternalInit.cs b/src/Shared/IsExternalInit.cs similarity index 100% rename from src/OpenTelemetry.Internal/IsExternalInit.cs rename to src/Shared/IsExternalInit.cs diff --git a/src/OpenTelemetry.Contrib.Shared/DiagnosticSourceInstrumentation/ListenerHandler.cs b/src/Shared/ListenerHandler.cs similarity index 100% rename from src/OpenTelemetry.Contrib.Shared/DiagnosticSourceInstrumentation/ListenerHandler.cs rename to src/Shared/ListenerHandler.cs diff --git a/src/OpenTelemetry.Contrib.Shared/DiagnosticSourceInstrumentation/MultiTypePropertyFetcher.cs b/src/Shared/MultiTypePropertyFetcher.cs similarity index 100% rename from src/OpenTelemetry.Contrib.Shared/DiagnosticSourceInstrumentation/MultiTypePropertyFetcher.cs rename to src/Shared/MultiTypePropertyFetcher.cs diff --git a/src/OpenTelemetry.Internal/NullableAttributes.cs b/src/Shared/NullableAttributes.cs similarity index 100% rename from src/OpenTelemetry.Internal/NullableAttributes.cs rename to src/Shared/NullableAttributes.cs diff --git a/src/OpenTelemetry.Contrib.Shared/DiagnosticSourceInstrumentation/PropertyFetcher.cs b/src/Shared/PropertyFetcher.cs similarity index 100% rename from src/OpenTelemetry.Contrib.Shared/DiagnosticSourceInstrumentation/PropertyFetcher.cs rename to src/Shared/PropertyFetcher.cs diff --git a/src/OpenTelemetry.Contrib.Shared/Api/ResourceSemanticConventions.cs b/src/Shared/ResourceSemanticConventions.cs similarity index 100% rename from src/OpenTelemetry.Contrib.Shared/Api/ResourceSemanticConventions.cs rename to src/Shared/ResourceSemanticConventions.cs diff --git a/src/OpenTelemetry.Contrib.Shared/Api/SemanticConventions.cs b/src/Shared/SemanticConventions.cs similarity index 100% rename from src/OpenTelemetry.Contrib.Shared/Api/SemanticConventions.cs rename to src/Shared/SemanticConventions.cs diff --git a/src/OpenTelemetry.Contrib.Shared/ServiceProviderExtensions.cs b/src/Shared/ServiceProviderExtensions.cs similarity index 100% rename from src/OpenTelemetry.Contrib.Shared/ServiceProviderExtensions.cs rename to src/Shared/ServiceProviderExtensions.cs diff --git a/src/OpenTelemetry.Contrib.Shared/Api/SpanAttributeConstants.cs b/src/Shared/SpanAttributeConstants.cs similarity index 100% rename from src/OpenTelemetry.Contrib.Shared/Api/SpanAttributeConstants.cs rename to src/Shared/SpanAttributeConstants.cs diff --git a/src/OpenTelemetry.Contrib.Shared/Api/SpanHelper.cs b/src/Shared/SpanHelper.cs similarity index 100% rename from src/OpenTelemetry.Contrib.Shared/Api/SpanHelper.cs rename to src/Shared/SpanHelper.cs diff --git a/test/OpenTelemetry.Exporter.Geneva.Tests/GenevaLogExporterTests.cs b/test/OpenTelemetry.Exporter.Geneva.Tests/GenevaLogExporterTests.cs index 04f3c055db..aba31bb007 100644 --- a/test/OpenTelemetry.Exporter.Geneva.Tests/GenevaLogExporterTests.cs +++ b/test/OpenTelemetry.Exporter.Geneva.Tests/GenevaLogExporterTests.cs @@ -50,6 +50,13 @@ public void ExportExceptionStackDefaultIsDrop() Assert.Equal(ExceptionStackExportMode.Drop, exporterOptions.ExceptionStackExportMode); } + [Fact] + public void ExportEventNameDefaultIsNone() + { + GenevaExporterOptions exporterOptions = new GenevaExporterOptions(); + Assert.Equal(EventNameExportMode.None, exporterOptions.EventNameExportMode); + } + [Fact] public void SpecialCharactersInTableNameMappings() { @@ -1009,6 +1016,139 @@ public void SerializationTestForException() } } + [Theory] + [InlineData(EventNameExportMode.None, false)] + [InlineData(EventNameExportMode.None, true)] + [InlineData(EventNameExportMode.ExportAsPartAName, false)] + [InlineData(EventNameExportMode.ExportAsPartAName, true)] + public void SerializationTestForEventName(EventNameExportMode eventNameExportMode, bool hasTableNameMapping) + { + // ARRANGE + string path = string.Empty; + Socket server = null; + var logRecordList = new List(); + try + { + var exporterOptions = new GenevaExporterOptions(); + exporterOptions.EventNameExportMode = eventNameExportMode; + + if (hasTableNameMapping) + { + exporterOptions.TableNameMappings = new Dictionary() + { + ["*"] = "CustomTableName", + }; + } + + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + exporterOptions.ConnectionString = "EtwSession=OpenTelemetry"; + } + else + { + path = GenerateTempFilePath(); + exporterOptions.ConnectionString = "Endpoint=unix:" + path; + var endpoint = new UnixDomainSocketEndPoint(path); + server = new Socket(AddressFamily.Unix, SocketType.Stream, ProtocolType.IP); + server.Bind(endpoint); + server.Listen(1); + } + + using var loggerFactory = LoggerFactory.Create(builder => builder + .AddOpenTelemetry(options => + { + options.AddGenevaLogExporter(options => + { + options.ConnectionString = exporterOptions.ConnectionString; + options.EventNameExportMode = exporterOptions.EventNameExportMode; + + if (hasTableNameMapping) + { + options.TableNameMappings = exporterOptions.TableNameMappings; + } + }); + options.AddInMemoryExporter(logRecordList); + })); + + // Create a test exporter to get MessagePack byte data to validate if the data was serialized correctly. + 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(); + + // ACT + // This is treated as structured logging as the state can be converted to IReadOnlyList> + + #region Test for `ILogger.Log` + logger.Log( + logLevel: LogLevel.Information, + eventId: new EventId(1, "TestEventNameWithLogMethod"), + state: null, + exception: new Exception("Exception Message"), + formatter: null); + + // VALIDATE + Assert.Single(logRecordList); + 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 eventName = GetField(fluentdData, "env_name"); + + if (eventNameExportMode.HasFlag(EventNameExportMode.ExportAsPartAName)) + { + Assert.Equal("TestEventNameWithLogMethod", eventName); + } + else + { + Assert.Equal(hasTableNameMapping ? "CustomTableName" : "Log", eventName); + } + + #endregion + + logRecordList.Clear(); + + #region Test for extension method + logger.LogInformation(eventId: new EventId(1, "TestEventNameWithLogExtensionMethod"), "Hello from {Name} {Price}.", "tomato", 2.99); + + _ = exporter.SerializeLogRecord(logRecordList[0]); + fluentdData = MessagePack.MessagePackSerializer.Deserialize(m_buffer.Value, MessagePack.Resolvers.ContractlessStandardResolver.Instance); + eventName = GetField(fluentdData, "env_name"); + + if (eventNameExportMode.HasFlag(EventNameExportMode.ExportAsPartAName)) + { + Assert.Equal("TestEventNameWithLogExtensionMethod", eventName); + } + else + { + Assert.Equal(hasTableNameMapping ? "CustomTableName" : "Log", eventName); + } + #endregion + + logRecordList.Clear(); + + #region Test with eventName as null + logger.LogInformation(eventId: 1, "Hello from {Name} {Price}.", "tomato", 2.99); + + _ = exporter.SerializeLogRecord(logRecordList[0]); + fluentdData = MessagePack.MessagePackSerializer.Deserialize(m_buffer.Value, MessagePack.Resolvers.ContractlessStandardResolver.Instance); + eventName = GetField(fluentdData, "env_name"); + Assert.Equal(hasTableNameMapping ? "CustomTableName" : "Log", eventName); + #endregion + + } + finally + { + server?.Dispose(); + try + { + File.Delete(path); + } + catch + { + } + } + } + [Fact] public void SerializationTestForEventId() { diff --git a/test/OpenTelemetry.Instrumentation.AspNet.Tests/OpenTelemetry.Instrumentation.AspNet.Tests.csproj b/test/OpenTelemetry.Instrumentation.AspNet.Tests/OpenTelemetry.Instrumentation.AspNet.Tests.csproj index 5a1b585cda..f59b1e785e 100644 --- a/test/OpenTelemetry.Instrumentation.AspNet.Tests/OpenTelemetry.Instrumentation.AspNet.Tests.csproj +++ b/test/OpenTelemetry.Instrumentation.AspNet.Tests/OpenTelemetry.Instrumentation.AspNet.Tests.csproj @@ -26,7 +26,7 @@ - +