From df961d41f9854f54c919a7c2aaa185901d7dfe25 Mon Sep 17 00:00:00 2001 From: "Eric J. Smith" Date: Mon, 28 Oct 2024 12:45:31 -0500 Subject: [PATCH] Use default activity kind --- Foundatio.sln | 1 + .../Jobs/HostedJobService.cs | 2 +- .../Jobs/JobHostExtensions.cs | 14 +++++++------- .../Jobs/JobManager.cs | 2 +- .../Jobs/ScheduledJobService.cs | 2 +- .../Messaging/MessageBusTestBase.cs | 2 +- 6 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Foundatio.sln b/Foundatio.sln index d771108a..322e7430 100644 --- a/Foundatio.sln +++ b/Foundatio.sln @@ -15,6 +15,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution samples\Directory.Build.props = samples\Directory.Build.props NuGet.config = NuGet.config README.md = README.md + .github\workflows\build-workflow.yml = .github\workflows\build-workflow.yml EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{A1DFF80C-113F-4FEC-84BB-1E3790FB410F}" diff --git a/src/Foundatio.Extensions.Hosting/Jobs/HostedJobService.cs b/src/Foundatio.Extensions.Hosting/Jobs/HostedJobService.cs index d9aa026a..99f5d8c2 100644 --- a/src/Foundatio.Extensions.Hosting/Jobs/HostedJobService.cs +++ b/src/Foundatio.Extensions.Hosting/Jobs/HostedJobService.cs @@ -52,7 +52,7 @@ private async Task ExecuteAsync(CancellationToken stoppingToken) try { - using var activity = FoundatioDiagnostics.ActivitySource.StartActivity("Job " + _jobOptions.Name, ActivityKind.Server); + using var activity = FoundatioDiagnostics.ActivitySource.StartActivity("Job " + _jobOptions.Name); await runner.RunAsync(stoppingToken).AnyContext(); #if NET8_0_OR_GREATER diff --git a/src/Foundatio.Extensions.Hosting/Jobs/JobHostExtensions.cs b/src/Foundatio.Extensions.Hosting/Jobs/JobHostExtensions.cs index 14d986b1..8c878b60 100644 --- a/src/Foundatio.Extensions.Hosting/Jobs/JobHostExtensions.cs +++ b/src/Foundatio.Extensions.Hosting/Jobs/JobHostExtensions.cs @@ -133,29 +133,29 @@ public static IServiceCollection AddDistributedCronJob(this IServiceCollectio { services.AddTransient(); var jobOptionsBuilder = new ScheduledJobOptionsBuilder(); - jobOptionsBuilder.Name(typeof(T).FullName).Distributed(true).CronSchedule(cronSchedule).JobFactory(sp => sp.GetRequiredService()); + jobOptionsBuilder.Name(typeof(T).FullName).Distributed().CronSchedule(cronSchedule).JobFactory(sp => sp.GetRequiredService()); configureJobOptions?.Invoke(jobOptionsBuilder); return services.AddCronJob(jobOptionsBuilder.Target); } public static IServiceCollection AddDistributedCronJob(this IServiceCollection services, string name, string cronSchedule, Func action) { - return services.AddCronJob(o => o.Name(name).Distributed(true).CronSchedule(cronSchedule).JobFactory(sp => new DynamicJob(sp, action))); + return services.AddCronJob(o => o.Name(name).Distributed().CronSchedule(cronSchedule).JobFactory(sp => new DynamicJob(sp, action))); } public static IServiceCollection AddDistributedCronJob(this IServiceCollection services, string name, string cronSchedule, Func action) { - return services.AddCronJob(o => o.Name(name).Distributed(true).CronSchedule(cronSchedule).JobFactory(sp => new DynamicJob(sp, (xp, _) => action(xp)))); + return services.AddCronJob(o => o.Name(name).Distributed().CronSchedule(cronSchedule).JobFactory(sp => new DynamicJob(sp, (xp, _) => action(xp)))); } public static IServiceCollection AddDistributedCronJob(this IServiceCollection services, string name, string cronSchedule, Func action) { - return services.AddCronJob(o => o.Name(name).Distributed(true).CronSchedule(cronSchedule).JobFactory(sp => new DynamicJob(sp, (_, _) => action()))); + return services.AddCronJob(o => o.Name(name).Distributed().CronSchedule(cronSchedule).JobFactory(sp => new DynamicJob(sp, (_, _) => action()))); } public static IServiceCollection AddDistributedCronJob(this IServiceCollection services, string name, string cronSchedule, Action action) { - return services.AddCronJob(o => o.Name(name).Distributed(true).CronSchedule(cronSchedule).JobFactory(sp => new DynamicJob(sp, (xp, ct) => + return services.AddCronJob(o => o.Name(name).Distributed().CronSchedule(cronSchedule).JobFactory(sp => new DynamicJob(sp, (xp, ct) => { action(xp, ct); return Task.CompletedTask; @@ -164,7 +164,7 @@ public static IServiceCollection AddDistributedCronJob(this IServiceCollection s public static IServiceCollection AddDistributedCronJob(this IServiceCollection services, string name, string cronSchedule, Action action) { - return services.AddCronJob(o => o.Name(name).Distributed(true).CronSchedule(cronSchedule).JobFactory(sp => new DynamicJob(sp, (_, ct) => + return services.AddCronJob(o => o.Name(name).Distributed().CronSchedule(cronSchedule).JobFactory(sp => new DynamicJob(sp, (_, ct) => { action(ct); return Task.CompletedTask; @@ -173,7 +173,7 @@ public static IServiceCollection AddDistributedCronJob(this IServiceCollection s public static IServiceCollection AddDistributedCronJob(this IServiceCollection services, string name, string cronSchedule, Action action) { - return services.AddCronJob(o => o.Name(name).Distributed(true).CronSchedule(cronSchedule).JobFactory(sp => new DynamicJob(sp, (_, _) => + return services.AddCronJob(o => o.Name(name).Distributed().CronSchedule(cronSchedule).JobFactory(sp => new DynamicJob(sp, (_, _) => { action(); return Task.CompletedTask; diff --git a/src/Foundatio.Extensions.Hosting/Jobs/JobManager.cs b/src/Foundatio.Extensions.Hosting/Jobs/JobManager.cs index 948217df..87d46e78 100644 --- a/src/Foundatio.Extensions.Hosting/Jobs/JobManager.cs +++ b/src/Foundatio.Extensions.Hosting/Jobs/JobManager.cs @@ -202,7 +202,7 @@ public async Task RunJobAsync(string jobName, CancellationToken cancellationToke if (job == null) throw new ArgumentException("Job not found.", nameof(jobName)); - using var activity = FoundatioDiagnostics.ActivitySource.StartActivity("Job: " + job.Options.Name, ActivityKind.Server); + using var activity = FoundatioDiagnostics.ActivitySource.StartActivity("Job: " + job.Options.Name); await job.StartAsync(cancellationToken).AnyContext(); } diff --git a/src/Foundatio.Extensions.Hosting/Jobs/ScheduledJobService.cs b/src/Foundatio.Extensions.Hosting/Jobs/ScheduledJobService.cs index 59045e08..85d11df3 100644 --- a/src/Foundatio.Extensions.Hosting/Jobs/ScheduledJobService.cs +++ b/src/Foundatio.Extensions.Hosting/Jobs/ScheduledJobService.cs @@ -37,7 +37,7 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken) { foreach (var jobToRun in _jobManager.Jobs) { - using var activity = FoundatioDiagnostics.ActivitySource.StartActivity("Scheduled Job: " + jobToRun.Options.Name, ActivityKind.Server); + using var activity = FoundatioDiagnostics.ActivitySource.StartActivity("Scheduled Job: " + jobToRun.Options.Name); if (await jobToRun.ShouldRunAsync()) await jobToRun.StartAsync(stoppingToken).AnyContext(); diff --git a/src/Foundatio.TestHarness/Messaging/MessageBusTestBase.cs b/src/Foundatio.TestHarness/Messaging/MessageBusTestBase.cs index 54253f68..498b2985 100644 --- a/src/Foundatio.TestHarness/Messaging/MessageBusTestBase.cs +++ b/src/Foundatio.TestHarness/Messaging/MessageBusTestBase.cs @@ -55,7 +55,7 @@ public virtual async Task CanUseMessageOptionsAsync() ActivitySource.AddActivityListener(listener); - using var activity = FoundatioDiagnostics.ActivitySource.StartActivity("Parent", ActivityKind.Internal); + using var activity = FoundatioDiagnostics.ActivitySource.StartActivity("Parent"); Assert.Equal(Activity.Current, activity); var countdown = new AsyncCountdownEvent(1);