Skip to content

Commit

Permalink
warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-hensley committed Apr 8, 2024
1 parent 5551679 commit 62c6376
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/OpenTelemetry.ResourceDetectors.Host/HostDetector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public sealed class HostDetector : IResourceDetector
private const string ETCVARDBUSMACHINEID = "/var/lib/dbus/machine-id";
private readonly PlatformID platformId;
private readonly Func<IEnumerable<string>> getFilePaths;
private readonly Func<string> getMacOsMachineId;
private readonly Func<string> getWindowsMachineId;
private readonly Func<string?> getMacOsMachineId;
private readonly Func<string?> getWindowsMachineId;

/// <summary>
/// Initializes a new instance of the <see cref="HostDetector"/> class.
Expand All @@ -42,7 +42,7 @@ public HostDetector()
/// <param name="getFilePaths">Function to get Linux file paths to probe.</param>
/// <param name="getMacOsMachineId">Function to get MacOS machine ID.</param>
/// <param name="getWindowsMachineId">Function to get Windows machine ID.</param>
internal HostDetector(PlatformID platformId, Func<IEnumerable<string>> getFilePaths, Func<string> getMacOsMachineId, Func<string> getWindowsMachineId)
internal HostDetector(PlatformID platformId, Func<IEnumerable<string>> getFilePaths, Func<string?> getMacOsMachineId, Func<string?> getWindowsMachineId)
{
this.platformId = platformId;
this.getFilePaths = getFilePaths ?? throw new ArgumentNullException(nameof(getFilePaths));
Expand All @@ -64,7 +64,7 @@ public Resource Detect()
};
var machineId = this.GetMachineId();

if (!string.IsNullOrEmpty(machineId))
if (machineId != null && !string.IsNullOrEmpty(machineId))
{
attributes.Add(new(HostSemanticConventions.AttributeHostId, machineId));
}
Expand Down Expand Up @@ -142,7 +142,7 @@ private static IEnumerable<string> GetFilePaths()
};
}

private string GetMachineIdLinux()
private string? GetMachineIdLinux()
{
var paths = this.getFilePaths();

Expand Down

0 comments on commit 62c6376

Please sign in to comment.