diff --git a/build/Common.nonprod.props b/build/Common.nonprod.props
index 7f617c45496..6de6e014c88 100644
--- a/build/Common.nonprod.props
+++ b/build/Common.nonprod.props
@@ -44,4 +44,24 @@
+
+
+
+
+
+
+
+
+
+ $(DefineConstants);@(CompilerConstantsForDependenciesWithExposedExperimentalFeatures)
+
+
diff --git a/build/Common.prod.props b/build/Common.prod.props
index 011f7d9b313..2f7b7cc900f 100644
--- a/build/Common.prod.props
+++ b/build/Common.prod.props
@@ -39,6 +39,10 @@
+
@@ -82,6 +86,15 @@
$(DefineConstants);EXPOSE_EXPERIMENTAL_FEATURES
+
+
+
diff --git a/docs/diagnostics/experimental-apis/OTEL1000.md b/docs/diagnostics/experimental-apis/OTEL1000.md
index 1ea4be023a3..28b8147293c 100644
--- a/docs/diagnostics/experimental-apis/OTEL1000.md
+++ b/docs/diagnostics/experimental-apis/OTEL1000.md
@@ -4,11 +4,17 @@
This is an Experimental API diagnostic covering the following APIs:
+* `ILoggingBuilder.UseOpenTelemetry`
+
+Experimental APIs may be changed or removed in the future.
+
+The following portions of `OTEL1000` were released stable in `1.9.0` and are no
+longer considered experimental:
+
* `LoggerProviderBuilder`
* `LoggerProvider`
* `IDeferredLoggerProviderBuilder`
-
-Experimental APIs may be changed or removed in the future.
+* `OpenTelemetryBuilder.WithLogging`
## Details
diff --git a/docs/diagnostics/experimental-apis/OTEL1001.md b/docs/diagnostics/experimental-apis/OTEL1001.md
index 5386726e644..aeb8952630c 100644
--- a/docs/diagnostics/experimental-apis/OTEL1001.md
+++ b/docs/diagnostics/experimental-apis/OTEL1001.md
@@ -9,6 +9,7 @@ This is an Experimental API diagnostic covering the following APIs:
* `LogRecordAttributeList`
* `LogRecordData`
* `LogRecordSeverity`
+* `Sdk.CreateLoggerProviderBuilder`
Experimental APIs may be changed or removed in the future.
diff --git a/docs/logs/dedicated-pipeline/DedicatedLogging/DedicatedLoggingServiceCollectionExtensions.cs b/docs/logs/dedicated-pipeline/DedicatedLogging/DedicatedLoggingServiceCollectionExtensions.cs
index 538f23b5cb4..c9343185e21 100644
--- a/docs/logs/dedicated-pipeline/DedicatedLogging/DedicatedLoggingServiceCollectionExtensions.cs
+++ b/docs/logs/dedicated-pipeline/DedicatedLogging/DedicatedLoggingServiceCollectionExtensions.cs
@@ -11,20 +11,25 @@ public static class DedicatedLoggingServiceCollectionExtensions
public static IServiceCollection AddDedicatedLogging(
this IServiceCollection services,
IConfiguration configuration,
- Action configureOpenTelemetry)
+ Action configureOpenTelemetry)
{
ArgumentNullException.ThrowIfNull(configureOpenTelemetry);
- services.TryAddSingleton(sp =>
+ services.TryAddSingleton(_ =>
{
- var loggerFactory = LoggerFactory.Create(builder =>
+ var services = new ServiceCollection();
+ services.AddLogging(builder =>
{
builder.AddConfiguration(configuration);
- builder.AddOpenTelemetry(configureOpenTelemetry);
+ builder.AddOpenTelemetry();
});
- return new DedicatedLoggerFactory(loggerFactory);
+ services.ConfigureOpenTelemetryLoggerProvider(configureOpenTelemetry);
+
+ var sp = services.BuildServiceProvider();
+
+ return new DedicatedLoggerFactory(sp);
});
services.TryAdd(ServiceDescriptor.Singleton(typeof(IDedicatedLogger<>), typeof(DedicatedLogger<>)));
@@ -54,11 +59,13 @@ public void Log(LogLevel logLevel, EventId eventId, TState state, Except
private sealed class DedicatedLoggerFactory : ILoggerFactory
{
+ private readonly ServiceProvider serviceProvider;
private readonly ILoggerFactory innerLoggerFactory;
- public DedicatedLoggerFactory(ILoggerFactory loggerFactory)
+ public DedicatedLoggerFactory(ServiceProvider serviceProvider)
{
- this.innerLoggerFactory = loggerFactory;
+ this.serviceProvider = serviceProvider;
+ this.innerLoggerFactory = serviceProvider.GetRequiredService();
}
public void AddProvider(ILoggerProvider provider)
@@ -68,6 +75,6 @@ public ILogger CreateLogger(string categoryName)
=> this.innerLoggerFactory.CreateLogger(categoryName);
public void Dispose()
- => this.innerLoggerFactory.Dispose();
+ => this.serviceProvider.Dispose();
}
}
diff --git a/docs/logs/dedicated-pipeline/Program.cs b/docs/logs/dedicated-pipeline/Program.cs
index ad671445cde..c465c77d0d3 100644
--- a/docs/logs/dedicated-pipeline/Program.cs
+++ b/docs/logs/dedicated-pipeline/Program.cs
@@ -8,18 +8,19 @@
builder.Logging.ClearProviders();
-builder.Logging.AddOpenTelemetry(options =>
-{
- // Set up primary pipeline for common app logs
- options.AddConsoleExporter();
-});
+builder.Services.AddOpenTelemetry()
+ .WithLogging(logging =>
+ {
+ // Set up primary pipeline for common app logs
+ logging.AddConsoleExporter();
+ });
builder.Services.AddDedicatedLogging(
builder.Configuration.GetSection("DedicatedLogging"), // Bind configuration for dedicated logging pipeline
- options =>
+ logging =>
{
// Set up secondary pipeline for dedicated logs
- options.AddConsoleExporter();
+ logging.AddConsoleExporter();
});
var app = builder.Build();
diff --git a/docs/logs/getting-started-aspnetcore/Program.cs b/docs/logs/getting-started-aspnetcore/Program.cs
index 179d9d2237a..123bf54a2c9 100644
--- a/docs/logs/getting-started-aspnetcore/Program.cs
+++ b/docs/logs/getting-started-aspnetcore/Program.cs
@@ -6,25 +6,21 @@
var builder = WebApplication.CreateBuilder(args);
-// Remove default providers and add OpenTelemetry logging provider.
-// For instructional purposes only, disable the default .NET console logging provider to
-// use the verbose OpenTelemetry console exporter instead. For most development
-// and production scenarios the default console provider works well and there is no need to
+// For instructional purposes only, disable the default .NET logging providers.
+// We remove the console logging provider in this demo to use the verbose
+// OpenTelemetry console exporter instead. For most development and production
+// scenarios the default console provider works well and there is no need to
// clear these providers.
builder.Logging.ClearProviders();
-builder.Logging.AddOpenTelemetry(logging =>
-{
- var resourceBuilder = ResourceBuilder
- .CreateDefault()
- .AddService(builder.Environment.ApplicationName);
-
- logging.SetResourceBuilder(resourceBuilder)
-
- // ConsoleExporter is used for demo purpose only.
- // In production environment, ConsoleExporter should be replaced with other exporters (e.g. OTLP Exporter).
- .AddConsoleExporter();
-});
+// Add OpenTelemetry logging provider by calling the WithLogging extension.
+builder.Services.AddOpenTelemetry()
+ .ConfigureResource(r => r.AddService(builder.Environment.ApplicationName))
+ .WithLogging(logging => logging
+ /* Note: ConsoleExporter is used for demo purpose only. In production
+ environment, ConsoleExporter should be replaced with other exporters
+ (e.g. OTLP Exporter). */
+ .AddConsoleExporter());
var app = builder.Build();
diff --git a/examples/AspNetCore/Program.cs b/examples/AspNetCore/Program.cs
index 89ac46932dc..809534f5c76 100644
--- a/examples/AspNetCore/Program.cs
+++ b/examples/AspNetCore/Program.cs
@@ -24,20 +24,21 @@
// Note: Switch between Explicit/Exponential by setting HistogramAggregation in appsettings.json
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", defaultValue: "otel-test")!,
- serviceVersion: typeof(Program).Assembly.GetName().Version?.ToString() ?? "unknown",
- serviceInstanceId: Environment.MachineName);
-
// Create a service to expose ActivitySource, and Metric Instruments
// for manual instrumentation
appBuilder.Services.AddSingleton();
-// Configure OpenTelemetry tracing & metrics with auto-start using the
+// Clear default logging providers used by WebApplication host.
+appBuilder.Logging.ClearProviders();
+
+// Configure OpenTelemetry logging, metrics, & tracing with auto-start using the
// AddOpenTelemetry extension from OpenTelemetry.Extensions.Hosting.
appBuilder.Services.AddOpenTelemetry()
- .ConfigureResource(configureResource)
+ .ConfigureResource(r => r
+ .AddService(
+ serviceName: appBuilder.Configuration.GetValue("ServiceName", defaultValue: "otel-test")!,
+ serviceVersion: typeof(Program).Assembly.GetName().Version?.ToString() ?? "unknown",
+ serviceInstanceId: Environment.MachineName))
.WithTracing(builder =>
{
// Tracing
@@ -121,34 +122,25 @@
builder.AddConsoleExporter();
break;
}
- });
-
-// Clear default logging providers used by WebApplication host.
-appBuilder.Logging.ClearProviders();
-
-// Configure OpenTelemetry Logging.
-appBuilder.Logging.AddOpenTelemetry(options =>
-{
- // Note: See appsettings.json Logging:OpenTelemetry section for configuration.
-
- var resourceBuilder = ResourceBuilder.CreateDefault();
- configureResource(resourceBuilder);
- options.SetResourceBuilder(resourceBuilder);
-
- switch (logExporter)
+ })
+ .WithLogging(builder =>
{
- case "otlp":
- options.AddOtlpExporter(otlpOptions =>
- {
- // Use IConfiguration directly for Otlp exporter endpoint option.
- otlpOptions.Endpoint = new Uri(appBuilder.Configuration.GetValue("Otlp:Endpoint", defaultValue: "http://localhost:4317")!);
- });
- break;
- default:
- options.AddConsoleExporter();
- break;
- }
-});
+ // Note: See appsettings.json Logging:OpenTelemetry section for configuration.
+
+ switch (logExporter)
+ {
+ case "otlp":
+ builder.AddOtlpExporter(otlpOptions =>
+ {
+ // Use IConfiguration directly for Otlp exporter endpoint option.
+ otlpOptions.Endpoint = new Uri(appBuilder.Configuration.GetValue("Otlp:Endpoint", defaultValue: "http://localhost:4317")!);
+ });
+ break;
+ default:
+ builder.AddConsoleExporter();
+ break;
+ }
+ });
appBuilder.Services.AddControllers();
diff --git a/src/OpenTelemetry.Api.ProviderBuilderExtensions/.publicApi/Experimental/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Api.ProviderBuilderExtensions/.publicApi/Experimental/PublicAPI.Unshipped.txt
index a0f2e472dd6..e69de29bb2d 100644
--- a/src/OpenTelemetry.Api.ProviderBuilderExtensions/.publicApi/Experimental/PublicAPI.Unshipped.txt
+++ b/src/OpenTelemetry.Api.ProviderBuilderExtensions/.publicApi/Experimental/PublicAPI.Unshipped.txt
@@ -1,9 +0,0 @@
-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/Stable/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Api.ProviderBuilderExtensions/.publicApi/Stable/PublicAPI.Unshipped.txt
index e69de29bb2d..a0f2e472dd6 100644
--- a/src/OpenTelemetry.Api.ProviderBuilderExtensions/.publicApi/Stable/PublicAPI.Unshipped.txt
+++ b/src/OpenTelemetry.Api.ProviderBuilderExtensions/.publicApi/Stable/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/CHANGELOG.md b/src/OpenTelemetry.Api.ProviderBuilderExtensions/CHANGELOG.md
index 1f2a27b7f38..9d22648cde4 100644
--- a/src/OpenTelemetry.Api.ProviderBuilderExtensions/CHANGELOG.md
+++ b/src/OpenTelemetry.Api.ProviderBuilderExtensions/CHANGELOG.md
@@ -2,6 +2,12 @@
## Unreleased
+* The experimental APIs previously covered by `OTEL1000`
+ (`LoggerProviderBuilder` `AddInstrumentation` & `ConfigureServices` extensions
+ and `IServiceCollection.ConfigureOpenTelemetryLoggerProvider` extension) will
+ now be part of the public API and supported in stable builds.
+ ([#5648](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5648))
+
## 1.9.0-alpha.1
Released 2024-May-20
diff --git a/src/OpenTelemetry.Api.ProviderBuilderExtensions/Logs/OpenTelemetryDependencyInjectionLoggerProviderBuilderExtensions.cs b/src/OpenTelemetry.Api.ProviderBuilderExtensions/Logs/OpenTelemetryDependencyInjectionLoggerProviderBuilderExtensions.cs
index 257b7332bec..c3105bc4c08 100644
--- a/src/OpenTelemetry.Api.ProviderBuilderExtensions/Logs/OpenTelemetryDependencyInjectionLoggerProviderBuilderExtensions.cs
+++ b/src/OpenTelemetry.Api.ProviderBuilderExtensions/Logs/OpenTelemetryDependencyInjectionLoggerProviderBuilderExtensions.cs
@@ -13,40 +13,18 @@ namespace OpenTelemetry.Logs;
///
/// Contains extension methods for the class.
///
-#if EXPOSE_EXPERIMENTAL_FEATURES
-#if NET8_0_OR_GREATER
-[Experimental(DiagnosticDefinitions.LoggerProviderExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)]
-#endif
-public
-#else
-internal
-#endif
-static class OpenTelemetryDependencyInjectionLoggerProviderBuilderExtensions
+public 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.
- ///
- ///
- /// Note: The type specified by will be
- /// registered as a singleton service into application services.
- ///
- /// Instrumentation type.
- /// .
- /// The supplied for chaining.
-#endif
public static LoggerProviderBuilder AddInstrumentation<
#if NET6_0_OR_GREATER
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)]
@@ -64,24 +42,13 @@ 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
{
@@ -95,24 +62,13 @@ 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.
- ///
- /// Instrumentation type.
- /// .
- /// Instrumentation factory.
- /// The supplied for chaining.
-#endif
public static LoggerProviderBuilder AddInstrumentation(
this LoggerProviderBuilder loggerProviderBuilder,
Func instrumentationFactory)
@@ -128,16 +84,6 @@ 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.
///
@@ -145,7 +91,6 @@ public static LoggerProviderBuilder AddInstrumentation(
/// .
/// Instrumentation factory.
/// The supplied for chaining.
-#endif
public static LoggerProviderBuilder AddInstrumentation(
this LoggerProviderBuilder loggerProviderBuilder,
Func instrumentationFactory)
@@ -165,32 +110,17 @@ 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 8e6f899b24e..8d33a420a61 100644
--- a/src/OpenTelemetry.Api.ProviderBuilderExtensions/Logs/OpenTelemetryDependencyInjectionLoggingServiceCollectionExtensions.cs
+++ b/src/OpenTelemetry.Api.ProviderBuilderExtensions/Logs/OpenTelemetryDependencyInjectionLoggingServiceCollectionExtensions.cs
@@ -1,9 +1,6 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
-#if EXPOSE_EXPERIMENTAL_FEATURES && NET8_0_OR_GREATER
-using System.Diagnostics.CodeAnalysis;
-#endif
using Microsoft.Extensions.DependencyInjection;
using OpenTelemetry.Internal;
@@ -12,23 +9,13 @@ namespace OpenTelemetry.Logs;
///
/// Extension methods for setting up OpenTelemetry logging services in an .
///
-#if EXPOSE_EXPERIMENTAL_FEATURES
-#if NET8_0_OR_GREATER
-[Experimental(DiagnosticDefinitions.LoggerProviderExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)]
-#endif
-public
-#else
-internal
-#endif
-static class OpenTelemetryDependencyInjectionLoggingServiceCollectionExtensions
+public 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,29 +32,6 @@ static class OpenTelemetryDependencyInjectionLoggingServiceCollectionExtensions
/// 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)
@@ -80,40 +44,6 @@ 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
@@ -145,7 +75,6 @@ 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/Experimental/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Api/.publicApi/Experimental/PublicAPI.Unshipped.txt
index 2c2dcbb59e2..4cb12fd2969 100644
--- a/src/OpenTelemetry.Api/.publicApi/Experimental/PublicAPI.Unshipped.txt
+++ b/src/OpenTelemetry.Api/.publicApi/Experimental/PublicAPI.Unshipped.txt
@@ -1,19 +1,12 @@
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
diff --git a/src/OpenTelemetry.Api/.publicApi/Stable/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Api/.publicApi/Stable/PublicAPI.Unshipped.txt
index e69de29bb2d..d50e30cadb4 100644
--- a/src/OpenTelemetry.Api/.publicApi/Stable/PublicAPI.Unshipped.txt
+++ b/src/OpenTelemetry.Api/.publicApi/Stable/PublicAPI.Unshipped.txt
@@ -0,0 +1,7 @@
+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.LoggerProvider
+OpenTelemetry.Logs.LoggerProvider.LoggerProvider() -> void
+OpenTelemetry.Logs.LoggerProviderBuilder
+OpenTelemetry.Logs.LoggerProviderBuilder.LoggerProviderBuilder() -> void
diff --git a/src/OpenTelemetry.Api/CHANGELOG.md b/src/OpenTelemetry.Api/CHANGELOG.md
index 9bdc9bf5d16..e340f5d5b22 100644
--- a/src/OpenTelemetry.Api/CHANGELOG.md
+++ b/src/OpenTelemetry.Api/CHANGELOG.md
@@ -2,6 +2,11 @@
## Unreleased
+* The experimental APIs previously covered by `OTEL1000` (`LoggerProvider`,
+ `LoggerProviderBuilder`, & `IDeferredLoggerProviderBuilder`) will now be part
+ of the public API and supported in stable builds.
+ ([#5648](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5648))
+
## 1.9.0-alpha.1
Released 2024-May-20
diff --git a/src/OpenTelemetry.Api/Logs/IDeferredLoggerProviderBuilder.cs b/src/OpenTelemetry.Api/Logs/IDeferredLoggerProviderBuilder.cs
index 70528fe6cb7..7421a9df268 100644
--- a/src/OpenTelemetry.Api/Logs/IDeferredLoggerProviderBuilder.cs
+++ b/src/OpenTelemetry.Api/Logs/IDeferredLoggerProviderBuilder.cs
@@ -3,33 +3,14 @@
#nullable enable
-#if NET8_0_OR_GREATER && EXPOSE_EXPERIMENTAL_FEATURES
-using System.Diagnostics.CodeAnalysis;
-using OpenTelemetry.Internal;
-#endif
-
namespace OpenTelemetry.Logs;
-#if EXPOSE_EXPERIMENTAL_FEATURES
-///
-/// Describes a logger provider builder that supports deferred
-/// initialization using an to perform
-/// dependency injection.
-///
-///
-#if NET8_0_OR_GREATER
-[Experimental(DiagnosticDefinitions.LoggerProviderExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)]
-#endif
-public
-#else
///
/// Describes a logger provider builder that supports deferred
/// initialization using an to perform
/// dependency injection.
///
-internal
-#endif
-interface IDeferredLoggerProviderBuilder
+public interface IDeferredLoggerProviderBuilder
{
///
/// Register a callback action to configure the
/// LoggerProvider is the entry point of the OpenTelemetry API. It provides access to .
///
-///
-#if NET8_0_OR_GREATER
-[Experimental(DiagnosticDefinitions.LoggerProviderExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)]
-#endif
-public
-#else
-///
-/// LoggerProvider is the entry point of the OpenTelemetry API. It provides access to .
-///
-internal
-#endif
- class LoggerProvider : BaseProvider
+public class LoggerProvider : BaseProvider
{
private static readonly NoopLogger NoopLogger = new();
@@ -38,37 +26,55 @@ protected LoggerProvider()
{
}
+#if EXPOSE_EXPERIMENTAL_FEATURES
///
/// Gets a logger.
///
+ ///
/// instance.
#if NET8_0_OR_GREATER
[Experimental(DiagnosticDefinitions.LogsBridgeExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)]
#endif
- public Logger GetLogger()
+ public
+#else
+ internal
+#endif
+ Logger GetLogger()
=> this.GetLogger(name: null, version: null);
+#if EXPOSE_EXPERIMENTAL_FEATURES
///
/// Gets a logger with the given name.
///
+ ///
/// Optional name identifying the instrumentation library.
/// instance.
#if NET8_0_OR_GREATER
[Experimental(DiagnosticDefinitions.LogsBridgeExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)]
#endif
- public Logger GetLogger(string? name)
+ public
+#else
+ internal
+#endif
+ Logger GetLogger(string? name)
=> this.GetLogger(name, version: null);
+#if EXPOSE_EXPERIMENTAL_FEATURES
///
/// Gets a logger with the given name and version.
///
+ ///
/// Optional name identifying the instrumentation library.
/// Optional version of the instrumentation library.
/// instance.
#if NET8_0_OR_GREATER
[Experimental(DiagnosticDefinitions.LogsBridgeExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)]
#endif
- public Logger GetLogger(string? name, string? version)
+ public
+#else
+ internal
+#endif
+ Logger GetLogger(string? name, string? version)
{
if (!this.TryCreateLogger(name, out var logger))
{
@@ -80,16 +86,22 @@ public Logger GetLogger(string? name, string? version)
return logger;
}
+#if EXPOSE_EXPERIMENTAL_FEATURES
///
/// Try to create a logger with the given name.
///
+ ///
/// Optional name identifying the instrumentation library.
/// .
/// if the logger was created.
#if NET8_0_OR_GREATER
[Experimental(DiagnosticDefinitions.LogsBridgeExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)]
#endif
- protected virtual bool TryCreateLogger(
+ protected
+#else
+ internal
+#endif
+ virtual bool TryCreateLogger(
string? name,
#if NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER
[NotNullWhen(true)]
diff --git a/src/OpenTelemetry.Api/Logs/LoggerProviderBuilder.cs b/src/OpenTelemetry.Api/Logs/LoggerProviderBuilder.cs
index 3fa9c6fc743..b0aec6bfca7 100644
--- a/src/OpenTelemetry.Api/Logs/LoggerProviderBuilder.cs
+++ b/src/OpenTelemetry.Api/Logs/LoggerProviderBuilder.cs
@@ -3,29 +3,12 @@
#nullable enable
-#if NET8_0_OR_GREATER && EXPOSE_EXPERIMENTAL_FEATURES
-using System.Diagnostics.CodeAnalysis;
-using OpenTelemetry.Internal;
-#endif
-
namespace OpenTelemetry.Logs;
-#if EXPOSE_EXPERIMENTAL_FEATURES
-///
-/// LoggerProviderBuilder base class.
-///
-///
-#if NET8_0_OR_GREATER
-[Experimental(DiagnosticDefinitions.LoggerProviderExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)]
-#endif
-public
-#else
///
/// LoggerProviderBuilder base class.
///
-internal
-#endif
- abstract class LoggerProviderBuilder
+public abstract class LoggerProviderBuilder
{
///
/// Initializes a new instance of the class.
diff --git a/src/OpenTelemetry.Exporter.Console/.publicApi/Experimental/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.Console/.publicApi/Experimental/PublicAPI.Unshipped.txt
index be114835ccd..e69de29bb2d 100644
--- a/src/OpenTelemetry.Exporter.Console/.publicApi/Experimental/PublicAPI.Unshipped.txt
+++ b/src/OpenTelemetry.Exporter.Console/.publicApi/Experimental/PublicAPI.Unshipped.txt
@@ -1,3 +0,0 @@
-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/Stable/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.Console/.publicApi/Stable/PublicAPI.Unshipped.txt
index e69de29bb2d..be114835ccd 100644
--- a/src/OpenTelemetry.Exporter.Console/.publicApi/Stable/PublicAPI.Unshipped.txt
+++ b/src/OpenTelemetry.Exporter.Console/.publicApi/Stable/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/CHANGELOG.md b/src/OpenTelemetry.Exporter.Console/CHANGELOG.md
index 6605e9d684f..f6a7ebb48b8 100644
--- a/src/OpenTelemetry.Exporter.Console/CHANGELOG.md
+++ b/src/OpenTelemetry.Exporter.Console/CHANGELOG.md
@@ -2,6 +2,11 @@
## Unreleased
+* The experimental APIs previously covered by `OTEL1000`
+ (`LoggerProviderBuilder.AddConsoleExporter` extension) will now be part of the
+ public API and supported in stable builds.
+ ([#5648](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5648))
+
## 1.9.0-alpha.1
Released 2024-May-20
diff --git a/src/OpenTelemetry.Exporter.Console/ConsoleExporterLoggingExtensions.cs b/src/OpenTelemetry.Exporter.Console/ConsoleExporterLoggingExtensions.cs
index 6b024498cb7..80c767343b7 100644
--- a/src/OpenTelemetry.Exporter.Console/ConsoleExporterLoggingExtensions.cs
+++ b/src/OpenTelemetry.Exporter.Console/ConsoleExporterLoggingExtensions.cs
@@ -1,9 +1,6 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
-#if EXPOSE_EXPERIMENTAL_FEATURES && NET8_0_OR_GREATER
-using System.Diagnostics.CodeAnalysis;
-#endif
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using OpenTelemetry.Exporter;
@@ -18,7 +15,7 @@ public static class ConsoleExporterLoggingExtensions
///
/// options to use.
/// The instance of to chain the calls.
- /// todo: [Obsolete("Call LoggerProviderBuilder.AddConsoleExporter instead this method will be removed in a future version.")]
+ // TODO: [Obsolete("Call LoggerProviderBuilder.AddConsoleExporter instead this method will be removed in a future version.")]
public static OpenTelemetryLoggerOptions AddConsoleExporter(this OpenTelemetryLoggerOptions loggerOptions)
=> AddConsoleExporter(loggerOptions, configure: null);
@@ -28,7 +25,7 @@ public static OpenTelemetryLoggerOptions AddConsoleExporter(this OpenTelemetryLo
/// options to use.
/// Callback action for configuring .
/// The instance of to chain the calls.
- /// todo: [Obsolete("Call LoggerProviderBuilder.AddConsoleExporter instead this method will be removed in a future version.")]
+ // TODO: [Obsolete("Call LoggerProviderBuilder.AddConsoleExporter instead this method will be removed in a future version.")]
public static OpenTelemetryLoggerOptions AddConsoleExporter(this OpenTelemetryLoggerOptions loggerOptions, Action configure)
{
Guard.ThrowIfNull(loggerOptions);
@@ -38,69 +35,26 @@ 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.
-#if NET8_0_OR_GREATER
- [Experimental(DiagnosticDefinitions.LoggerProviderExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)]
-#endif
- public
-#else
- ///
- /// Adds Console exporter with LoggerProviderBuilder.
- ///
- /// .
- /// The supplied instance of to chain the calls.
- internal
-#endif
- static LoggerProviderBuilder AddConsoleExporter(
+ public 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.
-#if NET8_0_OR_GREATER
- [Experimental(DiagnosticDefinitions.LoggerProviderExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)]
-#endif
- public
-#else
///
/// Adds Console exporter with LoggerProviderBuilder.
///
/// .
/// Callback action for configuring .
/// The supplied instance of to chain the calls.
- internal
-#endif
- static LoggerProviderBuilder AddConsoleExporter(
+ public 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.
-#if NET8_0_OR_GREATER
- [Experimental(DiagnosticDefinitions.LoggerProviderExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)]
-#endif
- public
-#else
///
/// Adds Console exporter with LoggerProviderBuilder.
///
@@ -108,9 +62,7 @@ static LoggerProviderBuilder AddConsoleExporter(
/// Name which is used when retrieving options.
/// Callback action for configuring .
/// The supplied instance of to chain the calls.
- internal
-#endif
- static LoggerProviderBuilder AddConsoleExporter(
+ public static LoggerProviderBuilder AddConsoleExporter(
this LoggerProviderBuilder loggerProviderBuilder,
string name,
Action configure)
diff --git a/src/OpenTelemetry.Exporter.InMemory/.publicApi/Experimental/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.InMemory/.publicApi/Experimental/PublicAPI.Unshipped.txt
index f7378ee36cc..e69de29bb2d 100644
--- a/src/OpenTelemetry.Exporter.InMemory/.publicApi/Experimental/PublicAPI.Unshipped.txt
+++ b/src/OpenTelemetry.Exporter.InMemory/.publicApi/Experimental/PublicAPI.Unshipped.txt
@@ -1 +0,0 @@
-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/Stable/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.InMemory/.publicApi/Stable/PublicAPI.Unshipped.txt
index e69de29bb2d..f7378ee36cc 100644
--- a/src/OpenTelemetry.Exporter.InMemory/.publicApi/Stable/PublicAPI.Unshipped.txt
+++ b/src/OpenTelemetry.Exporter.InMemory/.publicApi/Stable/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/CHANGELOG.md b/src/OpenTelemetry.Exporter.InMemory/CHANGELOG.md
index d4aa853c675..8b932042281 100644
--- a/src/OpenTelemetry.Exporter.InMemory/CHANGELOG.md
+++ b/src/OpenTelemetry.Exporter.InMemory/CHANGELOG.md
@@ -2,6 +2,11 @@
## Unreleased
+* The experimental APIs previously covered by `OTEL1000`
+ (`LoggerProviderBuilder.AddInMemoryExporter` extension) will now be part of
+ the public API and supported in stable builds.
+ ([#5648](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5648))
+
## 1.9.0-alpha.1
Released 2024-May-20
diff --git a/src/OpenTelemetry.Exporter.InMemory/InMemoryExporterLoggingExtensions.cs b/src/OpenTelemetry.Exporter.InMemory/InMemoryExporterLoggingExtensions.cs
index 982595f8824..19b2079921e 100644
--- a/src/OpenTelemetry.Exporter.InMemory/InMemoryExporterLoggingExtensions.cs
+++ b/src/OpenTelemetry.Exporter.InMemory/InMemoryExporterLoggingExtensions.cs
@@ -1,9 +1,6 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
-#if EXPOSE_EXPERIMENTAL_FEATURES && NET8_0_OR_GREATER
-using System.Diagnostics.CodeAnalysis;
-#endif
using OpenTelemetry.Exporter;
using OpenTelemetry.Internal;
@@ -17,7 +14,7 @@ public static class InMemoryExporterLoggingExtensions
/// options to use.
/// Collection which will be populated with the exported .
/// The supplied instance of to chain the calls.
- /// todo: [Obsolete("Call LoggerProviderBuilder.AddInMemoryExporter instead this method will be removed in a future version.")]
+ // TODO: [Obsolete("Call LoggerProviderBuilder.AddInMemoryExporter instead this method will be removed in a future version.")]
public static OpenTelemetryLoggerOptions AddInMemoryExporter(
this OpenTelemetryLoggerOptions loggerOptions,
ICollection exportedItems)
@@ -31,28 +28,13 @@ 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.
-#if NET8_0_OR_GREATER
- [Experimental(DiagnosticDefinitions.LoggerProviderExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)]
-#endif
- 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(
+ public static LoggerProviderBuilder AddInMemoryExporter(
this LoggerProviderBuilder loggerProviderBuilder,
ICollection exportedItems)
{
diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/Experimental/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/Experimental/PublicAPI.Unshipped.txt
index e6bd747c9de..e69de29bb2d 100644
--- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/Experimental/PublicAPI.Unshipped.txt
+++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/Experimental/PublicAPI.Unshipped.txt
@@ -1,5 +0,0 @@
-static OpenTelemetry.Logs.OtlpLogExporterHelperExtensions.AddOtlpExporter(this OpenTelemetry.Logs.LoggerProviderBuilder! builder) -> OpenTelemetry.Logs.LoggerProviderBuilder!
-static OpenTelemetry.Logs.OtlpLogExporterHelperExtensions.AddOtlpExporter(this OpenTelemetry.Logs.LoggerProviderBuilder! builder, string? name, System.Action? configureExporterAndProcessor) -> OpenTelemetry.Logs.LoggerProviderBuilder!
-static OpenTelemetry.Logs.OtlpLogExporterHelperExtensions.AddOtlpExporter(this OpenTelemetry.Logs.LoggerProviderBuilder! builder, string? name, System.Action? configureExporter) -> OpenTelemetry.Logs.LoggerProviderBuilder!
-static OpenTelemetry.Logs.OtlpLogExporterHelperExtensions.AddOtlpExporter(this OpenTelemetry.Logs.LoggerProviderBuilder! builder, System.Action! configureExporterAndProcessor) -> OpenTelemetry.Logs.LoggerProviderBuilder!
-static OpenTelemetry.Logs.OtlpLogExporterHelperExtensions.AddOtlpExporter(this OpenTelemetry.Logs.LoggerProviderBuilder! builder, System.Action! configureExporter) -> OpenTelemetry.Logs.LoggerProviderBuilder!
diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/Stable/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/Stable/PublicAPI.Unshipped.txt
index e69de29bb2d..e6bd747c9de 100644
--- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/Stable/PublicAPI.Unshipped.txt
+++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/.publicApi/Stable/PublicAPI.Unshipped.txt
@@ -0,0 +1,5 @@
+static OpenTelemetry.Logs.OtlpLogExporterHelperExtensions.AddOtlpExporter(this OpenTelemetry.Logs.LoggerProviderBuilder! builder) -> OpenTelemetry.Logs.LoggerProviderBuilder!
+static OpenTelemetry.Logs.OtlpLogExporterHelperExtensions.AddOtlpExporter(this OpenTelemetry.Logs.LoggerProviderBuilder! builder, string? name, System.Action? configureExporterAndProcessor) -> OpenTelemetry.Logs.LoggerProviderBuilder!
+static OpenTelemetry.Logs.OtlpLogExporterHelperExtensions.AddOtlpExporter(this OpenTelemetry.Logs.LoggerProviderBuilder! builder, string? name, System.Action? configureExporter) -> OpenTelemetry.Logs.LoggerProviderBuilder!
+static OpenTelemetry.Logs.OtlpLogExporterHelperExtensions.AddOtlpExporter(this OpenTelemetry.Logs.LoggerProviderBuilder! builder, System.Action! configureExporterAndProcessor) -> OpenTelemetry.Logs.LoggerProviderBuilder!
+static OpenTelemetry.Logs.OtlpLogExporterHelperExtensions.AddOtlpExporter(this OpenTelemetry.Logs.LoggerProviderBuilder! builder, System.Action! configureExporter) -> OpenTelemetry.Logs.LoggerProviderBuilder!
diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md
index 08310125087..4c2d56a7243 100644
--- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md
+++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md
@@ -2,6 +2,11 @@
## Unreleased
+* The experimental APIs previously covered by `OTEL1000`
+ (`LoggerProviderBuilder.AddOtlpExporter` extension) will now be part of the
+ public API and supported in stable builds.
+ ([#5648](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5648))
+
## 1.9.0-alpha.1
Released 2024-May-20
diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpLogExporterHelperExtensions.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpLogExporterHelperExtensions.cs
index ca5a759caf4..3a994c8e772 100644
--- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpLogExporterHelperExtensions.cs
+++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpLogExporterHelperExtensions.cs
@@ -4,9 +4,6 @@
#nullable enable
using System.Diagnostics;
-#if EXPOSE_EXPERIMENTAL_FEATURES && NET8_0_OR_GREATER
-using System.Diagnostics.CodeAnalysis;
-#endif
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
@@ -28,6 +25,7 @@ public static class OtlpLogExporterHelperExtensions
///
/// options to use.
/// The instance of to chain the calls.
+ // TODO: [Obsolete("Call LoggerProviderBuilder.AddOtlpExporter instead this method will be removed in a future version.")]
public static OpenTelemetryLoggerOptions AddOtlpExporter(this OpenTelemetryLoggerOptions loggerOptions)
=> AddOtlpExporter(loggerOptions, name: null, configure: null);
@@ -37,6 +35,7 @@ public static OpenTelemetryLoggerOptions AddOtlpExporter(this OpenTelemetryLogge
/// options to use.
/// Callback action for configuring .
/// The instance of to chain the calls.
+ // TODO: [Obsolete("Call LoggerProviderBuilder.AddOtlpExporter instead this method will be removed in a future version.")]
public static OpenTelemetryLoggerOptions AddOtlpExporter(
this OpenTelemetryLoggerOptions loggerOptions,
Action configure)
@@ -49,6 +48,7 @@ public static OpenTelemetryLoggerOptions AddOtlpExporter(
/// Optional name which is used when retrieving options.
/// Optional callback action for configuring .
/// The instance of to chain the calls.
+ // TODO: [Obsolete("Call LoggerProviderBuilder.AddOtlpExporter instead this method will be removed in a future version.")]
public static OpenTelemetryLoggerOptions AddOtlpExporter(
this OpenTelemetryLoggerOptions loggerOptions,
string? name,
@@ -81,6 +81,7 @@ public static OpenTelemetryLoggerOptions AddOtlpExporter(
/// options to use.
/// Callback action for configuring and .
/// The instance of to chain the calls.
+ // TODO: [Obsolete("Call LoggerProviderBuilder.AddOtlpExporter instead this method will be removed in a future version.")]
public static OpenTelemetryLoggerOptions AddOtlpExporter(
this OpenTelemetryLoggerOptions loggerOptions,
Action configureExporterAndProcessor)
@@ -93,6 +94,7 @@ public static OpenTelemetryLoggerOptions AddOtlpExporter(
/// Optional name which is used when retrieving options.
/// Optional callback action for configuring and .
/// The instance of to chain the calls.
+ // TODO: [Obsolete("Call LoggerProviderBuilder.AddOtlpExporter instead this method will be removed in a future version.")]
public static OpenTelemetryLoggerOptions AddOtlpExporter(
this OpenTelemetryLoggerOptions loggerOptions,
string? name,
@@ -119,96 +121,42 @@ public static OpenTelemetryLoggerOptions AddOtlpExporter(
});
}
-#if EXPOSE_EXPERIMENTAL_FEATURES
///
/// Adds an OTLP exporter to the LoggerProvider.
///
- /// WARNING: This is an experimental API which might change or be removed in the future. Use at your own risk.
/// builder to use.
/// The instance of to chain the calls.
-#if NET8_0_OR_GREATER
- [Experimental(DiagnosticDefinitions.LoggerProviderExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)]
-#endif
- public
-#else
- ///
- /// Adds an OTLP exporter to the LoggerProvider.
- ///
- /// builder to use.
- /// The instance of to chain the calls.
- internal
-#endif
- static LoggerProviderBuilder AddOtlpExporter(this LoggerProviderBuilder builder)
+ public static LoggerProviderBuilder AddOtlpExporter(this LoggerProviderBuilder builder)
=> AddOtlpExporter(builder, name: null, configureExporter: null);
-#if EXPOSE_EXPERIMENTAL_FEATURES
- ///
- /// Adds an OTLP exporter to the LoggerProvider.
- ///
- /// WARNING: This is an experimental API which might change or be removed in the future. Use at your own risk.
- /// builder to use.
- /// Callback action for configuring .
- /// The instance of to chain the calls.
-#if NET8_0_OR_GREATER
- [Experimental(DiagnosticDefinitions.LoggerProviderExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)]
-#endif
- public
-#else
///
/// Adds an OTLP exporter to the LoggerProvider.
///
/// builder to use.
/// Callback action for configuring .
/// The instance of to chain the calls.
- internal
-#endif
- static LoggerProviderBuilder AddOtlpExporter(this LoggerProviderBuilder builder, Action configureExporter)
+ public static LoggerProviderBuilder AddOtlpExporter(this LoggerProviderBuilder builder, Action configureExporter)
=> AddOtlpExporter(builder, name: null, configureExporter);
-#if EXPOSE_EXPERIMENTAL_FEATURES
///
/// Adds an OTLP exporter to the LoggerProvider.
///
- /// WARNING: This is an experimental API which might change or be removed in the future. Use at your own risk.
/// builder to use.
/// Callback action for
/// configuring and .
/// The instance of to chain the calls.
-#if NET8_0_OR_GREATER
- [Experimental(DiagnosticDefinitions.LoggerProviderExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)]
-#endif
- public
-#else
- internal
-#endif
- static LoggerProviderBuilder AddOtlpExporter(this LoggerProviderBuilder builder, Action configureExporterAndProcessor)
+ public static LoggerProviderBuilder AddOtlpExporter(this LoggerProviderBuilder builder, Action configureExporterAndProcessor)
=> AddOtlpExporter(builder, name: null, configureExporterAndProcessor);
-#if EXPOSE_EXPERIMENTAL_FEATURES
///
/// Adds OpenTelemetry Protocol (OTLP) exporter to the LoggerProvider.
///
- /// WARNING: This is an experimental API which might change or be removed in the future. Use at your own risk.
/// builder to use.
/// Optional name which is used when retrieving options.
/// Optional callback action for configuring .
/// The instance of to chain the calls.
-#if NET8_0_OR_GREATER
- [Experimental(DiagnosticDefinitions.LoggerProviderExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)]
-#endif
- public
-#else
- ///
- /// Adds OpenTelemetry Protocol (OTLP) exporter to the LoggerProvider.
- ///
- /// builder to use.
- /// Optional name which is used when retrieving options.
- /// Optional callback action for configuring .
- /// The instance of to chain the calls.
- internal
-#endif
- static LoggerProviderBuilder AddOtlpExporter(
+ public static LoggerProviderBuilder AddOtlpExporter(
this LoggerProviderBuilder builder,
string? name,
Action? configureExporter)
@@ -265,22 +213,6 @@ static LoggerProviderBuilder AddOtlpExporter(
});
}
-#if EXPOSE_EXPERIMENTAL_FEATURES
- ///
- /// Adds an OTLP exporter to the LoggerProvider.
- ///
- /// WARNING: This is an experimental API which might change or be removed in the future. Use at your own risk.
- /// builder to use.
- /// Optional name which is used when retrieving options.
- /// Optional callback action for
- /// configuring and .
- /// The instance of to chain the calls.
-#if NET8_0_OR_GREATER
- [Experimental(DiagnosticDefinitions.LoggerProviderExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)]
-#endif
- public
-#else
///
/// Adds an OTLP exporter to the LoggerProvider.
///
@@ -290,9 +222,7 @@ static LoggerProviderBuilder AddOtlpExporter(
/// configuring and .
/// The instance of to chain the calls.
- internal
-#endif
- static LoggerProviderBuilder AddOtlpExporter(
+ public static LoggerProviderBuilder AddOtlpExporter(
this LoggerProviderBuilder builder,
string? name,
Action? configureExporterAndProcessor)
diff --git a/src/OpenTelemetry.Extensions.Hosting/.publicApi/Experimental/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Extensions.Hosting/.publicApi/Experimental/PublicAPI.Unshipped.txt
index f83d7ca4a0f..e69de29bb2d 100644
--- a/src/OpenTelemetry.Extensions.Hosting/.publicApi/Experimental/PublicAPI.Unshipped.txt
+++ b/src/OpenTelemetry.Extensions.Hosting/.publicApi/Experimental/PublicAPI.Unshipped.txt
@@ -1,3 +0,0 @@
-OpenTelemetry.OpenTelemetryBuilder.WithLogging() -> OpenTelemetry.OpenTelemetryBuilder!
-OpenTelemetry.OpenTelemetryBuilder.WithLogging(System.Action! configure) -> OpenTelemetry.OpenTelemetryBuilder!
-OpenTelemetry.OpenTelemetryBuilder.WithLogging(System.Action? configureBuilder, System.Action? configureOptions) -> OpenTelemetry.OpenTelemetryBuilder!
diff --git a/src/OpenTelemetry.Extensions.Hosting/.publicApi/Stable/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Extensions.Hosting/.publicApi/Stable/PublicAPI.Unshipped.txt
index e69de29bb2d..f83d7ca4a0f 100644
--- a/src/OpenTelemetry.Extensions.Hosting/.publicApi/Stable/PublicAPI.Unshipped.txt
+++ b/src/OpenTelemetry.Extensions.Hosting/.publicApi/Stable/PublicAPI.Unshipped.txt
@@ -0,0 +1,3 @@
+OpenTelemetry.OpenTelemetryBuilder.WithLogging() -> OpenTelemetry.OpenTelemetryBuilder!
+OpenTelemetry.OpenTelemetryBuilder.WithLogging(System.Action! configure) -> OpenTelemetry.OpenTelemetryBuilder!
+OpenTelemetry.OpenTelemetryBuilder.WithLogging(System.Action? configureBuilder, System.Action? configureOptions) -> OpenTelemetry.OpenTelemetryBuilder!
diff --git a/src/OpenTelemetry.Extensions.Hosting/CHANGELOG.md b/src/OpenTelemetry.Extensions.Hosting/CHANGELOG.md
index a5921a6dd90..3bcc96de580 100644
--- a/src/OpenTelemetry.Extensions.Hosting/CHANGELOG.md
+++ b/src/OpenTelemetry.Extensions.Hosting/CHANGELOG.md
@@ -2,6 +2,11 @@
## Unreleased
+* The experimental APIs previously covered by `OTEL1000`
+ (`OpenTelemetryBuilder.WithLogging` method) will now be part of the public API
+ and supported in stable builds.
+ ([#5648](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5648))
+
## 1.9.0-alpha.1
Released 2024-May-20
diff --git a/src/OpenTelemetry.Extensions.Hosting/OpenTelemetryBuilder.cs b/src/OpenTelemetry.Extensions.Hosting/OpenTelemetryBuilder.cs
index 042a211e76b..5512befb59e 100644
--- a/src/OpenTelemetry.Extensions.Hosting/OpenTelemetryBuilder.cs
+++ b/src/OpenTelemetry.Extensions.Hosting/OpenTelemetryBuilder.cs
@@ -1,9 +1,6 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
-#if EXPOSE_EXPERIMENTAL_FEATURES && NET8_0_OR_GREATER
-using System.Diagnostics.CodeAnalysis;
-#endif
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Diagnostics.Metrics;
using Microsoft.Extensions.Logging;
@@ -112,13 +109,10 @@ 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.
/// Notes:
///
/// - This is safe to be called multiple times and by library authors.
@@ -131,33 +125,9 @@ public OpenTelemetryBuilder WithTracing(Action configure)
///
/// The supplied for chaining
/// calls.
-#if NET8_0_OR_GREATER
- [Experimental(DiagnosticDefinitions.LoggerProviderExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)]
-#endif
- public
-#else
- ///
- /// Adds logging services into the builder.
- ///
- ///
- /// Notes:
- ///
- /// - This is safe to be called multiple times and by library authors.
- /// Only a single will be created for a given
- /// .
- /// - This method automatically registers an named 'OpenTelemetry' into the .
- ///
- ///
- /// The supplied for chaining
- /// calls.
- internal
-#endif
- OpenTelemetryBuilder WithLogging()
+ public OpenTelemetryBuilder WithLogging()
=> this.WithLogging(configureBuilder: null, configureOptions: null);
-#if EXPOSE_EXPERIMENTAL_FEATURES
///
/// Adds logging services into the builder.
///
@@ -166,44 +136,13 @@ OpenTelemetryBuilder WithLogging()
/// configuration callback.
/// The supplied for chaining
/// calls.
-#if NET8_0_OR_GREATER
- [Experimental(DiagnosticDefinitions.LoggerProviderExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)]
-#endif
- public
-#else
- ///
- /// Adds logging services into the builder.
- ///
- ///
- ///
- /// configuration callback.
- /// The supplied for chaining
- /// calls.
- internal
-#endif
- OpenTelemetryBuilder WithLogging(Action configure)
+ public OpenTelemetryBuilder WithLogging(Action configure)
{
Guard.ThrowIfNull(configure);
return this.WithLogging(configureBuilder: configure, configureOptions: null);
}
-#if EXPOSE_EXPERIMENTAL_FEATURES
- ///
- /// Adds logging services into the builder.
- ///
- ///
- /// Optional configuration callback.
- /// Optional configuration callback.
- /// The supplied for chaining
- /// calls.
-#if NET8_0_OR_GREATER
- [Experimental(DiagnosticDefinitions.LoggerProviderExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)]
-#endif
- public
-#else
///
/// Adds logging services into the builder.
///
@@ -211,14 +150,15 @@ OpenTelemetryBuilder WithLogging(Action configure)
/// Optional configuration callback.
/// Optional configuration callback.
+ /// cref="OpenTelemetryLoggerOptions"/> configuration callback. are used by the named 'OpenTelemetry' automatically registered
+ /// by this method.
/// The supplied for chaining
/// calls.
- internal
-#endif
- OpenTelemetryBuilder WithLogging(
- Action? configureBuilder,
- Action? configureOptions)
+ public OpenTelemetryBuilder WithLogging(
+ Action? configureBuilder,
+ Action? configureOptions)
{
OpenTelemetryBuilderSdkExtensions.WithLogging(this, configureBuilder, configureOptions);
diff --git a/src/OpenTelemetry/.publicApi/Experimental/PublicAPI.Unshipped.txt b/src/OpenTelemetry/.publicApi/Experimental/PublicAPI.Unshipped.txt
index 22a73f5d6bb..a6594de1a9c 100644
--- a/src/OpenTelemetry/.publicApi/Experimental/PublicAPI.Unshipped.txt
+++ b/src/OpenTelemetry/.publicApi/Experimental/PublicAPI.Unshipped.txt
@@ -1,8 +1,6 @@
abstract OpenTelemetry.Metrics.ExemplarReservoir.Collect() -> OpenTelemetry.Metrics.ReadOnlyExemplarCollection
abstract OpenTelemetry.Metrics.ExemplarReservoir.Offer(in OpenTelemetry.Metrics.ExemplarMeasurement measurement) -> void
abstract OpenTelemetry.Metrics.ExemplarReservoir.Offer(in OpenTelemetry.Metrics.ExemplarMeasurement measurement) -> void
-OpenTelemetry.Logs.LoggerProviderBuilderExtensions
-OpenTelemetry.Logs.LoggerProviderExtensions
OpenTelemetry.Logs.LogRecord.Logger.get -> OpenTelemetry.Logs.Logger!
OpenTelemetry.Logs.LogRecord.Severity.get -> OpenTelemetry.Logs.LogRecordSeverity?
OpenTelemetry.Logs.LogRecord.Severity.set -> void
@@ -24,20 +22,8 @@ OpenTelemetry.Metrics.MetricStreamConfiguration.CardinalityLimit.set -> void
OpenTelemetry.Metrics.MetricStreamConfiguration.ExemplarReservoirFactory.get -> System.Func?
OpenTelemetry.Metrics.MetricStreamConfiguration.ExemplarReservoirFactory.set -> void
override sealed OpenTelemetry.Metrics.FixedSizeExemplarReservoir.Collect() -> OpenTelemetry.Metrics.ReadOnlyExemplarCollection
-static OpenTelemetry.Logs.LoggerProviderBuilderExtensions.AddProcessor(this OpenTelemetry.Logs.LoggerProviderBuilder! loggerProviderBuilder, OpenTelemetry.BaseProcessor! processor) -> OpenTelemetry.Logs.LoggerProviderBuilder!
-static OpenTelemetry.Logs.LoggerProviderBuilderExtensions.AddProcessor(this OpenTelemetry.Logs.LoggerProviderBuilder! loggerProviderBuilder, System.Func!>! implementationFactory) -> OpenTelemetry.Logs.LoggerProviderBuilder!
-static OpenTelemetry.Logs.LoggerProviderBuilderExtensions.AddProcessor(this OpenTelemetry.Logs.LoggerProviderBuilder! loggerProviderBuilder) -> OpenTelemetry.Logs.LoggerProviderBuilder!
-static OpenTelemetry.Logs.LoggerProviderBuilderExtensions.Build(this OpenTelemetry.Logs.LoggerProviderBuilder! loggerProviderBuilder) -> OpenTelemetry.Logs.LoggerProvider!
-static OpenTelemetry.Logs.LoggerProviderBuilderExtensions.ConfigureResource(this OpenTelemetry.Logs.LoggerProviderBuilder! loggerProviderBuilder, System.Action! configure) -> OpenTelemetry.Logs.LoggerProviderBuilder!
-static OpenTelemetry.Logs.LoggerProviderBuilderExtensions.SetResourceBuilder(this OpenTelemetry.Logs.LoggerProviderBuilder! loggerProviderBuilder, OpenTelemetry.Resources.ResourceBuilder! resourceBuilder) -> OpenTelemetry.Logs.LoggerProviderBuilder!
-static OpenTelemetry.Logs.LoggerProviderExtensions.AddProcessor(this OpenTelemetry.Logs.LoggerProvider! provider, OpenTelemetry.BaseProcessor! processor) -> OpenTelemetry.Logs.LoggerProvider!
-static OpenTelemetry.Logs.LoggerProviderExtensions.ForceFlush(this OpenTelemetry.Logs.LoggerProvider! provider, int timeoutMilliseconds = -1) -> bool
-static OpenTelemetry.Logs.LoggerProviderExtensions.Shutdown(this OpenTelemetry.Logs.LoggerProvider! provider, int timeoutMilliseconds = -1) -> bool
-static OpenTelemetry.OpenTelemetryBuilderSdkExtensions.WithLogging(this OpenTelemetry.IOpenTelemetryBuilder! builder) -> OpenTelemetry.IOpenTelemetryBuilder!
-static OpenTelemetry.OpenTelemetryBuilderSdkExtensions.WithLogging(this OpenTelemetry.IOpenTelemetryBuilder! builder, System.Action! configure) -> OpenTelemetry.IOpenTelemetryBuilder!
-static OpenTelemetry.OpenTelemetryBuilderSdkExtensions.WithLogging(this OpenTelemetry.IOpenTelemetryBuilder! builder, System.Action? configureBuilder, System.Action? configureOptions) -> OpenTelemetry.IOpenTelemetryBuilder!
-static OpenTelemetry.Sdk.CreateLoggerProviderBuilder() -> OpenTelemetry.Logs.LoggerProviderBuilder!
static Microsoft.Extensions.Logging.OpenTelemetryLoggingExtensions.UseOpenTelemetry(this Microsoft.Extensions.Logging.ILoggingBuilder! builder) -> Microsoft.Extensions.Logging.ILoggingBuilder!
static Microsoft.Extensions.Logging.OpenTelemetryLoggingExtensions.UseOpenTelemetry(this Microsoft.Extensions.Logging.ILoggingBuilder! builder, System.Action! configure) -> Microsoft.Extensions.Logging.ILoggingBuilder!
static Microsoft.Extensions.Logging.OpenTelemetryLoggingExtensions.UseOpenTelemetry(this Microsoft.Extensions.Logging.ILoggingBuilder! builder, System.Action? configureBuilder, System.Action? configureOptions) -> Microsoft.Extensions.Logging.ILoggingBuilder!
+static OpenTelemetry.Sdk.CreateLoggerProviderBuilder() -> OpenTelemetry.Logs.LoggerProviderBuilder!
virtual OpenTelemetry.Metrics.FixedSizeExemplarReservoir.OnCollected() -> void
diff --git a/src/OpenTelemetry/.publicApi/Stable/PublicAPI.Unshipped.txt b/src/OpenTelemetry/.publicApi/Stable/PublicAPI.Unshipped.txt
index a9a6c031d7a..4ebd84b69d9 100644
--- a/src/OpenTelemetry/.publicApi/Stable/PublicAPI.Unshipped.txt
+++ b/src/OpenTelemetry/.publicApi/Stable/PublicAPI.Unshipped.txt
@@ -1,3 +1,5 @@
+OpenTelemetry.Logs.LoggerProviderBuilderExtensions
+OpenTelemetry.Logs.LoggerProviderExtensions
OpenTelemetry.Metrics.Exemplar
OpenTelemetry.Metrics.Exemplar.DoubleValue.get -> double
OpenTelemetry.Metrics.Exemplar.Exemplar() -> void
@@ -25,4 +27,16 @@ OpenTelemetry.ReadOnlyFilteredTagCollection.Enumerator.Enumerator() -> void
OpenTelemetry.ReadOnlyFilteredTagCollection.Enumerator.MoveNext() -> bool
OpenTelemetry.ReadOnlyFilteredTagCollection.GetEnumerator() -> OpenTelemetry.ReadOnlyFilteredTagCollection.Enumerator
OpenTelemetry.ReadOnlyFilteredTagCollection.ReadOnlyFilteredTagCollection() -> void
+static OpenTelemetry.OpenTelemetryBuilderSdkExtensions.WithLogging(this OpenTelemetry.IOpenTelemetryBuilder! builder) -> OpenTelemetry.IOpenTelemetryBuilder!
+static OpenTelemetry.OpenTelemetryBuilderSdkExtensions.WithLogging(this OpenTelemetry.IOpenTelemetryBuilder! builder, System.Action! configure) -> OpenTelemetry.IOpenTelemetryBuilder!
+static OpenTelemetry.OpenTelemetryBuilderSdkExtensions.WithLogging(this OpenTelemetry.IOpenTelemetryBuilder! builder, System.Action? configureBuilder, System.Action? configureOptions) -> OpenTelemetry.IOpenTelemetryBuilder!
+static OpenTelemetry.Logs.LoggerProviderBuilderExtensions.AddProcessor(this OpenTelemetry.Logs.LoggerProviderBuilder! loggerProviderBuilder, OpenTelemetry.BaseProcessor! processor) -> OpenTelemetry.Logs.LoggerProviderBuilder!
+static OpenTelemetry.Logs.LoggerProviderBuilderExtensions.AddProcessor(this OpenTelemetry.Logs.LoggerProviderBuilder! loggerProviderBuilder, System.Func!>! implementationFactory) -> OpenTelemetry.Logs.LoggerProviderBuilder!
+static OpenTelemetry.Logs.LoggerProviderBuilderExtensions.AddProcessor(this OpenTelemetry.Logs.LoggerProviderBuilder! loggerProviderBuilder) -> OpenTelemetry.Logs.LoggerProviderBuilder!
+static OpenTelemetry.Logs.LoggerProviderBuilderExtensions.Build(this OpenTelemetry.Logs.LoggerProviderBuilder! loggerProviderBuilder) -> OpenTelemetry.Logs.LoggerProvider!
+static OpenTelemetry.Logs.LoggerProviderBuilderExtensions.ConfigureResource(this OpenTelemetry.Logs.LoggerProviderBuilder! loggerProviderBuilder, System.Action! configure) -> OpenTelemetry.Logs.LoggerProviderBuilder!
+static OpenTelemetry.Logs.LoggerProviderBuilderExtensions.SetResourceBuilder(this OpenTelemetry.Logs.LoggerProviderBuilder! loggerProviderBuilder, OpenTelemetry.Resources.ResourceBuilder! resourceBuilder) -> OpenTelemetry.Logs.LoggerProviderBuilder!
+static OpenTelemetry.Logs.LoggerProviderExtensions.AddProcessor(this OpenTelemetry.Logs.LoggerProvider! provider, OpenTelemetry.BaseProcessor! processor) -> OpenTelemetry.Logs.LoggerProvider!
+static OpenTelemetry.Logs.LoggerProviderExtensions.ForceFlush(this OpenTelemetry.Logs.LoggerProvider! provider, int timeoutMilliseconds = -1) -> bool
+static OpenTelemetry.Logs.LoggerProviderExtensions.Shutdown(this OpenTelemetry.Logs.LoggerProvider! provider, int timeoutMilliseconds = -1) -> bool
static OpenTelemetry.Metrics.MeterProviderBuilderExtensions.SetExemplarFilter(this OpenTelemetry.Metrics.MeterProviderBuilder! meterProviderBuilder, OpenTelemetry.Metrics.ExemplarFilterType exemplarFilter) -> OpenTelemetry.Metrics.MeterProviderBuilder!
diff --git a/src/OpenTelemetry/BatchExportProcessor.cs b/src/OpenTelemetry/BatchExportProcessor.cs
index 8e1e2ed0e58..b377d5e89e5 100644
--- a/src/OpenTelemetry/BatchExportProcessor.cs
+++ b/src/OpenTelemetry/BatchExportProcessor.cs
@@ -20,10 +20,10 @@ public abstract class BatchExportProcessor : BaseExportProcessor
internal const int DefaultMaxExportBatchSize = 512;
internal readonly int MaxExportBatchSize;
+ internal readonly int ScheduledDelayMilliseconds;
+ internal readonly int ExporterTimeoutMilliseconds;
private readonly CircularBuffer circularBuffer;
- private readonly int scheduledDelayMilliseconds;
- private readonly int exporterTimeoutMilliseconds;
private readonly Thread exporterThread;
private readonly AutoResetEvent exportTrigger = new(false);
private readonly ManualResetEvent dataExportedNotification = new(false);
@@ -54,8 +54,8 @@ protected BatchExportProcessor(
Guard.ThrowIfOutOfRange(exporterTimeoutMilliseconds, min: 0);
this.circularBuffer = new CircularBuffer(maxQueueSize);
- this.scheduledDelayMilliseconds = scheduledDelayMilliseconds;
- this.exporterTimeoutMilliseconds = exporterTimeoutMilliseconds;
+ this.ScheduledDelayMilliseconds = scheduledDelayMilliseconds;
+ this.ExporterTimeoutMilliseconds = exporterTimeoutMilliseconds;
this.MaxExportBatchSize = maxExportBatchSize;
this.exporterThread = new Thread(this.ExporterProc)
{
@@ -252,7 +252,7 @@ private void ExporterProc()
{
try
{
- WaitHandle.WaitAny(triggers, this.scheduledDelayMilliseconds);
+ WaitHandle.WaitAny(triggers, this.ScheduledDelayMilliseconds);
}
catch (ObjectDisposedException)
{
diff --git a/src/OpenTelemetry/CHANGELOG.md b/src/OpenTelemetry/CHANGELOG.md
index 763f3f370a0..5f11580af07 100644
--- a/src/OpenTelemetry/CHANGELOG.md
+++ b/src/OpenTelemetry/CHANGELOG.md
@@ -2,6 +2,12 @@
## Unreleased
+* The experimental APIs previously covered by `OTEL1000`
+ (`LoggerProviderBuilder` `AddProcessor` & `ConfigureResource` extensions, and
+ `LoggerProvider` `ForceFlush` & `Shutdown` extensions) will now be part of the
+ public API and supported in stable builds.
+ ([#5648](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5648))
+
## 1.9.0-alpha.1
Released 2024-May-20
diff --git a/src/OpenTelemetry/Logs/Builder/LoggerProviderBuilderExtensions.cs b/src/OpenTelemetry/Logs/Builder/LoggerProviderBuilderExtensions.cs
index 3fad4d173dc..36ac8ac8e6e 100644
--- a/src/OpenTelemetry/Logs/Builder/LoggerProviderBuilderExtensions.cs
+++ b/src/OpenTelemetry/Logs/Builder/LoggerProviderBuilderExtensions.cs
@@ -14,30 +14,8 @@ namespace OpenTelemetry.Logs;
///
/// Contains extension methods for the class.
///
-#if EXPOSE_EXPERIMENTAL_FEATURES
-#if NET8_0_OR_GREATER
-[Experimental(DiagnosticDefinitions.LoggerProviderExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)]
-#endif
-public
-#else
-internal
-#endif
- static class LoggerProviderBuilderExtensions
+public 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 associated with
/// this provider is built from.
@@ -49,7 +27,6 @@ static class LoggerProviderBuilderExtensions
/// .
/// from which Resource will be built.
/// Returns for chaining.
-#endif
public static LoggerProviderBuilder SetResourceBuilder(this LoggerProviderBuilder loggerProviderBuilder, ResourceBuilder resourceBuilder)
{
Guard.ThrowIfNull(resourceBuilder);
@@ -65,24 +42,13 @@ 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 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);
@@ -98,22 +64,12 @@ 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);
@@ -129,30 +85,16 @@ 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)]
@@ -173,22 +115,12 @@ 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)
@@ -206,20 +138,11 @@ 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/ILogger/OpenTelemetryLoggerOptions.cs b/src/OpenTelemetry/Logs/ILogger/OpenTelemetryLoggerOptions.cs
index 06b3478e548..921fd948ce0 100644
--- a/src/OpenTelemetry/Logs/ILogger/OpenTelemetryLoggerOptions.cs
+++ b/src/OpenTelemetry/Logs/ILogger/OpenTelemetryLoggerOptions.cs
@@ -82,6 +82,7 @@ public class OpenTelemetryLoggerOptions
///
/// Log processor to add.
/// Returns for chaining.
+ // TODO: [Obsolete("Use LoggerProviderBuilder.AddProcessor instead this method will be removed in a future version.")]
public OpenTelemetryLoggerOptions AddProcessor(BaseProcessor processor)
{
Guard.ThrowIfNull(processor);
@@ -96,6 +97,7 @@ public OpenTelemetryLoggerOptions AddProcessor(BaseProcessor processo
///
/// The factory that creates the service.
/// Returns for chaining.
+ // TODO: [Obsolete("Use LoggerProviderBuilder.AddProcessor instead this method will be removed in a future version.")]
public OpenTelemetryLoggerOptions AddProcessor(
Func> implementationFactory)
{
@@ -112,6 +114,7 @@ public OpenTelemetryLoggerOptions AddProcessor(
///
/// from which Resource will be built.
/// Returns for chaining.
+ // TODO: [Obsolete("Use LoggerProviderBuilder.SetResourceBuilder instead this method will be removed in a future version.")]
public OpenTelemetryLoggerOptions SetResourceBuilder(ResourceBuilder resourceBuilder)
{
Guard.ThrowIfNull(resourceBuilder);
diff --git a/src/OpenTelemetry/Logs/ILogger/OpenTelemetryLoggingExtensions.cs b/src/OpenTelemetry/Logs/ILogger/OpenTelemetryLoggingExtensions.cs
index 6fdf9244170..ba488b00df3 100644
--- a/src/OpenTelemetry/Logs/ILogger/OpenTelemetryLoggingExtensions.cs
+++ b/src/OpenTelemetry/Logs/ILogger/OpenTelemetryLoggingExtensions.cs
@@ -1,13 +1,10 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
+using System.Diagnostics;
#if NET6_0_OR_GREATER
using System.Diagnostics.CodeAnalysis;
#endif
-#if EXPOSE_EXPERIMENTAL_FEATURES
-using System.ComponentModel;
-#endif
-using System.Diagnostics;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Logging;
@@ -39,11 +36,10 @@ public static class OpenTelemetryLoggingExtensions
///
/// The to use.
/// The supplied for call chaining.
-#if EXPOSE_EXPERIMENTAL_FEATURES
- // todo: [Obsolete("Call UseOpenTelemetry instead this method will be removed in a future version.")]
+ /* TODO:
// Note: We hide AddOpenTelemetry from IDEs using EditorBrowsable when UseOpenTelemetry is present to reduce confusion.
[EditorBrowsable(EditorBrowsableState.Never)]
-#endif
+ [Obsolete("Call UseOpenTelemetry instead this method will be removed in a future version.")] */
public static ILoggingBuilder AddOpenTelemetry(
this ILoggingBuilder builder)
=> AddOpenTelemetryInternal(builder, configureBuilder: null, configureOptions: null);
@@ -55,11 +51,10 @@ public static ILoggingBuilder AddOpenTelemetry(
/// The to use.
/// Optional configuration action.
/// The supplied for call chaining.
-#if EXPOSE_EXPERIMENTAL_FEATURES
- // todo: [Obsolete("Call UseOpenTelemetry instead this method will be removed in a future version.")]
+ /* TODO:
// Note: We hide AddOpenTelemetry from IDEs using EditorBrowsable when UseOpenTelemetry is present to reduce confusion.
[EditorBrowsable(EditorBrowsableState.Never)]
-#endif
+ [Obsolete("Call UseOpenTelemetry instead this method will be removed in a future version.")]*/
public static ILoggingBuilder AddOpenTelemetry(
this ILoggingBuilder builder,
Action? configure)
@@ -70,7 +65,6 @@ public static ILoggingBuilder AddOpenTelemetry(
/// Adds an OpenTelemetry logger named 'OpenTelemetry' to the .
///
///
- /// 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 .
@@ -82,19 +76,9 @@ public static ILoggingBuilder AddOpenTelemetry(
#endif
public
#else
- ///
- /// Adds an OpenTelemetry logger named 'OpenTelemetry' to the .
- ///
- ///
- /// Note: This is safe to be called multiple times and by library authors.
- /// Only a single will be created
- /// for a given .
- ///
- /// The to use.
- /// The supplied for call chaining.
internal
#endif
- static ILoggingBuilder UseOpenTelemetry(
+ static ILoggingBuilder UseOpenTelemetry(
this ILoggingBuilder builder)
=> AddOpenTelemetryInternal(builder, configureBuilder: null, configureOptions: null);
@@ -104,23 +88,16 @@ static ILoggingBuilder UseOpenTelemetry(
///
///
/// The to use.
- /// Optional configuration action.
+ /// configuration action.
/// The supplied for call chaining.
#if NET8_0_OR_GREATER
[Experimental(DiagnosticDefinitions.LoggerProviderExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)]
#endif
public
#else
- ///
- /// Adds an OpenTelemetry logger named 'OpenTelemetry' to the .
- ///
- ///
- /// The to use.
- /// configuration action.
- /// The supplied for call chaining.
internal
#endif
- static ILoggingBuilder UseOpenTelemetry(
+ static ILoggingBuilder UseOpenTelemetry(
this ILoggingBuilder builder,
Action configure)
{
@@ -143,17 +120,9 @@ static ILoggingBuilder UseOpenTelemetry(
#endif
public
#else
- ///
- /// Adds an OpenTelemetry logger named 'OpenTelemetry' to the .
- ///
- ///
- /// The to use.
- /// Optional configuration action.
- /// Optional configuration action.
- /// The supplied for call chaining.
internal
#endif
- static ILoggingBuilder UseOpenTelemetry(
+ static ILoggingBuilder UseOpenTelemetry(
this ILoggingBuilder builder,
Action? configureBuilder,
Action? configureOptions)
diff --git a/src/OpenTelemetry/Logs/LoggerProviderExtensions.cs b/src/OpenTelemetry/Logs/LoggerProviderExtensions.cs
index 66dbac5ad42..f5d795fba2b 100644
--- a/src/OpenTelemetry/Logs/LoggerProviderExtensions.cs
+++ b/src/OpenTelemetry/Logs/LoggerProviderExtensions.cs
@@ -1,9 +1,6 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
-#if EXPOSE_EXPERIMENTAL_FEATURES && NET8_0_OR_GREATER
-using System.Diagnostics.CodeAnalysis;
-#endif
using OpenTelemetry.Internal;
namespace OpenTelemetry.Logs;
@@ -11,22 +8,12 @@ namespace OpenTelemetry.Logs;
///
/// Contains extension methods for the class.
///
-#if EXPOSE_EXPERIMENTAL_FEATURES
-#if NET8_0_OR_GREATER
-[Experimental(DiagnosticDefinitions.LoggerProviderExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)]
-#endif
-public
-#else
-internal
-#endif
- static class LoggerProviderExtensions
+public static class LoggerProviderExtensions
{
-#if EXPOSE_EXPERIMENTAL_FEATURES
///
/// Add a processor to the .
///
///
- ///
/// Note: The supplied will be
/// automatically disposed when then the is disposed.
@@ -34,19 +21,6 @@ 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);
@@ -60,27 +34,6 @@ 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.
@@ -99,7 +52,6 @@ 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);
@@ -113,28 +65,6 @@ 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.
@@ -154,7 +84,6 @@ 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/Logs/LoggerProviderSdk.cs b/src/OpenTelemetry/Logs/LoggerProviderSdk.cs
index f3fc00fe8a1..9dd7297dfa8 100644
--- a/src/OpenTelemetry/Logs/LoggerProviderSdk.cs
+++ b/src/OpenTelemetry/Logs/LoggerProviderSdk.cs
@@ -194,7 +194,12 @@ public bool ContainsBatchProcessor(BaseProcessor processor)
}
///
- protected override bool TryCreateLogger(
+#if EXPOSE_EXPERIMENTAL_FEATURES
+ protected
+#else
+ internal
+#endif
+ override bool TryCreateLogger(
string? name,
#if NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER
[NotNullWhen(true)]
diff --git a/src/OpenTelemetry/OpenTelemetryBuilderSdkExtensions.cs b/src/OpenTelemetry/OpenTelemetryBuilderSdkExtensions.cs
index 4ae87d34078..c499ef02631 100644
--- a/src/OpenTelemetry/OpenTelemetryBuilderSdkExtensions.cs
+++ b/src/OpenTelemetry/OpenTelemetryBuilderSdkExtensions.cs
@@ -1,9 +1,6 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
-#if EXPOSE_EXPERIMENTAL_FEATURES && NET8_0_OR_GREATER
-using System.Diagnostics.CodeAnalysis;
-#endif
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Diagnostics.Metrics;
using Microsoft.Extensions.Logging;
@@ -129,14 +126,11 @@ public static IOpenTelemetryBuilder WithTracing(
return builder;
}
-#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.
/// Notes:
///
/// - This is safe to be called multiple times and by library authors.
@@ -149,48 +143,9 @@ public static IOpenTelemetryBuilder WithTracing(
///
/// The supplied for chaining
/// calls.
-#if NET8_0_OR_GREATER
- [Experimental(DiagnosticDefinitions.LoggerProviderExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)]
-#endif
- public
-#else
- ///
- /// Adds logging services into the builder.
- ///
- /// .
- ///
- /// Notes:
- ///
- /// - This is safe to be called multiple times and by library authors.
- /// Only a single will be created for a given
- /// .
- /// - This method automatically registers an named 'OpenTelemetry' into the .
- ///
- ///
- /// The supplied for chaining
- /// calls.
- internal
-#endif
- static IOpenTelemetryBuilder WithLogging(this IOpenTelemetryBuilder builder)
+ public static IOpenTelemetryBuilder WithLogging(this IOpenTelemetryBuilder builder)
=> WithLogging(builder, configureBuilder: null, configureOptions: null);
-#if EXPOSE_EXPERIMENTAL_FEATURES
- ///
- /// Adds logging services into the builder.
- ///
- ///
- /// .
- ///
- /// configuration callback.
- /// The supplied for chaining
- /// calls.
-#if NET8_0_OR_GREATER
- [Experimental(DiagnosticDefinitions.LoggerProviderExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)]
-#endif
- public
-#else
///
/// Adds logging services into the builder.
///
@@ -200,18 +155,15 @@ static IOpenTelemetryBuilder WithLogging(this IOpenTelemetryBuilder builder)
/// configuration callback.
/// The supplied for chaining
/// calls.
- internal
-#endif
- static IOpenTelemetryBuilder WithLogging(
- this IOpenTelemetryBuilder builder,
- Action configure)
+ public static IOpenTelemetryBuilder WithLogging(
+ this IOpenTelemetryBuilder builder,
+ Action configure)
{
Guard.ThrowIfNull(configure);
return WithLogging(builder, configureBuilder: configure, configureOptions: null);
}
-#if EXPOSE_EXPERIMENTAL_FEATURES
///
/// Adds logging services into the builder.
///
@@ -220,31 +172,16 @@ static IOpenTelemetryBuilder WithLogging(
/// Optional configuration callback.
/// Optional configuration callback.
+ /// cref="OpenTelemetryLoggerOptions"/> configuration callback. are used by the named 'OpenTelemetry' automatically registered
+ /// by this method.
/// The supplied for chaining
/// calls.
-#if NET8_0_OR_GREATER
- [Experimental(DiagnosticDefinitions.LoggerProviderExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)]
-#endif
- public
-#else
- ///
- /// Adds logging services into the builder.
- ///
- ///
- /// .
- /// Optional configuration callback.
- /// Optional configuration callback.
- /// The supplied for chaining
- /// calls.
- internal
-#endif
- static IOpenTelemetryBuilder WithLogging(
- this IOpenTelemetryBuilder builder,
- Action? configureBuilder,
- Action? configureOptions)
+ public static IOpenTelemetryBuilder WithLogging(
+ this IOpenTelemetryBuilder builder,
+ Action? configureBuilder,
+ Action? configureOptions)
{
builder.Services.AddLogging(
logging => logging.UseOpenTelemetry(configureBuilder, configureOptions));
diff --git a/src/OpenTelemetry/Sdk.cs b/src/OpenTelemetry/Sdk.cs
index 9dd0f2776e0..3a95120e3ef 100644
--- a/src/OpenTelemetry/Sdk.cs
+++ b/src/OpenTelemetry/Sdk.cs
@@ -90,7 +90,7 @@ public static TracerProviderBuilder CreateTracerProviderBuilder()
/// instance, which is used
/// to build a .
#if NET8_0_OR_GREATER
- [Experimental(DiagnosticDefinitions.LoggerProviderExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)]
+ [Experimental(DiagnosticDefinitions.LogsBridgeExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)]
#endif
public
#else
diff --git a/test/Benchmarks/Helper/LogRecordHelper.cs b/test/Benchmarks/Helper/LogRecordHelper.cs
index 0cfd5efde25..f08e62527f5 100644
--- a/test/Benchmarks/Helper/LogRecordHelper.cs
+++ b/test/Benchmarks/Helper/LogRecordHelper.cs
@@ -12,9 +12,9 @@ internal static LogRecord CreateTestLogRecord()
{
var items = new List(1);
using var factory = LoggerFactory.Create(builder => builder
- .AddOpenTelemetry(loggerOptions =>
+ .UseOpenTelemetry(logging =>
{
- loggerOptions.AddInMemoryExporter(items);
+ logging.AddInMemoryExporter(items);
}));
var logger = factory.CreateLogger("TestLogger");
diff --git a/test/Benchmarks/Logs/LogBenchmarks.cs b/test/Benchmarks/Logs/LogBenchmarks.cs
index ed1d637e7b8..1854eb26f2a 100644
--- a/test/Benchmarks/Logs/LogBenchmarks.cs
+++ b/test/Benchmarks/Logs/LogBenchmarks.cs
@@ -50,14 +50,14 @@ public LogBenchmarks()
this.loggerFactoryWithOneProcessor = LoggerFactory.Create(builder =>
{
- builder.AddOpenTelemetry(options => options
+ builder.UseOpenTelemetry(logging => logging
.AddProcessor(new DummyLogProcessor()));
});
this.loggerWithOneProcessor = this.loggerFactoryWithOneProcessor.CreateLogger();
this.loggerFactoryWithTwoProcessor = LoggerFactory.Create(builder =>
{
- builder.AddOpenTelemetry(options => options
+ builder.UseOpenTelemetry(logging => logging
.AddProcessor(new DummyLogProcessor())
.AddProcessor(new DummyLogProcessor()));
});
@@ -65,7 +65,7 @@ public LogBenchmarks()
this.loggerFactoryWithThreeProcessor = LoggerFactory.Create(builder =>
{
- builder.AddOpenTelemetry(options => options
+ builder.UseOpenTelemetry(logging => logging
.AddProcessor(new DummyLogProcessor())
.AddProcessor(new DummyLogProcessor())
.AddProcessor(new DummyLogProcessor()));
diff --git a/test/OpenTelemetry.Api.Tests/Logs/LoggerProviderTests.cs b/test/OpenTelemetry.Api.Tests/Logs/LoggerProviderTests.cs
index e26443707d2..24d343d98bd 100644
--- a/test/OpenTelemetry.Api.Tests/Logs/LoggerProviderTests.cs
+++ b/test/OpenTelemetry.Api.Tests/Logs/LoggerProviderTests.cs
@@ -62,7 +62,11 @@ private sealed class NoopLoggerProvider : LoggerProvider
private sealed class TestLoggerProvider : LoggerProvider
{
+#if OPENTELEMETRY_API_EXPERIMENTAL_FEATURES_EXPOSED
protected override bool TryCreateLogger(
+#else
+ internal override bool TryCreateLogger(
+#endif
string? name,
#if NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER
[NotNullWhen(true)]
diff --git a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/IntegrationTest/IntegrationTests.cs b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/IntegrationTest/IntegrationTests.cs
index 9fbe4b5703a..14b73571e35 100644
--- a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/IntegrationTest/IntegrationTests.cs
+++ b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/IntegrationTest/IntegrationTests.cs
@@ -4,7 +4,6 @@
using System.Diagnostics;
using System.Diagnostics.Metrics;
using System.Diagnostics.Tracing;
-using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation;
using OpenTelemetry.Logs;
@@ -235,7 +234,7 @@ public void LogExportResultIsSuccess(OtlpExportProtocol protocol, string endpoin
using var loggerFactory = LoggerFactory.Create(builder =>
{
builder
- .AddOpenTelemetry(options => options
+ .UseOpenTelemetry(logging => logging
.AddProcessor(sp =>
OtlpLogExporterHelperExtensions.BuildOtlpLogExporter(
sp,
diff --git a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs
index fd0ea958c28..f494a2683c6 100644
--- a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs
+++ b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs
@@ -3,7 +3,6 @@
using System.Collections.ObjectModel;
using System.Diagnostics;
-using System.Reflection;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
@@ -111,46 +110,32 @@ public void UserHttpFactoryCalledWhenUsingHttpProtobuf()
[Fact]
public void AddOtlpExporterSetsDefaultBatchExportProcessor()
{
- var loggerProvider = Sdk.CreateLoggerProviderBuilder()
+ using var loggerProvider = Sdk.CreateLoggerProviderBuilder()
.AddOtlpExporter()
.Build();
- CheckProcessorDefaults();
-
- loggerProvider.Dispose();
-
- void CheckProcessorDefaults()
- {
- var bindingFlags = BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic;
-
- var processor = typeof(BaseProcessor)
- .Assembly
- .GetType("OpenTelemetry.Logs.LoggerProviderSdk")
- .GetProperty("Processor", bindingFlags)
- .GetValue(loggerProvider) as BatchExportProcessor;
+ var loggerProviderSdk = loggerProvider as LoggerProviderSdk;
+ Assert.NotNull(loggerProviderSdk);
- Assert.NotNull(processor);
+ var batchProcessor = loggerProviderSdk.Processor as BatchLogRecordExportProcessor;
+ Assert.NotNull(batchProcessor);
- var scheduledDelayMilliseconds = typeof(BatchExportProcessor)
- .GetField("scheduledDelayMilliseconds", bindingFlags)
- .GetValue(processor);
-
- Assert.Equal(5000, scheduledDelayMilliseconds);
- }
+ Assert.Equal(BatchLogRecordExportProcessor.DefaultScheduledDelayMilliseconds, batchProcessor.ScheduledDelayMilliseconds);
+ Assert.Equal(BatchLogRecordExportProcessor.DefaultExporterTimeoutMilliseconds, batchProcessor.ExporterTimeoutMilliseconds);
+ Assert.Equal(BatchLogRecordExportProcessor.DefaultMaxExportBatchSize, batchProcessor.MaxExportBatchSize);
}
- [Fact]
- public void AddOtlpLogExporterReceivesAttributesWithParseStateValueSetToFalse()
+ [Theory]
+ [InlineData(false)]
+ [InlineData(true)]
+ public void AddOtlpLogExporterReceivesAttributesWithParseStateValueSetToFalse(bool callUseOpenTelemetry)
{
bool optionsValidated = false;
var logRecords = new List();
using var loggerFactory = LoggerFactory.Create(builder =>
{
- builder
- .AddOpenTelemetry(options => options
- .AddInMemoryExporter(logRecords)
- .AddOtlpExporter());
+ ConfigureOtlpExporter(builder, callUseOpenTelemetry, logRecords: logRecords);
builder.Services.Configure(o =>
{
@@ -172,21 +157,20 @@ public void AddOtlpLogExporterReceivesAttributesWithParseStateValueSetToFalse()
}
[Theory]
- [InlineData(true)]
- [InlineData(false)]
- public void AddOtlpLogExporterParseStateValueCanBeTurnedOff(bool parseState)
+ [InlineData(true, false)]
+ [InlineData(false, false)]
+ [InlineData(true, true)]
+ [InlineData(false, true)]
+ public void AddOtlpLogExporterParseStateValueCanBeTurnedOff(bool parseState, bool callUseOpenTelemetry)
{
var logRecords = new List();
using var loggerFactory = LoggerFactory.Create(builder =>
{
- builder
- .AddOpenTelemetry(options =>
- {
- options.ParseStateValues = parseState;
- options
- .AddInMemoryExporter(logRecords)
- .AddOtlpExporter();
- });
+ ConfigureOtlpExporter(
+ builder,
+ callUseOpenTelemetry,
+ configureOptions: o => o.ParseStateValues = parseState,
+ logRecords: logRecords);
});
var logger = loggerFactory.CreateLogger("OtlpLogExporterTests");
@@ -215,17 +199,19 @@ public void AddOtlpLogExporterParseStateValueCanBeTurnedOff(bool parseState)
}
[Theory]
- [InlineData(true)]
- [InlineData(false)]
- public void AddOtlpLogExporterParseStateValueCanBeTurnedOffHosting(bool parseState)
+ [InlineData(true, false)]
+ [InlineData(false, false)]
+ [InlineData(true, true)]
+ [InlineData(false, true)]
+ public void AddOtlpLogExporterParseStateValueCanBeTurnedOffHosting(bool parseState, bool callUseOpenTelemetry)
{
var logRecords = new List();
var hostBuilder = new HostBuilder();
- hostBuilder.ConfigureLogging(logging => logging
- .AddOpenTelemetry(options => options
- .AddInMemoryExporter(logRecords)
- .AddOtlpExporter()));
+ hostBuilder.ConfigureLogging(logging =>
+ {
+ ConfigureOtlpExporter(logging, callUseOpenTelemetry, logRecords: logRecords);
+ });
hostBuilder.ConfigureServices(services =>
services.Configure(options => options.ParseStateValues = parseState));
@@ -263,12 +249,13 @@ public void OtlpLogRecordTestWhenStateValuesArePopulated()
var logRecords = new List();
using var loggerFactory = LoggerFactory.Create(builder =>
{
- builder.AddOpenTelemetry(options =>
- {
- options.IncludeFormattedMessage = true;
- options.ParseStateValues = true;
- options.AddInMemoryExporter(logRecords);
- });
+ builder.UseOpenTelemetry(
+ logging => logging.AddInMemoryExporter(logRecords),
+ options =>
+ {
+ options.IncludeFormattedMessage = true;
+ options.ParseStateValues = true;
+ });
});
var logger = loggerFactory.CreateLogger("OtlpLogExporterTests");
@@ -308,12 +295,13 @@ public void CheckToOtlpLogRecordEventId(string emitLogEventAttributes)
var logRecords = new List();
using var loggerFactory = LoggerFactory.Create(builder =>
{
- builder.AddOpenTelemetry(options =>
- {
- options.IncludeFormattedMessage = true;
- options.ParseStateValues = true;
- options.AddInMemoryExporter(logRecords);
- });
+ builder.UseOpenTelemetry(
+ logging => logging.AddInMemoryExporter(logRecords),
+ options =>
+ {
+ options.IncludeFormattedMessage = true;
+ options.ParseStateValues = true;
+ });
});
var logger = loggerFactory.CreateLogger("OtlpLogExporterTests");
@@ -377,10 +365,7 @@ public void CheckToOtlpLogRecordTimestamps()
var logRecords = new List();
using var loggerFactory = LoggerFactory.Create(builder =>
{
- builder.AddOpenTelemetry(options =>
- {
- options.AddInMemoryExporter(logRecords);
- });
+ builder.UseOpenTelemetry(logging => logging.AddInMemoryExporter(logRecords));
});
var logger = loggerFactory.CreateLogger("OtlpLogExporterTests");
@@ -400,10 +385,7 @@ public void CheckToOtlpLogRecordTraceIdSpanIdFlagWithNoActivity()
var logRecords = new List();
using var loggerFactory = LoggerFactory.Create(builder =>
{
- builder.AddOpenTelemetry(options =>
- {
- options.AddInMemoryExporter(logRecords);
- });
+ builder.UseOpenTelemetry(logging => logging.AddInMemoryExporter(logRecords));
});
var logger = loggerFactory.CreateLogger("OtlpLogExporterTests");
@@ -426,10 +408,7 @@ public void CheckToOtlpLogRecordSpanIdTraceIdAndFlag()
var logRecords = new List();
using var loggerFactory = LoggerFactory.Create(builder =>
{
- builder.AddOpenTelemetry(options =>
- {
- options.AddInMemoryExporter(logRecords);
- });
+ builder.UseOpenTelemetry(logging => logging.AddInMemoryExporter(logRecords));
});
var logger = loggerFactory.CreateLogger("OtlpLogExporterTests");
@@ -466,12 +445,11 @@ public void CheckToOtlpLogRecordSeverityLevelAndText(LogLevel logLevel)
var logRecords = new List();
using var loggerFactory = LoggerFactory.Create(builder =>
{
- builder.AddOpenTelemetry(options =>
- {
- options.AddInMemoryExporter(logRecords);
- options.IncludeFormattedMessage = true;
- })
- .AddFilter("CheckToOtlpLogRecordSeverityLevelAndText", LogLevel.Trace);
+ builder
+ .UseOpenTelemetry(
+ logging => logging.AddInMemoryExporter(logRecords),
+ options => options.IncludeFormattedMessage = true)
+ .AddFilter("CheckToOtlpLogRecordSeverityLevelAndText", LogLevel.Trace);
});
var logger = loggerFactory.CreateLogger("CheckToOtlpLogRecordSeverityLevelAndText");
@@ -519,12 +497,13 @@ public void CheckToOtlpLogRecordBodyIsPopulated(bool includeFormattedMessage)
var logRecords = new List();
using var loggerFactory = LoggerFactory.Create(builder =>
{
- builder.AddOpenTelemetry(options =>
- {
- options.AddInMemoryExporter(logRecords);
- options.IncludeFormattedMessage = includeFormattedMessage;
- options.ParseStateValues = true;
- });
+ builder.UseOpenTelemetry(
+ logging => logging.AddInMemoryExporter(logRecords),
+ options =>
+ {
+ options.IncludeFormattedMessage = includeFormattedMessage;
+ options.ParseStateValues = true;
+ });
});
var logger = loggerFactory.CreateLogger("OtlpLogExporterTests");
@@ -642,10 +621,7 @@ public void CheckToOtlpLogRecordExceptionAttributes()
var logRecords = new List();
using var loggerFactory = LoggerFactory.Create(builder =>
{
- builder.AddOpenTelemetry(options =>
- {
- options.AddInMemoryExporter(logRecords);
- });
+ builder.UseOpenTelemetry(logging => logging.AddInMemoryExporter(logRecords));
});
var logger = loggerFactory.CreateLogger("OtlpLogExporterTests");
@@ -683,11 +659,9 @@ public void CheckToOtlpLogRecordRespectsAttributeLimits()
var logRecords = new List();
using var loggerFactory = LoggerFactory.Create(builder =>
{
- builder.AddOpenTelemetry(options =>
- {
- options.ParseStateValues = true;
- options.AddInMemoryExporter(logRecords);
- });
+ builder.UseOpenTelemetry(
+ logging => logging.AddInMemoryExporter(logRecords),
+ options => options.ParseStateValues = true);
});
var logger = loggerFactory.CreateLogger(string.Empty);
@@ -789,11 +763,9 @@ public void ToOtlpLog_WhenOptionsIncludeScopesIsFalse_DoesNotContainScopeAttribu
var logRecords = new List(1);
using var loggerFactory = LoggerFactory.Create(builder =>
{
- builder.AddOpenTelemetry(options =>
- {
- options.IncludeScopes = false;
- options.AddInMemoryExporter(logRecords);
- });
+ builder.UseOpenTelemetry(
+ logging => logging.AddInMemoryExporter(logRecords),
+ options => options.IncludeScopes = false);
});
var logger = loggerFactory.CreateLogger("Some category");
@@ -826,11 +798,9 @@ public void ToOtlpLog_WhenOptionsIncludeScopesIsTrue_ContainsScopeAttributeStrin
var logRecords = new List(1);
using var loggerFactory = LoggerFactory.Create(builder =>
{
- builder.AddOpenTelemetry(options =>
- {
- options.IncludeScopes = true;
- options.AddInMemoryExporter(logRecords);
- });
+ builder.UseOpenTelemetry(
+ logging => logging.AddInMemoryExporter(logRecords),
+ options => options.IncludeScopes = true);
});
var logger = loggerFactory.CreateLogger(nameof(OtlpLogExporterTests));
@@ -866,11 +836,9 @@ public void ToOtlpLog_WhenOptionsIncludeScopesIsTrue_ContainsScopeAttributeBoolV
var logRecords = new List(1);
using var loggerFactory = LoggerFactory.Create(builder =>
{
- builder.AddOpenTelemetry(options =>
- {
- options.IncludeScopes = true;
- options.AddInMemoryExporter(logRecords);
- });
+ builder.UseOpenTelemetry(
+ logging => logging.AddInMemoryExporter(logRecords),
+ options => options.IncludeScopes = true);
});
var logger = loggerFactory.CreateLogger(nameof(OtlpLogExporterTests));
@@ -918,11 +886,9 @@ public void ToOtlpLog_WhenOptionsIncludeScopesIsTrue_ContainsScopeAttributeIntVa
var logRecords = new List(1);
using var loggerFactory = LoggerFactory.Create(builder =>
{
- builder.AddOpenTelemetry(options =>
- {
- options.IncludeScopes = true;
- options.AddInMemoryExporter(logRecords);
- });
+ builder.UseOpenTelemetry(
+ logging => logging.AddInMemoryExporter(logRecords),
+ options => options.IncludeScopes = true);
});
var logger = loggerFactory.CreateLogger(nameof(OtlpLogExporterTests));
@@ -958,11 +924,9 @@ public void ToOtlpLog_WhenOptionsIncludeScopesIsTrue_ContainsScopeAttributeDoubl
var logRecords = new List(1);
using var loggerFactory = LoggerFactory.Create(builder =>
{
- builder.AddOpenTelemetry(options =>
- {
- options.IncludeScopes = true;
- options.AddInMemoryExporter(logRecords);
- });
+ builder.UseOpenTelemetry(
+ logging => logging.AddInMemoryExporter(logRecords),
+ options => options.IncludeScopes = true);
});
var logger = loggerFactory.CreateLogger(nameof(OtlpLogExporterTests));
@@ -998,11 +962,9 @@ public void ToOtlpLog_WhenOptionsIncludeScopesIsTrue_ContainsScopeAttributeDoubl
var logRecords = new List(1);
using var loggerFactory = LoggerFactory.Create(builder =>
{
- builder.AddOpenTelemetry(options =>
- {
- options.IncludeScopes = true;
- options.AddInMemoryExporter(logRecords);
- });
+ builder.UseOpenTelemetry(
+ logging => logging.AddInMemoryExporter(logRecords),
+ options => options.IncludeScopes = true);
});
var logger = loggerFactory.CreateLogger(nameof(OtlpLogExporterTests));
@@ -1035,11 +997,9 @@ public void ToOtlpLog_WhenOptionsIncludeScopesIsTrue_AndScopeStateIsOfTypeString
var logRecords = new List(1);
using var loggerFactory = LoggerFactory.Create(builder =>
{
- builder.AddOpenTelemetry(options =>
- {
- options.IncludeScopes = true;
- options.AddInMemoryExporter(logRecords);
- });
+ builder.UseOpenTelemetry(
+ logging => logging.AddInMemoryExporter(logRecords),
+ options => options.IncludeScopes = true);
});
var logger = loggerFactory.CreateLogger(nameof(OtlpLogExporterTests));
@@ -1071,11 +1031,9 @@ public void ToOtlpLog_WhenOptionsIncludeScopesIsTrue_AndScopeStateIsOfPrimitiveT
var logRecords = new List(1);
using var loggerFactory = LoggerFactory.Create(builder =>
{
- builder.AddOpenTelemetry(options =>
- {
- options.IncludeScopes = true;
- options.AddInMemoryExporter(logRecords);
- });
+ builder.UseOpenTelemetry(
+ logging => logging.AddInMemoryExporter(logRecords),
+ options => options.IncludeScopes = true);
});
var logger = loggerFactory.CreateLogger(nameof(OtlpLogExporterTests));
@@ -1102,11 +1060,9 @@ public void ToOtlpLog_WhenOptionsIncludeScopesIsTrue_AndScopeStateIsOfDictionary
var logRecords = new List(1);
using var loggerFactory = LoggerFactory.Create(builder =>
{
- builder.AddOpenTelemetry(options =>
- {
- options.IncludeScopes = true;
- options.AddInMemoryExporter(logRecords);
- });
+ builder.UseOpenTelemetry(
+ logging => logging.AddInMemoryExporter(logRecords),
+ options => options.IncludeScopes = true);
});
var logger = loggerFactory.CreateLogger(nameof(OtlpLogExporterTests));
@@ -1141,11 +1097,9 @@ public void ToOtlpLog_WhenOptionsIncludeScopesIsTrue_AndScopeStateIsOfEnumerable
var logRecords = new List(1);
using var loggerFactory = LoggerFactory.Create(builder =>
{
- builder.AddOpenTelemetry(options =>
- {
- options.IncludeScopes = true;
- options.AddInMemoryExporter(logRecords);
- });
+ builder.UseOpenTelemetry(
+ logging => logging.AddInMemoryExporter(logRecords),
+ options => options.IncludeScopes = true);
});
var logger = loggerFactory.CreateLogger(nameof(OtlpLogExporterTests));
@@ -1180,11 +1134,9 @@ public void ToOtlpLog_WhenOptionsIncludeScopesIsTrue_AndMultipleScopesAreAdded_C
var logRecords = new List(1);
using var loggerFactory = LoggerFactory.Create(builder =>
{
- builder.AddOpenTelemetry(options =>
- {
- options.IncludeScopes = true;
- options.AddInMemoryExporter(logRecords);
- });
+ builder.UseOpenTelemetry(
+ logging => logging.AddInMemoryExporter(logRecords),
+ options => options.IncludeScopes = true);
});
var logger = loggerFactory.CreateLogger(nameof(OtlpLogExporterTests));
@@ -1223,11 +1175,9 @@ public void ToOtlpLog_WhenOptionsIncludeScopesIsTrue_AndMultipleScopeLevelsAreAd
var logRecords = new List(1);
using var loggerFactory = LoggerFactory.Create(builder =>
{
- builder.AddOpenTelemetry(options =>
- {
- options.IncludeScopes = true;
- options.AddInMemoryExporter(logRecords);
- });
+ builder.UseOpenTelemetry(
+ logging => logging.AddInMemoryExporter(logRecords),
+ options => options.IncludeScopes = true);
});
var logger = loggerFactory.CreateLogger(nameof(OtlpLogExporterTests));
@@ -1265,11 +1215,9 @@ public void ToOtlpLog_WhenOptionsIncludeScopesIsTrue_AndScopeIsUsedInLogMethod_C
var logRecords = new List(1);
using var loggerFactory = LoggerFactory.Create(builder =>
{
- builder.AddOpenTelemetry(options =>
- {
- options.IncludeScopes = true;
- options.AddInMemoryExporter(logRecords);
- });
+ builder.UseOpenTelemetry(
+ logging => logging.AddInMemoryExporter(logRecords),
+ options => options.IncludeScopes = true);
});
var logger = loggerFactory.CreateLogger(nameof(OtlpLogExporterTests));
@@ -1303,56 +1251,66 @@ public void ToOtlpLog_WhenOptionsIncludeScopesIsTrue_AndScopeIsUsedInLogMethod_C
Assert.Contains(scopeValue2, allScopeValues);
}
- [Fact]
- public void AddOtlpLogExporterDefaultOptionsTest()
+ [Theory]
+ [InlineData(true)]
+ [InlineData(false)]
+ public void AddOtlpLogExporterDefaultOptionsTest(bool callUseOpenTelemetry)
{
- var options = new OpenTelemetryLoggerOptions();
-
- options.AddOtlpExporter();
-
- var provider = new OpenTelemetryLoggerProvider(new TestOptionsMonitor(options));
+ var services = new ServiceCollection();
+ services.AddLogging(builder =>
+ {
+ ConfigureOtlpExporter(builder, callUseOpenTelemetry);
+ });
- var processor = GetProcessor(provider);
+ using var sp = services.BuildServiceProvider();
- Assert.NotNull(processor);
+ sp.GetRequiredService();
- var batchProcesor = processor as BatchLogRecordExportProcessor;
+ var provider = sp.GetRequiredService() as LoggerProviderSdk;
+ Assert.NotNull(provider);
+ var batchProcesor = provider.Processor as BatchLogRecordExportProcessor;
Assert.NotNull(batchProcesor);
- var batchProcessorType = typeof(BatchExportProcessor);
-
- Assert.Equal(5000, batchProcessorType.GetField("scheduledDelayMilliseconds", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(batchProcesor));
+ Assert.Equal(BatchLogRecordExportProcessor.DefaultScheduledDelayMilliseconds, batchProcesor.ScheduledDelayMilliseconds);
}
[Theory]
- [InlineData(ExportProcessorType.Simple)]
- [InlineData(ExportProcessorType.Batch)]
- public void AddOtlpLogExporterLogRecordProcessorOptionsTest(ExportProcessorType processorType)
+ [InlineData(ExportProcessorType.Simple, false)]
+ [InlineData(ExportProcessorType.Batch, false)]
+ [InlineData(ExportProcessorType.Simple, true)]
+ [InlineData(ExportProcessorType.Batch, true)]
+ public void AddOtlpLogExporterLogRecordProcessorOptionsTest(ExportProcessorType processorType, bool callUseOpenTelemetry)
{
- var options = new OpenTelemetryLoggerOptions();
-
- options.AddOtlpExporter((o, l) =>
+ var services = new ServiceCollection();
+ services.AddLogging(builder =>
{
- l.ExportProcessorType = processorType;
- l.BatchExportProcessorOptions = new BatchExportLogRecordProcessorOptions() { ScheduledDelayMilliseconds = 1000 };
+ ConfigureOtlpExporter(
+ builder,
+ callUseOpenTelemetry,
+ configureExporterAndProcessor: (e, p) =>
+ {
+ p.ExportProcessorType = processorType;
+ p.BatchExportProcessorOptions = new BatchExportLogRecordProcessorOptions() { ScheduledDelayMilliseconds = 1000 };
+ });
});
- var provider = new OpenTelemetryLoggerProvider(new TestOptionsMonitor(options));
+ using var sp = services.BuildServiceProvider();
+
+ sp.GetRequiredService();
- var processor = GetProcessor(provider);
+ var provider = sp.GetRequiredService() as LoggerProviderSdk;
+ Assert.NotNull(provider);
+ var processor = provider.Processor;
Assert.NotNull(processor);
if (processorType == ExportProcessorType.Batch)
{
var batchProcesor = processor as BatchLogRecordExportProcessor;
-
Assert.NotNull(batchProcesor);
- var batchProcessorType = typeof(BatchExportProcessor);
-
- Assert.Equal(1000, batchProcessorType.GetField("scheduledDelayMilliseconds", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(batchProcesor));
+ Assert.Equal(1000, batchProcesor.ScheduledDelayMilliseconds);
}
else
{
@@ -1368,9 +1326,7 @@ public void ValidateInstrumentationScope()
var logRecords = new List();
using var loggerFactory = LoggerFactory.Create(builder =>
{
- builder
- .AddOpenTelemetry(options => options
- .AddInMemoryExporter(logRecords));
+ builder.UseOpenTelemetry(logging => logging.AddInMemoryExporter(logRecords));
});
var logger1 = loggerFactory.CreateLogger("OtlpLogExporterTests-A");
@@ -1421,9 +1377,11 @@ public void ValidateInstrumentationScope()
}
[Theory]
- [InlineData(null)]
- [InlineData("logging")]
- public void VerifyEnvironmentVariablesTakenFromIConfigurationWhenUsingLoggerFactoryCreate(string optionsName)
+ [InlineData(null, false)]
+ [InlineData("logging", false)]
+ [InlineData(null, true)]
+ [InlineData("logging", true)]
+ public void VerifyEnvironmentVariablesTakenFromIConfigurationWhenUsingLoggerFactoryCreate(string optionsName, bool callUseOpenTelemetry)
{
RunVerifyEnvironmentVariablesTakenFromIConfigurationTest(
optionsName,
@@ -1433,7 +1391,10 @@ public void VerifyEnvironmentVariablesTakenFromIConfigurationWhenUsingLoggerFact
{
configure(logging.Services);
- logging.AddOpenTelemetry(o => o.AddOtlpExporter(optionsName, configure: null));
+ ConfigureOtlpExporter(
+ logging,
+ callUseOpenTelemetry,
+ name: optionsName);
});
return (factory, factory);
@@ -1441,9 +1402,11 @@ public void VerifyEnvironmentVariablesTakenFromIConfigurationWhenUsingLoggerFact
}
[Theory]
- [InlineData(null)]
- [InlineData("logging")]
- public void VerifyEnvironmentVariablesTakenFromIConfigurationWhenUsingLoggingBuilder(string optionsName)
+ [InlineData(null, false)]
+ [InlineData("logging", false)]
+ [InlineData(null, true)]
+ [InlineData("logging", true)]
+ public void VerifyEnvironmentVariablesTakenFromIConfigurationWhenUsingLoggingBuilder(string optionsName, bool callUseOpenTelemetry)
{
RunVerifyEnvironmentVariablesTakenFromIConfigurationTest(
optionsName,
@@ -1454,8 +1417,10 @@ public void VerifyEnvironmentVariablesTakenFromIConfigurationWhenUsingLoggingBui
configure(services);
services.AddLogging(
- logging => logging.AddOpenTelemetry(o =>
- o.AddOtlpExporter(optionsName, configure: null)));
+ logging => ConfigureOtlpExporter(
+ logging,
+ callUseOpenTelemetry,
+ name: optionsName));
var sp = services.BuildServiceProvider();
@@ -1582,11 +1547,62 @@ private static OtlpCommon.KeyValue TryGetAttribute(OtlpLogs.LogRecord record, st
return record.Attributes.FirstOrDefault(att => att.Key == key);
}
- private static BaseProcessor GetProcessor(OpenTelemetryLoggerProvider provider)
+ private static void ConfigureOtlpExporter(
+ ILoggingBuilder builder,
+ bool callUseOpenTelemetry,
+ string name = null,
+ Action configureExporter = null,
+ Action configureExporterAndProcessor = null,
+ Action configureOptions = null,
+ List logRecords = null)
{
- var sdkProvider = typeof(OpenTelemetryLoggerProvider).GetField("Provider", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(provider);
+ if (callUseOpenTelemetry)
+ {
+ builder.UseOpenTelemetry(
+ logging =>
+ {
+ if (configureExporterAndProcessor != null)
+ {
+ logging.AddOtlpExporter(name, configureExporterAndProcessor);
+ }
+ else
+ {
+ logging.AddOtlpExporter(name, configureExporter);
+ }
+
+ if (logRecords != null)
+ {
+ logging.AddInMemoryExporter(logRecords);
+ }
+ },
+ options =>
+ {
+ configureOptions?.Invoke(options);
+ });
+ }
+ else
+ {
+#pragma warning disable CS0618 // Type or member is obsolete
+ builder.AddOpenTelemetry(options =>
+ {
+ configureOptions?.Invoke(options);
+
+ if (configureExporterAndProcessor != null)
+ {
+ options.AddOtlpExporter(name, configureExporterAndProcessor);
+ }
+ else
+ {
+ options.AddOtlpExporter(name, configureExporter);
+ }
- return (BaseProcessor)sdkProvider.GetType().GetProperty("Processor", BindingFlags.Instance | BindingFlags.Public).GetMethod.Invoke(sdkProvider, null);
+ if (logRecords != null)
+ {
+ options.AddInMemoryExporter(logRecords);
+ }
+ });
+#pragma warning restore CS0618 // Type or member is obsolete
+ }
}
private sealed class TestOptionsMonitor : IOptionsMonitor
diff --git a/test/OpenTelemetry.Tests.Stress.Logs/Program.cs b/test/OpenTelemetry.Tests.Stress.Logs/Program.cs
index dececdacb51..c8b640aea37 100644
--- a/test/OpenTelemetry.Tests.Stress.Logs/Program.cs
+++ b/test/OpenTelemetry.Tests.Stress.Logs/Program.cs
@@ -23,9 +23,9 @@ public LogsStressTest(StressTestOptions options)
{
this.loggerFactory = LoggerFactory.Create(builder =>
{
- builder.AddOpenTelemetry(options =>
+ builder.AddOpenTelemetry(logging =>
{
- options.AddProcessor(new DummyProcessor());
+ logging.AddProcessor(new DummyProcessor());
});
});