Skip to content

Commit

Permalink
Merge pull request #2440 from RocketSurgeonsGuild/fix/telemetry
Browse files Browse the repository at this point in the history
fixed telemetry not working
  • Loading branch information
david-driscoll authored Dec 25, 2024
2 parents a7f14ce + a9b5f76 commit 1fec639
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 74 deletions.
4 changes: 2 additions & 2 deletions .build/Build.CI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public static RocketSurgeonGitHubActionsConfiguration CiMiddleware(RocketSurgeon
.ExcludeRepositoryConfigurationFiles()
.Jobs.OfType<RocketSurgeonsGithubActionsJob>()
.First(z => z.Name.Equals("build", StringComparison.OrdinalIgnoreCase));
_ = job
job
.UseDotNetSdks("8.0", "9.0")
.ConfigureStep<CheckoutStep>(step => step.FetchDepth = 0)
.PublishLogs<Pipeline>();
Expand All @@ -76,7 +76,7 @@ public static RocketSurgeonGitHubActionsConfiguration CiMiddleware(RocketSurgeon

public static RocketSurgeonGitHubActionsConfiguration LintStagedMiddleware(RocketSurgeonGitHubActionsConfiguration configuration)
{
_ = configuration
configuration
.Jobs.OfType<RocketSurgeonsGithubActionsJob>()
.First(z => z.Name.Equals("Build", StringComparison.OrdinalIgnoreCase))
.UseDotNetSdks("8.0", "9.0");
Expand Down
15 changes: 15 additions & 0 deletions .idea/.idea.LaunchPad/.idea/git_toolbox_prj.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions src/Foundation/Conventions/FluentValidationConvention.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void Register(IConventionContext context, IConfiguration configuration, I
{
ArgumentNullException.ThrowIfNull(context);

_ = context.TypeProvider
context.TypeProvider
.Scan(
services,
z => z
Expand All @@ -68,13 +68,13 @@ public void Register(IConventionContext context, IConfiguration configuration, I
))
{
// need to do validations using ValidateOnStart
_ = services.Decorate<HealthCheckService, CustomHealthCheckService>();
_ = services.AddSingleton<ValidationHealthCheckResults>();
_ = services.AddSingleton(typeof(IValidateOptions<>), typeof(HealthCheckFluentValidationOptions<>));
services.Decorate<HealthCheckService, CustomHealthCheckService>();
services.AddSingleton<ValidationHealthCheckResults>();
services.AddSingleton(typeof(IValidateOptions<>), typeof(HealthCheckFluentValidationOptions<>));
}
else
{
_ = services.AddSingleton(typeof(IValidateOptions<>), typeof(FluentValidationOptions<>));
services.AddSingleton(typeof(IValidateOptions<>), typeof(FluentValidationOptions<>));
}

services.TryAddEnumerable(ServiceDescriptor.Describe(typeof(IPipelineBehavior<,>), typeof(ValidationPipelineBehavior<,>), _options.MediatorLifetime));
Expand Down
2 changes: 1 addition & 1 deletion src/Foundation/Conventions/OptionsConvention.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void Register(IConventionContext context, IConfiguration configuration, I
{
var attribute = options.GetCustomAttribute<RegisterOptionsConfigurationAttribute>()!;
#pragma warning disable IL2060
_ = _configureMethod
_configureMethod
.MakeGenericMethod(options)
.Invoke(null, [services, attribute.OptionsName, configuration.GetSection(attribute.ConfigurationKey)]);
#pragma warning restore IL2060
Expand Down
22 changes: 22 additions & 0 deletions src/Foundation/Conventions/SerilogTelemetryConvention.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Options;
using Rocket.Surgery.Conventions;
using Rocket.Surgery.LaunchPad.Serilog;
using Serilog;

namespace Rocket.Surgery.LaunchPad.Foundation.Conventions;

/// <summary>
/// Defines serilog telemetry configuration
/// </summary>
[PublicAPI]
[ExportConvention]
[ConventionCategory(ConventionCategory.Core)]
public partial class SerilogTelemetryConvention : ISerilogConvention
{
/// <inheritdoc />
public void Register(IConventionContext context, IConfiguration configuration, IServiceProvider services, LoggerConfiguration loggerConfiguration)
{
loggerConfiguration.WriteTo.OpenTelemetry(_ => { }, configuration.GetValue<string>);
}
}
1 change: 1 addition & 0 deletions src/Foundation/Rocket.Surgery.LaunchPad.Foundation.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Serilog\Rocket.Surgery.LaunchPad.Serilog.csproj" />
<ProjectReference Include="..\Telemetry\Rocket.Surgery.LaunchPad.Telemetry.csproj" />
<ProjectReference Include="..\Analyzers\Rocket.Surgery.LaunchPad.Analyzers.csproj" IncludeAssets="analyzers" ExcludeAssets="compile;runtime;native" PrivateAssets="contentfiles;build;buildMultitargeting;buildTransitive" OutputItemType="Analyzer" />
<PackageReference Include="Polyfill" IncludeAssets="runtime;build;buildMultitargeting;buildTransitive;native;contentfiles;analyzers" PrivateAssets="All" Condition="'$(TargetFramework)' == 'netstandard2.1'" />
Expand Down
8 changes: 5 additions & 3 deletions src/Mapping/DateTimeMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ public static DateTimeOffset ToDateTimeOffset(DateTime source)
{
return source switch
{
{ Kind: DateTimeKind.Unspecified or DateTimeKind.Local, } => new(source.ToUniversalTime(), TimeSpan.Zero),
{ Kind: DateTimeKind.Utc, } => new(source, TimeSpan.Zero),
{ Kind: DateTimeKind.Unspecified } => new(source.ToUniversalTime(), TimeSpan.Zero),
{ Kind: DateTimeKind.Local } => new(source.ToUniversalTime(), TimeSpan.Zero),
{ Kind: DateTimeKind.Utc, } => new(source, TimeSpan.Zero),
_ => new (source),
};
}
}
}
56 changes: 0 additions & 56 deletions src/Telemetry/Conventions/SerilogTelemetryConvention.cs

This file was deleted.

2 changes: 0 additions & 2 deletions src/Telemetry/Rocket.Surgery.LaunchPad.Telemetry.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,5 @@
<ItemGroup>
<PackageReference Include="OpenTelemetry" />
<PackageReference Include="Rocket.Surgery.Conventions" />
<PackageReference Include="Serilog.Sinks.OpenTelemetry" />
<ProjectReference Include="..\Serilog\Rocket.Surgery.LaunchPad.Serilog.csproj" />
</ItemGroup>
</Project>
10 changes: 5 additions & 5 deletions test/Sample.Graphql.Tests/Helpers/GraphQlExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public Task Start(IAlbaHost host)

public IHostBuilder Configure(IHostBuilder builder)
{
_ = builder.ConfigureServices(
builder.ConfigureServices(
z => z
.AddW3CLogging(_ => { })
.AddHttpLogging(_ => { })
Expand All @@ -38,12 +38,12 @@ public IHostBuilder Configure(IHostBuilder builder)
opt => opt.IncludeExceptionDetails = true
)
);
_ = builder.ConfigureServices(
builder.ConfigureServices(
s =>
{
_ = s.AddHttpClient();
_ = s.AddRocketClient();
_ = s.ConfigureOptions<CO>();
s.AddHttpClient();
s.AddRocketClient();
s.ConfigureOptions<CO>();
}
);

Expand Down
1 change: 1 addition & 0 deletions test/coverage.runsettings
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@
<ModulePath>.*Microsoft\.CodeAnalysis\.Analyzers\.dll</ModulePath>
<ModulePath>.*Microsoft\.CodeAnalysis\.BannedApiAnalyzers\.dll</ModulePath>
<ModulePath>.*Microsoft\.CodeAnalysis\.Common\.dll</ModulePath>
<ModulePath>.*Microsoft\.CodeAnalysis\.CSharp\.dll</ModulePath>
<ModulePath>.*Microsoft\.CodeAnalysis\.CSharp\.Workspaces\.dll</ModulePath>
<ModulePath>.*Microsoft\.CodeAnalysis\.Features\.dll</ModulePath>
<ModulePath>.*Microsoft\.CodeAnalysis\.Workspaces\.Common\.dll</ModulePath>
Expand Down

0 comments on commit 1fec639

Please sign in to comment.