Skip to content

Commit

Permalink
[Instrumentation.Hangfire] Fix analysis warnings (#964)
Browse files Browse the repository at this point in the history
Fix/suppress code analysis warnings in OpenTelemetry.Instrumentation.Hangfire.
Contributes to #950.
  • Loading branch information
martincostello authored Feb 22, 2023
1 parent 3ccf594 commit 2402943
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace OpenTelemetry.Instrumentation.Hangfire.Implementation;
using OpenTelemetry.Context.Propagation;
using OpenTelemetry.Trace;

internal class HangfireInstrumentationJobFilterAttribute : JobFilterAttribute, IServerFilter, IClientFilter
internal sealed class HangfireInstrumentationJobFilterAttribute : JobFilterAttribute, IServerFilter, IClientFilter
{
private readonly HangfireInstrumentationOptions options;

Expand All @@ -37,6 +37,8 @@ public HangfireInstrumentationJobFilterAttribute(HangfireInstrumentationOptions
this.options = options;
}

public HangfireInstrumentationOptions Options { get; }

public void OnPerforming(PerformingContext performingContext)
{
// Short-circuit if nobody is listening
Expand Down Expand Up @@ -123,7 +125,7 @@ private static void InjectActivityProperties(IDictionary<string, string> jobPara

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

private void SetStatusAndRecordException(Activity activity, Exception exception)
Expand Down

0 comments on commit 2402943

Please sign in to comment.