Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
stevejgordon committed Jan 18, 2024
1 parent 8569c32 commit e839231
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 17 deletions.
1 change: 0 additions & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
<UseArtifactsOutput>true</UseArtifactsOutput>
<SolutionRoot>$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), build.bat))</SolutionRoot>
<ArtifactsPath>$(MSBuildThisFileDirectory).artifacts</ArtifactsPath>
<ExposedPublicKey>002400000480000094000000060200000024000052534131000400000100010015b0fa59d868c7f3ea2ae67567b19e102465745f01b430a38a42b92fd41a0f5869bec1f2b33b589d78662af432fe6b789ef72d4738f7b1a86264d7aeb5185ed8995b2bb104e7c5c58845f1a618be829e410fa34a6bd7d714ece191ed68a66333a83ae7456ee32e9aeb54bc1d7410ae8c344367257e9001abb5e96ce1f1d97696</ExposedPublicKey>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MinVer" Version="4.3.0" PrivateAssets="all" />
Expand Down
7 changes: 4 additions & 3 deletions examples/Example.Elastic.OpenTelemetry.AspNetCore/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static class ServiceCollectionExtensions
/// <param name="serviceCollection">TODO</param>
/// <returns>TODO</returns>
public static IServiceCollection AddElasticOpenTelemetryForAspNetCore(this IServiceCollection serviceCollection) =>
new AgentBuilder().AddAspNetCore().Build(serviceCollection);
new AgentBuilder().AddAspNetCore().Register(serviceCollection);

/// <summary>
/// TODO
Expand All @@ -27,7 +27,7 @@ public static IServiceCollection AddElasticOpenTelemetryForAspNetCore(this IServ
/// <param name="activitySourceNames"></param>
/// <returns></returns>
public static IServiceCollection AddElasticOpenTelemetryForAspNetCore(this IServiceCollection serviceCollection, params string[] activitySourceNames) =>
new AgentBuilder(activitySourceNames).AddAspNetCore().Build(serviceCollection);
new AgentBuilder(activitySourceNames).AddAspNetCore().Register(serviceCollection);

/// <summary>
/// TODO
Expand All @@ -36,5 +36,5 @@ public static IServiceCollection AddElasticOpenTelemetryForAspNetCore(this IServ
/// <param name="configureTracerProvider"></param>
/// <returns></returns>
public static IServiceCollection AddElasticOpenTelemetryForAspNetCore(this IServiceCollection serviceCollection, Action<TracerProviderBuilder> configureTracerProvider) =>
new AgentBuilder().AddAspNetCore().ConfigureTracer(configureTracerProvider).Build(serviceCollection);
new AgentBuilder().AddAspNetCore().ConfigureTracer(configureTracerProvider).Register(serviceCollection);
}
9 changes: 6 additions & 3 deletions src/Elastic.OpenTelemetry/AgentBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.

/// <summary>
Expand Down Expand Up @@ -186,7 +184,12 @@ public IAgent Build()
return tracerProvider is not null ? new Agent(tracerProvider) : new Agent();
}

internal IServiceCollection Build(IServiceCollection serviceCollection)
/// <summary>
/// Register the OpenTelemetry SDK services and Elastic defaults into the supplied <see cref="IServiceCollection"/>.
/// </summary>
/// <param name="serviceCollection">A <see cref="IServiceCollection"/> to which OpenTelemetry SDK services will be added.</param>
/// <returns>The supplied <see cref="IServiceCollection"/>.</returns>
public IServiceCollection Register(IServiceCollection serviceCollection)
{
_ = serviceCollection
.AddOpenTelemetry()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static class ServiceCollectionExtensions
/// <param name="serviceCollection">TODO</param>
/// <returns>TODO</returns>
public static IServiceCollection AddElasticOpenTelemetry(this IServiceCollection serviceCollection) =>
new AgentBuilder().Build(serviceCollection);
new AgentBuilder().Register(serviceCollection);

/// <summary>
/// TODO
Expand All @@ -26,7 +26,7 @@ public static IServiceCollection AddElasticOpenTelemetry(this IServiceCollection
/// <param name="activitySourceNames"></param>
/// <returns></returns>
public static IServiceCollection AddElasticOpenTelemetry(this IServiceCollection serviceCollection, params string[] activitySourceNames) =>
new AgentBuilder(activitySourceNames).Build(serviceCollection);
new AgentBuilder(activitySourceNames).Register(serviceCollection);

/// <summary>
/// TODO
Expand All @@ -35,5 +35,5 @@ public static IServiceCollection AddElasticOpenTelemetry(this IServiceCollection
/// <param name="configureTracerProvider"></param>
/// <returns></returns>
public static IServiceCollection AddElasticOpenTelemetry(this IServiceCollection serviceCollection, Action<TracerProviderBuilder> configureTracerProvider) =>
new AgentBuilder().ConfigureTracer(configureTracerProvider).Build(serviceCollection);
new AgentBuilder().ConfigureTracer(configureTracerProvider).Register(serviceCollection);
}
4 changes: 0 additions & 4 deletions src/Elastic.OpenTelemetry/Elastic.OpenTelemetry.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,5 @@
<PackageReference Include="OpenTelemetry.Instrumentation.Process" Version="0.5.0-beta.4" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.7.0" />
</ItemGroup>

<ItemGroup>
<InternalsVisibleTo Include="Elastic.OpenTelemetry.AspNetCore" Key="$(ExposedPublicKey)" />
</ItemGroup>

</Project>

0 comments on commit e839231

Please sign in to comment.