Skip to content

Commit

Permalink
Fix some lp errors
Browse files Browse the repository at this point in the history
  • Loading branch information
david-driscoll committed Apr 18, 2024
1 parent b0af7be commit 4c998eb
Show file tree
Hide file tree
Showing 21 changed files with 230 additions and 272 deletions.
8 changes: 3 additions & 5 deletions sample/Sample.BlazorServer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@
using Sample.BlazorServer;
using Sample.BlazorServer.Data;

var builder = await WebApplication
.CreateBuilder(args)
.LaunchWith(RocketBooster.For(Imports.Instance), b => b.Set(AssemblyLoadContext.Default));
var builder = WebApplication.CreateBuilder(args);

builder.Services.AddRazorPages();
builder.Services.AddServerSideBlazor();
builder.Services.AddSingleton<WeatherForecastService>();

var app = builder.Build();
var app = await builder.LaunchWith(RocketBooster.For(Imports.Instance), b => b.Set(AssemblyLoadContext.Default));

if (builder.Environment.IsDevelopment())
{
Expand All @@ -38,4 +36,4 @@

await app.RunAsync();

public partial class Program;
public partial class Program;
8 changes: 3 additions & 5 deletions sample/Sample.BlazorWasm/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@
using Rocket.Surgery.WebAssembly.Hosting;
using Sample.BlazorWasm;

var builder = await WebAssemblyHostBuilder
.CreateDefault(args)
.ConfigureRocketSurgery(Imports.Instance);
var builder = WebAssemblyHostBuilder.CreateDefault(args);

builder.RootComponents.Add<Sample.BlazorWasm.App>("app");
builder.Services.AddScoped(_ => new HttpClient { BaseAddress = new(builder.HostEnvironment.BaseAddress), });

await builder.Build().RunAsync();
await ( await builder.ConfigureRocketSurgery(Imports.Instance) ).RunAsync();

public static class TestHandler
{
Expand Down Expand Up @@ -58,4 +56,4 @@ public Task<Response> Handle(Request request, CancellationToken cancellationToke
);
}
}
}
}
9 changes: 4 additions & 5 deletions sample/Sample.Classic.Restful/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
using Sample.Classic.Restful;
using Swashbuckle.AspNetCore.SwaggerGen;

var builder = await WebApplication
.CreateBuilder(args)
.LaunchWith(RocketBooster.For(Imports.Instance), b => b.Set(AssemblyLoadContext.Default));
var builder = WebApplication
.CreateBuilder(args);
builder.Services.AddControllers().AddControllersAsServices();
builder.Services
.Configure<SwaggerGenOptions>(
Expand All @@ -23,7 +22,7 @@
}
)
);
var app = builder.Build();
var app = await builder.LaunchWith(RocketBooster.For(Imports.Instance), b => b.Set(AssemblyLoadContext.Default));

app.UseProblemDetails();
app.UseHttpsRedirection();
Expand All @@ -43,4 +42,4 @@

await app.RunAsync();

public partial class Program;
public partial class Program;
6 changes: 3 additions & 3 deletions sample/Sample.Graphql/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
.AddMutationType()
.ModifyRequestOptions(options => options.IncludeExceptionDetails = true);

var app = ( await builder
.LaunchWith(RocketBooster.For(Imports.Instance), b => b.Set(AssemblyLoadContext.Default)) ).Build();
var app = await builder
.LaunchWith(RocketBooster.For(Imports.Instance), b => b.Set(AssemblyLoadContext.Default));

app.UseHttpLogging();
app.UseLaunchPadRequestLogging();
Expand All @@ -41,4 +41,4 @@

app.Run();

public partial class Program;
public partial class Program;
6 changes: 2 additions & 4 deletions sample/Sample.Grpc/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@
using Sample.Grpc;
using Sample.Grpc.Services;

var builder = await WebApplication
var app = await WebApplication
.CreateBuilder(args)
.LaunchWith(RocketBooster.For(Imports.Instance), b => b.Set(AssemblyLoadContext.Default));

var app = builder.Build();

app.UseLaunchPadRequestLogging();

app.UseRouting();
Expand All @@ -27,4 +25,4 @@

await app.RunAsync();

public partial class Program;
public partial class Program;
8 changes: 3 additions & 5 deletions sample/Sample.Pages/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@
using Rocket.Surgery.LaunchPad.AspNetCore;
using Sample.Pages;

var builder = await WebApplication
.CreateBuilder(args)
.LaunchWith(RocketBooster.For(Imports.Instance), b => b.Set(AssemblyLoadContext.Default));
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddRazorPages();
builder.Services.AddControllersWithViews();

var app = builder.Build();
var app = await builder.LaunchWith(RocketBooster.For(Imports.Instance), b => b.Set(AssemblyLoadContext.Default));

if (builder.Environment.IsDevelopment())
{
Expand Down Expand Up @@ -129,4 +127,4 @@ static Task WriteResponse(HttpContext context, HealthReport healthReport)
);
}

public partial class Program;
public partial class Program;
8 changes: 4 additions & 4 deletions sample/Sample.Worker/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
using Rocket.Surgery.Hosting;
using Sample.Worker;

var builder = await Host
.CreateApplicationBuilder(args)
.LaunchWith(RocketBooster.For(Imports.Instance));
var builder = Host
.CreateApplicationBuilder(args);
builder.Services.AddHostedService<BackgroundWorker>();

await builder.RunAsync();

await ( await builder.LaunchWith(RocketBooster.For(Imports.Instance)) ).RunAsync();
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.Extensions.Configuration;
using OpenTelemetry;
using OpenTelemetry.Metrics;
using OpenTelemetry.Trace;
using Rocket.Surgery.Conventions;
Expand All @@ -8,25 +9,20 @@
namespace Rocket.Surgery.LaunchPad.AspNetCore.Conventions;

/// <summary>
/// ProblemDetailsConvention.
/// Implements the <see cref="IServiceConvention" />
/// AspNetCoreConventionInstrumentationConvention.
/// Implements the <see cref="IOpenTelemetryConvention" />
/// </summary>
/// <seealso cref="IServiceConvention" />
/// <seealso cref="IServiceConvention" />
/// <seealso cref="IOpenTelemetryConvention" />
/// <seealso cref="IOpenTelemetryConvention" />
[PublicAPI]
[ExportConvention]
[AfterConvention(typeof(AspNetCoreConvention))]
public class AspNetCoreConventionInstrumentationConvention : IOpenTelemetryMetricsConvention, IOpenTelemetryTracingConvention
public class AspNetCoreConventionInstrumentationConvention : IOpenTelemetryConvention
{
/// <inheritdoc />
public void Register(IConventionContext conventionContext, IConfiguration configuration, MeterProviderBuilder builder)
public void Register(IConventionContext conventionContext, IConfiguration configuration, IOpenTelemetryBuilder builder)
{
builder.AddAspNetCoreInstrumentation();
}

/// <inheritdoc />
public void Register(IConventionContext conventionContext, IConfiguration configuration, TracerProviderBuilder builder)
{
builder.AddAspNetCoreInstrumentation(options => options.RecordException = true);
builder.WithTracing(b => b.AddAspNetCoreInstrumentation(options => options.RecordException = true));
builder.WithMetrics(b => b.AddAspNetCoreInstrumentation());
}
}
18 changes: 7 additions & 11 deletions src/Foundation/Conventions/InstrumentationConvention.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.Extensions.Configuration;
using OpenTelemetry;
using OpenTelemetry.Metrics;
using OpenTelemetry.Trace;
using Rocket.Surgery.Conventions;
Expand All @@ -9,22 +10,17 @@ namespace Rocket.Surgery.LaunchPad.Foundation.Conventions;

/// <summary>
/// InstrumentationConvention.
/// Implements <see cref="IOpenTelemetryMetricsConvention" /> and <see cref="IOpenTelemetryTracingConvention" />
/// Implements <see cref="IOpenTelemetryConvention" /> and <see cref="IOpenTelemetryConvention" />
/// </summary>
/// <seealso cref="IServiceConvention" />
/// <seealso cref="IOpenTelemetryConvention" />
[PublicAPI]
[ExportConvention]
public class InstrumentationConvention : IOpenTelemetryMetricsConvention, IOpenTelemetryTracingConvention
public class InstrumentationConvention : IOpenTelemetryConvention
{
/// <inheritdoc />
public void Register(IConventionContext conventionContext, IConfiguration configuration, MeterProviderBuilder builder)
public void Register(IConventionContext conventionContext, IConfiguration configuration, IOpenTelemetryBuilder builder)
{
builder.AddHttpClientInstrumentation();
}

/// <inheritdoc />
public void Register(IConventionContext conventionContext, IConfiguration configuration, TracerProviderBuilder builder)
{
builder.AddHttpClientInstrumentation(x => x.RecordException = true);
builder.WithTracing(b => b.AddHttpClientInstrumentation(x => x.RecordException = true));
builder.WithMetrics(b => b.AddHttpClientInstrumentation());
}
}
26 changes: 14 additions & 12 deletions src/Hosting/Conventions/OpenTelemetryConvention.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,28 @@
using Microsoft.Extensions.DependencyInjection;
using Rocket.Surgery.Conventions;
using Rocket.Surgery.Conventions.DependencyInjection;
using Rocket.Surgery.LaunchPad.Hosting.Telemetry;
using Rocket.Surgery.LaunchPad.Serilog;
using Rocket.Surgery.LaunchPad.Telemetry;

namespace Rocket.Surgery.LaunchPad.Hosting.Conventions;

/// <summary>
/// EnvironmentLoggingConvention.
/// Implements the <see cref="ISerilogConvention" />
/// Implements the <see cref="IServiceAsyncConvention" />
/// </summary>
/// <seealso cref="ISerilogConvention" />
/// <seealso cref="IServiceAsyncConvention" />
[PublicAPI]
[ExportConvention]
public class OpenTelemetryConvention : IServiceConvention
public class OpenTelemetryConvention : IServiceAsyncConvention
{
/// <inheritdoc />
public void Register(IConventionContext context, IConfiguration configuration, IServiceCollection services)
{
services
.AddOpenTelemetry()
.ApplyConventions(context)
;
}
public async ValueTask Register(
IConventionContext context,
IConfiguration configuration,
IServiceCollection services,
CancellationToken cancellationToken
) =>
await services
.AddOpenTelemetry()
.ApplyConventionsAsync(context, cancellationToken)
.ConfigureAwait(false);
}
3 changes: 3 additions & 0 deletions src/Hosting/Rocket.Surgery.LaunchPad.Hosting.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@
<ProjectReference Include="..\Foundation\Rocket.Surgery.LaunchPad.Foundation.csproj" />
<ProjectReference Include="..\Serilog\Rocket.Surgery.LaunchPad.Serilog.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Telemetry\" />
</ItemGroup>
</Project>
35 changes: 0 additions & 35 deletions src/Hosting/Telemetry/OpenTelemetryHostBuilderExtensions.cs

This file was deleted.

43 changes: 0 additions & 43 deletions src/Hosting/Telemetry/RocketSurgeryOpenTelemetryExtensions.cs

This file was deleted.

11 changes: 6 additions & 5 deletions src/HotChocolate/Conventions/InstrumentationConvention.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.Extensions.Configuration;
using OpenTelemetry;
using OpenTelemetry.Trace;
using Rocket.Surgery.Conventions;
using Rocket.Surgery.Conventions.DependencyInjection;
Expand All @@ -8,16 +9,16 @@ namespace Rocket.Surgery.LaunchPad.HotChocolate.Conventions;

/// <summary>
/// InstrumentationConvention.
/// Implements <see cref="IOpenTelemetryMetricsConvention" /> and <see cref="IOpenTelemetryTracingConvention" />
/// Implements <see cref="IOpenTelemetryConvention" /> and <see cref="IOpenTelemetryConvention" />
/// </summary>
/// <seealso cref="IServiceConvention" />
/// <seealso cref="IOpenTelemetryConvention" />
[PublicAPI]
[ExportConvention]
public class InstrumentationConvention : IOpenTelemetryTracingConvention
public class InstrumentationConvention : IOpenTelemetryConvention
{
/// <inheritdoc />
public void Register(IConventionContext conventionContext, IConfiguration configuration, TracerProviderBuilder builder)
public void Register(IConventionContext conventionContext, IConfiguration configuration, IOpenTelemetryBuilder builder)
{
builder.AddHotChocolateInstrumentation();
builder.WithTracing(b => b.AddHotChocolateInstrumentation());
}
}
Loading

0 comments on commit 4c998eb

Please sign in to comment.