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

logging and additional fallback for installation ID #1103

Merged
merged 6 commits into from
Jul 10, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

### Changes

- Add additional logging and additional fallback for installation ID ([#1103](https://github.com/getsentry/sentry-dotnet/pull/1103))

## 3.6.1

### Fixes
Expand Down
11 changes: 9 additions & 2 deletions src/Sentry/GlobalSessionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ public GlobalSessionManager(SentryOptions options)

Directory.CreateDirectory(directoryPath);

_options.DiagnosticLogger?.LogDebug(
"Created directory for installation ID file ({0}).",
directoryPath
);

var filePath = Path.Combine(directoryPath, ".installation");

// Read installation ID stored in a file
Expand Down Expand Up @@ -94,6 +99,7 @@ public GlobalSessionManager(SentryOptions options)
{
try
{
// Get MAC address of the first network adapter
var installationId = NetworkInterface
.GetAllNetworkInterfaces()
.Where(nic =>
Expand All @@ -105,7 +111,7 @@ public GlobalSessionManager(SentryOptions options)
if (string.IsNullOrWhiteSpace(installationId))
{
_options.DiagnosticLogger?.LogError(
"Failed to resolve hardware installation ID."
"Failed to find an appropriate network interface for installation ID."
);

return null;
Expand Down Expand Up @@ -145,7 +151,8 @@ public GlobalSessionManager(SentryOptions options)

var id =
TryGetPersistentInstallationId() ??
TryGetHardwareInstallationId();
TryGetHardwareInstallationId() ??
Environment.MachineName;
Tyrrrz marked this conversation as resolved.
Show resolved Hide resolved

if (!string.IsNullOrWhiteSpace(id))
{
Expand Down