Skip to content

Commit

Permalink
Add device context
Browse files Browse the repository at this point in the history
  • Loading branch information
tustanivsky committed Aug 18, 2023
1 parent d253bd4 commit a85365b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,10 @@ void FSentryCrashContext::Apply(TSharedPtr<SentryScopeDesktop> Scope)
Scope->SetExtraValue("Crash GUID", SessionContext.CrashGUIDRoot);
Scope->SetExtraValue("Executable Name", SessionContext.ExecutableName);
Scope->SetExtraValue("Game Name", SessionContext.GameName);
Scope->SetExtraValue("CPU Brand", SessionContext.CPUBrand);
Scope->SetExtraValue("CPU Vendor", SessionContext.CPUVendor);
Scope->SetExtraValue("Number of Cores", FString::FromInt(SessionContext.NumberOfCores));
Scope->SetExtraValue("Number of Cores including Hyperthreads", FString::FromInt(SessionContext.NumberOfCoresIncludingHyperthreads));
Scope->SetExtraValue("Process Id", FString::FromInt(SessionContext.ProcessId));
Scope->SetExtraValue("Seconds Since Start", FString::FromInt(SessionContext.SecondsSinceStart));
Scope->SetExtraValue("Command Line", SessionContext.CommandLine);
Scope->SetExtraValue("Memory Stats Page Size", FString::FromInt(SessionContext.MemoryStats.PageSize));
Scope->SetExtraValue("Memory Stats Total Physical GB", FString::FromInt(SessionContext.MemoryStats.TotalPhysicalGB));
Scope->SetExtraValue("Memory Stats Total Virtual", FString::Printf(TEXT("%lld"), SessionContext.MemoryStats.TotalVirtual));

if(Settings->SendDefaultPii)
Expand Down
14 changes: 14 additions & 0 deletions plugin-dev/Source/Sentry/Private/SentrySubsystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ void USentrySubsystem::Initialize()

#if PLATFORM_WINDOWS || PLATFORM_LINUX || PLATFORM_MAC
AddGpuContext();
AddDeviceContext();
#endif

PromoteTags();
Expand Down Expand Up @@ -306,6 +307,19 @@ void USentrySubsystem::AddGpuContext()
SubsystemNativeImpl->SetContext(TEXT("gpu"), GpuContext);
}

void USentrySubsystem::AddDeviceContext()
{
const FPlatformMemoryConstants& MemoryConstants = FPlatformMemory::GetConstants();

TMap<FString, FString> DeviceContext;
DeviceContext.Add(TEXT("cpu_description"), FPlatformMisc::GetCPUBrand());
DeviceContext.Add(TEXT("number_of_cores"), FString::FromInt(FPlatformMisc::NumberOfCores()));
DeviceContext.Add(TEXT("number_of_cores_including_hyperthreads"), FString::FromInt(FPlatformMisc::NumberOfCoresIncludingHyperthreads()));
DeviceContext.Add(TEXT("physical_memory_size_gb"), FString::FromInt(MemoryConstants.TotalPhysicalGB));

SubsystemNativeImpl->SetContext(TEXT("device"), DeviceContext);
}

void USentrySubsystem::PromoteTags()
{
const USentrySettings* Settings = FSentryModule::Get().GetSettings();
Expand Down
3 changes: 3 additions & 0 deletions plugin-dev/Source/Sentry/Public/SentrySubsystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,9 @@ class SENTRY_API USentrySubsystem : public UGameInstanceSubsystem
/** Adds GPU context data for all events captured by Sentry SDK. */
void AddGpuContext();

/** Adds GPU context data for all events captured by Sentry SDK. */
void AddDeviceContext();

/** Promote specified values to tags for all events captured by Sentry SDK. */
void PromoteTags();

Expand Down

0 comments on commit a85365b

Please sign in to comment.