Skip to content

Commit

Permalink
Avoid calls the Thread.CurrentThread where possible (#1466)
Browse files Browse the repository at this point in the history
Co-authored-by: Bruno Garcia <bruno@brunogarcia.com>
  • Loading branch information
SimonCropp and bruno-garcia authored Feb 11, 2022
1 parent 86c0fcd commit cb7ae0c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
- Reduced the logger noise from EF when not using Performance Monitoring ([#1441](https://github.com/getsentry/sentry-dotnet/pull/1441))
- Create CachingTransport directories in constructor to avoid DirectoryNotFoundException ([#1432](https://github.com/getsentry/sentry-dotnet/pull/1432))
- UnobservedTaskException is now considered as Unhandled ([#1447](https://github.com/getsentry/sentry-dotnet/pull/1447))
- Avoid calls the Thread.CurrentThread where possible ([#1466](https://github.com/getsentry/sentry-dotnet/pull/1466))
- Rename thread pool protocol keys to snake case ([#1472](https://github.com/getsentry/sentry-dotnet/pull/1472))
- Treat IOException as a network issue ([#1476](https://github.com/getsentry/sentry-dotnet/pull/1476))
- Fix incorrect sdk name in envelope header ([#1474](https://github.com/getsentry/sentry-dotnet/pull/1474))
Expand Down
2 changes: 1 addition & 1 deletion src/Sentry/Internal/MainExceptionProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ internal IEnumerable<SentryException> CreateSentryException(Exception exception)
Type = exception.GetType()?.FullName,
Module = exception.GetType()?.Assembly?.FullName,
Value = exception.Message,
ThreadId = Thread.CurrentThread.ManagedThreadId,
ThreadId = Environment.CurrentManagedThreadId,
Mechanism = GetMechanism(exception)
};

Expand Down
5 changes: 3 additions & 2 deletions src/Sentry/Internal/MainSentryEventProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,13 @@ public SentryEvent Process(SentryEvent @event)
var stackTrace = SentryStackTraceFactoryAccessor().Create(@event.Exception);
if (stackTrace != null)
{
var currentThread = Thread.CurrentThread;
var thread = new SentryThread
{
Crashed = false,
Current = true,
Name = Thread.CurrentThread.Name,
Id = Environment.CurrentManagedThreadId,
Name = currentThread.Name,
Id = currentThread.ManagedThreadId,
Stacktrace = stackTrace
};

Expand Down

0 comments on commit cb7ae0c

Please sign in to comment.