diff --git a/Directory.Build.props b/Directory.Build.props index c2b84ab..e219530 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -18,7 +18,6 @@ true $([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), build.bat)) $(MSBuildThisFileDirectory).artifacts - 002400000480000094000000060200000024000052534131000400000100010015b0fa59d868c7f3ea2ae67567b19e102465745f01b430a38a42b92fd41a0f5869bec1f2b33b589d78662af432fe6b789ef72d4738f7b1a86264d7aeb5185ed8995b2bb104e7c5c58845f1a618be829e410fa34a6bd7d714ece191ed68a66333a83ae7456ee32e9aeb54bc1d7410ae8c344367257e9001abb5e96ce1f1d97696 diff --git a/examples/Example.Elastic.OpenTelemetry.AspNetCore/Program.cs b/examples/Example.Elastic.OpenTelemetry.AspNetCore/Program.cs index 2abeea0..803560c 100644 --- a/examples/Example.Elastic.OpenTelemetry.AspNetCore/Program.cs +++ b/examples/Example.Elastic.OpenTelemetry.AspNetCore/Program.cs @@ -6,9 +6,10 @@ var builder = WebApplication.CreateBuilder(args); // Add services to the container. -builder.Services.AddHttpClient(); -builder.Services.AddElasticOpenTelemetryForAspNetCore(HomeController.ActivitySourceName); -builder.Services.AddControllersWithViews(); +builder.Services + .AddHttpClient() + .AddElasticOpenTelemetryForAspNetCore(HomeController.ActivitySourceName) + .AddControllersWithViews(); var app = builder.Build(); diff --git a/src/Elastic.OpenTelemetry.AspNetCore/ServiceCollectionExtensions.cs b/src/Elastic.OpenTelemetry.AspNetCore/ServiceCollectionExtensions.cs index cd4e897..0fd5715 100644 --- a/src/Elastic.OpenTelemetry.AspNetCore/ServiceCollectionExtensions.cs +++ b/src/Elastic.OpenTelemetry.AspNetCore/ServiceCollectionExtensions.cs @@ -18,7 +18,7 @@ public static class ServiceCollectionExtensions /// TODO /// TODO public static IServiceCollection AddElasticOpenTelemetryForAspNetCore(this IServiceCollection serviceCollection) => - new AgentBuilder().AddAspNetCore().Build(serviceCollection); + new AgentBuilder().AddAspNetCore().Register(serviceCollection); /// /// TODO @@ -27,7 +27,7 @@ public static IServiceCollection AddElasticOpenTelemetryForAspNetCore(this IServ /// /// public static IServiceCollection AddElasticOpenTelemetryForAspNetCore(this IServiceCollection serviceCollection, params string[] activitySourceNames) => - new AgentBuilder(activitySourceNames).AddAspNetCore().Build(serviceCollection); + new AgentBuilder(activitySourceNames).AddAspNetCore().Register(serviceCollection); /// /// TODO @@ -36,5 +36,5 @@ public static IServiceCollection AddElasticOpenTelemetryForAspNetCore(this IServ /// /// public static IServiceCollection AddElasticOpenTelemetryForAspNetCore(this IServiceCollection serviceCollection, Action configureTracerProvider) => - new AgentBuilder().AddAspNetCore().ConfigureTracer(configureTracerProvider).Build(serviceCollection); + new AgentBuilder().AddAspNetCore().ConfigureTracer(configureTracerProvider).Register(serviceCollection); } diff --git a/src/Elastic.OpenTelemetry/AgentBuilder.cs b/src/Elastic.OpenTelemetry/AgentBuilder.cs index 96c1816..479addd 100644 --- a/src/Elastic.OpenTelemetry/AgentBuilder.cs +++ b/src/Elastic.OpenTelemetry/AgentBuilder.cs @@ -86,8 +86,6 @@ public AgentBuilder AddTracerSources(string activitySourceNameA, string activity return this; } - internal string Thing { get; } = "HI"; - // TODO - Other AddTracerSources for up to x sources to avoid params allocation. /// @@ -186,7 +184,12 @@ public IAgent Build() return tracerProvider is not null ? new Agent(tracerProvider) : new Agent(); } - internal IServiceCollection Build(IServiceCollection serviceCollection) + /// + /// Register the OpenTelemetry SDK services and Elastic defaults into the supplied . + /// + /// A to which OpenTelemetry SDK services will be added. + /// The supplied . + public IServiceCollection Register(IServiceCollection serviceCollection) { _ = serviceCollection .AddOpenTelemetry() diff --git a/src/Elastic.OpenTelemetry/DependencyInjection/ServiceCollectionExtensions.cs b/src/Elastic.OpenTelemetry/DependencyInjection/ServiceCollectionExtensions.cs index 2f8f03a..6329005 100644 --- a/src/Elastic.OpenTelemetry/DependencyInjection/ServiceCollectionExtensions.cs +++ b/src/Elastic.OpenTelemetry/DependencyInjection/ServiceCollectionExtensions.cs @@ -17,7 +17,7 @@ public static class ServiceCollectionExtensions /// TODO /// TODO public static IServiceCollection AddElasticOpenTelemetry(this IServiceCollection serviceCollection) => - new AgentBuilder().Build(serviceCollection); + new AgentBuilder().Register(serviceCollection); /// /// TODO @@ -26,7 +26,7 @@ public static IServiceCollection AddElasticOpenTelemetry(this IServiceCollection /// /// public static IServiceCollection AddElasticOpenTelemetry(this IServiceCollection serviceCollection, params string[] activitySourceNames) => - new AgentBuilder(activitySourceNames).Build(serviceCollection); + new AgentBuilder(activitySourceNames).Register(serviceCollection); /// /// TODO @@ -35,5 +35,5 @@ public static IServiceCollection AddElasticOpenTelemetry(this IServiceCollection /// /// public static IServiceCollection AddElasticOpenTelemetry(this IServiceCollection serviceCollection, Action configureTracerProvider) => - new AgentBuilder().ConfigureTracer(configureTracerProvider).Build(serviceCollection); + new AgentBuilder().ConfigureTracer(configureTracerProvider).Register(serviceCollection); } diff --git a/src/Elastic.OpenTelemetry/Elastic.OpenTelemetry.csproj b/src/Elastic.OpenTelemetry/Elastic.OpenTelemetry.csproj index 781f2f4..fdb9eeb 100644 --- a/src/Elastic.OpenTelemetry/Elastic.OpenTelemetry.csproj +++ b/src/Elastic.OpenTelemetry/Elastic.OpenTelemetry.csproj @@ -18,9 +18,5 @@ - - - -