From a85365b8fe4c4c999a62942d85e5cb7e6528aed1 Mon Sep 17 00:00:00 2001 From: Ivan Tustanivskyi Date: Fri, 18 Aug 2023 11:51:18 +0300 Subject: [PATCH] Add device context --- .../Desktop/CrashReporter/SentryCrashContext.cpp | 5 ----- .../Source/Sentry/Private/SentrySubsystem.cpp | 14 ++++++++++++++ plugin-dev/Source/Sentry/Public/SentrySubsystem.h | 3 +++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/plugin-dev/Source/Sentry/Private/Desktop/CrashReporter/SentryCrashContext.cpp b/plugin-dev/Source/Sentry/Private/Desktop/CrashReporter/SentryCrashContext.cpp index e5b72ecc4..855444f45 100644 --- a/plugin-dev/Source/Sentry/Private/Desktop/CrashReporter/SentryCrashContext.cpp +++ b/plugin-dev/Source/Sentry/Private/Desktop/CrashReporter/SentryCrashContext.cpp @@ -30,15 +30,10 @@ void FSentryCrashContext::Apply(TSharedPtr 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) diff --git a/plugin-dev/Source/Sentry/Private/SentrySubsystem.cpp b/plugin-dev/Source/Sentry/Private/SentrySubsystem.cpp index 6a8553869..412d53d7b 100644 --- a/plugin-dev/Source/Sentry/Private/SentrySubsystem.cpp +++ b/plugin-dev/Source/Sentry/Private/SentrySubsystem.cpp @@ -93,6 +93,7 @@ void USentrySubsystem::Initialize() #if PLATFORM_WINDOWS || PLATFORM_LINUX || PLATFORM_MAC AddGpuContext(); + AddDeviceContext(); #endif PromoteTags(); @@ -306,6 +307,19 @@ void USentrySubsystem::AddGpuContext() SubsystemNativeImpl->SetContext(TEXT("gpu"), GpuContext); } +void USentrySubsystem::AddDeviceContext() +{ + const FPlatformMemoryConstants& MemoryConstants = FPlatformMemory::GetConstants(); + + TMap 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(); diff --git a/plugin-dev/Source/Sentry/Public/SentrySubsystem.h b/plugin-dev/Source/Sentry/Public/SentrySubsystem.h index 1796b6298..948245103 100644 --- a/plugin-dev/Source/Sentry/Public/SentrySubsystem.h +++ b/plugin-dev/Source/Sentry/Public/SentrySubsystem.h @@ -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();