diff --git a/.editorconfig b/.editorconfig index fcbf24f9a5d..63cdbe40a1a 100644 --- a/.editorconfig +++ b/.editorconfig @@ -34,7 +34,7 @@ csharp_indent_switch_labels = true csharp_indent_labels = flush_left # Modifier preferences -csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion +csharp_preferred_modifier_order = public,private,protected,internal,file,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,required,volatile,async:suggestion dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent # this. preferences diff --git a/.github/workflows/apicompatibility.yml b/.github/workflows/apicompatibility.yml index ec6706fdfab..8451c890c87 100644 --- a/.github/workflows/apicompatibility.yml +++ b/.github/workflows/apicompatibility.yml @@ -17,8 +17,11 @@ jobs: with: fetch-depth: 0 # fetching all + - name: Setup dotnet + uses: actions/setup-dotnet@v3 + - name: Install dependencies run: dotnet restore - name: Build - run: dotnet build --configuration Release --no-restore + run: dotnet build --configuration Release --no-restore --property:ExposeExperimentalFeatures=true diff --git a/.github/workflows/ci-aot.yml b/.github/workflows/ci-aot.yml index 1be900f89ca..499813e3669 100644 --- a/.github/workflows/ci-aot.yml +++ b/.github/workflows/ci-aot.yml @@ -24,6 +24,9 @@ jobs: with: fetch-depth: 0 # fetching all + - name: Setup dotnet + uses: actions/setup-dotnet@v3 + - name: publish AOT testApp, assert static analysis warning count, and run the app shell: pwsh run: .\build\test-aot-compatibility.ps1 ${{ matrix.version }} diff --git a/.github/workflows/ci-instrumentation-libraries.yml b/.github/workflows/ci-instrumentation-libraries.yml index 914f7efdad7..14da57a3298 100644 --- a/.github/workflows/ci-instrumentation-libraries.yml +++ b/.github/workflows/ci-instrumentation-libraries.yml @@ -31,6 +31,9 @@ jobs: with: fetch-depth: 0 # fetching all + - name: Setup dotnet + uses: actions/setup-dotnet@v3 + - name: Install dependencies run: dotnet restore ./build/InstrumentationLibraries.proj diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 734959b70de..68105bc9234 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ on: - '**.md' jobs: - build-test: + build-test-stable: strategy: fail-fast: false # ensures the entire test matrix is run, even if one permutation fails matrix: @@ -27,11 +27,42 @@ jobs: with: fetch-depth: 0 # fetching all + - name: Setup dotnet + uses: actions/setup-dotnet@v3 + + - name: Install dependencies + run: dotnet restore + + - name: Build + run: dotnet build --configuration Release --no-restore --property:ExposeExperimentalFeatures=false + + - name: Test ${{ matrix.version }} + run: dotnet test **/bin/**/${{ matrix.version }}/*.Tests.dll --logger:"console;verbosity=detailed" + + build-test-experimental: + strategy: + fail-fast: false # ensures the entire test matrix is run, even if one permutation fails + matrix: + os: [ windows-latest, ubuntu-latest ] + version: [ net462, net6.0, net7.0 ] + exclude: + - os: ubuntu-latest + version: net462 + + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 # fetching all + + - name: Setup dotnet + uses: actions/setup-dotnet@v3 + - name: Install dependencies run: dotnet restore - name: Build - run: dotnet build --configuration Release --no-restore + run: dotnet build --configuration Release --no-restore --property:ExposeExperimentalFeatures=true - name: Test ${{ matrix.version }} run: dotnet test **/bin/**/${{ matrix.version }}/*.Tests.dll --logger:"console;verbosity=detailed" diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index 4a68cb93e41..4ff17a15ea6 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -24,11 +24,14 @@ jobs: with: fetch-depth: 0 # fetching all + - name: Setup dotnet + uses: actions/setup-dotnet@v3 + - name: Install dependencies run: dotnet restore - name: dotnet build - run: dotnet build --configuration Release --no-restore + run: dotnet build --configuration Release --no-restore --property:ExposeExperimentalFeatures=true # - name: dotnet test # run: dotnet test --collect:"XPlat Code Coverage" --results-directory:"TestResults" --configuration Release --no-build -- RunConfiguration.DisableAppDomain=true diff --git a/.github/workflows/dotnet-format.yml b/.github/workflows/dotnet-format.yml index 73c2cde0bdc..b6d974ced3c 100644 --- a/.github/workflows/dotnet-format.yml +++ b/.github/workflows/dotnet-format.yml @@ -20,6 +20,9 @@ jobs: - name: check out code uses: actions/checkout@v3 + - name: Setup dotnet + uses: actions/setup-dotnet@v3 + - name: Install format tool run: dotnet tool install -g dotnet-format diff --git a/Directory.Packages.props b/Directory.Packages.props index 1c62e7e4daa..fc53674953f 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -67,21 +67,21 @@ - - + + - + - + diff --git a/NuGet.config b/NuGet.config index c821ba89f4e..6f5c8246395 100644 --- a/NuGet.config +++ b/NuGet.config @@ -1,11 +1,9 @@ - + - + @@ -16,8 +14,11 @@ + + + - + diff --git a/OpenTelemetry.sln b/OpenTelemetry.sln index 12c17122b4e..4f269da2bd2 100644 --- a/OpenTelemetry.sln +++ b/OpenTelemetry.sln @@ -44,8 +44,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{7CB2F02E build\process-codecoverage.ps1 = build\process-codecoverage.ps1 build\RELEASING.md = build\RELEASING.md build\stylecop.json = build\stylecop.json - build\xunit.runner.json = build\xunit.runner.json build\test-aot-compatibility.ps1 = build\test-aot-compatibility.ps1 + build\xunit.runner.json = build\xunit.runner.json EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Exporter.Zipkin", "src\OpenTelemetry.Exporter.Zipkin\OpenTelemetry.Exporter.Zipkin.csproj", "{7EDAE7FA-B44E-42CA-80FA-7DF2FAA2C5DD}" @@ -97,6 +97,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{ ProjectSection(SolutionItems) = preProject .github\workflows\apicompatibility.yml = .github\workflows\apicompatibility.yml .github\workflows\ci-aot.yml = .github\workflows\ci-aot.yml + .github\workflows\ci-instrumentation-libraries-md.yml = .github\workflows\ci-instrumentation-libraries-md.yml + .github\workflows\ci-instrumentation-libraries.yml = .github\workflows\ci-instrumentation-libraries.yml .github\workflows\ci-md.yml = .github\workflows\ci-md.yml .github\workflows\ci.yml = .github\workflows\ci.yml .github\workflows\code-coverage.yml = .github\workflows\code-coverage.yml diff --git a/build/Common.nonprod.props b/build/Common.nonprod.props index cdcba2f64b6..84759cd32a4 100644 --- a/build/Common.nonprod.props +++ b/build/Common.nonprod.props @@ -7,6 +7,10 @@ $([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), 'OpenTelemetry.sln'))\build\OpenTelemetry.test.ruleset + + net7.0 + + true diff --git a/build/Common.prod.props b/build/Common.prod.props index 0db040be0dd..0968f64c5a0 100644 --- a/build/Common.prod.props +++ b/build/Common.prod.props @@ -46,14 +46,17 @@ $(NoWarn),1573,1712 $(Build_ArtifactStagingDirectory) true - $(RepoRoot)\build\GlobalAttrExclusions.txt $(MinVerMajor).$(MinVerMinor).$(MinVerPatch).$(BuildNumber) + true + false + + @@ -89,10 +92,10 @@ - - - - + + + + diff --git a/build/Common.props b/build/Common.props index cf2ac9deb25..90abd8e31cc 100644 --- a/build/Common.props +++ b/build/Common.props @@ -1,15 +1,21 @@ - 10.0 + latest true $([System.IO.Directory]::GetParent($(MSBuildThisFileDirectory)).Parent.FullName) $(MSBuildThisFileDirectory)debug.snk $(DefineConstants);SIGNED true + true enable enable + true + + + + $(DefineConstants);EXPOSE_EXPERIMENTAL_FEATURES diff --git a/build/test-aot-compatibility.ps1 b/build/test-aot-compatibility.ps1 index 62f2f5770b6..c80070de223 100644 --- a/build/test-aot-compatibility.ps1 +++ b/build/test-aot-compatibility.ps1 @@ -1,13 +1,13 @@ param([string]$targetNetFramework) $rootDirectory = Split-Path $PSScriptRoot -Parent -$publishOutput = dotnet publish $rootDirectory/test/OpenTelemetry.AotCompatibility.TestApp/OpenTelemetry.AotCompatibility.TestApp.csproj -nodeReuse:false /p:UseSharedCompilation=false +$publishOutput = dotnet publish $rootDirectory/test/OpenTelemetry.AotCompatibility.TestApp/OpenTelemetry.AotCompatibility.TestApp.csproj -nodeReuse:false /p:UseSharedCompilation=false /p:ExposeExperimentalFeatures=true $actualWarningCount = 0 foreach ($line in $($publishOutput -split "`r`n")) { - if ($line -like "*analysis warning IL*") + if ($line -like "*analysis warning IL*") { Write-Host $line $actualWarningCount += 1 @@ -28,7 +28,7 @@ if ($LastExitCode -ne 0) popd Write-Host "Actual warning count is:", $actualWarningCount -$expectedWarningCount = 28 +$expectedWarningCount = 33 $testPassed = 0 if ($actualWarningCount -ne $expectedWarningCount) diff --git a/docs/metrics/getting-started-aspnetcore/Program.cs b/docs/metrics/getting-started-aspnetcore/Program.cs index 835703f0c81..98c7e98b343 100644 --- a/docs/metrics/getting-started-aspnetcore/Program.cs +++ b/docs/metrics/getting-started-aspnetcore/Program.cs @@ -14,7 +14,6 @@ // limitations under the License. // -using System.Diagnostics; using OpenTelemetry.Metrics; using OpenTelemetry.Resources; diff --git a/docs/trace/getting-started-jaeger/Program.cs b/docs/trace/getting-started-jaeger/Program.cs index b57660f7470..c8c4e666b30 100644 --- a/docs/trace/getting-started-jaeger/Program.cs +++ b/docs/trace/getting-started-jaeger/Program.cs @@ -14,12 +14,8 @@ // limitations under the License. // -using System; using System.Diagnostics; -using System.Net.Http; -using System.Threading.Tasks; using OpenTelemetry; -using OpenTelemetry.Exporter; using OpenTelemetry.Resources; using OpenTelemetry.Trace; diff --git a/examples/AspNetCore/Examples.AspNetCore.csproj b/examples/AspNetCore/Examples.AspNetCore.csproj index fe6b61f8962..abeb406696e 100644 --- a/examples/AspNetCore/Examples.AspNetCore.csproj +++ b/examples/AspNetCore/Examples.AspNetCore.csproj @@ -1,7 +1,7 @@ - net6.0 + $(DefaultTargetFrameworkForExampleApps) diff --git a/examples/AspNetCore/Program.cs b/examples/AspNetCore/Program.cs index bc4e0602cda..2ee28a5dae4 100644 --- a/examples/AspNetCore/Program.cs +++ b/examples/AspNetCore/Program.cs @@ -26,20 +26,20 @@ var appBuilder = WebApplication.CreateBuilder(args); // Note: Switch between Zipkin/Jaeger/OTLP/Console by setting UseTracingExporter in appsettings.json. -var tracingExporter = appBuilder.Configuration.GetValue("UseTracingExporter").ToLowerInvariant(); +var tracingExporter = appBuilder.Configuration.GetValue("UseTracingExporter", defaultValue: "console")!.ToLowerInvariant(); // Note: Switch between Prometheus/OTLP/Console by setting UseMetricsExporter in appsettings.json. -var metricsExporter = appBuilder.Configuration.GetValue("UseMetricsExporter").ToLowerInvariant(); +var metricsExporter = appBuilder.Configuration.GetValue("UseMetricsExporter", defaultValue: "console")!.ToLowerInvariant(); // Note: Switch between Console/OTLP by setting UseLogExporter in appsettings.json. -var logExporter = appBuilder.Configuration.GetValue("UseLogExporter").ToLowerInvariant(); +var logExporter = appBuilder.Configuration.GetValue("UseLogExporter", defaultValue: "console")!.ToLowerInvariant(); // Note: Switch between Explicit/Exponential by setting HistogramAggregation in appsettings.json -var histogramAggregation = appBuilder.Configuration.GetValue("HistogramAggregation").ToLowerInvariant(); +var histogramAggregation = appBuilder.Configuration.GetValue("HistogramAggregation", defaultValue: "explicit")!.ToLowerInvariant(); // Build a resource configuration action to set service information. Action configureResource = r => r.AddService( - serviceName: appBuilder.Configuration.GetValue("ServiceName"), + serviceName: appBuilder.Configuration.GetValue("ServiceName", defaultValue: "otel-test")!, serviceVersion: typeof(Program).Assembly.GetName().Version?.ToString() ?? "unknown", serviceInstanceId: Environment.MachineName); @@ -94,7 +94,7 @@ builder.AddOtlpExporter(otlpOptions => { // Use IConfiguration directly for Otlp exporter endpoint option. - otlpOptions.Endpoint = new Uri(appBuilder.Configuration.GetValue("Otlp:Endpoint")); + otlpOptions.Endpoint = new Uri(appBuilder.Configuration.GetValue("Otlp:Endpoint", defaultValue: "http://localhost:4317")!); }); break; @@ -110,7 +110,9 @@ // Ensure the MeterProvider subscribes to any custom Meters. builder .AddMeter(Instrumentation.MeterName) +#if EXPOSE_EXPERIMENTAL_FEATURES .SetExemplarFilter(new TraceBasedExemplarFilter()) +#endif .AddRuntimeInstrumentation() .AddHttpClientInstrumentation() .AddAspNetCoreInstrumentation(); @@ -140,7 +142,7 @@ builder.AddOtlpExporter(otlpOptions => { // Use IConfiguration directly for Otlp exporter endpoint option. - otlpOptions.Endpoint = new Uri(appBuilder.Configuration.GetValue("Otlp:Endpoint")); + otlpOptions.Endpoint = new Uri(appBuilder.Configuration.GetValue("Otlp:Endpoint", defaultValue: "http://localhost:4317")!); }); break; default: @@ -167,7 +169,7 @@ options.AddOtlpExporter(otlpOptions => { // Use IConfiguration directly for Otlp exporter endpoint option. - otlpOptions.Endpoint = new Uri(appBuilder.Configuration.GetValue("Otlp:Endpoint")); + otlpOptions.Endpoint = new Uri(appBuilder.Configuration.GetValue("Otlp:Endpoint", defaultValue: "http://localhost:4317")!); }); break; default: diff --git a/examples/Console/Examples.Console.csproj b/examples/Console/Examples.Console.csproj index 2f4f047c070..9b03f7e08db 100644 --- a/examples/Console/Examples.Console.csproj +++ b/examples/Console/Examples.Console.csproj @@ -2,7 +2,7 @@ Exe - net6.0 + $(DefaultTargetFrameworkForExampleApps) $(NoWarn),CS0618 diff --git a/examples/Console/Program.cs b/examples/Console/Program.cs index 56b04a7622c..e8cc6645ed1 100644 --- a/examples/Console/Program.cs +++ b/examples/Console/Program.cs @@ -163,6 +163,12 @@ internal class LogsOptions [Option('p', "protocol", HelpText = "Transport protocol used by OTLP exporter. Supported values: grpc and http/protobuf. Only applicable if Exporter is OTLP", Default = "grpc")] public string Protocol { get; set; } + + [Option("processorType", Default = "batch", HelpText = "export processor type. Supported values: simple and batch", Required = false)] + public string ProcessorType { get; set; } + + [Option("scheduledDelay", Default = 5000, HelpText = "The delay interval in milliseconds between two consecutive exports.", Required = false)] + public int ScheduledDelayInMilliseconds { get; set; } } [Verb("inmemory", HelpText = "Specify the options required to test InMemory Exporter")] diff --git a/examples/Console/TestLogs.cs b/examples/Console/TestLogs.cs index cc03e20ff14..06a8576f963 100644 --- a/examples/Console/TestLogs.cs +++ b/examples/Console/TestLogs.cs @@ -15,6 +15,7 @@ // using Microsoft.Extensions.Logging; +using OpenTelemetry; using OpenTelemetry.Logs; namespace Examples.Console; @@ -73,12 +74,36 @@ internal static object Run(LogsOptions options) System.Console.WriteLine($"Export protocol {options.Protocol} is not supported. Default protocol 'grpc' will be used."); } - opt.AddOtlpExporter(otlpOptions => + var processorType = ExportProcessorType.Batch; + if (options.ProcessorType.Trim().ToLower().Equals("batch")) { - otlpOptions.Protocol = protocol; + processorType = ExportProcessorType.Batch; + } + else if (options.Protocol.Trim().ToLower().Equals("simple")) + { + processorType = ExportProcessorType.Simple; + } + else + { + System.Console.WriteLine($"Export processor type {options.ProcessorType} is not supported. Default processor type 'batch' will be used."); + } + + opt.AddOtlpExporter((exporterOptions, processorOptions) => + { + exporterOptions.Protocol = protocol; if (!string.IsNullOrWhiteSpace(options.Endpoint)) { - otlpOptions.Endpoint = new Uri(options.Endpoint); + exporterOptions.Endpoint = new Uri(options.Endpoint); + } + + if (processorType == ExportProcessorType.Simple) + { + processorOptions.ExportProcessorType = ExportProcessorType.Simple; + } + else + { + processorOptions.ExportProcessorType = ExportProcessorType.Batch; + processorOptions.BatchExportProcessorOptions = new BatchExportLogRecordProcessorOptions() { ScheduledDelayMilliseconds = options.ScheduledDelayInMilliseconds }; } }); } diff --git a/examples/GrpcService/Examples.GrpcService.csproj b/examples/GrpcService/Examples.GrpcService.csproj index 4d7aed6d3b2..0203f0d80c5 100644 --- a/examples/GrpcService/Examples.GrpcService.csproj +++ b/examples/GrpcService/Examples.GrpcService.csproj @@ -1,7 +1,7 @@ - net6.0 + $(DefaultTargetFrameworkForExampleApps) diff --git a/examples/GrpcService/Startup.cs b/examples/GrpcService/Startup.cs index 85fbc5bb8fb..0d5ddeda954 100644 --- a/examples/GrpcService/Startup.cs +++ b/examples/GrpcService/Startup.cs @@ -36,24 +36,24 @@ public void ConfigureServices(IServiceCollection services) .WithTracing(builder => { builder - .ConfigureResource(r => r.AddService(this.Configuration.GetValue("ServiceName"))) + .ConfigureResource(r => r.AddService(this.Configuration.GetValue("ServiceName", defaultValue: "otel-test")!)) .AddAspNetCoreInstrumentation(); // Switch between Jaeger/Zipkin/Console by setting UseExporter in appsettings.json. - var exporter = this.Configuration.GetValue("UseExporter").ToLowerInvariant(); + var exporter = this.Configuration.GetValue("UseExporter", defaultValue: "console")!.ToLowerInvariant(); switch (exporter) { case "jaeger": - builder.AddJaegerExporter(jaegerOptions => + _ = builder.AddJaegerExporter(jaegerOptions => { - jaegerOptions.AgentHost = this.Configuration.GetValue("Jaeger:Host"); - jaegerOptions.AgentPort = this.Configuration.GetValue("Jaeger:Port"); + jaegerOptions.AgentHost = this.Configuration.GetValue("Jaeger:Host", defaultValue: "localhost"); + jaegerOptions.AgentPort = this.Configuration.GetValue("Jaeger:Port", defaultValue: 6831); }); break; case "zipkin": builder.AddZipkinExporter(zipkinOptions => { - zipkinOptions.Endpoint = new Uri(this.Configuration.GetValue("Zipkin:Endpoint")); + zipkinOptions.Endpoint = new Uri(this.Configuration.GetValue("Zipkin:Endpoint", defaultValue: "http://localhost:9411/api/v2/spans")!); }); break; default: diff --git a/examples/MicroserviceExample/WebApi/WebApi.csproj b/examples/MicroserviceExample/WebApi/WebApi.csproj index 3697a904239..57bf07e763f 100644 --- a/examples/MicroserviceExample/WebApi/WebApi.csproj +++ b/examples/MicroserviceExample/WebApi/WebApi.csproj @@ -1,6 +1,6 @@ - net7.0 + $(DefaultTargetFrameworkForExampleApps) diff --git a/examples/MicroserviceExample/WorkerService/WorkerService.csproj b/examples/MicroserviceExample/WorkerService/WorkerService.csproj index 78f61661324..b9b1a680772 100644 --- a/examples/MicroserviceExample/WorkerService/WorkerService.csproj +++ b/examples/MicroserviceExample/WorkerService/WorkerService.csproj @@ -1,6 +1,6 @@ - net7.0 + $(DefaultTargetFrameworkForExampleApps) diff --git a/global.json b/global.json index 0f417661e6d..aeb8ae7b1ee 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { "rollForward": "latestFeature", - "version": "7.0.101" + "version": "7.0.400" } } diff --git a/src/OpenTelemetry.Api.ProviderBuilderExtensions/.publicApi/net462/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Api.ProviderBuilderExtensions/.publicApi/Experimental/net462/PublicAPI.Unshipped.txt similarity index 100% rename from src/OpenTelemetry.Api.ProviderBuilderExtensions/.publicApi/net462/PublicAPI.Unshipped.txt rename to src/OpenTelemetry.Api.ProviderBuilderExtensions/.publicApi/Experimental/net462/PublicAPI.Unshipped.txt diff --git a/src/OpenTelemetry.Api.ProviderBuilderExtensions/.publicApi/Experimental/net6.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Api.ProviderBuilderExtensions/.publicApi/Experimental/net6.0/PublicAPI.Unshipped.txt new file mode 100644 index 00000000000..a0f2e472dd6 --- /dev/null +++ b/src/OpenTelemetry.Api.ProviderBuilderExtensions/.publicApi/Experimental/net6.0/PublicAPI.Unshipped.txt @@ -0,0 +1,9 @@ +OpenTelemetry.Logs.OpenTelemetryDependencyInjectionLoggerProviderBuilderExtensions +OpenTelemetry.Logs.OpenTelemetryDependencyInjectionLoggingServiceCollectionExtensions +static OpenTelemetry.Logs.OpenTelemetryDependencyInjectionLoggerProviderBuilderExtensions.AddInstrumentation(this OpenTelemetry.Logs.LoggerProviderBuilder! loggerProviderBuilder) -> OpenTelemetry.Logs.LoggerProviderBuilder! +static OpenTelemetry.Logs.OpenTelemetryDependencyInjectionLoggerProviderBuilderExtensions.AddInstrumentation(this OpenTelemetry.Logs.LoggerProviderBuilder! loggerProviderBuilder, System.Func! instrumentationFactory) -> OpenTelemetry.Logs.LoggerProviderBuilder! +static OpenTelemetry.Logs.OpenTelemetryDependencyInjectionLoggerProviderBuilderExtensions.AddInstrumentation(this OpenTelemetry.Logs.LoggerProviderBuilder! loggerProviderBuilder, System.Func! instrumentationFactory) -> OpenTelemetry.Logs.LoggerProviderBuilder! +static OpenTelemetry.Logs.OpenTelemetryDependencyInjectionLoggerProviderBuilderExtensions.AddInstrumentation(this OpenTelemetry.Logs.LoggerProviderBuilder! loggerProviderBuilder, T! instrumentation) -> OpenTelemetry.Logs.LoggerProviderBuilder! +static OpenTelemetry.Logs.OpenTelemetryDependencyInjectionLoggerProviderBuilderExtensions.ConfigureServices(this OpenTelemetry.Logs.LoggerProviderBuilder! loggerProviderBuilder, System.Action! configure) -> OpenTelemetry.Logs.LoggerProviderBuilder! +static OpenTelemetry.Logs.OpenTelemetryDependencyInjectionLoggingServiceCollectionExtensions.ConfigureOpenTelemetryLoggerProvider(this Microsoft.Extensions.DependencyInjection.IServiceCollection! services, System.Action! configure) -> Microsoft.Extensions.DependencyInjection.IServiceCollection! +static OpenTelemetry.Logs.OpenTelemetryDependencyInjectionLoggingServiceCollectionExtensions.ConfigureOpenTelemetryLoggerProvider(this Microsoft.Extensions.DependencyInjection.IServiceCollection! services, System.Action! configure) -> Microsoft.Extensions.DependencyInjection.IServiceCollection! diff --git a/src/OpenTelemetry.Api.ProviderBuilderExtensions/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Api.ProviderBuilderExtensions/.publicApi/Experimental/netstandard2.0/PublicAPI.Unshipped.txt similarity index 100% rename from src/OpenTelemetry.Api.ProviderBuilderExtensions/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt rename to src/OpenTelemetry.Api.ProviderBuilderExtensions/.publicApi/Experimental/netstandard2.0/PublicAPI.Unshipped.txt diff --git a/src/OpenTelemetry.Api.ProviderBuilderExtensions/.publicApi/net462/PublicAPI.Shipped.txt b/src/OpenTelemetry.Api.ProviderBuilderExtensions/.publicApi/Stable/net462/PublicAPI.Shipped.txt similarity index 100% rename from src/OpenTelemetry.Api.ProviderBuilderExtensions/.publicApi/net462/PublicAPI.Shipped.txt rename to src/OpenTelemetry.Api.ProviderBuilderExtensions/.publicApi/Stable/net462/PublicAPI.Shipped.txt diff --git a/src/OpenTelemetry.Extensions.Hosting/.publicApi/net462/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Api.ProviderBuilderExtensions/.publicApi/Stable/net462/PublicAPI.Unshipped.txt similarity index 100% rename from src/OpenTelemetry.Extensions.Hosting/.publicApi/net462/PublicAPI.Unshipped.txt rename to src/OpenTelemetry.Api.ProviderBuilderExtensions/.publicApi/Stable/net462/PublicAPI.Unshipped.txt diff --git a/src/OpenTelemetry.Api.ProviderBuilderExtensions/.publicApi/netstandard2.0/PublicAPI.Shipped.txt b/src/OpenTelemetry.Api.ProviderBuilderExtensions/.publicApi/Stable/net6.0/PublicAPI.Shipped.txt similarity index 100% rename from src/OpenTelemetry.Api.ProviderBuilderExtensions/.publicApi/netstandard2.0/PublicAPI.Shipped.txt rename to src/OpenTelemetry.Api.ProviderBuilderExtensions/.publicApi/Stable/net6.0/PublicAPI.Shipped.txt diff --git a/src/OpenTelemetry.Extensions.Hosting/.publicApi/net6.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Api.ProviderBuilderExtensions/.publicApi/Stable/net6.0/PublicAPI.Unshipped.txt similarity index 100% rename from src/OpenTelemetry.Extensions.Hosting/.publicApi/net6.0/PublicAPI.Unshipped.txt rename to src/OpenTelemetry.Api.ProviderBuilderExtensions/.publicApi/Stable/net6.0/PublicAPI.Unshipped.txt diff --git a/src/OpenTelemetry.Api.ProviderBuilderExtensions/.publicApi/net6.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Api.ProviderBuilderExtensions/.publicApi/Stable/netstandard2.0/PublicAPI.Shipped.txt similarity index 66% rename from src/OpenTelemetry.Api.ProviderBuilderExtensions/.publicApi/net6.0/PublicAPI.Unshipped.txt rename to src/OpenTelemetry.Api.ProviderBuilderExtensions/.publicApi/Stable/netstandard2.0/PublicAPI.Shipped.txt index b552d2cb69c..a647699c919 100644 --- a/src/OpenTelemetry.Api.ProviderBuilderExtensions/.publicApi/net6.0/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.Api.ProviderBuilderExtensions/.publicApi/Stable/netstandard2.0/PublicAPI.Shipped.txt @@ -1,28 +1,19 @@ -#nullable enable -OpenTelemetry.Metrics.OpenTelemetryDependencyInjectionMeterProviderBuilderExtensions -OpenTelemetry.Metrics.OpenTelemetryDependencyInjectionMetricsServiceCollectionExtensions -OpenTelemetry.Trace.OpenTelemetryDependencyInjectionTracerProviderBuilderExtensions -OpenTelemetry.Trace.OpenTelemetryDependencyInjectionTracingServiceCollectionExtensions -static OpenTelemetry.Metrics.OpenTelemetryDependencyInjectionMeterProviderBuilderExtensions.AddInstrumentation(this OpenTelemetry.Metrics.MeterProviderBuilder! meterProviderBuilder) -> OpenTelemetry.Metrics.MeterProviderBuilder! -static OpenTelemetry.Metrics.OpenTelemetryDependencyInjectionMeterProviderBuilderExtensions.AddInstrumentation(this OpenTelemetry.Metrics.MeterProviderBuilder! meterProviderBuilder, System.Func! instrumentationFactory) -> OpenTelemetry.Metrics.MeterProviderBuilder! -static OpenTelemetry.Metrics.OpenTelemetryDependencyInjectionMeterProviderBuilderExtensions.AddInstrumentation(this OpenTelemetry.Metrics.MeterProviderBuilder! meterProviderBuilder, System.Func! instrumentationFactory) -> OpenTelemetry.Metrics.MeterProviderBuilder! -static OpenTelemetry.Metrics.OpenTelemetryDependencyInjectionMeterProviderBuilderExtensions.AddInstrumentation(this OpenTelemetry.Metrics.MeterProviderBuilder! meterProviderBuilder, T! instrumentation) -> OpenTelemetry.Metrics.MeterProviderBuilder! -static OpenTelemetry.Metrics.OpenTelemetryDependencyInjectionMeterProviderBuilderExtensions.ConfigureServices(this OpenTelemetry.Metrics.MeterProviderBuilder! meterProviderBuilder, System.Action! configure) -> OpenTelemetry.Metrics.MeterProviderBuilder! -static OpenTelemetry.Metrics.OpenTelemetryDependencyInjectionMetricsServiceCollectionExtensions.ConfigureOpenTelemetryMeterProvider(this Microsoft.Extensions.DependencyInjection.IServiceCollection! services, System.Action! configure) -> Microsoft.Extensions.DependencyInjection.IServiceCollection! -static OpenTelemetry.Metrics.OpenTelemetryDependencyInjectionMetricsServiceCollectionExtensions.ConfigureOpenTelemetryMeterProvider(this Microsoft.Extensions.DependencyInjection.IServiceCollection! services, System.Action! configure) -> Microsoft.Extensions.DependencyInjection.IServiceCollection! -static OpenTelemetry.Trace.OpenTelemetryDependencyInjectionTracerProviderBuilderExtensions.AddInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! tracerProviderBuilder) -> OpenTelemetry.Trace.TracerProviderBuilder! -static OpenTelemetry.Trace.OpenTelemetryDependencyInjectionTracerProviderBuilderExtensions.AddInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! tracerProviderBuilder, System.Func! instrumentationFactory) -> OpenTelemetry.Trace.TracerProviderBuilder! -static OpenTelemetry.Trace.OpenTelemetryDependencyInjectionTracerProviderBuilderExtensions.AddInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! tracerProviderBuilder, System.Func! instrumentationFactory) -> OpenTelemetry.Trace.TracerProviderBuilder! -static OpenTelemetry.Trace.OpenTelemetryDependencyInjectionTracerProviderBuilderExtensions.AddInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! tracerProviderBuilder, T! instrumentation) -> OpenTelemetry.Trace.TracerProviderBuilder! -static OpenTelemetry.Trace.OpenTelemetryDependencyInjectionTracerProviderBuilderExtensions.ConfigureServices(this OpenTelemetry.Trace.TracerProviderBuilder! tracerProviderBuilder, System.Action! configure) -> OpenTelemetry.Trace.TracerProviderBuilder! -static OpenTelemetry.Trace.OpenTelemetryDependencyInjectionTracingServiceCollectionExtensions.ConfigureOpenTelemetryTracerProvider(this Microsoft.Extensions.DependencyInjection.IServiceCollection! services, System.Action! configure) -> Microsoft.Extensions.DependencyInjection.IServiceCollection! -static OpenTelemetry.Trace.OpenTelemetryDependencyInjectionTracingServiceCollectionExtensions.ConfigureOpenTelemetryTracerProvider(this Microsoft.Extensions.DependencyInjection.IServiceCollection! services, System.Action! configure) -> Microsoft.Extensions.DependencyInjection.IServiceCollection! -OpenTelemetry.Logs.OpenTelemetryDependencyInjectionLoggerProviderBuilderExtensions -OpenTelemetry.Logs.OpenTelemetryDependencyInjectionLoggingServiceCollectionExtensions -static OpenTelemetry.Logs.OpenTelemetryDependencyInjectionLoggerProviderBuilderExtensions.AddInstrumentation(this OpenTelemetry.Logs.LoggerProviderBuilder! loggerProviderBuilder) -> OpenTelemetry.Logs.LoggerProviderBuilder! -static OpenTelemetry.Logs.OpenTelemetryDependencyInjectionLoggerProviderBuilderExtensions.AddInstrumentation(this OpenTelemetry.Logs.LoggerProviderBuilder! loggerProviderBuilder, System.Func! instrumentationFactory) -> OpenTelemetry.Logs.LoggerProviderBuilder! -static OpenTelemetry.Logs.OpenTelemetryDependencyInjectionLoggerProviderBuilderExtensions.AddInstrumentation(this OpenTelemetry.Logs.LoggerProviderBuilder! loggerProviderBuilder, System.Func! instrumentationFactory) -> OpenTelemetry.Logs.LoggerProviderBuilder! -static OpenTelemetry.Logs.OpenTelemetryDependencyInjectionLoggerProviderBuilderExtensions.AddInstrumentation(this OpenTelemetry.Logs.LoggerProviderBuilder! loggerProviderBuilder, T! instrumentation) -> OpenTelemetry.Logs.LoggerProviderBuilder! -static OpenTelemetry.Logs.OpenTelemetryDependencyInjectionLoggerProviderBuilderExtensions.ConfigureServices(this OpenTelemetry.Logs.LoggerProviderBuilder! loggerProviderBuilder, System.Action! configure) -> OpenTelemetry.Logs.LoggerProviderBuilder! -static OpenTelemetry.Logs.OpenTelemetryDependencyInjectionLoggingServiceCollectionExtensions.ConfigureOpenTelemetryLoggerProvider(this Microsoft.Extensions.DependencyInjection.IServiceCollection! services, System.Action! configure) -> Microsoft.Extensions.DependencyInjection.IServiceCollection! -static OpenTelemetry.Logs.OpenTelemetryDependencyInjectionLoggingServiceCollectionExtensions.ConfigureOpenTelemetryLoggerProvider(this Microsoft.Extensions.DependencyInjection.IServiceCollection! services, System.Action! configure) -> Microsoft.Extensions.DependencyInjection.IServiceCollection! \ No newline at end of file +#nullable enable +OpenTelemetry.Metrics.OpenTelemetryDependencyInjectionMeterProviderBuilderExtensions +OpenTelemetry.Metrics.OpenTelemetryDependencyInjectionMetricsServiceCollectionExtensions +OpenTelemetry.Trace.OpenTelemetryDependencyInjectionTracerProviderBuilderExtensions +OpenTelemetry.Trace.OpenTelemetryDependencyInjectionTracingServiceCollectionExtensions +static OpenTelemetry.Metrics.OpenTelemetryDependencyInjectionMeterProviderBuilderExtensions.AddInstrumentation(this OpenTelemetry.Metrics.MeterProviderBuilder! meterProviderBuilder) -> OpenTelemetry.Metrics.MeterProviderBuilder! +static OpenTelemetry.Metrics.OpenTelemetryDependencyInjectionMeterProviderBuilderExtensions.AddInstrumentation(this OpenTelemetry.Metrics.MeterProviderBuilder! meterProviderBuilder, System.Func! instrumentationFactory) -> OpenTelemetry.Metrics.MeterProviderBuilder! +static OpenTelemetry.Metrics.OpenTelemetryDependencyInjectionMeterProviderBuilderExtensions.AddInstrumentation(this OpenTelemetry.Metrics.MeterProviderBuilder! meterProviderBuilder, System.Func! instrumentationFactory) -> OpenTelemetry.Metrics.MeterProviderBuilder! +static OpenTelemetry.Metrics.OpenTelemetryDependencyInjectionMeterProviderBuilderExtensions.AddInstrumentation(this OpenTelemetry.Metrics.MeterProviderBuilder! meterProviderBuilder, T! instrumentation) -> OpenTelemetry.Metrics.MeterProviderBuilder! +static OpenTelemetry.Metrics.OpenTelemetryDependencyInjectionMeterProviderBuilderExtensions.ConfigureServices(this OpenTelemetry.Metrics.MeterProviderBuilder! meterProviderBuilder, System.Action! configure) -> OpenTelemetry.Metrics.MeterProviderBuilder! +static OpenTelemetry.Metrics.OpenTelemetryDependencyInjectionMetricsServiceCollectionExtensions.ConfigureOpenTelemetryMeterProvider(this Microsoft.Extensions.DependencyInjection.IServiceCollection! services, System.Action! configure) -> Microsoft.Extensions.DependencyInjection.IServiceCollection! +static OpenTelemetry.Metrics.OpenTelemetryDependencyInjectionMetricsServiceCollectionExtensions.ConfigureOpenTelemetryMeterProvider(this Microsoft.Extensions.DependencyInjection.IServiceCollection! services, System.Action! configure) -> Microsoft.Extensions.DependencyInjection.IServiceCollection! +static OpenTelemetry.Trace.OpenTelemetryDependencyInjectionTracerProviderBuilderExtensions.AddInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! tracerProviderBuilder) -> OpenTelemetry.Trace.TracerProviderBuilder! +static OpenTelemetry.Trace.OpenTelemetryDependencyInjectionTracerProviderBuilderExtensions.AddInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! tracerProviderBuilder, System.Func! instrumentationFactory) -> OpenTelemetry.Trace.TracerProviderBuilder! +static OpenTelemetry.Trace.OpenTelemetryDependencyInjectionTracerProviderBuilderExtensions.AddInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! tracerProviderBuilder, System.Func! instrumentationFactory) -> OpenTelemetry.Trace.TracerProviderBuilder! +static OpenTelemetry.Trace.OpenTelemetryDependencyInjectionTracerProviderBuilderExtensions.AddInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! tracerProviderBuilder, T! instrumentation) -> OpenTelemetry.Trace.TracerProviderBuilder! +static OpenTelemetry.Trace.OpenTelemetryDependencyInjectionTracerProviderBuilderExtensions.ConfigureServices(this OpenTelemetry.Trace.TracerProviderBuilder! tracerProviderBuilder, System.Action! configure) -> OpenTelemetry.Trace.TracerProviderBuilder! +static OpenTelemetry.Trace.OpenTelemetryDependencyInjectionTracingServiceCollectionExtensions.ConfigureOpenTelemetryTracerProvider(this Microsoft.Extensions.DependencyInjection.IServiceCollection! services, System.Action! configure) -> Microsoft.Extensions.DependencyInjection.IServiceCollection! +static OpenTelemetry.Trace.OpenTelemetryDependencyInjectionTracingServiceCollectionExtensions.ConfigureOpenTelemetryTracerProvider(this Microsoft.Extensions.DependencyInjection.IServiceCollection! services, System.Action! configure) -> Microsoft.Extensions.DependencyInjection.IServiceCollection! diff --git a/src/OpenTelemetry.Extensions.Hosting/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Api.ProviderBuilderExtensions/.publicApi/Stable/netstandard2.0/PublicAPI.Unshipped.txt similarity index 100% rename from src/OpenTelemetry.Extensions.Hosting/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt rename to src/OpenTelemetry.Api.ProviderBuilderExtensions/.publicApi/Stable/netstandard2.0/PublicAPI.Unshipped.txt diff --git a/src/OpenTelemetry.Api.ProviderBuilderExtensions/AssemblyInfo.cs b/src/OpenTelemetry.Api.ProviderBuilderExtensions/AssemblyInfo.cs index e1ba813e7aa..678ad1e5c91 100644 --- a/src/OpenTelemetry.Api.ProviderBuilderExtensions/AssemblyInfo.cs +++ b/src/OpenTelemetry.Api.ProviderBuilderExtensions/AssemblyInfo.cs @@ -19,3 +19,22 @@ [assembly: InternalsVisibleTo("OpenTelemetry" + AssemblyInfo.PublicKey)] [assembly: InternalsVisibleTo("OpenTelemetry.Tests" + AssemblyInfo.PublicKey)] [assembly: InternalsVisibleTo("OpenTelemetry.Api.ProviderBuilderExtensions.Tests" + AssemblyInfo.PublicKey)] + +#if !EXPOSE_EXPERIMENTAL_FEATURES +[assembly: InternalsVisibleTo("OpenTelemetry.Exporter.Console" + AssemblyInfo.PublicKey)] +[assembly: InternalsVisibleTo("OpenTelemetry.Extensions.Hosting" + AssemblyInfo.PublicKey)] +#endif + +#if SIGNED +file static class AssemblyInfo +{ + public const string PublicKey = ", PublicKey=002400000480000094000000060200000024000052534131000400000100010051C1562A090FB0C9F391012A32198B5E5D9A60E9B80FA2D7B434C9E5CCB7259BD606E66F9660676AFC6692B8CDC6793D190904551D2103B7B22FA636DCBB8208839785BA402EA08FC00C8F1500CCEF28BBF599AA64FFB1E1D5DC1BF3420A3777BADFE697856E9D52070A50C3EA5821C80BEF17CA3ACFFA28F89DD413F096F898"; + public const string MoqPublicKey = ", PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7"; +} +#else +file static class AssemblyInfo +{ + public const string PublicKey = ""; + public const string MoqPublicKey = ""; +} +#endif diff --git a/src/OpenTelemetry.Api.ProviderBuilderExtensions/CHANGELOG.md b/src/OpenTelemetry.Api.ProviderBuilderExtensions/CHANGELOG.md index 135e8f96372..80639a59e98 100644 --- a/src/OpenTelemetry.Api.ProviderBuilderExtensions/CHANGELOG.md +++ b/src/OpenTelemetry.Api.ProviderBuilderExtensions/CHANGELOG.md @@ -6,10 +6,12 @@ Released 2023-Jul-12 -* Added extension methods to support using the [Logs Bridge +* **Experimental (pre-release builds only):** Added extension methods to support + using the [Logs Bridge API](https://github.com/open-telemetry/opentelemetry-specification/blob/976432b74c565e8a84af3570e9b82cb95e1d844c/specification/logs/bridge-api.md) implementation (eg `LoggerProviderBuilder`) with dependency injection. - ([#4433](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4433)) + ([#4433](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4433), + [#4735](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4735)) ## 1.5.1 diff --git a/src/OpenTelemetry.Api.ProviderBuilderExtensions/Logs/OpenTelemetryDependencyInjectionLoggerProviderBuilderExtensions.cs b/src/OpenTelemetry.Api.ProviderBuilderExtensions/Logs/OpenTelemetryDependencyInjectionLoggerProviderBuilderExtensions.cs index 4c2a12c27ec..e113baa8cd4 100644 --- a/src/OpenTelemetry.Api.ProviderBuilderExtensions/Logs/OpenTelemetryDependencyInjectionLoggerProviderBuilderExtensions.cs +++ b/src/OpenTelemetry.Api.ProviderBuilderExtensions/Logs/OpenTelemetryDependencyInjectionLoggerProviderBuilderExtensions.cs @@ -26,8 +26,26 @@ namespace OpenTelemetry.Logs; /// /// Contains extension methods for the class. /// -public static class OpenTelemetryDependencyInjectionLoggerProviderBuilderExtensions +#if EXPOSE_EXPERIMENTAL_FEATURES + public +#else + internal +#endif + static class OpenTelemetryDependencyInjectionLoggerProviderBuilderExtensions { +#if EXPOSE_EXPERIMENTAL_FEATURES + /// + /// Adds instrumentation to the provider. + /// + /// + /// + /// Note: The type specified by will be + /// registered as a singleton service into application services. + /// + /// Instrumentation type. + /// . + /// The supplied for chaining. +#else /// /// Adds instrumentation to the provider. /// @@ -38,6 +56,7 @@ public static class OpenTelemetryDependencyInjectionLoggerProviderBuilderExtensi /// Instrumentation type. /// . /// The supplied for chaining. +#endif public static LoggerProviderBuilder AddInstrumentation< #if NET6_0_OR_GREATER [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] @@ -55,13 +74,24 @@ public static LoggerProviderBuilder AddInstrumentation< return loggerProviderBuilder; } +#if EXPOSE_EXPERIMENTAL_FEATURES /// /// Adds instrumentation to the provider. /// /// Instrumentation type. + /// WARNING: This is an experimental API which might change or be removed in the future. Use at your own risk. /// . /// Instrumentation instance. /// The supplied for chaining. +#else + /// + /// Adds instrumentation to the provider. + /// + /// Instrumentation type. + /// . + /// Instrumentation instance. + /// The supplied for chaining. +#endif public static LoggerProviderBuilder AddInstrumentation(this LoggerProviderBuilder loggerProviderBuilder, T instrumentation) where T : class { @@ -75,6 +105,16 @@ public static LoggerProviderBuilder AddInstrumentation(this LoggerProviderBui return loggerProviderBuilder; } +#if EXPOSE_EXPERIMENTAL_FEATURES + /// + /// Adds instrumentation to the provider. + /// + /// Instrumentation type. + /// + /// . + /// Instrumentation factory. + /// The supplied for chaining. +#else /// /// Adds instrumentation to the provider. /// @@ -82,6 +122,7 @@ public static LoggerProviderBuilder AddInstrumentation(this LoggerProviderBui /// . /// Instrumentation factory. /// The supplied for chaining. +#endif public static LoggerProviderBuilder AddInstrumentation( this LoggerProviderBuilder loggerProviderBuilder, Func instrumentationFactory) @@ -97,6 +138,16 @@ public static LoggerProviderBuilder AddInstrumentation( return loggerProviderBuilder; } +#if EXPOSE_EXPERIMENTAL_FEATURES + /// + /// Adds instrumentation to the provider. + /// + /// Instrumentation type. + /// + /// . + /// Instrumentation factory. + /// The supplied for chaining. +#else /// /// Adds instrumentation to the provider. /// @@ -104,6 +155,7 @@ public static LoggerProviderBuilder AddInstrumentation( /// . /// Instrumentation factory. /// The supplied for chaining. +#endif public static LoggerProviderBuilder AddInstrumentation( this LoggerProviderBuilder loggerProviderBuilder, Func instrumentationFactory) @@ -123,17 +175,32 @@ public static LoggerProviderBuilder AddInstrumentation( return loggerProviderBuilder; } +#if EXPOSE_EXPERIMENTAL_FEATURES /// /// Register a callback action to configure the where logging services are configured. /// /// + /// /// Note: Logging services are only available during the application /// configuration phase. /// /// . /// Configuration callback. /// The supplied for chaining. +#else + /// + /// Register a callback action to configure the where logging services are configured. + /// + /// + /// Note: Logging services are only available during the application + /// configuration phase. + /// + /// . + /// Configuration callback. + /// The supplied for chaining. +#endif public static LoggerProviderBuilder ConfigureServices( this LoggerProviderBuilder loggerProviderBuilder, Action configure) diff --git a/src/OpenTelemetry.Api.ProviderBuilderExtensions/Logs/OpenTelemetryDependencyInjectionLoggingServiceCollectionExtensions.cs b/src/OpenTelemetry.Api.ProviderBuilderExtensions/Logs/OpenTelemetryDependencyInjectionLoggingServiceCollectionExtensions.cs index f9679b1e9de..14102cf30da 100644 --- a/src/OpenTelemetry.Api.ProviderBuilderExtensions/Logs/OpenTelemetryDependencyInjectionLoggingServiceCollectionExtensions.cs +++ b/src/OpenTelemetry.Api.ProviderBuilderExtensions/Logs/OpenTelemetryDependencyInjectionLoggingServiceCollectionExtensions.cs @@ -22,13 +22,20 @@ namespace OpenTelemetry.Logs; /// /// Extension methods for setting up OpenTelemetry logging services in an . /// -public static class OpenTelemetryDependencyInjectionLoggingServiceCollectionExtensions +#if EXPOSE_EXPERIMENTAL_FEATURES + public +#else + internal +#endif + static class OpenTelemetryDependencyInjectionLoggingServiceCollectionExtensions { +#if EXPOSE_EXPERIMENTAL_FEATURES /// /// Registers an action used to configure the OpenTelemetry . /// /// + /// /// Notes: /// /// This is safe to be called multiple times and by library authors. @@ -45,6 +52,29 @@ public static class OpenTelemetryDependencyInjectionLoggingServiceCollectionExte /// cref="LoggerProviderBuilder"/>. /// The so that additional calls /// can be chained. +#else + /// + /// Registers an action used to configure the OpenTelemetry . + /// + /// + /// Notes: + /// + /// This is safe to be called multiple times and by library authors. + /// Each registered configuration action will be applied + /// sequentially. + /// A will NOT be created automatically + /// using this method. To begin collecting logs use the + /// IServiceCollection.AddOpenTelemetry extension in the + /// OpenTelemetry.Extensions.Hosting package. + /// + /// + /// . + /// Callback action to configure the . + /// The so that additional calls + /// can be chained. +#endif public static IServiceCollection ConfigureOpenTelemetryLoggerProvider( this IServiceCollection services, Action configure) @@ -57,6 +87,40 @@ public static IServiceCollection ConfigureOpenTelemetryLoggerProvider( return services; } +#if EXPOSE_EXPERIMENTAL_FEATURES + /// + /// Registers an action used to configure the OpenTelemetry once the + /// is available. + /// + /// + /// + /// Notes: + /// + /// This is safe to be called multiple times and by library authors. + /// Each registered configuration action will be applied + /// sequentially. + /// A will NOT be created automatically + /// using this method. To begin collecting logs use the + /// IServiceCollection.AddOpenTelemetry extension in the + /// OpenTelemetry.Extensions.Hosting package. + /// The supplied configuration delegate is called once the is available. Services may NOT be added to a + /// once the has been created. Many helper extensions + /// register services and may throw if invoked inside the configuration + /// delegate. If you don't need access to the + /// call instead which is safe to be used with + /// helper extensions. + /// + /// + /// . + /// Callback action to configure the . + /// The so that additional calls + /// can be chained. +#else /// /// Registers an action used to configure the OpenTelemetry once the @@ -88,6 +152,7 @@ public static IServiceCollection ConfigureOpenTelemetryLoggerProvider( /// cref="LoggerProviderBuilder"/>. /// The so that additional calls /// can be chained. +#endif public static IServiceCollection ConfigureOpenTelemetryLoggerProvider( this IServiceCollection services, Action configure) diff --git a/src/OpenTelemetry.Api/.publicApi/net462/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Api/.publicApi/Experimental/net462/PublicAPI.Unshipped.txt similarity index 100% rename from src/OpenTelemetry.Api/.publicApi/net462/PublicAPI.Unshipped.txt rename to src/OpenTelemetry.Api/.publicApi/Experimental/net462/PublicAPI.Unshipped.txt diff --git a/src/OpenTelemetry.Api/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Api/.publicApi/Experimental/net6.0/PublicAPI.Unshipped.txt similarity index 100% rename from src/OpenTelemetry.Api/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt rename to src/OpenTelemetry.Api/.publicApi/Experimental/net6.0/PublicAPI.Unshipped.txt diff --git a/src/OpenTelemetry.Api/.publicApi/Experimental/netstandard2.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Api/.publicApi/Experimental/netstandard2.0/PublicAPI.Unshipped.txt new file mode 100644 index 00000000000..29b616ee92c --- /dev/null +++ b/src/OpenTelemetry.Api/.publicApi/Experimental/netstandard2.0/PublicAPI.Unshipped.txt @@ -0,0 +1,80 @@ +abstract OpenTelemetry.Logs.Logger.EmitLog(in OpenTelemetry.Logs.LogRecordData data, in OpenTelemetry.Logs.LogRecordAttributeList attributes) -> void +abstract OpenTelemetry.Logs.LoggerProviderBuilder.AddInstrumentation(System.Func! instrumentationFactory) -> OpenTelemetry.Logs.LoggerProviderBuilder! +OpenTelemetry.Logs.IDeferredLoggerProviderBuilder +OpenTelemetry.Logs.IDeferredLoggerProviderBuilder.Configure(System.Action! configure) -> OpenTelemetry.Logs.LoggerProviderBuilder! +OpenTelemetry.Logs.Logger +OpenTelemetry.Logs.Logger.EmitLog(in OpenTelemetry.Logs.LogRecordData data) -> void +OpenTelemetry.Logs.Logger.Logger(string? name) -> void +OpenTelemetry.Logs.Logger.Name.get -> string! +OpenTelemetry.Logs.Logger.Version.get -> string? +OpenTelemetry.Logs.LoggerProvider +OpenTelemetry.Logs.LoggerProvider.GetLogger() -> OpenTelemetry.Logs.Logger! +OpenTelemetry.Logs.LoggerProvider.GetLogger(string? name) -> OpenTelemetry.Logs.Logger! +OpenTelemetry.Logs.LoggerProvider.GetLogger(string? name, string? version) -> OpenTelemetry.Logs.Logger! +OpenTelemetry.Logs.LoggerProvider.LoggerProvider() -> void +OpenTelemetry.Logs.LoggerProviderBuilder +OpenTelemetry.Logs.LoggerProviderBuilder.LoggerProviderBuilder() -> void +OpenTelemetry.Logs.LogRecordAttributeList +OpenTelemetry.Logs.LogRecordAttributeList.Add(string! key, object? value) -> void +OpenTelemetry.Logs.LogRecordAttributeList.Add(System.Collections.Generic.KeyValuePair attribute) -> void +OpenTelemetry.Logs.LogRecordAttributeList.Clear() -> void +OpenTelemetry.Logs.LogRecordAttributeList.Count.get -> int +OpenTelemetry.Logs.LogRecordAttributeList.Enumerator +OpenTelemetry.Logs.LogRecordAttributeList.Enumerator.Current.get -> System.Collections.Generic.KeyValuePair +OpenTelemetry.Logs.LogRecordAttributeList.Enumerator.Dispose() -> void +OpenTelemetry.Logs.LogRecordAttributeList.Enumerator.Enumerator() -> void +OpenTelemetry.Logs.LogRecordAttributeList.Enumerator.MoveNext() -> bool +OpenTelemetry.Logs.LogRecordAttributeList.GetEnumerator() -> OpenTelemetry.Logs.LogRecordAttributeList.Enumerator +OpenTelemetry.Logs.LogRecordAttributeList.LogRecordAttributeList() -> void +OpenTelemetry.Logs.LogRecordAttributeList.RecordException(System.Exception! exception) -> void +OpenTelemetry.Logs.LogRecordAttributeList.this[int index].get -> System.Collections.Generic.KeyValuePair +OpenTelemetry.Logs.LogRecordAttributeList.this[int index].set -> void +OpenTelemetry.Logs.LogRecordAttributeList.this[string! key].set -> void +OpenTelemetry.Logs.LogRecordData +OpenTelemetry.Logs.LogRecordData.Body.get -> string? +OpenTelemetry.Logs.LogRecordData.Body.set -> void +OpenTelemetry.Logs.LogRecordData.LogRecordData() -> void +OpenTelemetry.Logs.LogRecordData.LogRecordData(in System.Diagnostics.ActivityContext activityContext) -> void +OpenTelemetry.Logs.LogRecordData.LogRecordData(System.Diagnostics.Activity? activity) -> void +OpenTelemetry.Logs.LogRecordData.Severity.get -> OpenTelemetry.Logs.LogRecordSeverity? +OpenTelemetry.Logs.LogRecordData.Severity.set -> void +OpenTelemetry.Logs.LogRecordData.SeverityText.get -> string? +OpenTelemetry.Logs.LogRecordData.SeverityText.set -> void +OpenTelemetry.Logs.LogRecordData.SpanId.get -> System.Diagnostics.ActivitySpanId +OpenTelemetry.Logs.LogRecordData.SpanId.set -> void +OpenTelemetry.Logs.LogRecordData.Timestamp.get -> System.DateTime +OpenTelemetry.Logs.LogRecordData.Timestamp.set -> void +OpenTelemetry.Logs.LogRecordData.TraceFlags.get -> System.Diagnostics.ActivityTraceFlags +OpenTelemetry.Logs.LogRecordData.TraceFlags.set -> void +OpenTelemetry.Logs.LogRecordData.TraceId.get -> System.Diagnostics.ActivityTraceId +OpenTelemetry.Logs.LogRecordData.TraceId.set -> void +OpenTelemetry.Logs.LogRecordSeverity +OpenTelemetry.Logs.LogRecordSeverity.Debug = 5 -> OpenTelemetry.Logs.LogRecordSeverity +OpenTelemetry.Logs.LogRecordSeverity.Debug2 = 6 -> OpenTelemetry.Logs.LogRecordSeverity +OpenTelemetry.Logs.LogRecordSeverity.Debug3 = 7 -> OpenTelemetry.Logs.LogRecordSeverity +OpenTelemetry.Logs.LogRecordSeverity.Debug4 = 8 -> OpenTelemetry.Logs.LogRecordSeverity +OpenTelemetry.Logs.LogRecordSeverity.Error = 17 -> OpenTelemetry.Logs.LogRecordSeverity +OpenTelemetry.Logs.LogRecordSeverity.Error2 = 18 -> OpenTelemetry.Logs.LogRecordSeverity +OpenTelemetry.Logs.LogRecordSeverity.Error3 = 19 -> OpenTelemetry.Logs.LogRecordSeverity +OpenTelemetry.Logs.LogRecordSeverity.Error4 = 20 -> OpenTelemetry.Logs.LogRecordSeverity +OpenTelemetry.Logs.LogRecordSeverity.Fatal = 21 -> OpenTelemetry.Logs.LogRecordSeverity +OpenTelemetry.Logs.LogRecordSeverity.Fatal2 = 22 -> OpenTelemetry.Logs.LogRecordSeverity +OpenTelemetry.Logs.LogRecordSeverity.Fatal3 = 23 -> OpenTelemetry.Logs.LogRecordSeverity +OpenTelemetry.Logs.LogRecordSeverity.Fatal4 = 24 -> OpenTelemetry.Logs.LogRecordSeverity +OpenTelemetry.Logs.LogRecordSeverity.Info = 9 -> OpenTelemetry.Logs.LogRecordSeverity +OpenTelemetry.Logs.LogRecordSeverity.Info2 = 10 -> OpenTelemetry.Logs.LogRecordSeverity +OpenTelemetry.Logs.LogRecordSeverity.Info3 = 11 -> OpenTelemetry.Logs.LogRecordSeverity +OpenTelemetry.Logs.LogRecordSeverity.Info4 = 12 -> OpenTelemetry.Logs.LogRecordSeverity +OpenTelemetry.Logs.LogRecordSeverity.Trace = 1 -> OpenTelemetry.Logs.LogRecordSeverity +OpenTelemetry.Logs.LogRecordSeverity.Trace2 = 2 -> OpenTelemetry.Logs.LogRecordSeverity +OpenTelemetry.Logs.LogRecordSeverity.Trace3 = 3 -> OpenTelemetry.Logs.LogRecordSeverity +OpenTelemetry.Logs.LogRecordSeverity.Trace4 = 4 -> OpenTelemetry.Logs.LogRecordSeverity +OpenTelemetry.Logs.LogRecordSeverity.Unspecified = 0 -> OpenTelemetry.Logs.LogRecordSeverity +OpenTelemetry.Logs.LogRecordSeverity.Warn = 13 -> OpenTelemetry.Logs.LogRecordSeverity +OpenTelemetry.Logs.LogRecordSeverity.Warn2 = 14 -> OpenTelemetry.Logs.LogRecordSeverity +OpenTelemetry.Logs.LogRecordSeverity.Warn3 = 15 -> OpenTelemetry.Logs.LogRecordSeverity +OpenTelemetry.Logs.LogRecordSeverity.Warn4 = 16 -> OpenTelemetry.Logs.LogRecordSeverity +OpenTelemetry.Logs.LogRecordSeverityExtensions +static OpenTelemetry.Logs.LogRecordAttributeList.CreateFromEnumerable(System.Collections.Generic.IEnumerable>! attributes) -> OpenTelemetry.Logs.LogRecordAttributeList +static OpenTelemetry.Logs.LogRecordSeverityExtensions.ToShortName(this OpenTelemetry.Logs.LogRecordSeverity logRecordSeverity) -> string! +virtual OpenTelemetry.Logs.LoggerProvider.TryCreateLogger(string? name, out OpenTelemetry.Logs.Logger? logger) -> bool diff --git a/src/OpenTelemetry.Api/.publicApi/net462/PublicAPI.Shipped.txt b/src/OpenTelemetry.Api/.publicApi/Stable/net462/PublicAPI.Shipped.txt similarity index 100% rename from src/OpenTelemetry.Api/.publicApi/net462/PublicAPI.Shipped.txt rename to src/OpenTelemetry.Api/.publicApi/Stable/net462/PublicAPI.Shipped.txt diff --git a/src/OpenTelemetry.Api.ProviderBuilderExtensions/.publicApi/net6.0/PublicAPI.Shipped.txt b/src/OpenTelemetry.Api/.publicApi/Stable/net462/PublicAPI.Unshipped.txt similarity index 100% rename from src/OpenTelemetry.Api.ProviderBuilderExtensions/.publicApi/net6.0/PublicAPI.Shipped.txt rename to src/OpenTelemetry.Api/.publicApi/Stable/net462/PublicAPI.Unshipped.txt diff --git a/src/OpenTelemetry.Api/.publicApi/netstandard2.0/PublicAPI.Shipped.txt b/src/OpenTelemetry.Api/.publicApi/Stable/net6.0/PublicAPI.Shipped.txt similarity index 100% rename from src/OpenTelemetry.Api/.publicApi/netstandard2.0/PublicAPI.Shipped.txt rename to src/OpenTelemetry.Api/.publicApi/Stable/net6.0/PublicAPI.Shipped.txt diff --git a/src/OpenTelemetry.Api/.publicApi/net6.0/PublicAPI.Shipped.txt b/src/OpenTelemetry.Api/.publicApi/Stable/net6.0/PublicAPI.Unshipped.txt similarity index 100% rename from src/OpenTelemetry.Api/.publicApi/net6.0/PublicAPI.Shipped.txt rename to src/OpenTelemetry.Api/.publicApi/Stable/net6.0/PublicAPI.Unshipped.txt diff --git a/src/OpenTelemetry.Api/.publicApi/net6.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Api/.publicApi/Stable/netstandard2.0/PublicAPI.Shipped.txt similarity index 77% rename from src/OpenTelemetry.Api/.publicApi/net6.0/PublicAPI.Unshipped.txt rename to src/OpenTelemetry.Api/.publicApi/Stable/netstandard2.0/PublicAPI.Shipped.txt index 7f881125632..b33cbc15745 100644 --- a/src/OpenTelemetry.Api/.publicApi/net6.0/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.Api/.publicApi/Stable/netstandard2.0/PublicAPI.Shipped.txt @@ -1,22 +1,45 @@ #nullable enable +~abstract OpenTelemetry.Context.Propagation.TextMapPropagator.Extract(OpenTelemetry.Context.Propagation.PropagationContext context, T carrier, System.Func> getter) -> OpenTelemetry.Context.Propagation.PropagationContext +~abstract OpenTelemetry.Context.Propagation.TextMapPropagator.Fields.get -> System.Collections.Generic.ISet +~abstract OpenTelemetry.Context.Propagation.TextMapPropagator.Inject(OpenTelemetry.Context.Propagation.PropagationContext context, T carrier, System.Action setter) -> void +abstract OpenTelemetry.Context.RuntimeContextSlot.Get() -> T +abstract OpenTelemetry.Context.RuntimeContextSlot.Set(T value) -> void +~abstract OpenTelemetry.Metrics.MeterProviderBuilder.AddInstrumentation(System.Func instrumentationFactory) -> OpenTelemetry.Metrics.MeterProviderBuilder +~abstract OpenTelemetry.Metrics.MeterProviderBuilder.AddMeter(params string[] names) -> OpenTelemetry.Metrics.MeterProviderBuilder +~abstract OpenTelemetry.Trace.TracerProviderBuilder.AddInstrumentation(System.Func instrumentationFactory) -> OpenTelemetry.Trace.TracerProviderBuilder +~abstract OpenTelemetry.Trace.TracerProviderBuilder.AddLegacySource(string operationName) -> OpenTelemetry.Trace.TracerProviderBuilder +~abstract OpenTelemetry.Trace.TracerProviderBuilder.AddSource(params string[] names) -> OpenTelemetry.Trace.TracerProviderBuilder OpenTelemetry.ActivityContextExtensions OpenTelemetry.Baggage OpenTelemetry.Baggage.Baggage() -> void OpenTelemetry.Baggage.ClearBaggage() -> OpenTelemetry.Baggage OpenTelemetry.Baggage.Count.get -> int OpenTelemetry.Baggage.Equals(OpenTelemetry.Baggage other) -> bool +~OpenTelemetry.Baggage.GetBaggage() -> System.Collections.Generic.IReadOnlyDictionary +~OpenTelemetry.Baggage.GetBaggage(string name) -> string +~OpenTelemetry.Baggage.GetEnumerator() -> System.Collections.Generic.Dictionary.Enumerator +~OpenTelemetry.Baggage.RemoveBaggage(string name) -> OpenTelemetry.Baggage +~OpenTelemetry.Baggage.SetBaggage(params System.Collections.Generic.KeyValuePair[] baggageItems) -> OpenTelemetry.Baggage +~OpenTelemetry.Baggage.SetBaggage(string name, string value) -> OpenTelemetry.Baggage +~OpenTelemetry.Baggage.SetBaggage(System.Collections.Generic.IEnumerable> baggageItems) -> OpenTelemetry.Baggage OpenTelemetry.BaseProvider +OpenTelemetry.BaseProvider.~BaseProvider() -> void OpenTelemetry.BaseProvider.BaseProvider() -> void OpenTelemetry.BaseProvider.Dispose() -> void -OpenTelemetry.BaseProvider.~BaseProvider() -> void OpenTelemetry.Context.AsyncLocalRuntimeContextSlot +~OpenTelemetry.Context.AsyncLocalRuntimeContextSlot.AsyncLocalRuntimeContextSlot(string name) -> void +~OpenTelemetry.Context.AsyncLocalRuntimeContextSlot.Value.get -> object +~OpenTelemetry.Context.AsyncLocalRuntimeContextSlot.Value.set -> void OpenTelemetry.Context.IRuntimeContextSlotValueAccessor +~OpenTelemetry.Context.IRuntimeContextSlotValueAccessor.Value.get -> object +~OpenTelemetry.Context.IRuntimeContextSlotValueAccessor.Value.set -> void OpenTelemetry.Context.Propagation.B3Propagator OpenTelemetry.Context.Propagation.B3Propagator.B3Propagator() -> void OpenTelemetry.Context.Propagation.B3Propagator.B3Propagator(bool singleHeader) -> void OpenTelemetry.Context.Propagation.BaggagePropagator OpenTelemetry.Context.Propagation.BaggagePropagator.BaggagePropagator() -> void OpenTelemetry.Context.Propagation.CompositeTextMapPropagator +~OpenTelemetry.Context.Propagation.CompositeTextMapPropagator.CompositeTextMapPropagator(System.Collections.Generic.IEnumerable propagators) -> void OpenTelemetry.Context.Propagation.PropagationContext OpenTelemetry.Context.Propagation.PropagationContext.ActivityContext.get -> System.Diagnostics.ActivityContext OpenTelemetry.Context.Propagation.PropagationContext.Baggage.get -> OpenTelemetry.Baggage @@ -31,105 +54,50 @@ OpenTelemetry.Context.Propagation.TraceContextPropagator.TraceContextPropagator( OpenTelemetry.Context.RuntimeContext OpenTelemetry.Context.RuntimeContextSlot OpenTelemetry.Context.RuntimeContextSlot.Dispose() -> void +~OpenTelemetry.Context.RuntimeContextSlot.Name.get -> string +~OpenTelemetry.Context.RuntimeContextSlot.RuntimeContextSlot(string name) -> void OpenTelemetry.Context.ThreadLocalRuntimeContextSlot -OpenTelemetry.Logs.IDeferredLoggerProviderBuilder -OpenTelemetry.Logs.IDeferredLoggerProviderBuilder.Configure(System.Action! configure) -> OpenTelemetry.Logs.LoggerProviderBuilder! -OpenTelemetry.Logs.LogRecordAttributeList -OpenTelemetry.Logs.LogRecordAttributeList.Add(System.Collections.Generic.KeyValuePair attribute) -> void -OpenTelemetry.Logs.LogRecordAttributeList.Add(string! key, object? value) -> void -OpenTelemetry.Logs.LogRecordAttributeList.Clear() -> void -OpenTelemetry.Logs.LogRecordAttributeList.Count.get -> int -OpenTelemetry.Logs.LogRecordAttributeList.Enumerator -OpenTelemetry.Logs.LogRecordAttributeList.Enumerator.Current.get -> System.Collections.Generic.KeyValuePair -OpenTelemetry.Logs.LogRecordAttributeList.Enumerator.Dispose() -> void -OpenTelemetry.Logs.LogRecordAttributeList.Enumerator.Enumerator() -> void -OpenTelemetry.Logs.LogRecordAttributeList.Enumerator.MoveNext() -> bool -OpenTelemetry.Logs.LogRecordAttributeList.GetEnumerator() -> OpenTelemetry.Logs.LogRecordAttributeList.Enumerator -OpenTelemetry.Logs.LogRecordAttributeList.LogRecordAttributeList() -> void -OpenTelemetry.Logs.LogRecordAttributeList.RecordException(System.Exception! exception) -> void -OpenTelemetry.Logs.LogRecordAttributeList.this[int index].get -> System.Collections.Generic.KeyValuePair -OpenTelemetry.Logs.LogRecordAttributeList.this[int index].set -> void -OpenTelemetry.Logs.LogRecordAttributeList.this[string! key].set -> void -OpenTelemetry.Logs.LogRecordData -OpenTelemetry.Logs.LogRecordData.Body.get -> string? -OpenTelemetry.Logs.LogRecordData.Body.set -> void -OpenTelemetry.Logs.LogRecordData.LogRecordData() -> void -OpenTelemetry.Logs.LogRecordData.LogRecordData(System.Diagnostics.Activity? activity) -> void -OpenTelemetry.Logs.LogRecordData.LogRecordData(in System.Diagnostics.ActivityContext activityContext) -> void -OpenTelemetry.Logs.LogRecordData.Severity.get -> OpenTelemetry.Logs.LogRecordSeverity? -OpenTelemetry.Logs.LogRecordData.Severity.set -> void -OpenTelemetry.Logs.LogRecordData.SeverityText.get -> string? -OpenTelemetry.Logs.LogRecordData.SeverityText.set -> void -OpenTelemetry.Logs.LogRecordData.SpanId.get -> System.Diagnostics.ActivitySpanId -OpenTelemetry.Logs.LogRecordData.SpanId.set -> void -OpenTelemetry.Logs.LogRecordData.Timestamp.get -> System.DateTime -OpenTelemetry.Logs.LogRecordData.Timestamp.set -> void -OpenTelemetry.Logs.LogRecordData.TraceFlags.get -> System.Diagnostics.ActivityTraceFlags -OpenTelemetry.Logs.LogRecordData.TraceFlags.set -> void -OpenTelemetry.Logs.LogRecordData.TraceId.get -> System.Diagnostics.ActivityTraceId -OpenTelemetry.Logs.LogRecordData.TraceId.set -> void -OpenTelemetry.Logs.LogRecordSeverity -OpenTelemetry.Logs.LogRecordSeverity.Debug = 5 -> OpenTelemetry.Logs.LogRecordSeverity -OpenTelemetry.Logs.LogRecordSeverity.Debug2 = 6 -> OpenTelemetry.Logs.LogRecordSeverity -OpenTelemetry.Logs.LogRecordSeverity.Debug3 = 7 -> OpenTelemetry.Logs.LogRecordSeverity -OpenTelemetry.Logs.LogRecordSeverity.Debug4 = 8 -> OpenTelemetry.Logs.LogRecordSeverity -OpenTelemetry.Logs.LogRecordSeverity.Error = 17 -> OpenTelemetry.Logs.LogRecordSeverity -OpenTelemetry.Logs.LogRecordSeverity.Error2 = 18 -> OpenTelemetry.Logs.LogRecordSeverity -OpenTelemetry.Logs.LogRecordSeverity.Error3 = 19 -> OpenTelemetry.Logs.LogRecordSeverity -OpenTelemetry.Logs.LogRecordSeverity.Error4 = 20 -> OpenTelemetry.Logs.LogRecordSeverity -OpenTelemetry.Logs.LogRecordSeverity.Fatal = 21 -> OpenTelemetry.Logs.LogRecordSeverity -OpenTelemetry.Logs.LogRecordSeverity.Fatal2 = 22 -> OpenTelemetry.Logs.LogRecordSeverity -OpenTelemetry.Logs.LogRecordSeverity.Fatal3 = 23 -> OpenTelemetry.Logs.LogRecordSeverity -OpenTelemetry.Logs.LogRecordSeverity.Fatal4 = 24 -> OpenTelemetry.Logs.LogRecordSeverity -OpenTelemetry.Logs.LogRecordSeverity.Info = 9 -> OpenTelemetry.Logs.LogRecordSeverity -OpenTelemetry.Logs.LogRecordSeverity.Info2 = 10 -> OpenTelemetry.Logs.LogRecordSeverity -OpenTelemetry.Logs.LogRecordSeverity.Info3 = 11 -> OpenTelemetry.Logs.LogRecordSeverity -OpenTelemetry.Logs.LogRecordSeverity.Info4 = 12 -> OpenTelemetry.Logs.LogRecordSeverity -OpenTelemetry.Logs.LogRecordSeverity.Trace = 1 -> OpenTelemetry.Logs.LogRecordSeverity -OpenTelemetry.Logs.LogRecordSeverity.Trace2 = 2 -> OpenTelemetry.Logs.LogRecordSeverity -OpenTelemetry.Logs.LogRecordSeverity.Trace3 = 3 -> OpenTelemetry.Logs.LogRecordSeverity -OpenTelemetry.Logs.LogRecordSeverity.Trace4 = 4 -> OpenTelemetry.Logs.LogRecordSeverity -OpenTelemetry.Logs.LogRecordSeverity.Unspecified = 0 -> OpenTelemetry.Logs.LogRecordSeverity -OpenTelemetry.Logs.LogRecordSeverity.Warn = 13 -> OpenTelemetry.Logs.LogRecordSeverity -OpenTelemetry.Logs.LogRecordSeverity.Warn2 = 14 -> OpenTelemetry.Logs.LogRecordSeverity -OpenTelemetry.Logs.LogRecordSeverity.Warn3 = 15 -> OpenTelemetry.Logs.LogRecordSeverity -OpenTelemetry.Logs.LogRecordSeverity.Warn4 = 16 -> OpenTelemetry.Logs.LogRecordSeverity -OpenTelemetry.Logs.LogRecordSeverityExtensions -OpenTelemetry.Logs.Logger -OpenTelemetry.Logs.Logger.EmitLog(in OpenTelemetry.Logs.LogRecordData data) -> void -OpenTelemetry.Logs.Logger.Logger(string? name) -> void -OpenTelemetry.Logs.Logger.Name.get -> string! -OpenTelemetry.Logs.Logger.Version.get -> string? -OpenTelemetry.Logs.LoggerProvider -OpenTelemetry.Logs.LoggerProvider.GetLogger() -> OpenTelemetry.Logs.Logger! -OpenTelemetry.Logs.LoggerProvider.GetLogger(string? name) -> OpenTelemetry.Logs.Logger! -OpenTelemetry.Logs.LoggerProvider.GetLogger(string? name, string? version) -> OpenTelemetry.Logs.Logger! -OpenTelemetry.Logs.LoggerProvider.LoggerProvider() -> void -OpenTelemetry.Logs.LoggerProviderBuilder -OpenTelemetry.Logs.LoggerProviderBuilder.LoggerProviderBuilder() -> void +~OpenTelemetry.Context.ThreadLocalRuntimeContextSlot.ThreadLocalRuntimeContextSlot(string name) -> void +~OpenTelemetry.Context.ThreadLocalRuntimeContextSlot.Value.get -> object +~OpenTelemetry.Context.ThreadLocalRuntimeContextSlot.Value.set -> void OpenTelemetry.Metrics.IDeferredMeterProviderBuilder +~OpenTelemetry.Metrics.IDeferredMeterProviderBuilder.Configure(System.Action configure) -> OpenTelemetry.Metrics.MeterProviderBuilder OpenTelemetry.Metrics.MeterProvider OpenTelemetry.Metrics.MeterProvider.MeterProvider() -> void OpenTelemetry.Metrics.MeterProviderBuilder OpenTelemetry.Metrics.MeterProviderBuilder.MeterProviderBuilder() -> void OpenTelemetry.Trace.ActivityExtensions OpenTelemetry.Trace.IDeferredTracerProviderBuilder +~OpenTelemetry.Trace.IDeferredTracerProviderBuilder.Configure(System.Action configure) -> OpenTelemetry.Trace.TracerProviderBuilder OpenTelemetry.Trace.Link +~OpenTelemetry.Trace.Link.Attributes.get -> System.Collections.Generic.IEnumerable> OpenTelemetry.Trace.Link.Context.get -> OpenTelemetry.Trace.SpanContext OpenTelemetry.Trace.Link.Equals(OpenTelemetry.Trace.Link other) -> bool OpenTelemetry.Trace.Link.Link() -> void OpenTelemetry.Trace.Link.Link(in OpenTelemetry.Trace.SpanContext spanContext) -> void +~OpenTelemetry.Trace.Link.Link(in OpenTelemetry.Trace.SpanContext spanContext, OpenTelemetry.Trace.SpanAttributes attributes) -> void OpenTelemetry.Trace.SpanAttributes +~OpenTelemetry.Trace.SpanAttributes.Add(string key, bool value) -> void +~OpenTelemetry.Trace.SpanAttributes.Add(string key, bool[] values) -> void +~OpenTelemetry.Trace.SpanAttributes.Add(string key, double value) -> void +~OpenTelemetry.Trace.SpanAttributes.Add(string key, double[] values) -> void +~OpenTelemetry.Trace.SpanAttributes.Add(string key, long value) -> void +~OpenTelemetry.Trace.SpanAttributes.Add(string key, long[] values) -> void +~OpenTelemetry.Trace.SpanAttributes.Add(string key, string value) -> void +~OpenTelemetry.Trace.SpanAttributes.Add(string key, string[] values) -> void OpenTelemetry.Trace.SpanAttributes.SpanAttributes() -> void +~OpenTelemetry.Trace.SpanAttributes.SpanAttributes(System.Collections.Generic.IEnumerable> attributes) -> void OpenTelemetry.Trace.SpanContext OpenTelemetry.Trace.SpanContext.Equals(OpenTelemetry.Trace.SpanContext other) -> bool OpenTelemetry.Trace.SpanContext.IsRemote.get -> bool OpenTelemetry.Trace.SpanContext.IsValid.get -> bool OpenTelemetry.Trace.SpanContext.SpanContext() -> void OpenTelemetry.Trace.SpanContext.SpanContext(in System.Diagnostics.ActivityContext activityContext) -> void +~OpenTelemetry.Trace.SpanContext.SpanContext(in System.Diagnostics.ActivityTraceId traceId, in System.Diagnostics.ActivitySpanId spanId, System.Diagnostics.ActivityTraceFlags traceFlags, bool isRemote = false, System.Collections.Generic.IEnumerable> traceState = null) -> void OpenTelemetry.Trace.SpanContext.SpanId.get -> System.Diagnostics.ActivitySpanId OpenTelemetry.Trace.SpanContext.TraceFlags.get -> System.Diagnostics.ActivityTraceFlags OpenTelemetry.Trace.SpanContext.TraceId.get -> System.Diagnostics.ActivityTraceId +~OpenTelemetry.Trace.SpanContext.TraceState.get -> System.Collections.Generic.IEnumerable> OpenTelemetry.Trace.SpanKind OpenTelemetry.Trace.SpanKind.Client = 3 -> OpenTelemetry.Trace.SpanKind OpenTelemetry.Trace.SpanKind.Consumer = 5 -> OpenTelemetry.Trace.SpanKind @@ -137,104 +105,28 @@ OpenTelemetry.Trace.SpanKind.Internal = 1 -> OpenTelemetry.Trace.SpanKind OpenTelemetry.Trace.SpanKind.Producer = 4 -> OpenTelemetry.Trace.SpanKind OpenTelemetry.Trace.SpanKind.Server = 2 -> OpenTelemetry.Trace.SpanKind OpenTelemetry.Trace.Status +~OpenTelemetry.Trace.Status.Description.get -> string OpenTelemetry.Trace.Status.Equals(OpenTelemetry.Trace.Status other) -> bool OpenTelemetry.Trace.Status.Status() -> void OpenTelemetry.Trace.Status.StatusCode.get -> OpenTelemetry.Trace.StatusCode +~OpenTelemetry.Trace.Status.WithDescription(string description) -> OpenTelemetry.Trace.Status OpenTelemetry.Trace.StatusCode OpenTelemetry.Trace.StatusCode.Error = 2 -> OpenTelemetry.Trace.StatusCode OpenTelemetry.Trace.StatusCode.Ok = 1 -> OpenTelemetry.Trace.StatusCode OpenTelemetry.Trace.StatusCode.Unset = 0 -> OpenTelemetry.Trace.StatusCode OpenTelemetry.Trace.TelemetrySpan +~OpenTelemetry.Trace.TelemetrySpan.AddEvent(string name) -> OpenTelemetry.Trace.TelemetrySpan +~OpenTelemetry.Trace.TelemetrySpan.AddEvent(string name, OpenTelemetry.Trace.SpanAttributes attributes) -> OpenTelemetry.Trace.TelemetrySpan +~OpenTelemetry.Trace.TelemetrySpan.AddEvent(string name, System.DateTimeOffset timestamp) -> OpenTelemetry.Trace.TelemetrySpan +~OpenTelemetry.Trace.TelemetrySpan.AddEvent(string name, System.DateTimeOffset timestamp, OpenTelemetry.Trace.SpanAttributes attributes) -> OpenTelemetry.Trace.TelemetrySpan OpenTelemetry.Trace.TelemetrySpan.Context.get -> OpenTelemetry.Trace.SpanContext OpenTelemetry.Trace.TelemetrySpan.Dispose() -> void OpenTelemetry.Trace.TelemetrySpan.End() -> void OpenTelemetry.Trace.TelemetrySpan.End(System.DateTimeOffset endTimestamp) -> void OpenTelemetry.Trace.TelemetrySpan.IsRecording.get -> bool OpenTelemetry.Trace.TelemetrySpan.ParentSpanId.get -> System.Diagnostics.ActivitySpanId -OpenTelemetry.Trace.TelemetrySpan.SetStatus(OpenTelemetry.Trace.Status value) -> void -OpenTelemetry.Trace.Tracer -OpenTelemetry.Trace.TracerProvider -OpenTelemetry.Trace.TracerProvider.TracerProvider() -> void -OpenTelemetry.Trace.TracerProviderBuilder -OpenTelemetry.Trace.TracerProviderBuilder.TracerProviderBuilder() -> void -abstract OpenTelemetry.Context.RuntimeContextSlot.Get() -> T -abstract OpenTelemetry.Context.RuntimeContextSlot.Set(T value) -> void -abstract OpenTelemetry.Logs.Logger.EmitLog(in OpenTelemetry.Logs.LogRecordData data, in OpenTelemetry.Logs.LogRecordAttributeList attributes) -> void -abstract OpenTelemetry.Logs.LoggerProviderBuilder.AddInstrumentation(System.Func! instrumentationFactory) -> OpenTelemetry.Logs.LoggerProviderBuilder! -override OpenTelemetry.Baggage.GetHashCode() -> int -override OpenTelemetry.Context.AsyncLocalRuntimeContextSlot.Get() -> T -override OpenTelemetry.Context.AsyncLocalRuntimeContextSlot.Set(T value) -> void -override OpenTelemetry.Context.Propagation.PropagationContext.GetHashCode() -> int -override OpenTelemetry.Context.ThreadLocalRuntimeContextSlot.Dispose(bool disposing) -> void -override OpenTelemetry.Context.ThreadLocalRuntimeContextSlot.Get() -> T -override OpenTelemetry.Context.ThreadLocalRuntimeContextSlot.Set(T value) -> void -override OpenTelemetry.Trace.Link.GetHashCode() -> int -override OpenTelemetry.Trace.SpanContext.GetHashCode() -> int -override OpenTelemetry.Trace.Status.GetHashCode() -> int -static OpenTelemetry.ActivityContextExtensions.IsValid(this System.Diagnostics.ActivityContext ctx) -> bool -static OpenTelemetry.Baggage.ClearBaggage(OpenTelemetry.Baggage baggage = default(OpenTelemetry.Baggage)) -> OpenTelemetry.Baggage -static OpenTelemetry.Baggage.Current.get -> OpenTelemetry.Baggage -static OpenTelemetry.Baggage.Current.set -> void -static OpenTelemetry.Baggage.operator !=(OpenTelemetry.Baggage left, OpenTelemetry.Baggage right) -> bool -static OpenTelemetry.Baggage.operator ==(OpenTelemetry.Baggage left, OpenTelemetry.Baggage right) -> bool -static OpenTelemetry.Context.Propagation.PropagationContext.operator !=(OpenTelemetry.Context.Propagation.PropagationContext left, OpenTelemetry.Context.Propagation.PropagationContext right) -> bool -static OpenTelemetry.Context.Propagation.PropagationContext.operator ==(OpenTelemetry.Context.Propagation.PropagationContext left, OpenTelemetry.Context.Propagation.PropagationContext right) -> bool -static OpenTelemetry.Logs.LogRecordAttributeList.CreateFromEnumerable(System.Collections.Generic.IEnumerable>! attributes) -> OpenTelemetry.Logs.LogRecordAttributeList -static OpenTelemetry.Logs.LogRecordSeverityExtensions.ToShortName(this OpenTelemetry.Logs.LogRecordSeverity logRecordSeverity) -> string! -static OpenTelemetry.Trace.Link.operator !=(OpenTelemetry.Trace.Link link1, OpenTelemetry.Trace.Link link2) -> bool -static OpenTelemetry.Trace.Link.operator ==(OpenTelemetry.Trace.Link link1, OpenTelemetry.Trace.Link link2) -> bool -static OpenTelemetry.Trace.SpanContext.implicit operator System.Diagnostics.ActivityContext(OpenTelemetry.Trace.SpanContext spanContext) -> System.Diagnostics.ActivityContext -static OpenTelemetry.Trace.SpanContext.operator !=(OpenTelemetry.Trace.SpanContext spanContext1, OpenTelemetry.Trace.SpanContext spanContext2) -> bool -static OpenTelemetry.Trace.SpanContext.operator ==(OpenTelemetry.Trace.SpanContext spanContext1, OpenTelemetry.Trace.SpanContext spanContext2) -> bool -static OpenTelemetry.Trace.Status.operator !=(OpenTelemetry.Trace.Status status1, OpenTelemetry.Trace.Status status2) -> bool -static OpenTelemetry.Trace.Status.operator ==(OpenTelemetry.Trace.Status status1, OpenTelemetry.Trace.Status status2) -> bool -static readonly OpenTelemetry.Trace.Status.Error -> OpenTelemetry.Trace.Status -static readonly OpenTelemetry.Trace.Status.Ok -> OpenTelemetry.Trace.Status -static readonly OpenTelemetry.Trace.Status.Unset -> OpenTelemetry.Trace.Status -virtual OpenTelemetry.BaseProvider.Dispose(bool disposing) -> void -virtual OpenTelemetry.Context.RuntimeContextSlot.Dispose(bool disposing) -> void -virtual OpenTelemetry.Logs.LoggerProvider.TryCreateLogger(string? name, out OpenTelemetry.Logs.Logger? logger) -> bool -~OpenTelemetry.Baggage.GetBaggage() -> System.Collections.Generic.IReadOnlyDictionary -~OpenTelemetry.Baggage.GetBaggage(string name) -> string -~OpenTelemetry.Baggage.GetEnumerator() -> System.Collections.Generic.Dictionary.Enumerator -~OpenTelemetry.Baggage.RemoveBaggage(string name) -> OpenTelemetry.Baggage -~OpenTelemetry.Baggage.SetBaggage(System.Collections.Generic.IEnumerable> baggageItems) -> OpenTelemetry.Baggage -~OpenTelemetry.Baggage.SetBaggage(params System.Collections.Generic.KeyValuePair[] baggageItems) -> OpenTelemetry.Baggage -~OpenTelemetry.Baggage.SetBaggage(string name, string value) -> OpenTelemetry.Baggage -~OpenTelemetry.Context.AsyncLocalRuntimeContextSlot.AsyncLocalRuntimeContextSlot(string name) -> void -~OpenTelemetry.Context.AsyncLocalRuntimeContextSlot.Value.get -> object -~OpenTelemetry.Context.AsyncLocalRuntimeContextSlot.Value.set -> void -~OpenTelemetry.Context.IRuntimeContextSlotValueAccessor.Value.get -> object -~OpenTelemetry.Context.IRuntimeContextSlotValueAccessor.Value.set -> void -~OpenTelemetry.Context.Propagation.CompositeTextMapPropagator.CompositeTextMapPropagator(System.Collections.Generic.IEnumerable propagators) -> void -~OpenTelemetry.Context.RuntimeContextSlot.Name.get -> string -~OpenTelemetry.Context.RuntimeContextSlot.RuntimeContextSlot(string name) -> void -~OpenTelemetry.Context.ThreadLocalRuntimeContextSlot.ThreadLocalRuntimeContextSlot(string name) -> void -~OpenTelemetry.Context.ThreadLocalRuntimeContextSlot.Value.get -> object -~OpenTelemetry.Context.ThreadLocalRuntimeContextSlot.Value.set -> void -~OpenTelemetry.Metrics.IDeferredMeterProviderBuilder.Configure(System.Action configure) -> OpenTelemetry.Metrics.MeterProviderBuilder -~OpenTelemetry.Trace.IDeferredTracerProviderBuilder.Configure(System.Action configure) -> OpenTelemetry.Trace.TracerProviderBuilder -~OpenTelemetry.Trace.Link.Attributes.get -> System.Collections.Generic.IEnumerable> -~OpenTelemetry.Trace.Link.Link(in OpenTelemetry.Trace.SpanContext spanContext, OpenTelemetry.Trace.SpanAttributes attributes) -> void -~OpenTelemetry.Trace.SpanAttributes.Add(string key, bool value) -> void -~OpenTelemetry.Trace.SpanAttributes.Add(string key, bool[] values) -> void -~OpenTelemetry.Trace.SpanAttributes.Add(string key, double value) -> void -~OpenTelemetry.Trace.SpanAttributes.Add(string key, double[] values) -> void -~OpenTelemetry.Trace.SpanAttributes.Add(string key, long value) -> void -~OpenTelemetry.Trace.SpanAttributes.Add(string key, long[] values) -> void -~OpenTelemetry.Trace.SpanAttributes.Add(string key, string value) -> void -~OpenTelemetry.Trace.SpanAttributes.Add(string key, string[] values) -> void -~OpenTelemetry.Trace.SpanAttributes.SpanAttributes(System.Collections.Generic.IEnumerable> attributes) -> void -~OpenTelemetry.Trace.SpanContext.SpanContext(in System.Diagnostics.ActivityTraceId traceId, in System.Diagnostics.ActivitySpanId spanId, System.Diagnostics.ActivityTraceFlags traceFlags, bool isRemote = false, System.Collections.Generic.IEnumerable> traceState = null) -> void -~OpenTelemetry.Trace.SpanContext.TraceState.get -> System.Collections.Generic.IEnumerable> -~OpenTelemetry.Trace.Status.Description.get -> string -~OpenTelemetry.Trace.Status.WithDescription(string description) -> OpenTelemetry.Trace.Status -~OpenTelemetry.Trace.TelemetrySpan.AddEvent(string name) -> OpenTelemetry.Trace.TelemetrySpan -~OpenTelemetry.Trace.TelemetrySpan.AddEvent(string name, OpenTelemetry.Trace.SpanAttributes attributes) -> OpenTelemetry.Trace.TelemetrySpan -~OpenTelemetry.Trace.TelemetrySpan.AddEvent(string name, System.DateTimeOffset timestamp) -> OpenTelemetry.Trace.TelemetrySpan -~OpenTelemetry.Trace.TelemetrySpan.AddEvent(string name, System.DateTimeOffset timestamp, OpenTelemetry.Trace.SpanAttributes attributes) -> OpenTelemetry.Trace.TelemetrySpan -~OpenTelemetry.Trace.TelemetrySpan.RecordException(System.Exception ex) -> OpenTelemetry.Trace.TelemetrySpan ~OpenTelemetry.Trace.TelemetrySpan.RecordException(string type, string message, string stacktrace) -> OpenTelemetry.Trace.TelemetrySpan +~OpenTelemetry.Trace.TelemetrySpan.RecordException(System.Exception ex) -> OpenTelemetry.Trace.TelemetrySpan ~OpenTelemetry.Trace.TelemetrySpan.SetAttribute(string key, bool value) -> OpenTelemetry.Trace.TelemetrySpan ~OpenTelemetry.Trace.TelemetrySpan.SetAttribute(string key, bool[] values) -> OpenTelemetry.Trace.TelemetrySpan ~OpenTelemetry.Trace.TelemetrySpan.SetAttribute(string key, double value) -> OpenTelemetry.Trace.TelemetrySpan @@ -243,22 +135,23 @@ virtual OpenTelemetry.Logs.LoggerProvider.TryCreateLogger(string? name, out Open ~OpenTelemetry.Trace.TelemetrySpan.SetAttribute(string key, int[] values) -> OpenTelemetry.Trace.TelemetrySpan ~OpenTelemetry.Trace.TelemetrySpan.SetAttribute(string key, string value) -> OpenTelemetry.Trace.TelemetrySpan ~OpenTelemetry.Trace.TelemetrySpan.SetAttribute(string key, string[] values) -> OpenTelemetry.Trace.TelemetrySpan +OpenTelemetry.Trace.TelemetrySpan.SetStatus(OpenTelemetry.Trace.Status value) -> void ~OpenTelemetry.Trace.TelemetrySpan.UpdateName(string name) -> OpenTelemetry.Trace.TelemetrySpan +OpenTelemetry.Trace.Tracer ~OpenTelemetry.Trace.Tracer.StartActiveSpan(string name, OpenTelemetry.Trace.SpanKind kind = OpenTelemetry.Trace.SpanKind.Internal, in OpenTelemetry.Trace.SpanContext parentContext = default(OpenTelemetry.Trace.SpanContext), OpenTelemetry.Trace.SpanAttributes initialAttributes = null, System.Collections.Generic.IEnumerable links = null, System.DateTimeOffset startTime = default(System.DateTimeOffset)) -> OpenTelemetry.Trace.TelemetrySpan ~OpenTelemetry.Trace.Tracer.StartActiveSpan(string name, OpenTelemetry.Trace.SpanKind kind, in OpenTelemetry.Trace.TelemetrySpan parentSpan, OpenTelemetry.Trace.SpanAttributes initialAttributes = null, System.Collections.Generic.IEnumerable links = null, System.DateTimeOffset startTime = default(System.DateTimeOffset)) -> OpenTelemetry.Trace.TelemetrySpan ~OpenTelemetry.Trace.Tracer.StartRootSpan(string name, OpenTelemetry.Trace.SpanKind kind = OpenTelemetry.Trace.SpanKind.Internal, OpenTelemetry.Trace.SpanAttributes initialAttributes = null, System.Collections.Generic.IEnumerable links = null, System.DateTimeOffset startTime = default(System.DateTimeOffset)) -> OpenTelemetry.Trace.TelemetrySpan ~OpenTelemetry.Trace.Tracer.StartSpan(string name, OpenTelemetry.Trace.SpanKind kind = OpenTelemetry.Trace.SpanKind.Internal, in OpenTelemetry.Trace.SpanContext parentContext = default(OpenTelemetry.Trace.SpanContext), OpenTelemetry.Trace.SpanAttributes initialAttributes = null, System.Collections.Generic.IEnumerable links = null, System.DateTimeOffset startTime = default(System.DateTimeOffset)) -> OpenTelemetry.Trace.TelemetrySpan ~OpenTelemetry.Trace.Tracer.StartSpan(string name, OpenTelemetry.Trace.SpanKind kind, in OpenTelemetry.Trace.TelemetrySpan parentSpan, OpenTelemetry.Trace.SpanAttributes initialAttributes = null, System.Collections.Generic.IEnumerable links = null, System.DateTimeOffset startTime = default(System.DateTimeOffset)) -> OpenTelemetry.Trace.TelemetrySpan +OpenTelemetry.Trace.TracerProvider ~OpenTelemetry.Trace.TracerProvider.GetTracer(string name, string version = null) -> OpenTelemetry.Trace.Tracer -~abstract OpenTelemetry.Context.Propagation.TextMapPropagator.Extract(OpenTelemetry.Context.Propagation.PropagationContext context, T carrier, System.Func> getter) -> OpenTelemetry.Context.Propagation.PropagationContext -~abstract OpenTelemetry.Context.Propagation.TextMapPropagator.Fields.get -> System.Collections.Generic.ISet -~abstract OpenTelemetry.Context.Propagation.TextMapPropagator.Inject(OpenTelemetry.Context.Propagation.PropagationContext context, T carrier, System.Action setter) -> void -~abstract OpenTelemetry.Metrics.MeterProviderBuilder.AddInstrumentation(System.Func instrumentationFactory) -> OpenTelemetry.Metrics.MeterProviderBuilder -~abstract OpenTelemetry.Metrics.MeterProviderBuilder.AddMeter(params string[] names) -> OpenTelemetry.Metrics.MeterProviderBuilder -~abstract OpenTelemetry.Trace.TracerProviderBuilder.AddInstrumentation(System.Func instrumentationFactory) -> OpenTelemetry.Trace.TracerProviderBuilder -~abstract OpenTelemetry.Trace.TracerProviderBuilder.AddLegacySource(string operationName) -> OpenTelemetry.Trace.TracerProviderBuilder -~abstract OpenTelemetry.Trace.TracerProviderBuilder.AddSource(params string[] names) -> OpenTelemetry.Trace.TracerProviderBuilder +OpenTelemetry.Trace.TracerProvider.TracerProvider() -> void +OpenTelemetry.Trace.TracerProviderBuilder +OpenTelemetry.Trace.TracerProviderBuilder.TracerProviderBuilder() -> void ~override OpenTelemetry.Baggage.Equals(object obj) -> bool +override OpenTelemetry.Baggage.GetHashCode() -> int +override OpenTelemetry.Context.AsyncLocalRuntimeContextSlot.Get() -> T +override OpenTelemetry.Context.AsyncLocalRuntimeContextSlot.Set(T value) -> void ~override OpenTelemetry.Context.Propagation.B3Propagator.Extract(OpenTelemetry.Context.Propagation.PropagationContext context, T carrier, System.Func> getter) -> OpenTelemetry.Context.Propagation.PropagationContext ~override OpenTelemetry.Context.Propagation.B3Propagator.Fields.get -> System.Collections.Generic.ISet ~override OpenTelemetry.Context.Propagation.B3Propagator.Inject(OpenTelemetry.Context.Propagation.PropagationContext context, T carrier, System.Action setter) -> void @@ -269,20 +162,35 @@ virtual OpenTelemetry.Logs.LoggerProvider.TryCreateLogger(string? name, out Open ~override OpenTelemetry.Context.Propagation.CompositeTextMapPropagator.Fields.get -> System.Collections.Generic.ISet ~override OpenTelemetry.Context.Propagation.CompositeTextMapPropagator.Inject(OpenTelemetry.Context.Propagation.PropagationContext context, T carrier, System.Action setter) -> void ~override OpenTelemetry.Context.Propagation.PropagationContext.Equals(object obj) -> bool +override OpenTelemetry.Context.Propagation.PropagationContext.GetHashCode() -> int ~override OpenTelemetry.Context.Propagation.TraceContextPropagator.Extract(OpenTelemetry.Context.Propagation.PropagationContext context, T carrier, System.Func> getter) -> OpenTelemetry.Context.Propagation.PropagationContext ~override OpenTelemetry.Context.Propagation.TraceContextPropagator.Fields.get -> System.Collections.Generic.ISet ~override OpenTelemetry.Context.Propagation.TraceContextPropagator.Inject(OpenTelemetry.Context.Propagation.PropagationContext context, T carrier, System.Action setter) -> void +override OpenTelemetry.Context.ThreadLocalRuntimeContextSlot.Dispose(bool disposing) -> void +override OpenTelemetry.Context.ThreadLocalRuntimeContextSlot.Get() -> T +override OpenTelemetry.Context.ThreadLocalRuntimeContextSlot.Set(T value) -> void ~override OpenTelemetry.Trace.Link.Equals(object obj) -> bool +override OpenTelemetry.Trace.Link.GetHashCode() -> int ~override OpenTelemetry.Trace.SpanContext.Equals(object obj) -> bool +override OpenTelemetry.Trace.SpanContext.GetHashCode() -> int ~override OpenTelemetry.Trace.Status.Equals(object obj) -> bool +override OpenTelemetry.Trace.Status.GetHashCode() -> int ~override OpenTelemetry.Trace.Status.ToString() -> string +static OpenTelemetry.ActivityContextExtensions.IsValid(this System.Diagnostics.ActivityContext ctx) -> bool +static OpenTelemetry.Baggage.ClearBaggage(OpenTelemetry.Baggage baggage = default(OpenTelemetry.Baggage)) -> OpenTelemetry.Baggage ~static OpenTelemetry.Baggage.Create(System.Collections.Generic.Dictionary baggageItems = null) -> OpenTelemetry.Baggage +static OpenTelemetry.Baggage.Current.get -> OpenTelemetry.Baggage +static OpenTelemetry.Baggage.Current.set -> void ~static OpenTelemetry.Baggage.GetBaggage(OpenTelemetry.Baggage baggage = default(OpenTelemetry.Baggage)) -> System.Collections.Generic.IReadOnlyDictionary ~static OpenTelemetry.Baggage.GetBaggage(string name, OpenTelemetry.Baggage baggage = default(OpenTelemetry.Baggage)) -> string ~static OpenTelemetry.Baggage.GetEnumerator(OpenTelemetry.Baggage baggage = default(OpenTelemetry.Baggage)) -> System.Collections.Generic.Dictionary.Enumerator +static OpenTelemetry.Baggage.operator !=(OpenTelemetry.Baggage left, OpenTelemetry.Baggage right) -> bool +static OpenTelemetry.Baggage.operator ==(OpenTelemetry.Baggage left, OpenTelemetry.Baggage right) -> bool ~static OpenTelemetry.Baggage.RemoveBaggage(string name, OpenTelemetry.Baggage baggage = default(OpenTelemetry.Baggage)) -> OpenTelemetry.Baggage -~static OpenTelemetry.Baggage.SetBaggage(System.Collections.Generic.IEnumerable> baggageItems, OpenTelemetry.Baggage baggage = default(OpenTelemetry.Baggage)) -> OpenTelemetry.Baggage ~static OpenTelemetry.Baggage.SetBaggage(string name, string value, OpenTelemetry.Baggage baggage = default(OpenTelemetry.Baggage)) -> OpenTelemetry.Baggage +~static OpenTelemetry.Baggage.SetBaggage(System.Collections.Generic.IEnumerable> baggageItems, OpenTelemetry.Baggage baggage = default(OpenTelemetry.Baggage)) -> OpenTelemetry.Baggage +static OpenTelemetry.Context.Propagation.PropagationContext.operator !=(OpenTelemetry.Context.Propagation.PropagationContext left, OpenTelemetry.Context.Propagation.PropagationContext right) -> bool +static OpenTelemetry.Context.Propagation.PropagationContext.operator ==(OpenTelemetry.Context.Propagation.PropagationContext left, OpenTelemetry.Context.Propagation.PropagationContext right) -> bool ~static OpenTelemetry.Context.Propagation.Propagators.DefaultTextMapPropagator.get -> OpenTelemetry.Context.Propagation.TextMapPropagator ~static OpenTelemetry.Context.RuntimeContext.ContextSlotType.get -> System.Type ~static OpenTelemetry.Context.RuntimeContext.ContextSlotType.set -> void @@ -296,6 +204,18 @@ virtual OpenTelemetry.Logs.LoggerProvider.TryCreateLogger(string? name, out Open ~static OpenTelemetry.Trace.ActivityExtensions.RecordException(this System.Diagnostics.Activity activity, System.Exception ex) -> void ~static OpenTelemetry.Trace.ActivityExtensions.RecordException(this System.Diagnostics.Activity activity, System.Exception ex, in System.Diagnostics.TagList tags) -> void ~static OpenTelemetry.Trace.ActivityExtensions.SetStatus(this System.Diagnostics.Activity activity, OpenTelemetry.Trace.Status status) -> void +static OpenTelemetry.Trace.Link.operator !=(OpenTelemetry.Trace.Link link1, OpenTelemetry.Trace.Link link2) -> bool +static OpenTelemetry.Trace.Link.operator ==(OpenTelemetry.Trace.Link link1, OpenTelemetry.Trace.Link link2) -> bool +static OpenTelemetry.Trace.SpanContext.implicit operator System.Diagnostics.ActivityContext(OpenTelemetry.Trace.SpanContext spanContext) -> System.Diagnostics.ActivityContext +static OpenTelemetry.Trace.SpanContext.operator !=(OpenTelemetry.Trace.SpanContext spanContext1, OpenTelemetry.Trace.SpanContext spanContext2) -> bool +static OpenTelemetry.Trace.SpanContext.operator ==(OpenTelemetry.Trace.SpanContext spanContext1, OpenTelemetry.Trace.SpanContext spanContext2) -> bool +static OpenTelemetry.Trace.Status.operator !=(OpenTelemetry.Trace.Status status1, OpenTelemetry.Trace.Status status2) -> bool +static OpenTelemetry.Trace.Status.operator ==(OpenTelemetry.Trace.Status status1, OpenTelemetry.Trace.Status status2) -> bool ~static OpenTelemetry.Trace.Tracer.CurrentSpan.get -> OpenTelemetry.Trace.TelemetrySpan ~static OpenTelemetry.Trace.Tracer.WithSpan(OpenTelemetry.Trace.TelemetrySpan span) -> OpenTelemetry.Trace.TelemetrySpan -~static OpenTelemetry.Trace.TracerProvider.Default.get -> OpenTelemetry.Trace.TracerProvider \ No newline at end of file +~static OpenTelemetry.Trace.TracerProvider.Default.get -> OpenTelemetry.Trace.TracerProvider +static readonly OpenTelemetry.Trace.Status.Error -> OpenTelemetry.Trace.Status +static readonly OpenTelemetry.Trace.Status.Ok -> OpenTelemetry.Trace.Status +static readonly OpenTelemetry.Trace.Status.Unset -> OpenTelemetry.Trace.Status +virtual OpenTelemetry.BaseProvider.Dispose(bool disposing) -> void +virtual OpenTelemetry.Context.RuntimeContextSlot.Dispose(bool disposing) -> void diff --git a/src/OpenTelemetry.Exporter.Console/.publicApi/net6.0/PublicAPI.Shipped.txt b/src/OpenTelemetry.Api/.publicApi/Stable/netstandard2.0/PublicAPI.Unshipped.txt similarity index 100% rename from src/OpenTelemetry.Exporter.Console/.publicApi/net6.0/PublicAPI.Shipped.txt rename to src/OpenTelemetry.Api/.publicApi/Stable/netstandard2.0/PublicAPI.Unshipped.txt diff --git a/src/OpenTelemetry.Api/AssemblyInfo.cs b/src/OpenTelemetry.Api/AssemblyInfo.cs index 2af154f989e..3709e7402a8 100644 --- a/src/OpenTelemetry.Api/AssemblyInfo.cs +++ b/src/OpenTelemetry.Api/AssemblyInfo.cs @@ -23,14 +23,24 @@ [assembly: InternalsVisibleTo("OpenTelemetry.Tests" + AssemblyInfo.PublicKey)] [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2" + AssemblyInfo.MoqPublicKey)] +#if !EXPOSE_EXPERIMENTAL_FEATURES +[assembly: InternalsVisibleTo("OpenTelemetry.Api.ProviderBuilderExtensions.Tests" + AssemblyInfo.PublicKey)] +[assembly: InternalsVisibleTo("OpenTelemetry.Exporter.Console" + AssemblyInfo.PublicKey)] +[assembly: InternalsVisibleTo("OpenTelemetry.Exporter.InMemory" + AssemblyInfo.PublicKey)] +[assembly: InternalsVisibleTo("OpenTelemetry.Exporter.OpenTelemetryProtocol" + AssemblyInfo.PublicKey)] +[assembly: InternalsVisibleTo("OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests" + AssemblyInfo.PublicKey)] +[assembly: InternalsVisibleTo("OpenTelemetry.Extensions.Hosting" + AssemblyInfo.PublicKey)] +[assembly: InternalsVisibleTo("OpenTelemetry.Extensions.Hosting.Tests" + AssemblyInfo.PublicKey)] +#endif + #if SIGNED -internal static class AssemblyInfo +file static class AssemblyInfo { public const string PublicKey = ", PublicKey=002400000480000094000000060200000024000052534131000400000100010051C1562A090FB0C9F391012A32198B5E5D9A60E9B80FA2D7B434C9E5CCB7259BD606E66F9660676AFC6692B8CDC6793D190904551D2103B7B22FA636DCBB8208839785BA402EA08FC00C8F1500CCEF28BBF599AA64FFB1E1D5DC1BF3420A3777BADFE697856E9D52070A50C3EA5821C80BEF17CA3ACFFA28F89DD413F096F898"; public const string MoqPublicKey = ", PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7"; } #else -internal static class AssemblyInfo +file static class AssemblyInfo { public const string PublicKey = ""; public const string MoqPublicKey = ""; diff --git a/src/OpenTelemetry.Api/CHANGELOG.md b/src/OpenTelemetry.Api/CHANGELOG.md index 30bd4685d90..1cd2eddfa1a 100644 --- a/src/OpenTelemetry.Api/CHANGELOG.md +++ b/src/OpenTelemetry.Api/CHANGELOG.md @@ -9,19 +9,19 @@ Released 2023-Jul-12 * Updated `System.Diagnostics.DiagnosticSource` package version to `7.0.2`. ([#4576](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4576)) -* **Breaking change** In order to make `RuntimeContext` compatible with - ahead-of-time compilation (AOT), - `RuntimeContext.ContextSlotType` can only be assigned one - of the following types: `AsyncLocalRuntimeContextSlot<>`, +* **Breaking change:** In order to make `RuntimeContext` compatible with + ahead-of-time compilation (AOT), `RuntimeContext.ContextSlotType` can only be + assigned one of the following types: `AsyncLocalRuntimeContextSlot<>`, `ThreadLocalRuntimeContextSlot<>`, and `RemotingRuntimeContextSlot<>`. A `System.NotSupportedException` will be thrown if you try to assign any type other than the three types mentioned. ([#4542](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4542)) -* Added [Logs Bridge +* **Experimental (pre-release builds only):** Added [Logs Bridge API](https://github.com/open-telemetry/opentelemetry-specification/blob/976432b74c565e8a84af3570e9b82cb95e1d844c/specification/logs/bridge-api.md) implementation (`LoggerProviderBuilder`, `LoggerProvider`, `Logger`, etc.). - ([#4433](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4433)) + ([#4433](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4433), + [#4735](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4735)) ## 1.5.1 diff --git a/src/OpenTelemetry.Api/Logs/IDeferredLoggerProviderBuilder.cs b/src/OpenTelemetry.Api/Logs/IDeferredLoggerProviderBuilder.cs index 5c8585b799e..cf6852327ac 100644 --- a/src/OpenTelemetry.Api/Logs/IDeferredLoggerProviderBuilder.cs +++ b/src/OpenTelemetry.Api/Logs/IDeferredLoggerProviderBuilder.cs @@ -18,12 +18,23 @@ namespace OpenTelemetry.Logs; +#if EXPOSE_EXPERIMENTAL_FEATURES /// /// Describes a logger provider builder that supports deferred /// initialization using an to perform /// dependency injection. /// -public interface IDeferredLoggerProviderBuilder +/// +public +#else +/// +/// Describes a logger provider builder that supports deferred +/// initialization using an to perform +/// dependency injection. +/// +internal +#endif + interface IDeferredLoggerProviderBuilder { /// /// Register a callback action to configure the /// Stores attributes to be added to a log message. /// -public struct LogRecordAttributeList : IReadOnlyList> +/// +public +#else +/// +/// Stores attributes to be added to a log message. +/// +internal +#endif + struct LogRecordAttributeList : IReadOnlyList> { internal const int OverflowMaxCount = 8; internal const int OverflowAdditionalCapacity = 16; diff --git a/src/OpenTelemetry.Api/Logs/LogRecordData.cs b/src/OpenTelemetry.Api/Logs/LogRecordData.cs index 6daefdcee74..37225cb3e74 100644 --- a/src/OpenTelemetry.Api/Logs/LogRecordData.cs +++ b/src/OpenTelemetry.Api/Logs/LogRecordData.cs @@ -20,10 +20,19 @@ namespace OpenTelemetry.Logs; +#if EXPOSE_EXPERIMENTAL_FEATURES /// /// Stores details about a log message. /// -public struct LogRecordData +/// +public +#else +/// +/// Stores details about a log message. +/// +internal +#endif + struct LogRecordData { internal DateTime TimestampBacking = DateTime.UtcNow; diff --git a/src/OpenTelemetry.Api/Logs/LogRecordSeverity.cs b/src/OpenTelemetry.Api/Logs/LogRecordSeverity.cs index 076cd2545c0..3fc9a7aa660 100644 --- a/src/OpenTelemetry.Api/Logs/LogRecordSeverity.cs +++ b/src/OpenTelemetry.Api/Logs/LogRecordSeverity.cs @@ -18,10 +18,19 @@ namespace OpenTelemetry.Logs; +#if EXPOSE_EXPERIMENTAL_FEATURES /// /// Describes the severity level of a log record. /// -public enum LogRecordSeverity +/// +public +#else +/// +/// Describes the severity level of a log record. +/// +internal +#endif + enum LogRecordSeverity { /// Unspecified severity (0). Unspecified = 0, diff --git a/src/OpenTelemetry.Api/Logs/LogRecordSeverityExtensions.cs b/src/OpenTelemetry.Api/Logs/LogRecordSeverityExtensions.cs index f86892c3181..0a9556e4b6a 100644 --- a/src/OpenTelemetry.Api/Logs/LogRecordSeverityExtensions.cs +++ b/src/OpenTelemetry.Api/Logs/LogRecordSeverityExtensions.cs @@ -18,10 +18,19 @@ namespace OpenTelemetry.Logs; +#if EXPOSE_EXPERIMENTAL_FEATURES /// /// Contains extension methods for the enum. /// -public static class LogRecordSeverityExtensions +/// +public +#else +/// +/// Contains extension methods for the enum. +/// +internal +#endif + static class LogRecordSeverityExtensions { internal const string UnspecifiedShortName = "UNSPECIFIED"; diff --git a/src/OpenTelemetry.Api/Logs/Logger.cs b/src/OpenTelemetry.Api/Logs/Logger.cs index 25bd741f113..17297a977f1 100644 --- a/src/OpenTelemetry.Api/Logs/Logger.cs +++ b/src/OpenTelemetry.Api/Logs/Logger.cs @@ -18,10 +18,19 @@ namespace OpenTelemetry.Logs; +#if EXPOSE_EXPERIMENTAL_FEATURES /// /// Logger is the class responsible for creating log records. /// -public abstract class Logger +/// WARNING: This is an experimental API which might change or be removed in the future. Use at your own risk. +public +#else +/// +/// Logger is the class responsible for creating log records. +/// +internal +#endif + abstract class Logger { /// /// Initializes a new instance of the class. diff --git a/src/OpenTelemetry.Api/Logs/LoggerProvider.cs b/src/OpenTelemetry.Api/Logs/LoggerProvider.cs index e0d71637664..a0e65003fac 100644 --- a/src/OpenTelemetry.Api/Logs/LoggerProvider.cs +++ b/src/OpenTelemetry.Api/Logs/LoggerProvider.cs @@ -22,10 +22,19 @@ namespace OpenTelemetry.Logs; +#if EXPOSE_EXPERIMENTAL_FEATURES /// /// LoggerProvider is the entry point of the OpenTelemetry API. It provides access to . /// -public class LoggerProvider : BaseProvider +/// +public +#else +/// +/// LoggerProvider is the entry point of the OpenTelemetry API. It provides access to . +/// +internal +#endif + class LoggerProvider : BaseProvider { private static readonly NoopLogger NoopLogger = new(); diff --git a/src/OpenTelemetry.Api/Logs/LoggerProviderBuilder.cs b/src/OpenTelemetry.Api/Logs/LoggerProviderBuilder.cs index c8379f46fb1..76e7ad33ecc 100644 --- a/src/OpenTelemetry.Api/Logs/LoggerProviderBuilder.cs +++ b/src/OpenTelemetry.Api/Logs/LoggerProviderBuilder.cs @@ -18,10 +18,19 @@ namespace OpenTelemetry.Logs; +#if EXPOSE_EXPERIMENTAL_FEATURES /// /// LoggerProviderBuilder base class. /// -public abstract class LoggerProviderBuilder +/// +public +#else +/// +/// LoggerProviderBuilder base class. +/// +internal +#endif + abstract class LoggerProviderBuilder { /// /// Initializes a new instance of the class. diff --git a/src/OpenTelemetry.Exporter.Console/.publicApi/net462/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.Console/.publicApi/Experimental/net462/PublicAPI.Unshipped.txt similarity index 100% rename from src/OpenTelemetry.Exporter.Console/.publicApi/net462/PublicAPI.Unshipped.txt rename to src/OpenTelemetry.Exporter.Console/.publicApi/Experimental/net462/PublicAPI.Unshipped.txt diff --git a/src/OpenTelemetry.Exporter.Console/.publicApi/Experimental/net6.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.Console/.publicApi/Experimental/net6.0/PublicAPI.Unshipped.txt new file mode 100644 index 00000000000..be114835ccd --- /dev/null +++ b/src/OpenTelemetry.Exporter.Console/.publicApi/Experimental/net6.0/PublicAPI.Unshipped.txt @@ -0,0 +1,3 @@ +static OpenTelemetry.Logs.ConsoleExporterLoggingExtensions.AddConsoleExporter(this OpenTelemetry.Logs.LoggerProviderBuilder loggerProviderBuilder) -> OpenTelemetry.Logs.LoggerProviderBuilder +static OpenTelemetry.Logs.ConsoleExporterLoggingExtensions.AddConsoleExporter(this OpenTelemetry.Logs.LoggerProviderBuilder loggerProviderBuilder, string name, System.Action configure) -> OpenTelemetry.Logs.LoggerProviderBuilder +static OpenTelemetry.Logs.ConsoleExporterLoggingExtensions.AddConsoleExporter(this OpenTelemetry.Logs.LoggerProviderBuilder loggerProviderBuilder, System.Action configure) -> OpenTelemetry.Logs.LoggerProviderBuilder diff --git a/src/OpenTelemetry.Exporter.Console/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.Console/.publicApi/Experimental/netstandard2.0/PublicAPI.Unshipped.txt similarity index 100% rename from src/OpenTelemetry.Exporter.Console/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt rename to src/OpenTelemetry.Exporter.Console/.publicApi/Experimental/netstandard2.0/PublicAPI.Unshipped.txt diff --git a/src/OpenTelemetry.Exporter.Console/.publicApi/net462/PublicAPI.Shipped.txt b/src/OpenTelemetry.Exporter.Console/.publicApi/Stable/net462/PublicAPI.Shipped.txt similarity index 100% rename from src/OpenTelemetry.Exporter.Console/.publicApi/net462/PublicAPI.Shipped.txt rename to src/OpenTelemetry.Exporter.Console/.publicApi/Stable/net462/PublicAPI.Shipped.txt diff --git a/src/OpenTelemetry.Exporter.InMemory/.publicApi/net6.0/PublicAPI.Shipped.txt b/src/OpenTelemetry.Exporter.Console/.publicApi/Stable/net462/PublicAPI.Unshipped.txt similarity index 100% rename from src/OpenTelemetry.Exporter.InMemory/.publicApi/net6.0/PublicAPI.Shipped.txt rename to src/OpenTelemetry.Exporter.Console/.publicApi/Stable/net462/PublicAPI.Unshipped.txt diff --git a/src/OpenTelemetry.Exporter.Console/.publicApi/netstandard2.0/PublicAPI.Shipped.txt b/src/OpenTelemetry.Exporter.Console/.publicApi/Stable/net6.0/PublicAPI.Shipped.txt similarity index 100% rename from src/OpenTelemetry.Exporter.Console/.publicApi/netstandard2.0/PublicAPI.Shipped.txt rename to src/OpenTelemetry.Exporter.Console/.publicApi/Stable/net6.0/PublicAPI.Shipped.txt diff --git a/src/OpenTelemetry.Exporter.Console/.publicApi/Stable/net6.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.Console/.publicApi/Stable/net6.0/PublicAPI.Unshipped.txt new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/OpenTelemetry.Exporter.Console/.publicApi/net6.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.Console/.publicApi/Stable/netstandard2.0/PublicAPI.Shipped.txt similarity index 86% rename from src/OpenTelemetry.Exporter.Console/.publicApi/net6.0/PublicAPI.Unshipped.txt rename to src/OpenTelemetry.Exporter.Console/.publicApi/Stable/netstandard2.0/PublicAPI.Shipped.txt index edb9ad0036b..6f900a1f6f6 100644 --- a/src/OpenTelemetry.Exporter.Console/.publicApi/net6.0/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.Exporter.Console/.publicApi/Stable/netstandard2.0/PublicAPI.Shipped.txt @@ -21,16 +21,13 @@ override OpenTelemetry.Exporter.ConsoleActivityExporter.Export(in OpenTelemetry. override OpenTelemetry.Exporter.ConsoleLogRecordExporter.Dispose(bool disposing) -> void override OpenTelemetry.Exporter.ConsoleLogRecordExporter.Export(in OpenTelemetry.Batch batch) -> OpenTelemetry.ExportResult override OpenTelemetry.Exporter.ConsoleMetricExporter.Export(in OpenTelemetry.Batch batch) -> OpenTelemetry.ExportResult -static OpenTelemetry.Logs.ConsoleExporterLoggingExtensions.AddConsoleExporter(this OpenTelemetry.Logs.LoggerProviderBuilder loggerProviderBuilder) -> OpenTelemetry.Logs.LoggerProviderBuilder -static OpenTelemetry.Logs.ConsoleExporterLoggingExtensions.AddConsoleExporter(this OpenTelemetry.Logs.LoggerProviderBuilder loggerProviderBuilder, System.Action configure) -> OpenTelemetry.Logs.LoggerProviderBuilder -static OpenTelemetry.Logs.ConsoleExporterLoggingExtensions.AddConsoleExporter(this OpenTelemetry.Logs.LoggerProviderBuilder loggerProviderBuilder, string name, System.Action configure) -> OpenTelemetry.Logs.LoggerProviderBuilder static OpenTelemetry.Logs.ConsoleExporterLoggingExtensions.AddConsoleExporter(this OpenTelemetry.Logs.OpenTelemetryLoggerOptions loggerOptions) -> OpenTelemetry.Logs.OpenTelemetryLoggerOptions static OpenTelemetry.Logs.ConsoleExporterLoggingExtensions.AddConsoleExporter(this OpenTelemetry.Logs.OpenTelemetryLoggerOptions loggerOptions, System.Action configure) -> OpenTelemetry.Logs.OpenTelemetryLoggerOptions static OpenTelemetry.Metrics.ConsoleExporterMetricsExtensions.AddConsoleExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder) -> OpenTelemetry.Metrics.MeterProviderBuilder -static OpenTelemetry.Metrics.ConsoleExporterMetricsExtensions.AddConsoleExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configureExporterAndMetricReader) -> OpenTelemetry.Metrics.MeterProviderBuilder -static OpenTelemetry.Metrics.ConsoleExporterMetricsExtensions.AddConsoleExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configureExporter) -> OpenTelemetry.Metrics.MeterProviderBuilder static OpenTelemetry.Metrics.ConsoleExporterMetricsExtensions.AddConsoleExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, string name, System.Action configureExporterAndMetricReader) -> OpenTelemetry.Metrics.MeterProviderBuilder static OpenTelemetry.Metrics.ConsoleExporterMetricsExtensions.AddConsoleExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, string name, System.Action configureExporter) -> OpenTelemetry.Metrics.MeterProviderBuilder +static OpenTelemetry.Metrics.ConsoleExporterMetricsExtensions.AddConsoleExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configureExporterAndMetricReader) -> OpenTelemetry.Metrics.MeterProviderBuilder +static OpenTelemetry.Metrics.ConsoleExporterMetricsExtensions.AddConsoleExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configureExporter) -> OpenTelemetry.Metrics.MeterProviderBuilder static OpenTelemetry.Trace.ConsoleExporterHelperExtensions.AddConsoleExporter(this OpenTelemetry.Trace.TracerProviderBuilder builder) -> OpenTelemetry.Trace.TracerProviderBuilder +static OpenTelemetry.Trace.ConsoleExporterHelperExtensions.AddConsoleExporter(this OpenTelemetry.Trace.TracerProviderBuilder builder, string name, System.Action configure) -> OpenTelemetry.Trace.TracerProviderBuilder static OpenTelemetry.Trace.ConsoleExporterHelperExtensions.AddConsoleExporter(this OpenTelemetry.Trace.TracerProviderBuilder builder, System.Action configure) -> OpenTelemetry.Trace.TracerProviderBuilder -static OpenTelemetry.Trace.ConsoleExporterHelperExtensions.AddConsoleExporter(this OpenTelemetry.Trace.TracerProviderBuilder builder, string name, System.Action configure) -> OpenTelemetry.Trace.TracerProviderBuilder \ No newline at end of file diff --git a/src/OpenTelemetry.Exporter.Console/.publicApi/Stable/netstandard2.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.Console/.publicApi/Stable/netstandard2.0/PublicAPI.Unshipped.txt new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/OpenTelemetry.Exporter.Console/CHANGELOG.md b/src/OpenTelemetry.Exporter.Console/CHANGELOG.md index e7c5255d82b..a62e73c8ee9 100644 --- a/src/OpenTelemetry.Exporter.Console/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.Console/CHANGELOG.md @@ -6,16 +6,23 @@ Released 2023-Jul-12 -* Add back support for Exemplars. See [exemplars](../../docs/metrics/customizing-the-sdk/README.md#exemplars) - for instructions to enable exemplars. - ([#4553](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4553)) +* **Experimental (pre-release builds only):** + + * Note: See + [#4735](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4735) + for the introduction of experimental api support. + + * Add back support for Exemplars. See + [exemplars](../../docs/metrics/customizing-the-sdk/README.md#exemplars) for + instructions to enable exemplars. + ([#4553](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4553)) -* Updated to display `Severity` and `SeverityText` text instead of - `ILogger.LogLevel` when exporting `LogRecord` instances. - ([#4568](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4568)) + * Updated to display `Severity` and `SeverityText` text instead of + `ILogger.LogLevel` when exporting `LogRecord` instances. + ([#4568](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4568)) -* Added `LoggerProviderBuilder.AddConsoleExporter` registration extension. - ([#4583](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4583)) + * Added `LoggerProviderBuilder.AddConsoleExporter` registration extension. + ([#4583](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4583)) ## 1.5.1 diff --git a/src/OpenTelemetry.Exporter.Console/ConsoleExporterLoggingExtensions.cs b/src/OpenTelemetry.Exporter.Console/ConsoleExporterLoggingExtensions.cs index 23c7a78bd38..c041b43b3b6 100644 --- a/src/OpenTelemetry.Exporter.Console/ConsoleExporterLoggingExtensions.cs +++ b/src/OpenTelemetry.Exporter.Console/ConsoleExporterLoggingExtensions.cs @@ -48,26 +48,60 @@ public static OpenTelemetryLoggerOptions AddConsoleExporter(this OpenTelemetryLo return loggerOptions.AddProcessor(new SimpleLogRecordExportProcessor(new ConsoleLogRecordExporter(options))); } +#if EXPOSE_EXPERIMENTAL_FEATURES /// /// Adds Console exporter with LoggerProviderBuilder. /// + /// WARNING: This is an experimental API which might change or be removed in the future. Use at your own risk. /// . /// The supplied instance of to chain the calls. - public static LoggerProviderBuilder AddConsoleExporter( + public +#else + /// + /// Adds Console exporter with LoggerProviderBuilder. + /// + /// . + /// The supplied instance of to chain the calls. + internal +#endif + static LoggerProviderBuilder AddConsoleExporter( this LoggerProviderBuilder loggerProviderBuilder) => AddConsoleExporter(loggerProviderBuilder, name: null, configure: null); +#if EXPOSE_EXPERIMENTAL_FEATURES + /// + /// Adds Console exporter with LoggerProviderBuilder. + /// + /// + /// . + /// Callback action for configuring . + /// The supplied instance of to chain the calls. + public +#else /// /// Adds Console exporter with LoggerProviderBuilder. /// /// . /// Callback action for configuring . /// The supplied instance of to chain the calls. - public static LoggerProviderBuilder AddConsoleExporter( + internal +#endif + static LoggerProviderBuilder AddConsoleExporter( this LoggerProviderBuilder loggerProviderBuilder, Action configure) => AddConsoleExporter(loggerProviderBuilder, name: null, configure); +#if EXPOSE_EXPERIMENTAL_FEATURES + /// + /// Adds Console exporter with LoggerProviderBuilder. + /// + /// + /// . + /// Name which is used when retrieving options. + /// Callback action for configuring . + /// The supplied instance of to chain the calls. + public +#else /// /// Adds Console exporter with LoggerProviderBuilder. /// @@ -75,7 +109,9 @@ public static LoggerProviderBuilder AddConsoleExporter( /// Name which is used when retrieving options. /// Callback action for configuring . /// The supplied instance of to chain the calls. - public static LoggerProviderBuilder AddConsoleExporter( + internal +#endif + static LoggerProviderBuilder AddConsoleExporter( this LoggerProviderBuilder loggerProviderBuilder, string name, Action configure) diff --git a/src/OpenTelemetry.Exporter.Console/OpenTelemetry.Exporter.Console.csproj b/src/OpenTelemetry.Exporter.Console/OpenTelemetry.Exporter.Console.csproj index 8c6aaed69e3..6b065829b60 100644 --- a/src/OpenTelemetry.Exporter.Console/OpenTelemetry.Exporter.Console.csproj +++ b/src/OpenTelemetry.Exporter.Console/OpenTelemetry.Exporter.Console.csproj @@ -29,12 +29,15 @@ - + - - + + + + + diff --git a/src/OpenTelemetry.Exporter.InMemory/.publicApi/net462/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.InMemory/.publicApi/Experimental/net462/PublicAPI.Unshipped.txt similarity index 100% rename from src/OpenTelemetry.Exporter.InMemory/.publicApi/net462/PublicAPI.Unshipped.txt rename to src/OpenTelemetry.Exporter.InMemory/.publicApi/Experimental/net462/PublicAPI.Unshipped.txt diff --git a/src/OpenTelemetry.Exporter.InMemory/.publicApi/Experimental/net6.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.InMemory/.publicApi/Experimental/net6.0/PublicAPI.Unshipped.txt new file mode 100644 index 00000000000..f7378ee36cc --- /dev/null +++ b/src/OpenTelemetry.Exporter.InMemory/.publicApi/Experimental/net6.0/PublicAPI.Unshipped.txt @@ -0,0 +1 @@ +static OpenTelemetry.Logs.InMemoryExporterLoggingExtensions.AddInMemoryExporter(this OpenTelemetry.Logs.LoggerProviderBuilder loggerProviderBuilder, System.Collections.Generic.ICollection exportedItems) -> OpenTelemetry.Logs.LoggerProviderBuilder diff --git a/src/OpenTelemetry.Exporter.InMemory/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.InMemory/.publicApi/Experimental/netstandard2.0/PublicAPI.Unshipped.txt similarity index 100% rename from src/OpenTelemetry.Exporter.InMemory/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt rename to src/OpenTelemetry.Exporter.InMemory/.publicApi/Experimental/netstandard2.0/PublicAPI.Unshipped.txt diff --git a/src/OpenTelemetry.Exporter.InMemory/.publicApi/net462/PublicAPI.Shipped.txt b/src/OpenTelemetry.Exporter.InMemory/.publicApi/Stable/net462/PublicAPI.Shipped.txt similarity index 100% rename from src/OpenTelemetry.Exporter.InMemory/.publicApi/net462/PublicAPI.Shipped.txt rename to src/OpenTelemetry.Exporter.InMemory/.publicApi/Stable/net462/PublicAPI.Shipped.txt diff --git a/src/OpenTelemetry.Exporter.InMemory/.publicApi/Stable/net462/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.InMemory/.publicApi/Stable/net462/PublicAPI.Unshipped.txt new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/OpenTelemetry.Exporter.InMemory/.publicApi/netstandard2.0/PublicAPI.Shipped.txt b/src/OpenTelemetry.Exporter.InMemory/.publicApi/Stable/net6.0/PublicAPI.Shipped.txt similarity index 100% rename from src/OpenTelemetry.Exporter.InMemory/.publicApi/netstandard2.0/PublicAPI.Shipped.txt rename to src/OpenTelemetry.Exporter.InMemory/.publicApi/Stable/net6.0/PublicAPI.Shipped.txt diff --git a/src/OpenTelemetry.Exporter.InMemory/.publicApi/Stable/net6.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.InMemory/.publicApi/Stable/net6.0/PublicAPI.Unshipped.txt new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/OpenTelemetry.Exporter.InMemory/.publicApi/net6.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.InMemory/.publicApi/Stable/netstandard2.0/PublicAPI.Shipped.txt similarity index 92% rename from src/OpenTelemetry.Exporter.InMemory/.publicApi/net6.0/PublicAPI.Unshipped.txt rename to src/OpenTelemetry.Exporter.InMemory/.publicApi/Stable/netstandard2.0/PublicAPI.Shipped.txt index 2d87e5058f5..499065e2d09 100644 --- a/src/OpenTelemetry.Exporter.InMemory/.publicApi/net6.0/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.Exporter.InMemory/.publicApi/Stable/netstandard2.0/PublicAPI.Shipped.txt @@ -1,25 +1,24 @@ -OpenTelemetry.Exporter.InMemoryExporter -OpenTelemetry.Exporter.InMemoryExporter.InMemoryExporter(System.Collections.Generic.ICollection exportedItems) -> void -OpenTelemetry.Logs.InMemoryExporterLoggingExtensions -OpenTelemetry.Metrics.InMemoryExporterMetricsExtensions -OpenTelemetry.Metrics.MetricSnapshot -OpenTelemetry.Metrics.MetricSnapshot.Description.get -> string -OpenTelemetry.Metrics.MetricSnapshot.MeterName.get -> string -OpenTelemetry.Metrics.MetricSnapshot.MeterVersion.get -> string -OpenTelemetry.Metrics.MetricSnapshot.MetricPoints.get -> System.Collections.Generic.IReadOnlyList -OpenTelemetry.Metrics.MetricSnapshot.MetricSnapshot(OpenTelemetry.Metrics.Metric metric) -> void -OpenTelemetry.Metrics.MetricSnapshot.MetricType.get -> OpenTelemetry.Metrics.MetricType -OpenTelemetry.Metrics.MetricSnapshot.Name.get -> string -OpenTelemetry.Metrics.MetricSnapshot.Unit.get -> string -OpenTelemetry.Trace.InMemoryExporterHelperExtensions -override OpenTelemetry.Exporter.InMemoryExporter.Dispose(bool disposing) -> void -override OpenTelemetry.Exporter.InMemoryExporter.Export(in OpenTelemetry.Batch batch) -> OpenTelemetry.ExportResult -static OpenTelemetry.Logs.InMemoryExporterLoggingExtensions.AddInMemoryExporter(this OpenTelemetry.Logs.LoggerProviderBuilder loggerProviderBuilder, System.Collections.Generic.ICollection exportedItems) -> OpenTelemetry.Logs.LoggerProviderBuilder -static OpenTelemetry.Logs.InMemoryExporterLoggingExtensions.AddInMemoryExporter(this OpenTelemetry.Logs.OpenTelemetryLoggerOptions loggerOptions, System.Collections.Generic.ICollection exportedItems) -> OpenTelemetry.Logs.OpenTelemetryLoggerOptions -static OpenTelemetry.Metrics.InMemoryExporterMetricsExtensions.AddInMemoryExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Collections.Generic.ICollection exportedItems) -> OpenTelemetry.Metrics.MeterProviderBuilder -static OpenTelemetry.Metrics.InMemoryExporterMetricsExtensions.AddInMemoryExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Collections.Generic.ICollection exportedItems, System.Action configureMetricReader) -> OpenTelemetry.Metrics.MeterProviderBuilder -static OpenTelemetry.Metrics.InMemoryExporterMetricsExtensions.AddInMemoryExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Collections.Generic.ICollection exportedItems) -> OpenTelemetry.Metrics.MeterProviderBuilder -static OpenTelemetry.Metrics.InMemoryExporterMetricsExtensions.AddInMemoryExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Collections.Generic.ICollection exportedItems, System.Action configureMetricReader) -> OpenTelemetry.Metrics.MeterProviderBuilder -static OpenTelemetry.Metrics.InMemoryExporterMetricsExtensions.AddInMemoryExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, string name, System.Collections.Generic.ICollection exportedItems, System.Action configureMetricReader) -> OpenTelemetry.Metrics.MeterProviderBuilder -static OpenTelemetry.Metrics.InMemoryExporterMetricsExtensions.AddInMemoryExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, string name, System.Collections.Generic.ICollection exportedItems, System.Action configureMetricReader) -> OpenTelemetry.Metrics.MeterProviderBuilder -static OpenTelemetry.Trace.InMemoryExporterHelperExtensions.AddInMemoryExporter(this OpenTelemetry.Trace.TracerProviderBuilder builder, System.Collections.Generic.ICollection exportedItems) -> OpenTelemetry.Trace.TracerProviderBuilder \ No newline at end of file +OpenTelemetry.Exporter.InMemoryExporter +OpenTelemetry.Exporter.InMemoryExporter.InMemoryExporter(System.Collections.Generic.ICollection exportedItems) -> void +OpenTelemetry.Logs.InMemoryExporterLoggingExtensions +OpenTelemetry.Metrics.InMemoryExporterMetricsExtensions +OpenTelemetry.Metrics.MetricSnapshot +OpenTelemetry.Metrics.MetricSnapshot.Description.get -> string +OpenTelemetry.Metrics.MetricSnapshot.MeterName.get -> string +OpenTelemetry.Metrics.MetricSnapshot.MeterVersion.get -> string +OpenTelemetry.Metrics.MetricSnapshot.MetricPoints.get -> System.Collections.Generic.IReadOnlyList +OpenTelemetry.Metrics.MetricSnapshot.MetricSnapshot(OpenTelemetry.Metrics.Metric metric) -> void +OpenTelemetry.Metrics.MetricSnapshot.MetricType.get -> OpenTelemetry.Metrics.MetricType +OpenTelemetry.Metrics.MetricSnapshot.Name.get -> string +OpenTelemetry.Metrics.MetricSnapshot.Unit.get -> string +OpenTelemetry.Trace.InMemoryExporterHelperExtensions +override OpenTelemetry.Exporter.InMemoryExporter.Dispose(bool disposing) -> void +override OpenTelemetry.Exporter.InMemoryExporter.Export(in OpenTelemetry.Batch batch) -> OpenTelemetry.ExportResult +static OpenTelemetry.Logs.InMemoryExporterLoggingExtensions.AddInMemoryExporter(this OpenTelemetry.Logs.OpenTelemetryLoggerOptions loggerOptions, System.Collections.Generic.ICollection exportedItems) -> OpenTelemetry.Logs.OpenTelemetryLoggerOptions +static OpenTelemetry.Metrics.InMemoryExporterMetricsExtensions.AddInMemoryExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, string name, System.Collections.Generic.ICollection exportedItems, System.Action configureMetricReader) -> OpenTelemetry.Metrics.MeterProviderBuilder +static OpenTelemetry.Metrics.InMemoryExporterMetricsExtensions.AddInMemoryExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, string name, System.Collections.Generic.ICollection exportedItems, System.Action configureMetricReader) -> OpenTelemetry.Metrics.MeterProviderBuilder +static OpenTelemetry.Metrics.InMemoryExporterMetricsExtensions.AddInMemoryExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Collections.Generic.ICollection exportedItems) -> OpenTelemetry.Metrics.MeterProviderBuilder +static OpenTelemetry.Metrics.InMemoryExporterMetricsExtensions.AddInMemoryExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Collections.Generic.ICollection exportedItems, System.Action configureMetricReader) -> OpenTelemetry.Metrics.MeterProviderBuilder +static OpenTelemetry.Metrics.InMemoryExporterMetricsExtensions.AddInMemoryExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Collections.Generic.ICollection exportedItems) -> OpenTelemetry.Metrics.MeterProviderBuilder +static OpenTelemetry.Metrics.InMemoryExporterMetricsExtensions.AddInMemoryExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Collections.Generic.ICollection exportedItems, System.Action configureMetricReader) -> OpenTelemetry.Metrics.MeterProviderBuilder +static OpenTelemetry.Trace.InMemoryExporterHelperExtensions.AddInMemoryExporter(this OpenTelemetry.Trace.TracerProviderBuilder builder, System.Collections.Generic.ICollection exportedItems) -> OpenTelemetry.Trace.TracerProviderBuilder diff --git a/src/OpenTelemetry.Exporter.InMemory/.publicApi/Stable/netstandard2.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.InMemory/.publicApi/Stable/netstandard2.0/PublicAPI.Unshipped.txt new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/OpenTelemetry.Exporter.InMemory/CHANGELOG.md b/src/OpenTelemetry.Exporter.InMemory/CHANGELOG.md index 2947bb52bc8..1edbdd46c20 100644 --- a/src/OpenTelemetry.Exporter.InMemory/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.InMemory/CHANGELOG.md @@ -6,8 +6,10 @@ Released 2023-Jul-12 -* Added `LoggerProviderBuilder.AddInMemoryExporter` registration extension. - ([#4584](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4584)) +* **Experimental (pre-release builds only):** Added + `LoggerProviderBuilder.AddInMemoryExporter` registration extension. + ([#4584](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4584), + [#4735](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4735)) ## 1.5.1 diff --git a/src/OpenTelemetry.Exporter.InMemory/InMemoryExporterLoggingExtensions.cs b/src/OpenTelemetry.Exporter.InMemory/InMemoryExporterLoggingExtensions.cs index 23a28319a9a..136ded44d1c 100644 --- a/src/OpenTelemetry.Exporter.InMemory/InMemoryExporterLoggingExtensions.cs +++ b/src/OpenTelemetry.Exporter.InMemory/InMemoryExporterLoggingExtensions.cs @@ -41,13 +41,25 @@ public static OpenTelemetryLoggerOptions AddInMemoryExporter( new SimpleLogRecordExportProcessor(logExporter)); } +#if EXPOSE_EXPERIMENTAL_FEATURES /// /// Adds InMemory exporter to the LoggerProviderBuilder. /// + /// WARNING: This is an experimental API which might change or be removed in the future. Use at your own risk. /// . /// Collection which will be populated with the exported . /// The supplied instance of to chain the calls. - public static LoggerProviderBuilder AddInMemoryExporter( + public +#else + /// + /// Adds InMemory exporter to the LoggerProviderBuilder. + /// + /// . + /// Collection which will be populated with the exported . + /// The supplied instance of to chain the calls. + internal +#endif + static LoggerProviderBuilder AddInMemoryExporter( this LoggerProviderBuilder loggerProviderBuilder, ICollection exportedItems) { diff --git a/src/OpenTelemetry.Exporter.InMemory/OpenTelemetry.Exporter.InMemory.csproj b/src/OpenTelemetry.Exporter.InMemory/OpenTelemetry.Exporter.InMemory.csproj index 88e23dc3e42..d026e8d970d 100644 --- a/src/OpenTelemetry.Exporter.InMemory/OpenTelemetry.Exporter.InMemory.csproj +++ b/src/OpenTelemetry.Exporter.InMemory/OpenTelemetry.Exporter.InMemory.csproj @@ -25,7 +25,7 @@ - + diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/Experimental/net462/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/Experimental/net462/PublicAPI.Unshipped.txt new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/Experimental/net6.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/Experimental/net6.0/PublicAPI.Unshipped.txt new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/Experimental/netstandard2.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/Experimental/netstandard2.0/PublicAPI.Unshipped.txt new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/Experimental/netstandard2.1/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/Experimental/netstandard2.1/PublicAPI.Unshipped.txt new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/net462/PublicAPI.Shipped.txt b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/Stable/net462/PublicAPI.Shipped.txt similarity index 100% rename from src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/net462/PublicAPI.Shipped.txt rename to src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/Stable/net462/PublicAPI.Shipped.txt diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/net462/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/Stable/net462/PublicAPI.Unshipped.txt similarity index 100% rename from src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/net462/PublicAPI.Unshipped.txt rename to src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/Stable/net462/PublicAPI.Unshipped.txt diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/net6.0/PublicAPI.Shipped.txt b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/Stable/net6.0/PublicAPI.Shipped.txt similarity index 100% rename from src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/net6.0/PublicAPI.Shipped.txt rename to src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/Stable/net6.0/PublicAPI.Shipped.txt diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/net6.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/Stable/net6.0/PublicAPI.Unshipped.txt similarity index 100% rename from src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/net6.0/PublicAPI.Unshipped.txt rename to src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/Stable/net6.0/PublicAPI.Unshipped.txt diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.0/PublicAPI.Shipped.txt b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/Stable/netstandard2.0/PublicAPI.Shipped.txt similarity index 100% rename from src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.0/PublicAPI.Shipped.txt rename to src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/Stable/netstandard2.0/PublicAPI.Shipped.txt diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/Stable/netstandard2.0/PublicAPI.Unshipped.txt similarity index 100% rename from src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt rename to src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/Stable/netstandard2.0/PublicAPI.Unshipped.txt diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.1/PublicAPI.Shipped.txt b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/Stable/netstandard2.1/PublicAPI.Shipped.txt similarity index 100% rename from src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.1/PublicAPI.Shipped.txt rename to src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/Stable/netstandard2.1/PublicAPI.Shipped.txt diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.1/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/Stable/netstandard2.1/PublicAPI.Unshipped.txt similarity index 100% rename from src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/netstandard2.1/PublicAPI.Unshipped.txt rename to src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/Stable/netstandard2.1/PublicAPI.Unshipped.txt diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md index 86a3c04ef39..fc9afc5e825 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md @@ -24,23 +24,31 @@ Released 2023-Jul-12 are now included in this package. ([#4556](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4556)) -* Add back support for Exemplars. See [exemplars](../../docs/metrics/customizing-the-sdk/README.md#exemplars) - for instructions to enable exemplars. - ([#4553](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4553)) - * Updated Grpc.Net.Client to `2.45.0` to fix unobserved exception from failed calls. ([#4573](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4573)) -* Updated to support `Severity` and `SeverityText` when exporting `LogRecord`s. - ([#4568](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4568)) - * Updated Grpc.Net.Client to `2.52.0` to address the vulnerability reported by CVE-2023-32731. Refer to [https://github.com/grpc/grpc/pull/32309](https://github.com/grpc/grpc/pull/32309) for more details. ([#4647](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4647)) +* **Experimental (pre-release builds only):** + + * Note: See + [#4735](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4735) + for the introduction of experimental api support. + + * Add back support for Exemplars. See + [exemplars](../../docs/metrics/customizing-the-sdk/README.md#exemplars) for + instructions to enable exemplars. + ([#4553](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4553)) + + * Updated to support `Severity` and `SeverityText` when exporting + `LogRecord`s. + ([#4568](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4568)) + ## 1.5.1 Released 2023-Jun-26 diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OpenTelemetry.Exporter.OpenTelemetryProtocol.csproj b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OpenTelemetry.Exporter.OpenTelemetryProtocol.csproj index 3146e3ccfd1..6342a5c789c 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OpenTelemetry.Exporter.OpenTelemetryProtocol.csproj +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OpenTelemetry.Exporter.OpenTelemetryProtocol.csproj @@ -21,17 +21,20 @@ - + - - + + + + + diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md index d5f213602a8..59b511d0187 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md @@ -58,7 +58,22 @@ environment variables. ## Enable Log Exporter -// TODO +```csharp +var loggerFactory = LoggerFactory.Create(builder => +{ + builder.AddOpenTelemetry(options => + { + options.AddOtlpExporter(); + }); +}); +``` + +By default, `AddOtlpExporter()` pairs the OTLP Log Exporter with a [batching +processor](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/sdk.md#batching-processor). +See [`TestLogs.cs`](../../examples/Console/TestLogs.cs) for example on how to +customize the `LogRecordExportProcessorOptions` or see the [Environment +Variables](#environment-variables) section below on how to customize using +environment variables. ## Configuration @@ -82,14 +97,6 @@ TODO: Show metrics specific configuration (i.e MetricReaderOptions). ## OtlpExporterOptions -* `ExportProcessorType`: Whether the exporter should use [Batch or Simple - exporting - processor](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/sdk.md#built-in-span-processors). - The default is Batch. - -* `BatchExportProcessorOptions`: Configuration options for the batch exporter. - Only used if ExportProcessorType is set to Batch. - * `Protocol`: OTLP transport protocol. Supported values: `OtlpExportProtocol.Grpc` and `OtlpExportProtocol.HttpProtobuf`. The default is `OtlpExportProtocol.Grpc`. @@ -109,6 +116,16 @@ TODO: Show metrics specific configuration (i.e MetricReaderOptions). * `TimeoutMilliseconds` : Max waiting time for the backend to process a batch. +The following options are only applicable to `OtlpTraceExporter`: + +* `ExportProcessorType`: Whether the exporter should use [Batch or Simple + exporting + processor](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/sdk.md#built-in-span-processors). + The default is Batch. + +* `BatchExportProcessorOptions`: Configuration options for the batch exporter. + Only used if ExportProcessorType is set to Batch. + See the [`TestOtlpExporter.cs`](../../examples/Console/TestOtlpExporter.cs) for an example of how to use the exporter. @@ -125,6 +142,30 @@ values of the `OtlpExporterOptions` | `OTEL_EXPORTER_OTLP_TIMEOUT` | `TimeoutMilliseconds` | | `OTEL_EXPORTER_OTLP_PROTOCOL` | `Protocol` (`grpc` or `http/protobuf`)| +The following environment variables can be used to override the default values +for `BatchExportProcessorOptions` in case of `OtlpTraceExporter` (following the +[OpenTelemetry +specification](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#batch-span-processor)) + +| Environment variable | `OtlpExporterOptions.BatchExportProcessorOptions` property | +| ---------------------------------| ------------------------------------------------------------| +| `OTEL_BSP_SCHEDULE_DELAY` | `ScheduledDelayMilliseconds` | +| `OTEL_BSP_EXPORT_TIMEOUT` | `ExporterTimeoutMilliseconds` | +| `OTEL_BSP_MAX_QUEUE_SIZE` | `MaxQueueSize` | +| `OTEL_BSP_MAX_EXPORT_BATCH_SIZE` | `MaxExportBatchSize` | + +The following environment variables can be used to override the default values +for `BatchExportProcessorOptions` in case of `OtlpLogExporter` (following the +[OpenTelemetry +specification](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#batch-logrecord-processor)) + +| Environment variable | `LogRecordExportProcessorOptions.BatchExportProcessorOptions` property | +| ----------------------------------| ------------------------------------------------------------------------| +| `OTEL_BLRP_SCHEDULE_DELAY` | `ScheduledDelayMilliseconds` | +| `OTEL_BLRP_EXPORT_TIMEOUT` | `ExporterTimeoutMilliseconds` | +| `OTEL_BLRP_MAX_QUEUE_SIZE` | `MaxQueueSize` | +| `OTEL_BLRP_MAX_EXPORT_BATCH_SIZE` | `MaxExportBatchSize` | + The following environment variables can be used to override the default values of the `PeriodicExportingMetricReaderOptions` (following the [OpenTelemetry specification](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.12.0/specification/sdk-environment-variables.md#periodic-exporting-metricreader). diff --git a/src/OpenTelemetry.Exporter.Prometheus.HttpListener/Internal/PrometheusCollectionManager.cs b/src/OpenTelemetry.Exporter.Prometheus.HttpListener/Internal/PrometheusCollectionManager.cs index aef92a6b4d3..4ecef3aaa11 100644 --- a/src/OpenTelemetry.Exporter.Prometheus.HttpListener/Internal/PrometheusCollectionManager.cs +++ b/src/OpenTelemetry.Exporter.Prometheus.HttpListener/Internal/PrometheusCollectionManager.cs @@ -143,7 +143,7 @@ private void EnterGlobalLock() [MethodImpl(MethodImplOptions.AggressiveInlining)] private void ExitGlobalLock() { - this.globalLockState = 0; + Interlocked.Exchange(ref this.globalLockState, 0); } [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/OpenTelemetry.Extensions.Hosting/.publicApi/Experimental/net462/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Extensions.Hosting/.publicApi/Experimental/net462/PublicAPI.Unshipped.txt new file mode 100644 index 00000000000..8617a4e70a1 --- /dev/null +++ b/src/OpenTelemetry.Extensions.Hosting/.publicApi/Experimental/net462/PublicAPI.Unshipped.txt @@ -0,0 +1,2 @@ +OpenTelemetry.OpenTelemetryBuilder.WithLogging() -> OpenTelemetry.OpenTelemetryBuilder! +OpenTelemetry.OpenTelemetryBuilder.WithLogging(System.Action! configure) -> OpenTelemetry.OpenTelemetryBuilder! diff --git a/src/OpenTelemetry.Extensions.Hosting/.publicApi/Experimental/net6.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Extensions.Hosting/.publicApi/Experimental/net6.0/PublicAPI.Unshipped.txt new file mode 100644 index 00000000000..8617a4e70a1 --- /dev/null +++ b/src/OpenTelemetry.Extensions.Hosting/.publicApi/Experimental/net6.0/PublicAPI.Unshipped.txt @@ -0,0 +1,2 @@ +OpenTelemetry.OpenTelemetryBuilder.WithLogging() -> OpenTelemetry.OpenTelemetryBuilder! +OpenTelemetry.OpenTelemetryBuilder.WithLogging(System.Action! configure) -> OpenTelemetry.OpenTelemetryBuilder! diff --git a/src/OpenTelemetry.Extensions.Hosting/.publicApi/Experimental/netstandard2.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Extensions.Hosting/.publicApi/Experimental/netstandard2.0/PublicAPI.Unshipped.txt new file mode 100644 index 00000000000..8617a4e70a1 --- /dev/null +++ b/src/OpenTelemetry.Extensions.Hosting/.publicApi/Experimental/netstandard2.0/PublicAPI.Unshipped.txt @@ -0,0 +1,2 @@ +OpenTelemetry.OpenTelemetryBuilder.WithLogging() -> OpenTelemetry.OpenTelemetryBuilder! +OpenTelemetry.OpenTelemetryBuilder.WithLogging(System.Action! configure) -> OpenTelemetry.OpenTelemetryBuilder! diff --git a/src/OpenTelemetry.Extensions.Hosting/.publicApi/net462/PublicAPI.Shipped.txt b/src/OpenTelemetry.Extensions.Hosting/.publicApi/Stable/net462/PublicAPI.Shipped.txt similarity index 100% rename from src/OpenTelemetry.Extensions.Hosting/.publicApi/net462/PublicAPI.Shipped.txt rename to src/OpenTelemetry.Extensions.Hosting/.publicApi/Stable/net462/PublicAPI.Shipped.txt diff --git a/src/OpenTelemetry.Extensions.Hosting/.publicApi/Stable/net462/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Extensions.Hosting/.publicApi/Stable/net462/PublicAPI.Unshipped.txt new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/OpenTelemetry.Extensions.Hosting/.publicApi/net6.0/PublicAPI.Shipped.txt b/src/OpenTelemetry.Extensions.Hosting/.publicApi/Stable/net6.0/PublicAPI.Shipped.txt similarity index 100% rename from src/OpenTelemetry.Extensions.Hosting/.publicApi/net6.0/PublicAPI.Shipped.txt rename to src/OpenTelemetry.Extensions.Hosting/.publicApi/Stable/net6.0/PublicAPI.Shipped.txt diff --git a/src/OpenTelemetry.Extensions.Hosting/.publicApi/Stable/net6.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Extensions.Hosting/.publicApi/Stable/net6.0/PublicAPI.Unshipped.txt new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/OpenTelemetry.Extensions.Hosting/.publicApi/netstandard2.0/PublicAPI.Shipped.txt b/src/OpenTelemetry.Extensions.Hosting/.publicApi/Stable/netstandard2.0/PublicAPI.Shipped.txt similarity index 100% rename from src/OpenTelemetry.Extensions.Hosting/.publicApi/netstandard2.0/PublicAPI.Shipped.txt rename to src/OpenTelemetry.Extensions.Hosting/.publicApi/Stable/netstandard2.0/PublicAPI.Shipped.txt diff --git a/src/OpenTelemetry.Extensions.Hosting/.publicApi/Stable/netstandard2.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Extensions.Hosting/.publicApi/Stable/netstandard2.0/PublicAPI.Unshipped.txt new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/OpenTelemetry.Extensions.Hosting/AssemblyInfo.cs b/src/OpenTelemetry.Extensions.Hosting/AssemblyInfo.cs index abf21ce8c15..9c25df52d83 100644 --- a/src/OpenTelemetry.Extensions.Hosting/AssemblyInfo.cs +++ b/src/OpenTelemetry.Extensions.Hosting/AssemblyInfo.cs @@ -20,13 +20,13 @@ [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2" + AssemblyInfo.MoqPublicKey)] #if SIGNED -internal static class AssemblyInfo +file static class AssemblyInfo { public const string PublicKey = ", PublicKey=002400000480000094000000060200000024000052534131000400000100010051C1562A090FB0C9F391012A32198B5E5D9A60E9B80FA2D7B434C9E5CCB7259BD606E66F9660676AFC6692B8CDC6793D190904551D2103B7B22FA636DCBB8208839785BA402EA08FC00C8F1500CCEF28BBF599AA64FFB1E1D5DC1BF3420A3777BADFE697856E9D52070A50C3EA5821C80BEF17CA3ACFFA28F89DD413F096F898"; public const string MoqPublicKey = ", PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7"; } #else -internal static class AssemblyInfo +file static class AssemblyInfo { public const string PublicKey = ""; public const string MoqPublicKey = ""; diff --git a/src/OpenTelemetry.Extensions.Hosting/CHANGELOG.md b/src/OpenTelemetry.Extensions.Hosting/CHANGELOG.md index 5019a0e3bed..f52024b2215 100644 --- a/src/OpenTelemetry.Extensions.Hosting/CHANGELOG.md +++ b/src/OpenTelemetry.Extensions.Hosting/CHANGELOG.md @@ -2,6 +2,11 @@ ## Unreleased +* **Experimental (pre-release builds only):** Added [Logs Bridge + API](https://github.com/open-telemetry/opentelemetry-specification/blob/976432b74c565e8a84af3570e9b82cb95e1d844c/specification/logs/bridge-api.md) + implementation (`OpenTelemetryBuilder.WithLogging`). + ([#4735](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4735)) + ## 1.6.0-alpha.1 Released 2023-Jul-12 diff --git a/src/OpenTelemetry.Extensions.Hosting/OpenTelemetry.Extensions.Hosting.csproj b/src/OpenTelemetry.Extensions.Hosting/OpenTelemetry.Extensions.Hosting.csproj index 82f35987c84..cff040fe290 100644 --- a/src/OpenTelemetry.Extensions.Hosting/OpenTelemetry.Extensions.Hosting.csproj +++ b/src/OpenTelemetry.Extensions.Hosting/OpenTelemetry.Extensions.Hosting.csproj @@ -22,7 +22,7 @@ - + diff --git a/src/OpenTelemetry.Extensions.Hosting/OpenTelemetryBuilder.cs b/src/OpenTelemetry.Extensions.Hosting/OpenTelemetryBuilder.cs index 1f50f76637a..805808488a1 100644 --- a/src/OpenTelemetry.Extensions.Hosting/OpenTelemetryBuilder.cs +++ b/src/OpenTelemetry.Extensions.Hosting/OpenTelemetryBuilder.cs @@ -136,19 +136,46 @@ public OpenTelemetryBuilder WithTracing(Action configure) return this; } +#if EXPOSE_EXPERIMENTAL_FEATURES /// /// Adds logging services into the builder. /// /// + /// WARNING: This is an experimental API which might change or be removed in the future. Use at your own risk. /// Note: This is safe to be called multiple times and by library authors. /// Only a single will be created for a given /// . /// /// The supplied for chaining /// calls. - internal OpenTelemetryBuilder WithLogging() + public +#else + /// + /// Adds logging services into the builder. + /// + /// + /// Note: This is safe to be called multiple times and by library authors. + /// Only a single will be created for a given + /// . + /// + /// The supplied for chaining + /// calls. + internal +#endif + OpenTelemetryBuilder WithLogging() => this.WithLogging(b => { }); +#if EXPOSE_EXPERIMENTAL_FEATURES + /// + /// Adds logging services into the builder. + /// + /// + /// + /// configuration callback. + /// The supplied for chaining + /// calls. + public +#else /// /// Adds logging services into the builder. /// @@ -157,7 +184,9 @@ internal OpenTelemetryBuilder WithLogging() /// configuration callback. /// The supplied for chaining /// calls. - internal OpenTelemetryBuilder WithLogging(Action configure) + internal +#endif + OpenTelemetryBuilder WithLogging(Action configure) { Guard.ThrowIfNull(configure); diff --git a/src/OpenTelemetry.Instrumentation.AspNetCore/.publicApi/net6.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Instrumentation.AspNetCore/.publicApi/net6.0/PublicAPI.Unshipped.txt index b65b99a84c4..88cc5073da4 100644 --- a/src/OpenTelemetry.Instrumentation.AspNetCore/.publicApi/net6.0/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.Instrumentation.AspNetCore/.publicApi/net6.0/PublicAPI.Unshipped.txt @@ -27,3 +27,4 @@ static OpenTelemetry.Metrics.MeterProviderBuilderExtensions.AddAspNetCoreInstrum static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddAspNetCoreInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder builder) -> OpenTelemetry.Trace.TracerProviderBuilder static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddAspNetCoreInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder builder, string name, System.Action configureAspNetCoreInstrumentationOptions) -> OpenTelemetry.Trace.TracerProviderBuilder static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddAspNetCoreInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder builder, System.Action configureAspNetCoreInstrumentationOptions) -> OpenTelemetry.Trace.TracerProviderBuilder +virtual OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreMetricsInstrumentationOptions.AspNetCoreMetricEnrichmentFunc.Invoke(string name, Microsoft.AspNetCore.Http.HttpContext context, ref System.Diagnostics.TagList tags) -> void diff --git a/src/OpenTelemetry.Instrumentation.AspNetCore/.publicApi/net7.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Instrumentation.AspNetCore/.publicApi/net7.0/PublicAPI.Unshipped.txt index b65b99a84c4..88cc5073da4 100644 --- a/src/OpenTelemetry.Instrumentation.AspNetCore/.publicApi/net7.0/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.Instrumentation.AspNetCore/.publicApi/net7.0/PublicAPI.Unshipped.txt @@ -27,3 +27,4 @@ static OpenTelemetry.Metrics.MeterProviderBuilderExtensions.AddAspNetCoreInstrum static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddAspNetCoreInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder builder) -> OpenTelemetry.Trace.TracerProviderBuilder static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddAspNetCoreInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder builder, string name, System.Action configureAspNetCoreInstrumentationOptions) -> OpenTelemetry.Trace.TracerProviderBuilder static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddAspNetCoreInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder builder, System.Action configureAspNetCoreInstrumentationOptions) -> OpenTelemetry.Trace.TracerProviderBuilder +virtual OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreMetricsInstrumentationOptions.AspNetCoreMetricEnrichmentFunc.Invoke(string name, Microsoft.AspNetCore.Http.HttpContext context, ref System.Diagnostics.TagList tags) -> void diff --git a/src/OpenTelemetry.Instrumentation.AspNetCore/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Instrumentation.AspNetCore/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt index 68b0a198212..0d816a0b829 100644 --- a/src/OpenTelemetry.Instrumentation.AspNetCore/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.Instrumentation.AspNetCore/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt @@ -25,3 +25,4 @@ static OpenTelemetry.Metrics.MeterProviderBuilderExtensions.AddAspNetCoreInstrum static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddAspNetCoreInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder builder) -> OpenTelemetry.Trace.TracerProviderBuilder static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddAspNetCoreInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder builder, string name, System.Action configureAspNetCoreInstrumentationOptions) -> OpenTelemetry.Trace.TracerProviderBuilder static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddAspNetCoreInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder builder, System.Action configureAspNetCoreInstrumentationOptions) -> OpenTelemetry.Trace.TracerProviderBuilder +virtual OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreMetricsInstrumentationOptions.AspNetCoreMetricEnrichmentFunc.Invoke(string name, Microsoft.AspNetCore.Http.HttpContext context, ref System.Diagnostics.TagList tags) -> void diff --git a/src/OpenTelemetry.Instrumentation.AspNetCore/.publicApi/netstandard2.1/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Instrumentation.AspNetCore/.publicApi/netstandard2.1/PublicAPI.Unshipped.txt index b65b99a84c4..88cc5073da4 100644 --- a/src/OpenTelemetry.Instrumentation.AspNetCore/.publicApi/netstandard2.1/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.Instrumentation.AspNetCore/.publicApi/netstandard2.1/PublicAPI.Unshipped.txt @@ -27,3 +27,4 @@ static OpenTelemetry.Metrics.MeterProviderBuilderExtensions.AddAspNetCoreInstrum static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddAspNetCoreInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder builder) -> OpenTelemetry.Trace.TracerProviderBuilder static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddAspNetCoreInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder builder, string name, System.Action configureAspNetCoreInstrumentationOptions) -> OpenTelemetry.Trace.TracerProviderBuilder static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddAspNetCoreInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder builder, System.Action configureAspNetCoreInstrumentationOptions) -> OpenTelemetry.Trace.TracerProviderBuilder +virtual OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreMetricsInstrumentationOptions.AspNetCoreMetricEnrichmentFunc.Invoke(string name, Microsoft.AspNetCore.Http.HttpContext context, ref System.Diagnostics.TagList tags) -> void diff --git a/src/OpenTelemetry/.publicApi/netstandard2.1/PublicAPI.Unshipped.txt b/src/OpenTelemetry/.publicApi/Experimental/net462/PublicAPI.Unshipped.txt similarity index 87% rename from src/OpenTelemetry/.publicApi/netstandard2.1/PublicAPI.Unshipped.txt rename to src/OpenTelemetry/.publicApi/Experimental/net462/PublicAPI.Unshipped.txt index e75f84d65db..c274d8400be 100644 --- a/src/OpenTelemetry/.publicApi/netstandard2.1/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry/.publicApi/Experimental/net462/PublicAPI.Unshipped.txt @@ -1,5 +1,3 @@ -OpenTelemetry.Logs.BatchExportLogRecordProcessorOptions -OpenTelemetry.Logs.BatchExportLogRecordProcessorOptions.BatchExportLogRecordProcessorOptions() -> void OpenTelemetry.Logs.LoggerProviderBuilderExtensions OpenTelemetry.Logs.LoggerProviderExtensions OpenTelemetry.Logs.LogRecord.Logger.get -> OpenTelemetry.Logs.Logger? @@ -7,12 +5,6 @@ OpenTelemetry.Logs.LogRecord.Severity.get -> OpenTelemetry.Logs.LogRecordSeverit OpenTelemetry.Logs.LogRecord.Severity.set -> void OpenTelemetry.Logs.LogRecord.SeverityText.get -> string? OpenTelemetry.Logs.LogRecord.SeverityText.set -> void -OpenTelemetry.Logs.LogRecordExportProcessorOptions -OpenTelemetry.Logs.LogRecordExportProcessorOptions.BatchExportProcessorOptions.get -> OpenTelemetry.Logs.BatchExportLogRecordProcessorOptions! -OpenTelemetry.Logs.LogRecordExportProcessorOptions.BatchExportProcessorOptions.set -> void -OpenTelemetry.Logs.LogRecordExportProcessorOptions.ExportProcessorType.get -> OpenTelemetry.ExportProcessorType -OpenTelemetry.Logs.LogRecordExportProcessorOptions.ExportProcessorType.set -> void -OpenTelemetry.Logs.LogRecordExportProcessorOptions.LogRecordExportProcessorOptions() -> void OpenTelemetry.Metrics.AlwaysOffExemplarFilter OpenTelemetry.Metrics.AlwaysOffExemplarFilter.AlwaysOffExemplarFilter() -> void OpenTelemetry.Metrics.AlwaysOnExemplarFilter diff --git a/src/OpenTelemetry/.publicApi/net462/PublicAPI.Unshipped.txt b/src/OpenTelemetry/.publicApi/Experimental/net6.0/PublicAPI.Unshipped.txt similarity index 87% rename from src/OpenTelemetry/.publicApi/net462/PublicAPI.Unshipped.txt rename to src/OpenTelemetry/.publicApi/Experimental/net6.0/PublicAPI.Unshipped.txt index e75f84d65db..c274d8400be 100644 --- a/src/OpenTelemetry/.publicApi/net462/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry/.publicApi/Experimental/net6.0/PublicAPI.Unshipped.txt @@ -1,5 +1,3 @@ -OpenTelemetry.Logs.BatchExportLogRecordProcessorOptions -OpenTelemetry.Logs.BatchExportLogRecordProcessorOptions.BatchExportLogRecordProcessorOptions() -> void OpenTelemetry.Logs.LoggerProviderBuilderExtensions OpenTelemetry.Logs.LoggerProviderExtensions OpenTelemetry.Logs.LogRecord.Logger.get -> OpenTelemetry.Logs.Logger? @@ -7,12 +5,6 @@ OpenTelemetry.Logs.LogRecord.Severity.get -> OpenTelemetry.Logs.LogRecordSeverit OpenTelemetry.Logs.LogRecord.Severity.set -> void OpenTelemetry.Logs.LogRecord.SeverityText.get -> string? OpenTelemetry.Logs.LogRecord.SeverityText.set -> void -OpenTelemetry.Logs.LogRecordExportProcessorOptions -OpenTelemetry.Logs.LogRecordExportProcessorOptions.BatchExportProcessorOptions.get -> OpenTelemetry.Logs.BatchExportLogRecordProcessorOptions! -OpenTelemetry.Logs.LogRecordExportProcessorOptions.BatchExportProcessorOptions.set -> void -OpenTelemetry.Logs.LogRecordExportProcessorOptions.ExportProcessorType.get -> OpenTelemetry.ExportProcessorType -OpenTelemetry.Logs.LogRecordExportProcessorOptions.ExportProcessorType.set -> void -OpenTelemetry.Logs.LogRecordExportProcessorOptions.LogRecordExportProcessorOptions() -> void OpenTelemetry.Metrics.AlwaysOffExemplarFilter OpenTelemetry.Metrics.AlwaysOffExemplarFilter.AlwaysOffExemplarFilter() -> void OpenTelemetry.Metrics.AlwaysOnExemplarFilter diff --git a/src/OpenTelemetry/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry/.publicApi/Experimental/netstandard2.0/PublicAPI.Unshipped.txt similarity index 87% rename from src/OpenTelemetry/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt rename to src/OpenTelemetry/.publicApi/Experimental/netstandard2.0/PublicAPI.Unshipped.txt index e75f84d65db..c274d8400be 100644 --- a/src/OpenTelemetry/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry/.publicApi/Experimental/netstandard2.0/PublicAPI.Unshipped.txt @@ -1,5 +1,3 @@ -OpenTelemetry.Logs.BatchExportLogRecordProcessorOptions -OpenTelemetry.Logs.BatchExportLogRecordProcessorOptions.BatchExportLogRecordProcessorOptions() -> void OpenTelemetry.Logs.LoggerProviderBuilderExtensions OpenTelemetry.Logs.LoggerProviderExtensions OpenTelemetry.Logs.LogRecord.Logger.get -> OpenTelemetry.Logs.Logger? @@ -7,12 +5,6 @@ OpenTelemetry.Logs.LogRecord.Severity.get -> OpenTelemetry.Logs.LogRecordSeverit OpenTelemetry.Logs.LogRecord.Severity.set -> void OpenTelemetry.Logs.LogRecord.SeverityText.get -> string? OpenTelemetry.Logs.LogRecord.SeverityText.set -> void -OpenTelemetry.Logs.LogRecordExportProcessorOptions -OpenTelemetry.Logs.LogRecordExportProcessorOptions.BatchExportProcessorOptions.get -> OpenTelemetry.Logs.BatchExportLogRecordProcessorOptions! -OpenTelemetry.Logs.LogRecordExportProcessorOptions.BatchExportProcessorOptions.set -> void -OpenTelemetry.Logs.LogRecordExportProcessorOptions.ExportProcessorType.get -> OpenTelemetry.ExportProcessorType -OpenTelemetry.Logs.LogRecordExportProcessorOptions.ExportProcessorType.set -> void -OpenTelemetry.Logs.LogRecordExportProcessorOptions.LogRecordExportProcessorOptions() -> void OpenTelemetry.Metrics.AlwaysOffExemplarFilter OpenTelemetry.Metrics.AlwaysOffExemplarFilter.AlwaysOffExemplarFilter() -> void OpenTelemetry.Metrics.AlwaysOnExemplarFilter diff --git a/src/OpenTelemetry/.publicApi/net6.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry/.publicApi/Experimental/netstandard2.1/PublicAPI.Unshipped.txt similarity index 87% rename from src/OpenTelemetry/.publicApi/net6.0/PublicAPI.Unshipped.txt rename to src/OpenTelemetry/.publicApi/Experimental/netstandard2.1/PublicAPI.Unshipped.txt index e75f84d65db..c274d8400be 100644 --- a/src/OpenTelemetry/.publicApi/net6.0/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry/.publicApi/Experimental/netstandard2.1/PublicAPI.Unshipped.txt @@ -1,5 +1,3 @@ -OpenTelemetry.Logs.BatchExportLogRecordProcessorOptions -OpenTelemetry.Logs.BatchExportLogRecordProcessorOptions.BatchExportLogRecordProcessorOptions() -> void OpenTelemetry.Logs.LoggerProviderBuilderExtensions OpenTelemetry.Logs.LoggerProviderExtensions OpenTelemetry.Logs.LogRecord.Logger.get -> OpenTelemetry.Logs.Logger? @@ -7,12 +5,6 @@ OpenTelemetry.Logs.LogRecord.Severity.get -> OpenTelemetry.Logs.LogRecordSeverit OpenTelemetry.Logs.LogRecord.Severity.set -> void OpenTelemetry.Logs.LogRecord.SeverityText.get -> string? OpenTelemetry.Logs.LogRecord.SeverityText.set -> void -OpenTelemetry.Logs.LogRecordExportProcessorOptions -OpenTelemetry.Logs.LogRecordExportProcessorOptions.BatchExportProcessorOptions.get -> OpenTelemetry.Logs.BatchExportLogRecordProcessorOptions! -OpenTelemetry.Logs.LogRecordExportProcessorOptions.BatchExportProcessorOptions.set -> void -OpenTelemetry.Logs.LogRecordExportProcessorOptions.ExportProcessorType.get -> OpenTelemetry.ExportProcessorType -OpenTelemetry.Logs.LogRecordExportProcessorOptions.ExportProcessorType.set -> void -OpenTelemetry.Logs.LogRecordExportProcessorOptions.LogRecordExportProcessorOptions() -> void OpenTelemetry.Metrics.AlwaysOffExemplarFilter OpenTelemetry.Metrics.AlwaysOffExemplarFilter.AlwaysOffExemplarFilter() -> void OpenTelemetry.Metrics.AlwaysOnExemplarFilter diff --git a/src/OpenTelemetry/.publicApi/net462/PublicAPI.Shipped.txt b/src/OpenTelemetry/.publicApi/Stable/net462/PublicAPI.Shipped.txt similarity index 100% rename from src/OpenTelemetry/.publicApi/net462/PublicAPI.Shipped.txt rename to src/OpenTelemetry/.publicApi/Stable/net462/PublicAPI.Shipped.txt diff --git a/src/OpenTelemetry/.publicApi/Stable/net462/PublicAPI.Unshipped.txt b/src/OpenTelemetry/.publicApi/Stable/net462/PublicAPI.Unshipped.txt new file mode 100644 index 00000000000..3110de1318e --- /dev/null +++ b/src/OpenTelemetry/.publicApi/Stable/net462/PublicAPI.Unshipped.txt @@ -0,0 +1,8 @@ +OpenTelemetry.Logs.BatchExportLogRecordProcessorOptions +OpenTelemetry.Logs.BatchExportLogRecordProcessorOptions.BatchExportLogRecordProcessorOptions() -> void +OpenTelemetry.Logs.LogRecordExportProcessorOptions +OpenTelemetry.Logs.LogRecordExportProcessorOptions.BatchExportProcessorOptions.get -> OpenTelemetry.Logs.BatchExportLogRecordProcessorOptions! +OpenTelemetry.Logs.LogRecordExportProcessorOptions.BatchExportProcessorOptions.set -> void +OpenTelemetry.Logs.LogRecordExportProcessorOptions.ExportProcessorType.get -> OpenTelemetry.ExportProcessorType +OpenTelemetry.Logs.LogRecordExportProcessorOptions.ExportProcessorType.set -> void +OpenTelemetry.Logs.LogRecordExportProcessorOptions.LogRecordExportProcessorOptions() -> void diff --git a/src/OpenTelemetry/.publicApi/net6.0/PublicAPI.Shipped.txt b/src/OpenTelemetry/.publicApi/Stable/net6.0/PublicAPI.Shipped.txt similarity index 100% rename from src/OpenTelemetry/.publicApi/net6.0/PublicAPI.Shipped.txt rename to src/OpenTelemetry/.publicApi/Stable/net6.0/PublicAPI.Shipped.txt diff --git a/src/OpenTelemetry/.publicApi/Stable/net6.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry/.publicApi/Stable/net6.0/PublicAPI.Unshipped.txt new file mode 100644 index 00000000000..3110de1318e --- /dev/null +++ b/src/OpenTelemetry/.publicApi/Stable/net6.0/PublicAPI.Unshipped.txt @@ -0,0 +1,8 @@ +OpenTelemetry.Logs.BatchExportLogRecordProcessorOptions +OpenTelemetry.Logs.BatchExportLogRecordProcessorOptions.BatchExportLogRecordProcessorOptions() -> void +OpenTelemetry.Logs.LogRecordExportProcessorOptions +OpenTelemetry.Logs.LogRecordExportProcessorOptions.BatchExportProcessorOptions.get -> OpenTelemetry.Logs.BatchExportLogRecordProcessorOptions! +OpenTelemetry.Logs.LogRecordExportProcessorOptions.BatchExportProcessorOptions.set -> void +OpenTelemetry.Logs.LogRecordExportProcessorOptions.ExportProcessorType.get -> OpenTelemetry.ExportProcessorType +OpenTelemetry.Logs.LogRecordExportProcessorOptions.ExportProcessorType.set -> void +OpenTelemetry.Logs.LogRecordExportProcessorOptions.LogRecordExportProcessorOptions() -> void diff --git a/src/OpenTelemetry/.publicApi/netstandard2.0/PublicAPI.Shipped.txt b/src/OpenTelemetry/.publicApi/Stable/netstandard2.0/PublicAPI.Shipped.txt similarity index 100% rename from src/OpenTelemetry/.publicApi/netstandard2.0/PublicAPI.Shipped.txt rename to src/OpenTelemetry/.publicApi/Stable/netstandard2.0/PublicAPI.Shipped.txt diff --git a/src/OpenTelemetry/.publicApi/Stable/netstandard2.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry/.publicApi/Stable/netstandard2.0/PublicAPI.Unshipped.txt new file mode 100644 index 00000000000..3110de1318e --- /dev/null +++ b/src/OpenTelemetry/.publicApi/Stable/netstandard2.0/PublicAPI.Unshipped.txt @@ -0,0 +1,8 @@ +OpenTelemetry.Logs.BatchExportLogRecordProcessorOptions +OpenTelemetry.Logs.BatchExportLogRecordProcessorOptions.BatchExportLogRecordProcessorOptions() -> void +OpenTelemetry.Logs.LogRecordExportProcessorOptions +OpenTelemetry.Logs.LogRecordExportProcessorOptions.BatchExportProcessorOptions.get -> OpenTelemetry.Logs.BatchExportLogRecordProcessorOptions! +OpenTelemetry.Logs.LogRecordExportProcessorOptions.BatchExportProcessorOptions.set -> void +OpenTelemetry.Logs.LogRecordExportProcessorOptions.ExportProcessorType.get -> OpenTelemetry.ExportProcessorType +OpenTelemetry.Logs.LogRecordExportProcessorOptions.ExportProcessorType.set -> void +OpenTelemetry.Logs.LogRecordExportProcessorOptions.LogRecordExportProcessorOptions() -> void diff --git a/src/OpenTelemetry/.publicApi/netstandard2.1/PublicAPI.Shipped.txt b/src/OpenTelemetry/.publicApi/Stable/netstandard2.1/PublicAPI.Shipped.txt similarity index 100% rename from src/OpenTelemetry/.publicApi/netstandard2.1/PublicAPI.Shipped.txt rename to src/OpenTelemetry/.publicApi/Stable/netstandard2.1/PublicAPI.Shipped.txt diff --git a/src/OpenTelemetry/.publicApi/Stable/netstandard2.1/PublicAPI.Unshipped.txt b/src/OpenTelemetry/.publicApi/Stable/netstandard2.1/PublicAPI.Unshipped.txt new file mode 100644 index 00000000000..3110de1318e --- /dev/null +++ b/src/OpenTelemetry/.publicApi/Stable/netstandard2.1/PublicAPI.Unshipped.txt @@ -0,0 +1,8 @@ +OpenTelemetry.Logs.BatchExportLogRecordProcessorOptions +OpenTelemetry.Logs.BatchExportLogRecordProcessorOptions.BatchExportLogRecordProcessorOptions() -> void +OpenTelemetry.Logs.LogRecordExportProcessorOptions +OpenTelemetry.Logs.LogRecordExportProcessorOptions.BatchExportProcessorOptions.get -> OpenTelemetry.Logs.BatchExportLogRecordProcessorOptions! +OpenTelemetry.Logs.LogRecordExportProcessorOptions.BatchExportProcessorOptions.set -> void +OpenTelemetry.Logs.LogRecordExportProcessorOptions.ExportProcessorType.get -> OpenTelemetry.ExportProcessorType +OpenTelemetry.Logs.LogRecordExportProcessorOptions.ExportProcessorType.set -> void +OpenTelemetry.Logs.LogRecordExportProcessorOptions.LogRecordExportProcessorOptions() -> void diff --git a/src/OpenTelemetry/AssemblyInfo.cs b/src/OpenTelemetry/AssemblyInfo.cs index 6b94f59eb69..ddcbfd91a8e 100644 --- a/src/OpenTelemetry/AssemblyInfo.cs +++ b/src/OpenTelemetry/AssemblyInfo.cs @@ -25,3 +25,23 @@ [assembly: InternalsVisibleTo("OpenTelemetry.Extensions.Hosting.Tests" + AssemblyInfo.PublicKey)] [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2" + AssemblyInfo.MoqPublicKey)] [assembly: InternalsVisibleTo("Benchmarks" + AssemblyInfo.PublicKey)] + +#if !EXPOSE_EXPERIMENTAL_FEATURES +[assembly: InternalsVisibleTo("OpenTelemetry.Exporter.Console" + AssemblyInfo.PublicKey)] +[assembly: InternalsVisibleTo("OpenTelemetry.Exporter.OpenTelemetryProtocol" + AssemblyInfo.PublicKey)] +[assembly: InternalsVisibleTo("OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests" + AssemblyInfo.PublicKey)] +#endif + +#if SIGNED +file static class AssemblyInfo +{ + public const string PublicKey = ", PublicKey=002400000480000094000000060200000024000052534131000400000100010051C1562A090FB0C9F391012A32198B5E5D9A60E9B80FA2D7B434C9E5CCB7259BD606E66F9660676AFC6692B8CDC6793D190904551D2103B7B22FA636DCBB8208839785BA402EA08FC00C8F1500CCEF28BBF599AA64FFB1E1D5DC1BF3420A3777BADFE697856E9D52070A50C3EA5821C80BEF17CA3ACFFA28F89DD413F096F898"; + public const string MoqPublicKey = ", PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7"; +} +#else +file static class AssemblyInfo +{ + public const string PublicKey = ""; + public const string MoqPublicKey = ""; +} +#endif diff --git a/src/OpenTelemetry/CHANGELOG.md b/src/OpenTelemetry/CHANGELOG.md index 396db7aee78..6c0f86ca9a0 100644 --- a/src/OpenTelemetry/CHANGELOG.md +++ b/src/OpenTelemetry/CHANGELOG.md @@ -2,29 +2,47 @@ ## Unreleased +* **Experimental Feature** Added an opt-in feature to aggregate any metric + measurements that were dropped due to reaching the [max MetricPoints + limit](https://github.com/open-telemetry/opentelemetry-dotnet/tree/core-1.6.0-alpha.1/docs/metrics/customizing-the-sdk). + When this feature is enabled, SDK would aggregate such measurements using a + reserved MetricPoint with a single tag with key as `otel.metric.overflow` and + value as `true`. The feature is turned-off by default. You can enable it by + setting the environment variable + `OTEL_DOTNET_EXPERIMENTAL_METRICS_EMIT_OVERFLOW_ATTRIBUTE` to `true` before + setting up the `MeterProvider`. + ([#4737](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4737)) + ## 1.6.0-alpha.1 Released 2023-Jul-12 -* Add back support for Exemplars. See [exemplars](../../docs/metrics/customizing-the-sdk/README.md#exemplars) - for instructions to enable exemplars. - ([#4553](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4553)) - -* Added [Logs Bridge - API](https://github.com/open-telemetry/opentelemetry-specification/blob/976432b74c565e8a84af3570e9b82cb95e1d844c/specification/logs/bridge-api.md) - implementation (`Sdk.CreateLoggerProviderBuilder`, etc.). - ([#4433](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4433)) - -* Obsoleted `LogRecord.LogLevel` in favor of the `LogRecord.Severity` property - which matches the [OpenTelemetry Specification > Logs DataModel > Severity - definition](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/data-model.md#field-severitynumber). - ([#4433](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4433)) - -* Added `LogRecord.Logger` property to access the [OpenTelemetry Specification > - Instrumentation - Scope](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/glossary.md#instrumentation-scope) - provided during Logger creation. - ([#4433](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4433)) +* **Experimental (pre-release builds only):** + + * Note: See + [#4735](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4735) + for the introduction of experimental api support. + + * Add back support for Exemplars. See + [exemplars](../../docs/metrics/customizing-the-sdk/README.md#exemplars) for + instructions to enable exemplars. + ([#4553](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4553)) + + * Added [Logs Bridge + API](https://github.com/open-telemetry/opentelemetry-specification/blob/976432b74c565e8a84af3570e9b82cb95e1d844c/specification/logs/bridge-api.md) + implementation (`Sdk.CreateLoggerProviderBuilder`, etc.). + ([#4433](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4433)) + + * Obsoleted `LogRecord.LogLevel` in favor of the `LogRecord.Severity` property + which matches the [OpenTelemetry Specification > Logs DataModel > Severity + definition](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/data-model.md#field-severitynumber). + ([#4433](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4433)) + + * Added `LogRecord.Logger` property to access the [OpenTelemetry Specification + Instrumentation + Scope](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/glossary.md#instrumentation-scope) + provided during Logger creation. + ([#4433](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4433)) * Fix the issue of potentially running into the `ArgumentException`: `An instance of EventSource with Guid af2d5796-946b-50cb-5f76-166a609afcbb already diff --git a/src/OpenTelemetry/Logs/Builder/LoggerProviderBuilderExtensions.cs b/src/OpenTelemetry/Logs/Builder/LoggerProviderBuilderExtensions.cs index 1f772c2411b..47813a3a1af 100644 --- a/src/OpenTelemetry/Logs/Builder/LoggerProviderBuilderExtensions.cs +++ b/src/OpenTelemetry/Logs/Builder/LoggerProviderBuilderExtensions.cs @@ -29,17 +29,39 @@ namespace OpenTelemetry.Logs; /// /// Contains extension methods for the class. /// -public static class LoggerProviderBuilderExtensions +#if EXPOSE_EXPERIMENTAL_FEATURES +public +#else +internal +#endif + static class LoggerProviderBuilderExtensions { +#if EXPOSE_EXPERIMENTAL_FEATURES + /// + /// Sets the from which the associated with + /// this provider is built from. + /// + /// + /// + /// Note: Calling will override the currently set . + /// To modify the current call instead. + /// + /// . + /// from which Resource will be built. + /// Returns for chaining. +#else /// - /// Sets the from which the Resource associated with - /// this provider is built from. Overwrites currently set ResourceBuilder. - /// You should usually use instead - /// (call if desired). + /// Sets the from which the associated with + /// this provider is built from. /// + /// + /// Note: Calling will override the currently set . + /// To modify the current call instead. + /// /// . /// from which Resource will be built. /// Returns for chaining. +#endif public static LoggerProviderBuilder SetResourceBuilder(this LoggerProviderBuilder loggerProviderBuilder, ResourceBuilder resourceBuilder) { Guard.ThrowIfNull(resourceBuilder); @@ -55,13 +77,24 @@ public static LoggerProviderBuilder SetResourceBuilder(this LoggerProviderBuilde return loggerProviderBuilder; } +#if EXPOSE_EXPERIMENTAL_FEATURES + /// + /// Modify in-place the from which the associated with + /// this provider is built from. + /// + /// + /// . + /// An action which modifies the provided in-place. + /// Returns for chaining. +#else /// - /// Modify the from which the Resource associated with - /// this provider is built from in-place. + /// Modify in-place the from which the associated with + /// this provider is built from. /// /// . /// An action which modifies the provided in-place. /// Returns for chaining. +#endif public static LoggerProviderBuilder ConfigureResource(this LoggerProviderBuilder loggerProviderBuilder, Action configure) { Guard.ThrowIfNull(configure); @@ -77,12 +110,22 @@ public static LoggerProviderBuilder ConfigureResource(this LoggerProviderBuilder return loggerProviderBuilder; } +#if EXPOSE_EXPERIMENTAL_FEATURES + /// + /// Adds a processor to the provider. + /// + /// + /// . + /// LogRecord processor to add. + /// Returns for chaining. +#else /// /// Adds a processor to the provider. /// /// . /// LogRecord processor to add. /// Returns for chaining. +#endif public static LoggerProviderBuilder AddProcessor(this LoggerProviderBuilder loggerProviderBuilder, BaseProcessor processor) { Guard.ThrowIfNull(processor); @@ -98,16 +141,30 @@ public static LoggerProviderBuilder AddProcessor(this LoggerProviderBuilder logg return loggerProviderBuilder; } +#if EXPOSE_EXPERIMENTAL_FEATURES /// /// Adds a processor to the provider which will be retrieved using dependency injection. /// /// + /// /// Note: The type specified by will be /// registered as a singleton service into application services. /// /// Processor type. /// . /// The supplied for chaining. +#else + /// + /// Adds a processor to the provider which will be retrieved using dependency injection. + /// + /// + /// Note: The type specified by will be + /// registered as a singleton service into application services. + /// + /// Processor type. + /// . + /// The supplied for chaining. +#endif public static LoggerProviderBuilder AddProcessor< #if NET6_0_OR_GREATER [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] @@ -128,12 +185,22 @@ public static LoggerProviderBuilder AddProcessor< return loggerProviderBuilder; } +#if EXPOSE_EXPERIMENTAL_FEATURES + /// + /// Adds a processor to the provider which will be retrieved using dependency injection. + /// + /// + /// . + /// The factory that creates the service. + /// The supplied for chaining. +#else /// /// Adds a processor to the provider which will be retrieved using dependency injection. /// /// . /// The factory that creates the service. /// The supplied for chaining. +#endif public static LoggerProviderBuilder AddProcessor( this LoggerProviderBuilder loggerProviderBuilder, Func> implementationFactory) @@ -151,11 +218,20 @@ public static LoggerProviderBuilder AddProcessor( return loggerProviderBuilder; } +#if EXPOSE_EXPERIMENTAL_FEATURES /// /// Run the given actions to initialize the . /// + /// /// . /// . +#else + /// + /// Run the given actions to initialize the . + /// + /// . + /// . +#endif public static LoggerProvider Build(this LoggerProviderBuilder loggerProviderBuilder) { if (loggerProviderBuilder is LoggerProviderBuilderBase loggerProviderBuilderBase) diff --git a/src/OpenTelemetry/Logs/LogRecord.cs b/src/OpenTelemetry/Logs/LogRecord.cs index 41232d5797d..6dd0a2e5f65 100644 --- a/src/OpenTelemetry/Logs/LogRecord.cs +++ b/src/OpenTelemetry/Logs/LogRecord.cs @@ -160,7 +160,9 @@ public string? CategoryName /// /// Gets or sets the log . /// +#if EXPOSE_EXPERIMENTAL_FEATURES [Obsolete("Use Severity instead. LogLevel will be removed in a future version.")] +#endif public LogLevel LogLevel { get @@ -284,29 +286,56 @@ public Exception? Exception set => this.ILoggerData.Exception = value; } +#if EXPOSE_EXPERIMENTAL_FEATURES /// /// Gets or sets the original string representation of the severity as it is /// known at the source. /// - public string? SeverityText + /// + public +#else + /// + /// Gets or sets the original string representation of the severity as it is + /// known at the source. + /// + internal +#endif + string? SeverityText { get => this.Data.SeverityText; set => this.Data.SeverityText = value; } +#if EXPOSE_EXPERIMENTAL_FEATURES /// /// Gets or sets the log . /// - public LogRecordSeverity? Severity + /// + public +#else + /// + /// Gets or sets the log . + /// + internal +#endif + LogRecordSeverity? Severity { get => this.Data.Severity; set => this.Data.Severity = value; } +#if EXPOSE_EXPERIMENTAL_FEATURES /// /// Gets the which emitted the . /// + /// public Logger? Logger { get; internal set; } +#else + /// + /// Gets or sets the which emitted the . + /// + internal Logger? Logger { get; set; } +#endif /// /// Executes callback for each currently active scope objects in order diff --git a/src/OpenTelemetry/Logs/LoggerProviderExtensions.cs b/src/OpenTelemetry/Logs/LoggerProviderExtensions.cs index da788c1e735..5fbd0f84359 100644 --- a/src/OpenTelemetry/Logs/LoggerProviderExtensions.cs +++ b/src/OpenTelemetry/Logs/LoggerProviderExtensions.cs @@ -23,12 +23,19 @@ namespace OpenTelemetry.Logs; /// /// Contains extension methods for the class. /// -public static class LoggerProviderExtensions +#if EXPOSE_EXPERIMENTAL_FEATURES +public +#else +internal +#endif + static class LoggerProviderExtensions { +#if EXPOSE_EXPERIMENTAL_FEATURES /// /// Add a processor to the . /// /// + /// /// Note: The supplied will be /// automatically disposed when then the is disposed. @@ -36,6 +43,19 @@ public static class LoggerProviderExtensions /// instance on which ForceFlush will be called. /// Log processor to add. /// The supplied for chaining. +#else + /// + /// Add a processor to the . + /// + /// + /// Note: The supplied will be + /// automatically disposed when then the is disposed. + /// + /// instance on which ForceFlush will be called. + /// Log processor to add. + /// The supplied for chaining. +#endif public static LoggerProvider AddProcessor(this LoggerProvider provider, BaseProcessor processor) { Guard.ThrowIfNull(provider); @@ -49,6 +69,27 @@ public static LoggerProvider AddProcessor(this LoggerProvider provider, BaseProc return provider; } +#if EXPOSE_EXPERIMENTAL_FEATURES + /// + /// Flushes all the processors registered under , blocks the current thread + /// until flush completed, shutdown signaled or timed out. + /// + /// instance on which ForceFlush will be called. + /// + /// The number (non-negative) of milliseconds to wait, or + /// Timeout.Infinite to wait indefinitely. + /// + /// + /// Returns true when force flush succeeded; otherwise, false. + /// + /// + /// Thrown when the timeoutMilliseconds is smaller than -1. + /// + /// + /// + /// This function guarantees thread-safety. + /// +#else /// /// Flushes all the processors registered under , blocks the current thread /// until flush completed, shutdown signaled or timed out. @@ -67,6 +108,7 @@ public static LoggerProvider AddProcessor(this LoggerProvider provider, BaseProc /// /// This function guarantees thread-safety. /// +#endif public static bool ForceFlush(this LoggerProvider provider, int timeoutMilliseconds = Timeout.Infinite) { Guard.ThrowIfNull(provider); @@ -80,6 +122,28 @@ public static bool ForceFlush(this LoggerProvider provider, int timeoutMilliseco return true; } +#if EXPOSE_EXPERIMENTAL_FEATURES + /// + /// Attempts to shutdown the , blocks the current thread until + /// shutdown completed or timed out. + /// + /// instance on which Shutdown will be called. + /// + /// The number (non-negative) of milliseconds to wait, or + /// Timeout.Infinite to wait indefinitely. + /// + /// + /// Returns true when shutdown succeeded; otherwise, false. + /// + /// + /// Thrown when the timeoutMilliseconds is smaller than -1. + /// + /// + /// + /// This function guarantees thread-safety. Only the first call will + /// win, subsequent calls will be no-op. + /// +#else /// /// Attempts to shutdown the , blocks the current thread until /// shutdown completed or timed out. @@ -99,6 +163,7 @@ public static bool ForceFlush(this LoggerProvider provider, int timeoutMilliseco /// This function guarantees thread-safety. Only the first call will /// win, subsequent calls will be no-op. /// +#endif public static bool Shutdown(this LoggerProvider provider, int timeoutMilliseconds = Timeout.Infinite) { Guard.ThrowIfNull(provider); diff --git a/src/OpenTelemetry/Metrics/AggregatorStore.cs b/src/OpenTelemetry/Metrics/AggregatorStore.cs index b0c4f673114..489f3b63c29 100644 --- a/src/OpenTelemetry/Metrics/AggregatorStore.cs +++ b/src/OpenTelemetry/Metrics/AggregatorStore.cs @@ -22,9 +22,11 @@ namespace OpenTelemetry.Metrics; internal sealed class AggregatorStore { - private static readonly string MetricPointCapHitFixMessage = "Modify instrumentation to reduce the number of unique key/value pair combinations. Or use Views to drop unwanted tags. Or use MeterProviderBuilder.SetMaxMetricPointsPerMetricStream to set higher limit."; + private static readonly string MetricPointCapHitFixMessage = "Consider opting in for the experimental SDK feature to emit all the throttled metrics under the overflow attribute by setting env variable OTEL_DOTNET_EXPERIMENTAL_METRICS_EMIT_OVERFLOW_ATTRIBUTE = true. You could also modify instrumentation to reduce the number of unique key/value pair combinations. Or use Views to drop unwanted tags. Or use MeterProviderBuilder.SetMaxMetricPointsPerMetricStream to set higher limit."; private static readonly Comparison> DimensionComparisonDelegate = (x, y) => x.Key.CompareTo(y.Key); + private readonly object lockZeroTags = new(); + private readonly object lockOverflowTag = new(); private readonly HashSet tagKeysInteresting; private readonly int tagsKeysInterestingCount; @@ -43,17 +45,21 @@ internal sealed class AggregatorStore private readonly UpdateLongDelegate updateLongCallback; private readonly UpdateDoubleDelegate updateDoubleCallback; private readonly int maxMetricPoints; + private readonly bool emitOverflowAttribute; private readonly ExemplarFilter exemplarFilter; + private int metricPointIndex = 0; private int batchSize = 0; private int metricCapHitMessageLogged; private bool zeroTagMetricPointInitialized; + private bool overflowTagMetricPointInitialized; internal AggregatorStore( MetricStreamIdentity metricStreamIdentity, AggregationType aggType, AggregationTemporality temporality, int maxMetricPoints, + bool emitOverflowAttribute, ExemplarFilter exemplarFilter = null) { this.name = metricStreamIdentity.InstrumentName; @@ -81,6 +87,15 @@ internal AggregatorStore( this.tagKeysInteresting = hs; this.tagsKeysInterestingCount = hs.Count; } + + this.emitOverflowAttribute = emitOverflowAttribute; + + if (emitOverflowAttribute) + { + // Setting metricPointIndex to 1 as we would reserve the metricPoints[1] for overflow attribute. + // Newer attributes should be added starting at the index: 2 + this.metricPointIndex = 1; + } } private delegate void UpdateLongDelegate(long value, ReadOnlySpan> tags); @@ -197,6 +212,22 @@ private void InitializeZeroTagPointIfNotInitialized() } } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private void InitializeOverflowTagPointIfNotInitialized() + { + if (!this.overflowTagMetricPointInitialized) + { + lock (this.lockOverflowTag) + { + if (!this.overflowTagMetricPointInitialized) + { + this.metricPoints[1] = new MetricPoint(this, this.aggType, new KeyValuePair[] { new("otel.metric.overflow", true) }, this.histogramBounds, this.exponentialHistogramMaxSize, this.exponentialHistogramMaxScale); + this.overflowTagMetricPointInitialized = true; + } + } + } + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] private int LookupAggregatorStore(KeyValuePair[] tagKeysAndValues, int length) { @@ -329,12 +360,21 @@ private void UpdateLong(long value, ReadOnlySpan> t var index = this.FindMetricAggregatorsDefault(tags); if (index < 0) { - if (Interlocked.CompareExchange(ref this.metricCapHitMessageLogged, 1, 0) == 0) + if (this.emitOverflowAttribute) { - OpenTelemetrySdkEventSource.Log.MeasurementDropped(this.name, this.metricPointCapHitMessage, MetricPointCapHitFixMessage); + this.InitializeOverflowTagPointIfNotInitialized(); + this.metricPoints[1].Update(value); + return; } + else + { + if (Interlocked.CompareExchange(ref this.metricCapHitMessageLogged, 1, 0) == 0) + { + OpenTelemetrySdkEventSource.Log.MeasurementDropped(this.name, this.metricPointCapHitMessage, MetricPointCapHitFixMessage); + } - return; + return; + } } // TODO: can special case built-in filters to be bit faster. @@ -361,12 +401,21 @@ private void UpdateLongCustomTags(long value, ReadOnlySpan + /// Run the given actions to initialize the . + /// + /// . + /// . + public static MeterProvider? Build(this MeterProviderBuilder meterProviderBuilder) + { + if (meterProviderBuilder is MeterProviderBuilderBase meterProviderBuilderBase) + { + return meterProviderBuilderBase.InvokeBuild(); + } + + return null; + } + +#if EXPOSE_EXPERIMENTAL_FEATURES + /// + /// Sets the to be used for this provider. + /// This is applied to all the metrics from this provider. + /// + /// + /// . + /// ExemplarFilter to use. + /// The supplied for chaining. + public +#else /// /// Sets the to be used for this provider. /// This is applied to all the metrics from this provider. @@ -317,7 +343,9 @@ public static MeterProviderBuilder ConfigureResource(this MeterProviderBuilder m /// . /// ExemplarFilter to use. /// The supplied for chaining. - public static MeterProviderBuilder SetExemplarFilter(this MeterProviderBuilder meterProviderBuilder, ExemplarFilter exemplarFilter) + internal +#endif + static MeterProviderBuilder SetExemplarFilter(this MeterProviderBuilder meterProviderBuilder, ExemplarFilter exemplarFilter) { Guard.ThrowIfNull(exemplarFilter); @@ -331,19 +359,4 @@ public static MeterProviderBuilder SetExemplarFilter(this MeterProviderBuilder m return meterProviderBuilder; } - - /// - /// Run the given actions to initialize the . - /// - /// . - /// . - public static MeterProvider? Build(this MeterProviderBuilder meterProviderBuilder) - { - if (meterProviderBuilder is MeterProviderBuilderBase meterProviderBuilderBase) - { - return meterProviderBuilderBase.InvokeBuild(); - } - - return null; - } } diff --git a/src/OpenTelemetry/Metrics/Exemplar/AlwaysOffExemplarFilter.cs b/src/OpenTelemetry/Metrics/Exemplar/AlwaysOffExemplarFilter.cs index 2d3f3cab898..88077a2b100 100644 --- a/src/OpenTelemetry/Metrics/Exemplar/AlwaysOffExemplarFilter.cs +++ b/src/OpenTelemetry/Metrics/Exemplar/AlwaysOffExemplarFilter.cs @@ -16,11 +16,21 @@ namespace OpenTelemetry.Metrics; +#if EXPOSE_EXPERIMENTAL_FEATURES /// /// An ExemplarFilter which makes no measurements eligible for being an Exemplar. /// Using this ExemplarFilter is as good as disabling Exemplar feature. /// -public sealed class AlwaysOffExemplarFilter : ExemplarFilter +/// +public +#else +/// +/// An ExemplarFilter which makes no measurements eligible for being an Exemplar. +/// Using this ExemplarFilter is as good as disabling Exemplar feature. +/// +internal +#endif + sealed class AlwaysOffExemplarFilter : ExemplarFilter { public override bool ShouldSample(long value, ReadOnlySpan> tags) { diff --git a/src/OpenTelemetry/Metrics/Exemplar/AlwaysOnExemplarFilter.cs b/src/OpenTelemetry/Metrics/Exemplar/AlwaysOnExemplarFilter.cs index 79adb9eeba3..45886c2f35c 100644 --- a/src/OpenTelemetry/Metrics/Exemplar/AlwaysOnExemplarFilter.cs +++ b/src/OpenTelemetry/Metrics/Exemplar/AlwaysOnExemplarFilter.cs @@ -16,10 +16,19 @@ namespace OpenTelemetry.Metrics; +#if EXPOSE_EXPERIMENTAL_FEATURES /// /// An ExemplarFilter which makes all measurements eligible for being an Exemplar. /// -public sealed class AlwaysOnExemplarFilter : ExemplarFilter +/// +public +#else +/// +/// An ExemplarFilter which makes all measurements eligible for being an Exemplar. +/// +internal +#endif + sealed class AlwaysOnExemplarFilter : ExemplarFilter { public override bool ShouldSample(long value, ReadOnlySpan> tags) { diff --git a/src/OpenTelemetry/Metrics/Exemplar/Exemplar.cs b/src/OpenTelemetry/Metrics/Exemplar/Exemplar.cs index 5837ca362d0..7e5352c0bc3 100644 --- a/src/OpenTelemetry/Metrics/Exemplar/Exemplar.cs +++ b/src/OpenTelemetry/Metrics/Exemplar/Exemplar.cs @@ -18,14 +18,23 @@ namespace OpenTelemetry.Metrics; -#pragma warning disable SA1623 // The property's documentation summary text should begin with: `Gets or sets` +#if EXPOSE_EXPERIMENTAL_FEATURES /// /// Represents an Exemplar data. /// -public struct Exemplar +/// WARNING: This is an experimental API which might change or be removed in the future. Use at your own risk. +public +#else +/// +/// Represents an Exemplar data. +/// +#pragma warning disable SA1623 // The property's documentation summary text should begin with: `Gets or sets` +internal +#endif + struct Exemplar { /// - /// Gets the timestamp (UTC). + /// Gets the timestamp. /// public DateTimeOffset Timestamp { get; internal set; } @@ -52,5 +61,4 @@ public struct Exemplar /// public List> FilteredTags { get; internal set; } } -#pragma warning restore SA1623 diff --git a/src/OpenTelemetry/Metrics/Exemplar/ExemplarFilter.cs b/src/OpenTelemetry/Metrics/Exemplar/ExemplarFilter.cs index 9e79570ce77..b6739989a93 100644 --- a/src/OpenTelemetry/Metrics/Exemplar/ExemplarFilter.cs +++ b/src/OpenTelemetry/Metrics/Exemplar/ExemplarFilter.cs @@ -15,10 +15,19 @@ // namespace OpenTelemetry.Metrics; +#if EXPOSE_EXPERIMENTAL_FEATURES /// /// The base class for defining Exemplar Filter. /// -public abstract class ExemplarFilter +/// +public +#else +/// +/// The base class for defining Exemplar Filter. +/// +internal +#endif + abstract class ExemplarFilter { /// /// Determines if a given measurement is eligible for being diff --git a/src/OpenTelemetry/Metrics/Exemplar/TraceBasedExemplarFilter.cs b/src/OpenTelemetry/Metrics/Exemplar/TraceBasedExemplarFilter.cs index 69c4c29e9f8..41db4a22e06 100644 --- a/src/OpenTelemetry/Metrics/Exemplar/TraceBasedExemplarFilter.cs +++ b/src/OpenTelemetry/Metrics/Exemplar/TraceBasedExemplarFilter.cs @@ -18,11 +18,21 @@ namespace OpenTelemetry.Metrics; +#if EXPOSE_EXPERIMENTAL_FEATURES /// /// An ExemplarFilter which makes those measurements eligible for being an Exemplar, /// which are recorded in the context of a sampled parent activity (span). /// -public sealed class TraceBasedExemplarFilter : ExemplarFilter +/// +public +#else +/// +/// An ExemplarFilter which makes those measurements eligible for being an Exemplar, +/// which are recorded in the context of a sampled parent activity (span). +/// +internal +#endif + sealed class TraceBasedExemplarFilter : ExemplarFilter { public override bool ShouldSample(long value, ReadOnlySpan> tags) { diff --git a/src/OpenTelemetry/Metrics/MeterProviderSdk.cs b/src/OpenTelemetry/Metrics/MeterProviderSdk.cs index 70a17fc212c..e7cbe4c99f5 100644 --- a/src/OpenTelemetry/Metrics/MeterProviderSdk.cs +++ b/src/OpenTelemetry/Metrics/MeterProviderSdk.cs @@ -19,6 +19,7 @@ using System.Diagnostics; using System.Diagnostics.Metrics; using System.Text; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using OpenTelemetry.Internal; using OpenTelemetry.Resources; @@ -32,6 +33,8 @@ internal sealed class MeterProviderSdk : MeterProvider internal int ShutdownCount; internal bool Disposed; + private const string EmitOverFlowAttributeConfigKey = "OTEL_DOTNET_EXPERIMENTAL_METRICS_EMIT_OVERFLOW_ATTRIBUTE"; + private readonly List instrumentations = new(); private readonly List> viewConfigs; private readonly object collectLock = new(); @@ -48,6 +51,9 @@ internal MeterProviderSdk( var state = serviceProvider!.GetRequiredService(); state.RegisterProvider(this); + var config = serviceProvider!.GetRequiredService(); + _ = config.TryGetBoolValue(EmitOverFlowAttributeConfigKey, out bool isEmitOverflowAttributeKeySet); + this.ServiceProvider = serviceProvider!; if (ownsServiceProvider) @@ -79,7 +85,7 @@ internal MeterProviderSdk( reader.SetParentProvider(this); reader.SetMaxMetricStreams(state.MaxMetricStreams); - reader.SetMaxMetricPointsPerMetricStream(state.MaxMetricPointsPerMetricStream); + reader.SetMaxMetricPointsPerMetricStream(state.MaxMetricPointsPerMetricStream, isEmitOverflowAttributeKeySet); reader.SetExemplarFilter(state.ExemplarFilter); if (this.reader == null) diff --git a/src/OpenTelemetry/Metrics/Metric.cs b/src/OpenTelemetry/Metrics/Metric.cs index bdfd73368e7..cc42f96ffc2 100644 --- a/src/OpenTelemetry/Metrics/Metric.cs +++ b/src/OpenTelemetry/Metrics/Metric.cs @@ -35,6 +35,7 @@ internal Metric( MetricStreamIdentity instrumentIdentity, AggregationTemporality temporality, int maxMetricPointsPerMetricStream, + bool emitOverflowAttribute, ExemplarFilter exemplarFilter = null) { this.InstrumentIdentity = instrumentIdentity; @@ -141,7 +142,7 @@ internal Metric( throw new NotSupportedException($"Unsupported Instrument Type: {instrumentIdentity.InstrumentType.FullName}"); } - this.aggStore = new AggregatorStore(instrumentIdentity, aggType, temporality, maxMetricPointsPerMetricStream, exemplarFilter); + this.aggStore = new AggregatorStore(instrumentIdentity, aggType, temporality, maxMetricPointsPerMetricStream, emitOverflowAttribute, exemplarFilter); this.Temporality = temporality; this.InstrumentDisposed = false; } diff --git a/src/OpenTelemetry/Metrics/MetricPoint.cs b/src/OpenTelemetry/Metrics/MetricPoint.cs index 35ed8dd0c44..f4fc5c5a265 100644 --- a/src/OpenTelemetry/Metrics/MetricPoint.cs +++ b/src/OpenTelemetry/Metrics/MetricPoint.cs @@ -331,12 +331,23 @@ public bool TryGetHistogramMinMaxValues(out double min, out double max) return false; } +#if EXPOSE_EXPERIMENTAL_FEATURES /// /// Gets the exemplars associated with the metric point. /// + /// /// . [MethodImpl(MethodImplOptions.AggressiveInlining)] - public readonly Exemplar[] GetExemplars() + public +#else + /// + /// Gets the exemplars associated with the metric point. + /// + /// . + [MethodImpl(MethodImplOptions.AggressiveInlining)] + internal +#endif + readonly Exemplar[] GetExemplars() { // TODO: Do not expose Exemplar data structure (array now) return this.mpComponents?.Exemplars ?? Array.Empty(); diff --git a/src/OpenTelemetry/Metrics/MetricReaderExt.cs b/src/OpenTelemetry/Metrics/MetricReaderExt.cs index fdb2781f99a..f10119dd7cb 100644 --- a/src/OpenTelemetry/Metrics/MetricReaderExt.cs +++ b/src/OpenTelemetry/Metrics/MetricReaderExt.cs @@ -33,6 +33,7 @@ public abstract partial class MetricReader private Metric[] metrics; private Metric[] metricsCurrentBatch; private int metricIndex = -1; + private bool emitOverflowAttribute; private ExemplarFilter exemplarFilter; @@ -71,7 +72,7 @@ internal Metric AddMetricWithNoViews(Instrument instrument) Metric metric = null; try { - metric = new Metric(metricStreamIdentity, this.GetAggregationTemporality(metricStreamIdentity.InstrumentType), this.maxMetricPointsPerMetricStream, exemplarFilter: this.exemplarFilter); + metric = new Metric(metricStreamIdentity, this.GetAggregationTemporality(metricStreamIdentity.InstrumentType), this.maxMetricPointsPerMetricStream, this.emitOverflowAttribute, this.exemplarFilter); } catch (NotSupportedException nse) { @@ -156,7 +157,7 @@ internal List AddMetricsListWithViews(Instrument instrument, List 1) + { + this.emitOverflowAttribute = true; + } + } } private Batch GetMetricsBatch() diff --git a/src/OpenTelemetry/Sdk.cs b/src/OpenTelemetry/Sdk.cs index dbce381b747..2d608dd76ed 100644 --- a/src/OpenTelemetry/Sdk.cs +++ b/src/OpenTelemetry/Sdk.cs @@ -70,20 +70,6 @@ public static void SetDefaultTextMapPropagator(TextMapPropagator textMapPropagat Propagators.DefaultTextMapPropagator = textMapPropagator; } - /// - /// Creates a which is used to build - /// a . In a typical application, a single - /// is created at application startup and - /// disposed at application shutdown. It is important to ensure that the - /// provider is not disposed too early. - /// - /// instance, which is used - /// to build a . - public static LoggerProviderBuilder CreateLoggerProviderBuilder() - { - return new LoggerProviderBuilderBase(); - } - /// /// Creates a which is used to build /// a . In a typical application, a single @@ -110,6 +96,35 @@ public static TracerProviderBuilder CreateTracerProviderBuilder() return new TracerProviderBuilderBase(); } +#if EXPOSE_EXPERIMENTAL_FEATURES + /// + /// Creates a which is used to build + /// a . In a typical application, a single + /// is created at application startup and + /// disposed at application shutdown. It is important to ensure that the + /// provider is not disposed too early. + /// + /// WARNING: This is an experimental API which might change or be removed in the future. Use at your own risk. + /// instance, which is used + /// to build a . + public +#else + /// + /// Creates a which is used to build + /// a . In a typical application, a single + /// is created at application startup and + /// disposed at application shutdown. It is important to ensure that the + /// provider is not disposed too early. + /// + /// instance, which is used + /// to build a . + internal +#endif + static LoggerProviderBuilder CreateLoggerProviderBuilder() + { + return new LoggerProviderBuilderBase(); + } + internal static string ParseAssemblyInformationalVersion(string? informationalVersion) { if (string.IsNullOrWhiteSpace(informationalVersion)) diff --git a/src/Shared/DiagnosticSourceInstrumentation/PropertyFetcher.cs b/src/Shared/DiagnosticSourceInstrumentation/PropertyFetcher.cs index 7bf7ea2b338..76f005fe6d7 100644 --- a/src/Shared/DiagnosticSourceInstrumentation/PropertyFetcher.cs +++ b/src/Shared/DiagnosticSourceInstrumentation/PropertyFetcher.cs @@ -14,9 +14,11 @@ // limitations under the License. // +#nullable enable +#if NET6_0_OR_GREATER +using System.Diagnostics.CodeAnalysis; +#endif using System.Reflection; -using OpenTelemetry.Internal; -#pragma warning restore IDE0005 namespace OpenTelemetry.Instrumentation; @@ -26,8 +28,11 @@ namespace OpenTelemetry.Instrumentation; /// The type of the property being fetched. internal sealed class PropertyFetcher { +#if NET6_0_OR_GREATER + private const string TrimCompatibilityMessage = "PropertyFetcher is used to access properties on objects dynamically by design and cannot be made trim compatible."; +#endif private readonly string propertyName; - private PropertyFetch innerFetcher; + private PropertyFetch? innerFetcher; /// /// Initializes a new instance of the class. @@ -38,23 +43,6 @@ public PropertyFetcher(string propertyName) this.propertyName = propertyName; } - /// - /// Fetch the property from the object. - /// - /// Object to be fetched. - /// Property fetched. - public T Fetch(object obj) - { - Guard.ThrowIfNull(obj); - - if (!this.TryFetch(obj, out T value, true)) - { - throw new ArgumentException($"Unable to fetch property: '{nameof(obj)}'", nameof(obj)); - } - - return value; - } - /// /// Try to fetch the property from the object. /// @@ -62,7 +50,10 @@ public T Fetch(object obj) /// Fetched value. /// Set this to if we know is not . /// if the property was fetched. - public bool TryFetch(object obj, out T value, bool skipObjNullCheck = false) +#if NET6_0_OR_GREATER + [RequiresUnreferencedCode(TrimCompatibilityMessage)] +#endif + public bool TryFetch(object obj, out T? value, bool skipObjNullCheck = false) { if (!skipObjNullCheck && obj == null) { @@ -70,10 +61,7 @@ public bool TryFetch(object obj, out T value, bool skipObjNullCheck = false) return false; } - if (this.innerFetcher == null) - { - this.innerFetcher = PropertyFetch.Create(obj.GetType().GetTypeInfo(), this.propertyName); - } + this.innerFetcher ??= PropertyFetch.Create(obj.GetType().GetTypeInfo(), this.propertyName); if (this.innerFetcher == null) { @@ -85,19 +73,17 @@ public bool TryFetch(object obj, out T value, bool skipObjNullCheck = false) } // see https://github.com/dotnet/corefx/blob/master/src/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/DiagnosticSourceEventSource.cs - private class PropertyFetch +#if NET6_0_OR_GREATER + [RequiresUnreferencedCode(TrimCompatibilityMessage)] +#endif + private abstract class PropertyFetch { - public static PropertyFetch Create(TypeInfo type, string propertyName) + public static PropertyFetch? Create(TypeInfo type, string propertyName) { - var property = type.DeclaredProperties.FirstOrDefault(p => string.Equals(p.Name, propertyName, StringComparison.OrdinalIgnoreCase)); - if (property == null) - { - property = type.GetProperty(propertyName); - } - + var property = type.DeclaredProperties.FirstOrDefault(p => string.Equals(p.Name, propertyName, StringComparison.OrdinalIgnoreCase)) ?? type.GetProperty(propertyName); return CreateFetcherForProperty(property); - static PropertyFetch CreateFetcherForProperty(PropertyInfo propertyInfo) + static PropertyFetch? CreateFetcherForProperty(PropertyInfo? propertyInfo) { if (propertyInfo == null || !typeof(T).IsAssignableFrom(propertyInfo.PropertyType)) { @@ -105,34 +91,86 @@ static PropertyFetch CreateFetcherForProperty(PropertyInfo propertyInfo) return null; } - var typedPropertyFetcher = typeof(TypedPropertyFetch<,>); - var instantiatedTypedPropertyFetcher = typedPropertyFetcher.MakeGenericType( - typeof(T), propertyInfo.DeclaringType, propertyInfo.PropertyType); - return (PropertyFetch)Activator.CreateInstance(instantiatedTypedPropertyFetcher, propertyInfo); - } - } + var declaringType = propertyInfo.DeclaringType; + if (declaringType!.IsValueType) + { + throw new NotSupportedException( + $"Type: {declaringType.FullName} is a value type. PropertyFetcher can only operate on reference payload types."); + } - public virtual bool TryFetch(object obj, out T value) - { - value = default; - return false; + if (declaringType == typeof(object)) + { + // TODO: REMOVE this if branch when .NET 7 is out of support. + // This branch is never executed and is only needed for .NET 7 AOT-compiler at trimming stage; i.e., + // this is not needed in .NET 8, because the compiler is improved and call into MakeGenericMethod will be AOT-compatible. + // It is used to force the AOT compiler to create an instantiation of the method with a reference type. + // The code for that instantiation can then be reused at runtime to create instantiation over any other reference. + return CreateInstantiated(propertyInfo); + } + else + { + return DynamicInstantiationHelper(declaringType, propertyInfo); + } + + // Separated as a local function to be able to target the suppression to just this call. + // IL3050 was generated here because of the call to MakeGenericType, which is problematic in AOT if one of the type parameters is a value type; + // because the compiler might need to generate code specific to that type. + // If the type parameter is a reference type, there will be no problem; because the generated code can be shared among all reference type instantiations. +#if NET6_0_OR_GREATER + [RequiresUnreferencedCode(TrimCompatibilityMessage)] + [UnconditionalSuppressMessage("AOT", "IL3050", Justification = "The code guarantees that all the generic parameters are reference types.")] +#endif + static PropertyFetch? DynamicInstantiationHelper(Type declaringType, PropertyInfo propertyInfo) + { + return (PropertyFetch?)typeof(PropertyFetch) + .GetMethod(nameof(CreateInstantiated), BindingFlags.NonPublic | BindingFlags.Static)! + .MakeGenericMethod(declaringType) // This is validated in the earlier call chain to be a reference type. + .Invoke(null, new object[] { propertyInfo })!; + } + } } - private sealed class TypedPropertyFetch : PropertyFetch - where TDeclaredProperty : T + public abstract bool TryFetch(object obj, out T? value); + + // Goal: make PropertyFetcher AOT-compatible. + // AOT compiler can't guarantee correctness when call into MakeGenericType or MakeGenericMethod + // if one of the generic parameters is a value type (reference types are OK.) + // For PropertyFetcher, the decision was made to only support reference type payloads, i.e.: + // the object from which to get the property value MUST be a reference type. + // Create generics with the declared object type as a generic parameter is OK, but we need the return type + // of the property to be a value type (on top of reference types.) + // Normally, we would have a helper class like `PropertyFetchInstantiated` that takes 2 generic parameters, + // the declared object type, and the type of the property value. + // But that would mean calling MakeGenericType, with value type parameters which AOT won't support. + // + // As a workaround, Generic instantiation was split into: + // 1. The object type comes from the PropertyFetcher generic parameter. + // Compiler supports it even if it is a value type; the type is known statically during compilation + // since PropertyFetcher is used with it. + // 2. Then, the declared object type is passed as a generic parameter to a generic method on PropertyFetcher (or nested type.) + // Therefore, calling into MakeGenericMethod will only require specifying one parameter - the declared object type. + // The declared object type is guaranteed to be a reference type (throw on value type.) Thus, MakeGenericMethod is AOT compatible. + private static PropertyFetch CreateInstantiated(PropertyInfo propertyInfo) + where TDeclaredObject : class + => new PropertyFetchInstantiated(propertyInfo); + +#if NET6_0_OR_GREATER + [RequiresUnreferencedCode(TrimCompatibilityMessage)] +#endif + private sealed class PropertyFetchInstantiated : PropertyFetch + where TDeclaredObject : class { private readonly string propertyName; - private readonly Func propertyFetch; - - private PropertyFetch innerFetcher; + private readonly Func propertyFetch; + private PropertyFetch? innerFetcher; - public TypedPropertyFetch(PropertyInfo property) + public PropertyFetchInstantiated(PropertyInfo property) { this.propertyName = property.Name; - this.propertyFetch = (Func)property.GetMethod.CreateDelegate(typeof(Func)); + this.propertyFetch = (Func)property.GetMethod!.CreateDelegate(typeof(Func)); } - public override bool TryFetch(object obj, out T value) + public override bool TryFetch(object obj, out T? value) { if (obj is TDeclaredObject o) { diff --git a/src/Shared/Options/ConfigurationExtensions.cs b/src/Shared/Options/ConfigurationExtensions.cs index 7a00025a104..c99e5d8d7d6 100644 --- a/src/Shared/Options/ConfigurationExtensions.cs +++ b/src/Shared/Options/ConfigurationExtensions.cs @@ -95,6 +95,26 @@ public static bool TryGetIntValue( return true; } + public static bool TryGetBoolValue( + this IConfiguration configuration, + string key, + out bool value) + { + if (!configuration.TryGetStringValue(key, out var stringValue)) + { + value = default; + return false; + } + + if (!bool.TryParse(stringValue, out value)) + { + LogInvalidEnvironmentVariable?.Invoke(key, stringValue!); + return false; + } + + return true; + } + public static bool TryGetValue( this IConfiguration configuration, string key, diff --git a/test/OpenTelemetry.AotCompatibility.TestApp/OpenTelemetry.AotCompatibility.TestApp.csproj b/test/OpenTelemetry.AotCompatibility.TestApp/OpenTelemetry.AotCompatibility.TestApp.csproj index 3e7f96d259d..3b5c2304ce5 100644 --- a/test/OpenTelemetry.AotCompatibility.TestApp/OpenTelemetry.AotCompatibility.TestApp.csproj +++ b/test/OpenTelemetry.AotCompatibility.TestApp/OpenTelemetry.AotCompatibility.TestApp.csproj @@ -8,6 +8,10 @@ true + + + + diff --git a/test/OpenTelemetry.AotCompatibility.TestApp/Program.cs b/test/OpenTelemetry.AotCompatibility.TestApp/Program.cs index 254ee117fbc..9f55ced44ca 100644 --- a/test/OpenTelemetry.AotCompatibility.TestApp/Program.cs +++ b/test/OpenTelemetry.AotCompatibility.TestApp/Program.cs @@ -14,4 +14,17 @@ // limitations under the License. // -Console.WriteLine("Hello, World!"); +using OpenTelemetry.AotCompatibility.TestApp; + +try +{ + PropertyFetcherAotTest.Test(); +} +catch (Exception ex) +{ + Console.WriteLine(ex); + return -1; +} + +Console.WriteLine("Passed."); +return 0; diff --git a/test/OpenTelemetry.AotCompatibility.TestApp/PropertyFetcherAotTest.cs b/test/OpenTelemetry.AotCompatibility.TestApp/PropertyFetcherAotTest.cs new file mode 100644 index 00000000000..2d3564f0427 --- /dev/null +++ b/test/OpenTelemetry.AotCompatibility.TestApp/PropertyFetcherAotTest.cs @@ -0,0 +1,69 @@ +// +// 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.Diagnostics.CodeAnalysis; +using OpenTelemetry.Instrumentation; + +namespace OpenTelemetry.AotCompatibility.TestApp; + +internal class PropertyFetcherAotTest +{ + [UnconditionalSuppressMessage("", "IL2026", Justification = "Property presence guaranteed by explicit hints.")] + public static void Test() + { + var fetcher = new PropertyFetcher("Property"); + + GuaranteeProperties(); + var r = fetcher.TryFetch(new PayloadTypeWithBaseType(), out var value); + Assert(r, "TryFetch base did not return true."); + Assert(value!.GetType() == typeof(DerivedType), "TryFetch base value is not a derived type."); + + GuaranteeProperties(); + r = fetcher.TryFetch(new PayloadTypeWithDerivedType(), out value); + Assert(r, "TryFetch derived did not return true."); + Assert(value!.GetType() == typeof(DerivedType), "TryFetch derived value is not a derived type."); + } + + private static void GuaranteeProperties<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] T>() + { + } + + private static void Assert(bool condition, string message) + { + if (!condition) + { + throw new InvalidOperationException(message); + } + } + + private class BaseType + { + } + + private class DerivedType : BaseType + { + } + + private class PayloadTypeWithBaseType + { + public BaseType Property { get; set; } = new DerivedType(); + } + + private class PayloadTypeWithDerivedType + { + public DerivedType Property { get; set; } = new DerivedType(); + } +} diff --git a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/BaseOtlpHttpExportClientTests.cs b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/BaseOtlpHttpExportClientTests.cs index ab5586c385e..6633924ef83 100644 --- a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/BaseOtlpHttpExportClientTests.cs +++ b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/BaseOtlpHttpExportClientTests.cs @@ -14,7 +14,9 @@ // limitations under the License. // +#if NETFRAMEWORK using System.Net.Http; +#endif using OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation.ExportClient; using Xunit; diff --git a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/Implementation/ExportClient/OtlpHttpTraceExportClientTests.cs b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/Implementation/ExportClient/OtlpHttpTraceExportClientTests.cs index f0bfecb030b..38e9a95ea48 100644 --- a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/Implementation/ExportClient/OtlpHttpTraceExportClientTests.cs +++ b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/Implementation/ExportClient/OtlpHttpTraceExportClientTests.cs @@ -15,9 +15,8 @@ // using System.Diagnostics; -using System.Net.Http; #if !NET6_0_OR_GREATER -using System.Threading.Tasks; +using System.Net.Http; #endif using Moq; using Moq.Protected; diff --git a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/MockCollectorIntegrationTests.cs b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/MockCollectorIntegrationTests.cs index 0cad1f777cd..8f5c287d10d 100644 --- a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/MockCollectorIntegrationTests.cs +++ b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/MockCollectorIntegrationTests.cs @@ -15,11 +15,7 @@ // #if !NETFRAMEWORK -using System.Collections.Generic; using System.Diagnostics; -using System.Linq; -using System.Net.Http; -using System.Threading.Tasks; using Grpc.Core; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; @@ -69,13 +65,13 @@ public async Task TestRecoveryAfterFailedExport() })) .StartAsync().ConfigureAwait(false); - var httpClient = new HttpClient() { BaseAddress = new System.Uri("http://localhost:5050") }; + var httpClient = new HttpClient() { BaseAddress = new Uri("http://localhost:5050") }; var codes = new[] { Grpc.Core.StatusCode.Unimplemented, Grpc.Core.StatusCode.OK }; await httpClient.GetAsync($"/MockCollector/SetResponseCodes/{string.Join(",", codes.Select(x => (int)x))}").ConfigureAwait(false); var exportResults = new List(); - var otlpExporter = new OtlpTraceExporter(new OtlpExporterOptions() { Endpoint = new System.Uri("http://localhost:4317") }); + var otlpExporter = new OtlpTraceExporter(new OtlpExporterOptions() { Endpoint = new Uri("http://localhost:4317") }); var delegatingExporter = new DelegatingExporter { OnExportFunc = (batch) => diff --git a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpExporterOptionsExtensionsTests.cs b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpExporterOptionsExtensionsTests.cs index 1fe14aa63cb..892af9ab5c0 100644 --- a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpExporterOptionsExtensionsTests.cs +++ b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpExporterOptionsExtensionsTests.cs @@ -14,7 +14,6 @@ // limitations under the License. // -using Grpc.Core; using OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation.ExportClient; using Xunit; using Xunit.Sdk; diff --git a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs index 5125094074f..ed1aa8f5fc1 100644 --- a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs +++ b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs @@ -14,7 +14,6 @@ // limitations under the License. // -using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; using System.Reflection; diff --git a/test/OpenTelemetry.Exporter.Prometheus.HttpListener.Tests/PrometheusCollectionManagerTests.cs b/test/OpenTelemetry.Exporter.Prometheus.HttpListener.Tests/PrometheusCollectionManagerTests.cs index c535121609d..1b44b854d3c 100644 --- a/test/OpenTelemetry.Exporter.Prometheus.HttpListener.Tests/PrometheusCollectionManagerTests.cs +++ b/test/OpenTelemetry.Exporter.Prometheus.HttpListener.Tests/PrometheusCollectionManagerTests.cs @@ -15,9 +15,6 @@ // using System.Diagnostics.Metrics; -#if NETFRAMEWORK -using System.Linq; -#endif using OpenTelemetry.Metrics; using OpenTelemetry.Tests; using Xunit; diff --git a/test/OpenTelemetry.Exporter.Prometheus.HttpListener.Tests/PrometheusHttpListenerTests.cs b/test/OpenTelemetry.Exporter.Prometheus.HttpListener.Tests/PrometheusHttpListenerTests.cs index 7f7889af4e5..33180e8c14b 100644 --- a/test/OpenTelemetry.Exporter.Prometheus.HttpListener.Tests/PrometheusHttpListenerTests.cs +++ b/test/OpenTelemetry.Exporter.Prometheus.HttpListener.Tests/PrometheusHttpListenerTests.cs @@ -16,7 +16,9 @@ using System.Diagnostics.Metrics; using System.Net; +#if NETFRAMEWORK using System.Net.Http; +#endif using OpenTelemetry.Metrics; using OpenTelemetry.Tests; using Xunit; diff --git a/test/OpenTelemetry.Exporter.Zipkin.Tests/ZipkinExporterTests.cs b/test/OpenTelemetry.Exporter.Zipkin.Tests/ZipkinExporterTests.cs index ef32ebc29bd..719bdc3ac29 100644 --- a/test/OpenTelemetry.Exporter.Zipkin.Tests/ZipkinExporterTests.cs +++ b/test/OpenTelemetry.Exporter.Zipkin.Tests/ZipkinExporterTests.cs @@ -17,7 +17,9 @@ using System.Collections.Concurrent; using System.Diagnostics; using System.Net; +#if NETFRAMEWORK using System.Net.Http; +#endif using System.Text; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; diff --git a/test/OpenTelemetry.Extensions.Hosting.Tests/InMemoryExporterMetricsExtensionsTests.cs b/test/OpenTelemetry.Extensions.Hosting.Tests/InMemoryExporterMetricsExtensionsTests.cs index b1b9c86ae7c..0d686b895bd 100644 --- a/test/OpenTelemetry.Extensions.Hosting.Tests/InMemoryExporterMetricsExtensionsTests.cs +++ b/test/OpenTelemetry.Extensions.Hosting.Tests/InMemoryExporterMetricsExtensionsTests.cs @@ -16,11 +16,8 @@ #if NET6_0_OR_GREATER -using System; -using System.Collections.Generic; using System.Diagnostics.Metrics; using System.Net; -using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; diff --git a/test/OpenTelemetry.Instrumentation.Grpc.Tests/GrpcTestHelpers/ClientTestHelpers.cs b/test/OpenTelemetry.Instrumentation.Grpc.Tests/GrpcTestHelpers/ClientTestHelpers.cs index cdd6eb37eaf..f2b34dee76d 100644 --- a/test/OpenTelemetry.Instrumentation.Grpc.Tests/GrpcTestHelpers/ClientTestHelpers.cs +++ b/test/OpenTelemetry.Instrumentation.Grpc.Tests/GrpcTestHelpers/ClientTestHelpers.cs @@ -14,7 +14,9 @@ // limitations under the License. // +#if NETFRAMEWORK using System.Net.Http; +#endif using System.Net.Http.Headers; using Google.Protobuf; using Grpc.Net.Compression; diff --git a/test/OpenTelemetry.Instrumentation.Grpc.Tests/GrpcTestHelpers/ResponseUtils.cs b/test/OpenTelemetry.Instrumentation.Grpc.Tests/GrpcTestHelpers/ResponseUtils.cs index 93d91ab35c9..9cc409885fb 100644 --- a/test/OpenTelemetry.Instrumentation.Grpc.Tests/GrpcTestHelpers/ResponseUtils.cs +++ b/test/OpenTelemetry.Instrumentation.Grpc.Tests/GrpcTestHelpers/ResponseUtils.cs @@ -17,7 +17,9 @@ using System.Buffers.Binary; using System.Diagnostics; using System.Net; +#if NETFRAMEWORK using System.Net.Http; +#endif using System.Net.Http.Headers; namespace OpenTelemetry.Instrumentation.Grpc.Tests.GrpcTestHelpers; diff --git a/test/OpenTelemetry.Instrumentation.Grpc.Tests/GrpcTestHelpers/TestHttpMessageHandler.cs b/test/OpenTelemetry.Instrumentation.Grpc.Tests/GrpcTestHelpers/TestHttpMessageHandler.cs index 6fb8ff727e8..e104f11acbc 100644 --- a/test/OpenTelemetry.Instrumentation.Grpc.Tests/GrpcTestHelpers/TestHttpMessageHandler.cs +++ b/test/OpenTelemetry.Instrumentation.Grpc.Tests/GrpcTestHelpers/TestHttpMessageHandler.cs @@ -14,7 +14,9 @@ // limitations under the License. // +#if NETFRAMEWORK using System.Net.Http; +#endif namespace OpenTelemetry.Instrumentation.Grpc.Tests.GrpcTestHelpers; diff --git a/test/OpenTelemetry.Instrumentation.Grpc.Tests/GrpcTestHelpers/TrailingHeadersHelpers.cs b/test/OpenTelemetry.Instrumentation.Grpc.Tests/GrpcTestHelpers/TrailingHeadersHelpers.cs index 85e016566fc..8a4f00bdd8e 100644 --- a/test/OpenTelemetry.Instrumentation.Grpc.Tests/GrpcTestHelpers/TrailingHeadersHelpers.cs +++ b/test/OpenTelemetry.Instrumentation.Grpc.Tests/GrpcTestHelpers/TrailingHeadersHelpers.cs @@ -14,7 +14,9 @@ // limitations under the License. // +#if NETFRAMEWORK using System.Net.Http; +#endif using System.Net.Http.Headers; namespace OpenTelemetry.Instrumentation.Grpc.Tests.GrpcTestHelpers; diff --git a/test/OpenTelemetry.Instrumentation.Grpc.Tests/GrpcTests.client.cs b/test/OpenTelemetry.Instrumentation.Grpc.Tests/GrpcTests.client.cs index 2598106a702..407b6d9ab39 100644 --- a/test/OpenTelemetry.Instrumentation.Grpc.Tests/GrpcTests.client.cs +++ b/test/OpenTelemetry.Instrumentation.Grpc.Tests/GrpcTests.client.cs @@ -17,12 +17,16 @@ using System.Diagnostics; using System.Net; using Greet; +#if !NETFRAMEWORK using Grpc.Core; +#endif using Grpc.Net.Client; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Moq; +#if !NETFRAMEWORK using OpenTelemetry.Context.Propagation; +#endif using OpenTelemetry.Instrumentation.Grpc.Tests.GrpcTestHelpers; using OpenTelemetry.Instrumentation.GrpcNetClient; using OpenTelemetry.Instrumentation.GrpcNetClient.Implementation; diff --git a/test/OpenTelemetry.Instrumentation.Http.Tests/HttpClientTests.Basic.cs b/test/OpenTelemetry.Instrumentation.Http.Tests/HttpClientTests.Basic.cs index 5bb2e61620b..d7b41b75359 100644 --- a/test/OpenTelemetry.Instrumentation.Http.Tests/HttpClientTests.Basic.cs +++ b/test/OpenTelemetry.Instrumentation.Http.Tests/HttpClientTests.Basic.cs @@ -17,8 +17,8 @@ using System.Diagnostics; #if NETFRAMEWORK using System.Net; -#endif using System.Net.Http; +#endif using Microsoft.Extensions.DependencyInjection; using Moq; using OpenTelemetry.Context.Propagation; diff --git a/test/OpenTelemetry.Instrumentation.Http.Tests/HttpClientTests.cs b/test/OpenTelemetry.Instrumentation.Http.Tests/HttpClientTests.cs index 2b0f0e6fe0c..0ceeaa1eb42 100644 --- a/test/OpenTelemetry.Instrumentation.Http.Tests/HttpClientTests.cs +++ b/test/OpenTelemetry.Instrumentation.Http.Tests/HttpClientTests.cs @@ -15,7 +15,9 @@ // using System.Diagnostics; +#if NETFRAMEWORK using System.Net.Http; +#endif using System.Reflection; using System.Text.Json; using Moq; diff --git a/test/OpenTelemetry.Instrumentation.Http.Tests/HttpWebRequestActivitySourceTests.netfx.cs b/test/OpenTelemetry.Instrumentation.Http.Tests/HttpWebRequestActivitySourceTests.netfx.cs index 9cc64b81e2a..5ad9f6f2d69 100644 --- a/test/OpenTelemetry.Instrumentation.Http.Tests/HttpWebRequestActivitySourceTests.netfx.cs +++ b/test/OpenTelemetry.Instrumentation.Http.Tests/HttpWebRequestActivitySourceTests.netfx.cs @@ -15,16 +15,10 @@ // #if NETFRAMEWORK -using System; using System.Collections.Concurrent; -using System.Collections.Generic; using System.Diagnostics; -using System.IO; -using System.Linq; using System.Net; using System.Net.Http; -using System.Threading; -using System.Threading.Tasks; using OpenTelemetry.Instrumentation.Http.Implementation; using OpenTelemetry.Tests; using OpenTelemetry.Trace; diff --git a/test/OpenTelemetry.Instrumentation.Http.Tests/HttpWebRequestActivitySourceTestsDupe.netfx.cs b/test/OpenTelemetry.Instrumentation.Http.Tests/HttpWebRequestActivitySourceTestsDupe.netfx.cs index c58e18a285b..268f805d298 100644 --- a/test/OpenTelemetry.Instrumentation.Http.Tests/HttpWebRequestActivitySourceTestsDupe.netfx.cs +++ b/test/OpenTelemetry.Instrumentation.Http.Tests/HttpWebRequestActivitySourceTestsDupe.netfx.cs @@ -15,16 +15,10 @@ // #if NETFRAMEWORK -using System; using System.Collections.Concurrent; -using System.Collections.Generic; using System.Diagnostics; -using System.IO; -using System.Linq; using System.Net; using System.Net.Http; -using System.Threading; -using System.Threading.Tasks; using Microsoft.Extensions.Configuration; using OpenTelemetry.Instrumentation.Http.Implementation; using OpenTelemetry.Tests; diff --git a/test/OpenTelemetry.Instrumentation.Http.Tests/HttpWebRequestActivitySourceTestsNew.netfx.cs b/test/OpenTelemetry.Instrumentation.Http.Tests/HttpWebRequestActivitySourceTestsNew.netfx.cs index 8df8faa2edd..48661f69100 100644 --- a/test/OpenTelemetry.Instrumentation.Http.Tests/HttpWebRequestActivitySourceTestsNew.netfx.cs +++ b/test/OpenTelemetry.Instrumentation.Http.Tests/HttpWebRequestActivitySourceTestsNew.netfx.cs @@ -15,16 +15,10 @@ // #if NETFRAMEWORK -using System; using System.Collections.Concurrent; -using System.Collections.Generic; using System.Diagnostics; -using System.IO; -using System.Linq; using System.Net; using System.Net.Http; -using System.Threading; -using System.Threading.Tasks; using Microsoft.Extensions.Configuration; using OpenTelemetry.Instrumentation.Http.Implementation; using OpenTelemetry.Tests; diff --git a/test/OpenTelemetry.Instrumentation.Http.Tests/HttpWebRequestTests.Basic.cs b/test/OpenTelemetry.Instrumentation.Http.Tests/HttpWebRequestTests.Basic.cs index 2c598325602..85ab9988335 100644 --- a/test/OpenTelemetry.Instrumentation.Http.Tests/HttpWebRequestTests.Basic.cs +++ b/test/OpenTelemetry.Instrumentation.Http.Tests/HttpWebRequestTests.Basic.cs @@ -16,9 +16,6 @@ using System.Diagnostics; using System.Net; -#if !NETFRAMEWORK -using System.Net.Http; -#endif using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using Moq; diff --git a/test/OpenTelemetry.Instrumentation.Http.Tests/RetryHandler.cs b/test/OpenTelemetry.Instrumentation.Http.Tests/RetryHandler.cs index 426e60e7216..1ba12c16768 100644 --- a/test/OpenTelemetry.Instrumentation.Http.Tests/RetryHandler.cs +++ b/test/OpenTelemetry.Instrumentation.Http.Tests/RetryHandler.cs @@ -14,7 +14,9 @@ // limitations under the License. // +#if NETFRAMEWORK using System.Net.Http; +#endif namespace OpenTelemetry.Tests; diff --git a/test/OpenTelemetry.Instrumentation.SqlClient.Tests/SqlClientTests.cs b/test/OpenTelemetry.Instrumentation.SqlClient.Tests/SqlClientTests.cs index cd238196b0d..7f3978429c1 100644 --- a/test/OpenTelemetry.Instrumentation.SqlClient.Tests/SqlClientTests.cs +++ b/test/OpenTelemetry.Instrumentation.SqlClient.Tests/SqlClientTests.cs @@ -19,7 +19,9 @@ using Microsoft.Data.SqlClient; using Microsoft.Extensions.DependencyInjection; using OpenTelemetry.Instrumentation.SqlClient.Implementation; +#if !NETFRAMEWORK using OpenTelemetry.Tests; +#endif using OpenTelemetry.Trace; using Xunit; diff --git a/test/OpenTelemetry.Instrumentation.SqlClient.Tests/SqlEventSourceTests.netfx.cs b/test/OpenTelemetry.Instrumentation.SqlClient.Tests/SqlEventSourceTests.netfx.cs index 3b60521456f..131f5622b02 100644 --- a/test/OpenTelemetry.Instrumentation.SqlClient.Tests/SqlEventSourceTests.netfx.cs +++ b/test/OpenTelemetry.Instrumentation.SqlClient.Tests/SqlEventSourceTests.netfx.cs @@ -15,12 +15,10 @@ // #if NETFRAMEWORK -using System; using System.Data; using System.Data.SqlClient; using System.Diagnostics; using System.Diagnostics.Tracing; -using System.Threading.Tasks; using Moq; using OpenTelemetry.Instrumentation.SqlClient.Implementation; using OpenTelemetry.Tests; diff --git a/test/OpenTelemetry.Tests/Instrumentation/PropertyFetcherTest.cs b/test/OpenTelemetry.Tests/Instrumentation/PropertyFetcherTest.cs index 73538e0fe82..a80e5f5bd97 100644 --- a/test/OpenTelemetry.Tests/Instrumentation/PropertyFetcherTest.cs +++ b/test/OpenTelemetry.Tests/Instrumentation/PropertyFetcherTest.cs @@ -78,6 +78,41 @@ public void FetchPropertyMultiplePayloadTypes_IgnoreTypesWithoutExpectedProperty Assert.Equal("A", propertyValue); } + [Fact] + public void FetchPropertyWithDerivedInstanceType() + { + var fetch = new PropertyFetcher("Property"); + + Assert.True(fetch.TryFetch(new PayloadTypeWithBaseType(), out BaseType value)); + Assert.IsType(value); + } + + [Fact] + public void FetchPropertyWithDerivedDeclaredType() + { + var fetch = new PropertyFetcher("Property"); + + Assert.True(fetch.TryFetch(new PayloadTypeWithDerivedType(), out BaseType value)); + Assert.IsType(value); + } + + [Fact] + public void FetchPropertyWhenPayloadIsValueType() + { + var fetch = new PropertyFetcher("Property"); + var ex = Assert.Throws(() => fetch.TryFetch(new PayloadTypeIsValueType(), out BaseType value)); + Assert.Contains("PropertyFetcher can only operate on reference payload types.", ex.Message); + } + + private struct PayloadTypeIsValueType + { + public PayloadTypeIsValueType() + { + } + + public DerivedType Property { get; set; } = new DerivedType(); + } + private class PayloadTypeA { public string Property { get; set; } = "A"; @@ -91,4 +126,22 @@ private class PayloadTypeB private class PayloadTypeC { } + + private class BaseType + { + } + + private class DerivedType : BaseType + { + } + + private class PayloadTypeWithBaseType + { + public BaseType Property { get; set; } = new DerivedType(); + } + + private class PayloadTypeWithDerivedType + { + public DerivedType Property { get; set; } = new DerivedType(); + } } diff --git a/test/OpenTelemetry.Tests/Metrics/AggregatorTest.cs b/test/OpenTelemetry.Tests/Metrics/AggregatorTestsBase.cs similarity index 94% rename from test/OpenTelemetry.Tests/Metrics/AggregatorTest.cs rename to test/OpenTelemetry.Tests/Metrics/AggregatorTestsBase.cs index 7d52f3cad1d..969c6890a87 100644 --- a/test/OpenTelemetry.Tests/Metrics/AggregatorTest.cs +++ b/test/OpenTelemetry.Tests/Metrics/AggregatorTestsBase.cs @@ -1,4 +1,4 @@ -// +// // Copyright The OpenTelemetry Authors // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -19,13 +19,27 @@ namespace OpenTelemetry.Metrics.Tests; -public class AggregatorTest +#pragma warning disable SA1402 + +public abstract class AggregatorTestsBase { private static readonly Meter Meter = new("testMeter"); private static readonly Instrument Instrument = Meter.CreateHistogram("testInstrument"); private static readonly ExplicitBucketHistogramConfiguration HistogramConfiguration = new() { Boundaries = Metric.DefaultHistogramBounds }; private static readonly MetricStreamIdentity MetricStreamIdentity = new(Instrument, HistogramConfiguration); - private readonly AggregatorStore aggregatorStore = new(MetricStreamIdentity, AggregationType.HistogramWithBuckets, AggregationTemporality.Cumulative, 1024); + + private readonly bool emitOverflowAttribute; + private readonly AggregatorStore aggregatorStore; + + protected AggregatorTestsBase(bool emitOverflowAttribute) + { + if (emitOverflowAttribute) + { + this.emitOverflowAttribute = emitOverflowAttribute; + } + + this.aggregatorStore = new(MetricStreamIdentity, AggregationType.HistogramWithBuckets, AggregationTemporality.Cumulative, 1024, emitOverflowAttribute); + } [Fact] public void HistogramDistributeToAllBucketsDefault() @@ -284,6 +298,7 @@ internal void ExponentialHistogramTests(AggregationType aggregationType, Aggrega aggregationType, aggregationTemporality, maxMetricPoints: 1024, + this.emitOverflowAttribute, exemplarsEnabled ? new AlwaysOnExemplarFilter() : null); var expectedHistogram = new Base2ExponentialBucketHistogram(); @@ -391,7 +406,8 @@ internal void ExponentialMaxScaleConfigWorks(int? maxScale) metricStreamIdentity, AggregationType.Base2ExponentialHistogram, AggregationTemporality.Cumulative, - maxMetricPoints: 1024); + maxMetricPoints: 1024, + this.emitOverflowAttribute); aggregatorStore.Update(10, Array.Empty>()); @@ -463,3 +479,19 @@ private class ThreadArguments public double SumOfDelta; } } + +public class AggregatorTests : AggregatorTestsBase +{ + public AggregatorTests() + : base(false) + { + } +} + +public class AggregatorTestsWithOverflowAttribute : AggregatorTestsBase +{ + public AggregatorTestsWithOverflowAttribute() + : base(true) + { + } +} diff --git a/test/OpenTelemetry.Tests/Metrics/MetricAPITest.cs b/test/OpenTelemetry.Tests/Metrics/MetricApiTestsBase.cs similarity index 98% rename from test/OpenTelemetry.Tests/Metrics/MetricAPITest.cs rename to test/OpenTelemetry.Tests/Metrics/MetricApiTestsBase.cs index 5f403456a05..bfe2229dcf5 100644 --- a/test/OpenTelemetry.Tests/Metrics/MetricAPITest.cs +++ b/test/OpenTelemetry.Tests/Metrics/MetricApiTestsBase.cs @@ -1,4 +1,4 @@ -// +// // Copyright The OpenTelemetry Authors // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -24,7 +24,9 @@ namespace OpenTelemetry.Metrics.Tests; -public class MetricApiTest : MetricTestsBase +#pragma warning disable SA1402 + +public abstract class MetricApiTestsBase : MetricTestsBase, IDisposable { private const int MaxTimeToAllowForFlush = 10000; private static readonly int NumberOfThreads = Environment.ProcessorCount; @@ -33,9 +35,14 @@ public class MetricApiTest : MetricTestsBase private static readonly int NumberOfMetricUpdateByEachThread = 100000; private readonly ITestOutputHelper output; - public MetricApiTest(ITestOutputHelper output) + protected MetricApiTestsBase(ITestOutputHelper output, bool emitOverflowAttribute) { this.output = output; + + if (emitOverflowAttribute) + { + Environment.SetEnvironmentVariable(EmitOverFlowAttributeConfigKey, "true"); + } } [Fact] @@ -1518,6 +1525,11 @@ public void UnsupportedMetricInstrument() Assert.Empty(exportedItems); } + public void Dispose() + { + Environment.SetEnvironmentVariable(EmitOverFlowAttributeConfigKey, null); + } + private static void CounterUpdateThread(object obj) where T : struct, IComparable { @@ -1689,3 +1701,19 @@ private class UpdateThreadArguments public T[] ValuesToRecord; } } + +public class MetricApiTest : MetricApiTestsBase +{ + public MetricApiTest(ITestOutputHelper output) + : base(output, false) + { + } +} + +public class MetricApiTestWithOverflowAttribute : MetricApiTestsBase +{ + public MetricApiTestWithOverflowAttribute(ITestOutputHelper output) + : base(output, true) + { + } +} diff --git a/test/OpenTelemetry.Tests/Metrics/MetricOverflowAttributeTests.cs b/test/OpenTelemetry.Tests/Metrics/MetricOverflowAttributeTests.cs new file mode 100644 index 00000000000..98f7fa05392 --- /dev/null +++ b/test/OpenTelemetry.Tests/Metrics/MetricOverflowAttributeTests.cs @@ -0,0 +1,409 @@ +// +// 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.Diagnostics.Metrics; +using System.Reflection; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using OpenTelemetry.Tests; +using Xunit; + +namespace OpenTelemetry.Metrics.Tests; + +public class MetricOverflowAttributeTests +{ + [Theory] + [InlineData("false", false)] + [InlineData("False", false)] + [InlineData("FALSE", false)] + [InlineData("true", true)] + [InlineData("True", true)] + [InlineData("TRUE", true)] + public void TestEmitOverflowAttributeConfigWithEnvVar(string value, bool isEmitOverflowAttributeKeySet) + { + try + { + Environment.SetEnvironmentVariable(MetricTestsBase.EmitOverFlowAttributeConfigKey, value); + + var exportedItems = new List(); + + var meter = new Meter(Utils.GetCurrentMethodName()); + var counter = meter.CreateCounter("TestCounter"); + + using var meterProvider = Sdk.CreateMeterProviderBuilder() + .AddMeter(meter.Name) + .AddInMemoryExporter(exportedItems) + .Build(); + + counter.Add(10); + + meterProvider.ForceFlush(); + + Assert.Single(exportedItems); + var metric = exportedItems[0]; + + var aggregatorStore = typeof(Metric).GetField("aggStore", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(metric) as AggregatorStore; + var emitOverflowAttribute = (bool)typeof(AggregatorStore).GetField("emitOverflowAttribute", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(aggregatorStore); + + Assert.Equal(isEmitOverflowAttributeKeySet, emitOverflowAttribute); + } + finally + { + Environment.SetEnvironmentVariable(MetricTestsBase.EmitOverFlowAttributeConfigKey, null); + } + } + + [Theory] + [InlineData("false", false)] + [InlineData("False", false)] + [InlineData("FALSE", false)] + [InlineData("true", true)] + [InlineData("True", true)] + [InlineData("TRUE", true)] + public void TestEmitOverflowAttributeConfigWithOtherConfigProvider(string value, bool isEmitOverflowAttributeKeySet) + { + try + { + var exportedItems = new List(); + + var meter = new Meter(Utils.GetCurrentMethodName()); + var counter = meter.CreateCounter("TestCounter"); + + using var meterProvider = Sdk.CreateMeterProviderBuilder() + .ConfigureServices(services => + { + var configuration = new ConfigurationBuilder() + .AddInMemoryCollection(new Dictionary { [MetricTestsBase.EmitOverFlowAttributeConfigKey] = value }) + .Build(); + + services.AddSingleton(configuration); + }) + .AddMeter(meter.Name) + .AddInMemoryExporter(exportedItems) + .Build(); + + counter.Add(10); + + meterProvider.ForceFlush(); + + Assert.Single(exportedItems); + var metric = exportedItems[0]; + + var aggregatorStore = typeof(Metric).GetField("aggStore", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(metric) as AggregatorStore; + var emitOverflowAttribute = (bool)typeof(AggregatorStore).GetField("emitOverflowAttribute", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(aggregatorStore); + + Assert.Equal(isEmitOverflowAttributeKeySet, emitOverflowAttribute); + } + finally + { + Environment.SetEnvironmentVariable(MetricTestsBase.EmitOverFlowAttributeConfigKey, null); + } + } + + [Theory] + [InlineData(1, false)] + [InlineData(2, true)] + [InlineData(10, true)] + public void EmitOverflowAttributeIsOnlySetWhenMaxMetricPointsIsGreaterThanOne(int maxMetricPoints, bool isEmitOverflowAttributeKeySet) + { + try + { + Environment.SetEnvironmentVariable(MetricTestsBase.EmitOverFlowAttributeConfigKey, "true"); + + var exportedItems = new List(); + + var meter = new Meter(Utils.GetCurrentMethodName()); + var counter = meter.CreateCounter("TestCounter"); + + using var meterProvider = Sdk.CreateMeterProviderBuilder() + .SetMaxMetricPointsPerMetricStream(maxMetricPoints) + .AddMeter(meter.Name) + .AddInMemoryExporter(exportedItems) + .Build(); + + counter.Add(10); + + meterProvider.ForceFlush(); + + Assert.Single(exportedItems); + var metric = exportedItems[0]; + + var aggregatorStore = typeof(Metric).GetField("aggStore", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(metric) as AggregatorStore; + var emitOverflowAttribute = (bool)typeof(AggregatorStore).GetField("emitOverflowAttribute", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(aggregatorStore); + + Assert.Equal(isEmitOverflowAttributeKeySet, emitOverflowAttribute); + } + finally + { + Environment.SetEnvironmentVariable(MetricTestsBase.EmitOverFlowAttributeConfigKey, null); + } + } + + [Theory] + [InlineData(MetricReaderTemporalityPreference.Delta)] + [InlineData(MetricReaderTemporalityPreference.Cumulative)] + public void MetricOverflowAttributeIsRecordedCorrectlyForCounter(MetricReaderTemporalityPreference temporalityPreference) + { + try + { + Environment.SetEnvironmentVariable(MetricTestsBase.EmitOverFlowAttributeConfigKey, "true"); + + var exportedItems = new List(); + + var meter = new Meter(Utils.GetCurrentMethodName()); + var counter = meter.CreateCounter("TestCounter"); + + using var meterProvider = Sdk.CreateMeterProviderBuilder() + .AddMeter(meter.Name) + .AddInMemoryExporter(exportedItems, metricReaderOptions => metricReaderOptions.TemporalityPreference = temporalityPreference) + .Build(); + + // There are two reserved MetricPoints + // 1. For zero tags + // 2. For metric overflow attribute when user opts-in for this feature + + // Max number for MetricPoints available for use when emitted with tags + int maxMetricPointsForUse = MeterProviderBuilderSdk.MaxMetricPointsPerMetricDefault - 2; + + for (int i = 0; i < maxMetricPointsForUse; i++) + { + // Emit unique key-value pairs to use up the available MetricPoints + // Once this loop is run, we have used up all available MetricPoints for metrics emitted with tags + counter.Add(10, new KeyValuePair("Key", i)); + } + + meterProvider.ForceFlush(); + + Assert.Single(exportedItems); + var metric = exportedItems[0]; + + var metricPoints = new List(); + foreach (ref readonly var mp in metric.GetMetricPoints()) + { + metricPoints.Add(mp); + } + + MetricPoint overflowMetricPoint; + + // We still have not exceeded the max MetricPoint limit + Assert.DoesNotContain(metricPoints, mp => mp.Tags.KeyAndValues[0].Key == "otel.metric.overflow"); + + exportedItems.Clear(); + metricPoints.Clear(); + + counter.Add(5, new KeyValuePair("Key", 9999)); // Emit a metric to exceed the max MetricPoint limit + + meterProvider.ForceFlush(); + metric = exportedItems[0]; + foreach (ref readonly var mp in metric.GetMetricPoints()) + { + metricPoints.Add(mp); + } + + overflowMetricPoint = metricPoints.Single(mp => mp.Tags.KeyAndValues[0].Key == "otel.metric.overflow"); + Assert.Equal(true, overflowMetricPoint.Tags.KeyAndValues[0].Value); + Assert.Equal(1, overflowMetricPoint.Tags.Count); + Assert.Equal(5, overflowMetricPoint.GetSumLong()); + + exportedItems.Clear(); + metricPoints.Clear(); + + // Emit 50 more newer MetricPoints with distinct dimension combinations + for (int i = 10000; i < 10050; i++) + { + counter.Add(5, new KeyValuePair("Key", i)); + } + + meterProvider.ForceFlush(); + metric = exportedItems[0]; + foreach (ref readonly var mp in metric.GetMetricPoints()) + { + metricPoints.Add(mp); + } + + overflowMetricPoint = metricPoints.Single(mp => mp.Tags.KeyAndValues[0].Key == "otel.metric.overflow"); + if (temporalityPreference == MetricReaderTemporalityPreference.Delta) + { + Assert.Equal(250, overflowMetricPoint.GetSumLong()); // 50 * 5 + } + else + { + Assert.Equal(255, overflowMetricPoint.GetSumLong()); // 5 + (50 * 5) + } + + exportedItems.Clear(); + metricPoints.Clear(); + + // Test that the SDK continues to correctly aggregate the previously registered measurements even after overflow has occurred + counter.Add(15, new KeyValuePair("Key", 0)); + + meterProvider.ForceFlush(); + metric = exportedItems[0]; + foreach (ref readonly var mp in metric.GetMetricPoints()) + { + metricPoints.Add(mp); + } + + var metricPoint = metricPoints.Single(mp => mp.Tags.KeyAndValues[0].Key == "Key" && (int)mp.Tags.KeyAndValues[0].Value == 0); + + if (temporalityPreference == MetricReaderTemporalityPreference.Delta) + { + Assert.Equal(15, metricPoint.GetSumLong()); + } + else + { + overflowMetricPoint = metricPoints.Single(mp => mp.Tags.KeyAndValues[0].Key == "otel.metric.overflow"); + + Assert.Equal(25, metricPoint.GetSumLong()); // 10 + 15 + Assert.Equal(255, overflowMetricPoint.GetSumLong()); + } + } + finally + { + Environment.SetEnvironmentVariable(MetricTestsBase.EmitOverFlowAttributeConfigKey, null); + } + } + + [Theory] + [InlineData(MetricReaderTemporalityPreference.Delta)] + [InlineData(MetricReaderTemporalityPreference.Cumulative)] + public void MetricOverflowAttributeIsRecordedCorrectlyForHistogram(MetricReaderTemporalityPreference temporalityPreference) + { + try + { + Environment.SetEnvironmentVariable(MetricTestsBase.EmitOverFlowAttributeConfigKey, "true"); + + var exportedItems = new List(); + + var meter = new Meter(Utils.GetCurrentMethodName()); + var histogram = meter.CreateHistogram("TestHistogram"); + + using var meterProvider = Sdk.CreateMeterProviderBuilder() + .AddMeter(meter.Name) + .AddInMemoryExporter(exportedItems, metricReaderOptions => metricReaderOptions.TemporalityPreference = temporalityPreference) + .Build(); + + // There are two reserved MetricPoints + // 1. For zero tags + // 2. For metric overflow attribute when user opts-in for this feature + + // Max number for MetricPoints available for use when emitted with tags + int maxMetricPointsForUse = MeterProviderBuilderSdk.MaxMetricPointsPerMetricDefault - 2; + + for (int i = 0; i < maxMetricPointsForUse; i++) + { + // Emit unique key-value pairs to use up the available MetricPoints + // Once this loop is run, we have used up all available MetricPoints for metrics emitted with tags + histogram.Record(10, new KeyValuePair("Key", i)); + } + + meterProvider.ForceFlush(); + + Assert.Single(exportedItems); + var metric = exportedItems[0]; + + var metricPoints = new List(); + foreach (ref readonly var mp in metric.GetMetricPoints()) + { + metricPoints.Add(mp); + } + + MetricPoint overflowMetricPoint; + + // We still have not exceeded the max MetricPoint limit + Assert.DoesNotContain(metricPoints, mp => mp.Tags.KeyAndValues[0].Key == "otel.metric.overflow"); + + exportedItems.Clear(); + metricPoints.Clear(); + + histogram.Record(5, new KeyValuePair("Key", 9999)); // Emit a metric to exceed the max MetricPoint limit + + meterProvider.ForceFlush(); + metric = exportedItems[0]; + foreach (ref readonly var mp in metric.GetMetricPoints()) + { + metricPoints.Add(mp); + } + + overflowMetricPoint = metricPoints.Single(mp => mp.Tags.KeyAndValues[0].Key == "otel.metric.overflow"); + Assert.Equal(true, overflowMetricPoint.Tags.KeyAndValues[0].Value); + Assert.Equal(1, overflowMetricPoint.GetHistogramCount()); + Assert.Equal(5, overflowMetricPoint.GetHistogramSum()); + + exportedItems.Clear(); + metricPoints.Clear(); + + // Emit 50 more newer MetricPoints with distinct dimension combinations + for (int i = 10000; i < 10050; i++) + { + histogram.Record(5, new KeyValuePair("Key", i)); + } + + meterProvider.ForceFlush(); + metric = exportedItems[0]; + foreach (ref readonly var mp in metric.GetMetricPoints()) + { + metricPoints.Add(mp); + } + + overflowMetricPoint = metricPoints.Single(mp => mp.Tags.KeyAndValues[0].Key == "otel.metric.overflow"); + if (temporalityPreference == MetricReaderTemporalityPreference.Delta) + { + Assert.Equal(50, overflowMetricPoint.GetHistogramCount()); + Assert.Equal(250, overflowMetricPoint.GetHistogramSum()); // 50 * 5 + } + else + { + Assert.Equal(51, overflowMetricPoint.GetHistogramCount()); + Assert.Equal(255, overflowMetricPoint.GetHistogramSum()); // 5 + (50 * 5) + } + + exportedItems.Clear(); + metricPoints.Clear(); + + // Test that the SDK continues to correctly aggregate the previously registered measurements even after overflow has occurred + histogram.Record(15, new KeyValuePair("Key", 0)); + + meterProvider.ForceFlush(); + metric = exportedItems[0]; + foreach (ref readonly var mp in metric.GetMetricPoints()) + { + metricPoints.Add(mp); + } + + var metricPoint = metricPoints.Single(mp => mp.Tags.KeyAndValues[0].Key == "Key" && (int)mp.Tags.KeyAndValues[0].Value == 0); + + if (temporalityPreference == MetricReaderTemporalityPreference.Delta) + { + Assert.Equal(1, metricPoint.GetHistogramCount()); + Assert.Equal(15, metricPoint.GetHistogramSum()); + } + else + { + overflowMetricPoint = metricPoints.Single(mp => mp.Tags.KeyAndValues[0].Key == "otel.metric.overflow"); + + Assert.Equal(2, metricPoint.GetHistogramCount()); + Assert.Equal(25, metricPoint.GetHistogramSum()); // 10 + 15 + + Assert.Equal(255, overflowMetricPoint.GetHistogramSum()); + } + } + finally + { + Environment.SetEnvironmentVariable(MetricTestsBase.EmitOverFlowAttributeConfigKey, null); + } + } +} diff --git a/test/OpenTelemetry.Tests/Metrics/MetricSnapshotTests.cs b/test/OpenTelemetry.Tests/Metrics/MetricSnapshotTestsBase.cs similarity index 89% rename from test/OpenTelemetry.Tests/Metrics/MetricSnapshotTests.cs rename to test/OpenTelemetry.Tests/Metrics/MetricSnapshotTestsBase.cs index 37043198aef..dc0810fd338 100644 --- a/test/OpenTelemetry.Tests/Metrics/MetricSnapshotTests.cs +++ b/test/OpenTelemetry.Tests/Metrics/MetricSnapshotTestsBase.cs @@ -1,4 +1,4 @@ -// +// // Copyright The OpenTelemetry Authors // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -22,8 +22,18 @@ namespace OpenTelemetry.Metrics.Tests; -public class MetricSnapshotTests +#pragma warning disable SA1402 + +public abstract class MetricSnapshotTestsBase : IDisposable { + protected MetricSnapshotTestsBase(bool emitOverflowAttribute) + { + if (emitOverflowAttribute) + { + Environment.SetEnvironmentVariable(MetricTestsBase.EmitOverFlowAttributeConfigKey, "true"); + } + } + [Fact] public void VerifySnapshot_Counter() { @@ -87,7 +97,9 @@ public void VerifySnapshot_Counter() // Verify Snapshot 2 Assert.Equal(2, exportedSnapshots.Count); var snapshot2 = exportedSnapshots[1]; + Assert.Single(snapshot2.MetricPoints); + Assert.Equal(15, snapshot2.MetricPoints[0].GetSumLong()); } @@ -214,7 +226,7 @@ public void VerifySnapshot_ExponentialHistogram() metricPoint1.TryGetHistogramMinMaxValues(out var min, out var max); Assert.Equal(10, min); Assert.Equal(10, max); - AggregatorTest.AssertExponentialBucketsAreCorrect(expectedHistogram, metricPoint1.GetExponentialHistogramData()); + AggregatorTestsBase.AssertExponentialBucketsAreCorrect(expectedHistogram, metricPoint1.GetExponentialHistogramData()); // Verify Snapshot 1 Assert.Single(exportedSnapshots); @@ -225,7 +237,7 @@ public void VerifySnapshot_ExponentialHistogram() snapshot1.MetricPoints[0].TryGetHistogramMinMaxValues(out min, out max); Assert.Equal(10, min); Assert.Equal(10, max); - AggregatorTest.AssertExponentialBucketsAreCorrect(expectedHistogram, snapshot1.MetricPoints[0].GetExponentialHistogramData()); + AggregatorTestsBase.AssertExponentialBucketsAreCorrect(expectedHistogram, snapshot1.MetricPoints[0].GetExponentialHistogramData()); // Verify Metric == Snapshot Assert.Equal(metric1.Name, snapshot1.Name); @@ -259,7 +271,7 @@ public void VerifySnapshot_ExponentialHistogram() metricPoint1.TryGetHistogramMinMaxValues(out min, out max); Assert.Equal(5, min); Assert.Equal(10, max); - AggregatorTest.AssertExponentialBucketsAreCorrect(expectedHistogram, metricPoint2.GetExponentialHistogramData()); + AggregatorTestsBase.AssertExponentialBucketsAreCorrect(expectedHistogram, metricPoint2.GetExponentialHistogramData()); // Verify Snapshot 1 after second export // This value is expected to be unchanged. @@ -278,6 +290,27 @@ public void VerifySnapshot_ExponentialHistogram() snapshot2.MetricPoints[0].TryGetHistogramMinMaxValues(out min, out max); Assert.Equal(5, min); Assert.Equal(10, max); - AggregatorTest.AssertExponentialBucketsAreCorrect(expectedHistogram, snapshot2.MetricPoints[0].GetExponentialHistogramData()); + AggregatorTestsBase.AssertExponentialBucketsAreCorrect(expectedHistogram, snapshot2.MetricPoints[0].GetExponentialHistogramData()); + } + + public void Dispose() + { + Environment.SetEnvironmentVariable(MetricTestsBase.EmitOverFlowAttributeConfigKey, null); + } +} + +public class MetricSnapshotTests : MetricSnapshotTestsBase +{ + public MetricSnapshotTests() + : base(false) + { + } +} + +public class MetricSnapshotTestsWithOverflowAttribute : MetricSnapshotTestsBase +{ + public MetricSnapshotTestsWithOverflowAttribute() + : base(true) + { } } diff --git a/test/OpenTelemetry.Tests/Metrics/MetricTestsBase.cs b/test/OpenTelemetry.Tests/Metrics/MetricTestsBase.cs index 181027e37a2..85c1b2c0817 100644 --- a/test/OpenTelemetry.Tests/Metrics/MetricTestsBase.cs +++ b/test/OpenTelemetry.Tests/Metrics/MetricTestsBase.cs @@ -20,6 +20,8 @@ namespace OpenTelemetry.Metrics.Tests; public class MetricTestsBase { + public const string EmitOverFlowAttributeConfigKey = "OTEL_DOTNET_EXPERIMENTAL_METRICS_EMIT_OVERFLOW_ATTRIBUTE"; + public static void ValidateMetricPointTags(List> expectedTags, ReadOnlyTagCollection actualTags) { int tagIndex = 0; diff --git a/test/OpenTelemetry.Tests/Metrics/MetricViewTests.cs b/test/OpenTelemetry.Tests/Metrics/MetricViewTests.cs index 82cc2c57aff..df98fc6cc2a 100644 --- a/test/OpenTelemetry.Tests/Metrics/MetricViewTests.cs +++ b/test/OpenTelemetry.Tests/Metrics/MetricViewTests.cs @@ -636,7 +636,7 @@ public void ViewToProduceExponentialHistogram() var count = metricPoint.GetHistogramCount(); var sum = metricPoint.GetHistogramSum(); - AggregatorTest.AssertExponentialBucketsAreCorrect(expectedHistogram, metricPoint.GetExponentialHistogramData()); + AggregatorTestsBase.AssertExponentialBucketsAreCorrect(expectedHistogram, metricPoint.GetExponentialHistogramData()); Assert.Equal(50, sum); Assert.Equal(6, count); }