Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[repo/Hangfire] Prepare to .NET9 #2296

Merged
merged 3 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ private static void InjectActivityProperties(IDictionary<string, string> jobPara

private static IEnumerable<string> ExtractActivityProperties(Dictionary<string, string> telemetryData, string key)
{
return telemetryData.TryGetValue(key, out var value) ? new[] { value } : Enumerable.Empty<string>();
return telemetryData.TryGetValue(key, out var value) ? [value] : [];
}

private void SetStatusAndRecordException(Activity activity, Exception exception)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@

namespace OpenTelemetry.Instrumentation.Hangfire.Tests;

#pragma warning disable CA1515
public class HangfireFixture : IDisposable
#pragma warning restore CA1515
{
public HangfireFixture()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ public async Task Should_Create_Activity()
await this.WaitJobProcessedAsync(jobId, 5);

// Assert
Assert.Single(exportedItems, i => i.GetTagItem("job.id") as string == jobId);
var activity = exportedItems.Single(i => i.GetTagItem("job.id") as string == jobId);
Assert.Single(exportedItems, i => (i.GetTagItem("job.id") as string) == jobId);
var activity = exportedItems.Single(i => (i.GetTagItem("job.id") as string) == jobId);
Assert.Contains("JOB TestJob.Execute", activity.DisplayName);
Assert.Equal(ActivityKind.Internal, activity.Kind);
}
Expand All @@ -55,8 +55,8 @@ public async Task Should_Create_Activity_With_Status_Error_When_Job_Failed()
await this.WaitJobProcessedAsync(jobId, 5);

// Assert
Assert.Single(exportedItems, i => i.GetTagItem("job.id") as string == jobId);
var activity = exportedItems.Single(i => i.GetTagItem("job.id") as string == jobId);
Assert.Single(exportedItems, i => (i.GetTagItem("job.id") as string) == jobId);
var activity = exportedItems.Single(i => (i.GetTagItem("job.id") as string) == jobId);
Assert.Contains("JOB TestJob.ThrowException", activity.DisplayName);
Assert.Equal(ActivityKind.Internal, activity.Kind);
Assert.Equal(ActivityStatusCode.Error, activity.Status);
Expand All @@ -79,8 +79,8 @@ public async Task Should_Create_Activity_With_Exception_Event_When_Job_Failed_An
await this.WaitJobProcessedAsync(jobId, 5);

// Assert
Assert.Single(exportedItems, i => i.GetTagItem("job.id") as string == jobId);
var activity = exportedItems.Single(i => i.GetTagItem("job.id") as string == jobId);
Assert.Single(exportedItems, i => (i.GetTagItem("job.id") as string) == jobId);
var activity = exportedItems.Single(i => (i.GetTagItem("job.id") as string) == jobId);
Assert.Contains("JOB TestJob.ThrowException", activity.DisplayName);
Assert.Equal(ActivityKind.Internal, activity.Kind);
Assert.Equal(ActivityStatusCode.Error, activity.Status);
Expand All @@ -103,8 +103,8 @@ public async Task Should_Create_Activity_Without_Exception_Event_When_Job_Failed
await this.WaitJobProcessedAsync(jobId, 5);

// Assert
Assert.Single(exportedItems, i => i.GetTagItem("job.id") as string == jobId);
var activity = exportedItems.Single(i => i.GetTagItem("job.id") as string == jobId);
Assert.Single(exportedItems, i => (i.GetTagItem("job.id") as string) == jobId);
var activity = exportedItems.Single(i => (i.GetTagItem("job.id") as string) == jobId);
Assert.Contains("JOB TestJob.ThrowException", activity.DisplayName);
Assert.Equal(ActivityKind.Internal, activity.Kind);
Assert.Equal(ActivityStatusCode.Error, activity.Status);
Expand All @@ -128,8 +128,8 @@ public async Task Should_Create_Activity_With_Custom_DisplayName()
await this.WaitJobProcessedAsync(jobId, 5);

// Assert
Assert.Single(exportedItems, i => i.GetTagItem("job.id") as string == jobId);
var activity = exportedItems.Single(i => i.GetTagItem("job.id") as string == jobId);
Assert.Single(exportedItems, i => (i.GetTagItem("job.id") as string) == jobId);
var activity = exportedItems.Single(i => (i.GetTagItem("job.id") as string) == jobId);
Assert.Contains($"JOB {jobId}", activity.DisplayName);
Assert.Equal(ActivityKind.Internal, activity.Kind);
}
Expand Down Expand Up @@ -174,7 +174,7 @@ public async Task Should_Respect_Filter_Option(string filter, bool shouldRecord)
private async Task WaitJobProcessedAsync(string jobId, int timeToWaitInSeconds)
{
var timeout = DateTime.Now.AddSeconds(timeToWaitInSeconds);
string[] states = new[] { "Enqueued", "Processing" };
string[] states = ["Enqueued", "Processing"];
JobDetailsDto jobDetails;
while (((jobDetails = this.hangfireFixture.MonitoringApi.JobDetails(jobId)) == null || jobDetails.History.All(h => states.Contains(h.StateName)))
&& DateTime.Now < timeout)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace OpenTelemetry.Instrumentation.Hangfire.Tests;

public class ProcessorMock<T> : BaseProcessor<T>
internal class ProcessorMock<T> : BaseProcessor<T>
{
private readonly Action<T>? onStart;
private readonly Action<T>? onEnd;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace OpenTelemetry.Instrumentation.Hangfire.Tests;

public class TestJob
internal class TestJob
{
public void Execute()
{
Expand Down
Loading