Skip to content

Commit

Permalink
Split some crash context data between different categories
Browse files Browse the repository at this point in the history
  • Loading branch information
tustanivsky committed Aug 17, 2023
1 parent 20d9850 commit d253bd4
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
#include "SentryCrashContext.h"

#include "Desktop/SentryScopeDesktop.h"

#include "GenericPlatform/GenericPlatformDriver.h"
#include "SentrySettings.h"
#include "SentryModule.h"

#if PLATFORM_WINDOWS
#include "Windows/WindowsPlatformMisc.h"
#endif
#include "Desktop/SentryScopeDesktop.h"

#if USE_SENTRY_NATIVE

Expand All @@ -17,6 +14,8 @@ FSentryCrashContext::FSentryCrashContext(const FSharedCrashContext& Context)

void FSentryCrashContext::Apply(TSharedPtr<SentryScopeDesktop> Scope)
{
const USentrySettings* Settings = FSentryModule::Get().GetSettings();

const FSessionContext& SessionContext = CrashContext.SessionContext;

Scope->SetExtraValue("Crash Type", FGenericCrashContext::GetCrashTypeString(CrashContext.CrashType));
Expand All @@ -29,8 +28,6 @@ void FSentryCrashContext::Apply(TSharedPtr<SentryScopeDesktop> Scope)
Scope->SetExtraValue("Base Dir", SessionContext.BaseDir);
Scope->SetExtraValue("Is Source Distribution", SessionContext.bIsSourceDistribution ? TEXT("true") : TEXT("false"));
Scope->SetExtraValue("Crash GUID", SessionContext.CrashGUIDRoot);
Scope->SetExtraValue("Epic Account Id", SessionContext.EpicAccountId);
Scope->SetExtraValue("Login Id", SessionContext.LoginIdStr);
Scope->SetExtraValue("Executable Name", SessionContext.ExecutableName);
Scope->SetExtraValue("Game Name", SessionContext.GameName);
Scope->SetExtraValue("CPU Brand", SessionContext.CPUBrand);
Expand All @@ -44,14 +41,11 @@ void FSentryCrashContext::Apply(TSharedPtr<SentryScopeDesktop> Scope)
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));

FGPUDriverInfo GpuDriverInfo = FPlatformMisc::GetGPUDriverInfo(FPlatformMisc::GetPrimaryGPUBrand());

TMap<FString, FString> GpuContext;
GpuContext.Add(TEXT("name"), GpuDriverInfo.DeviceDescription);
GpuContext.Add(TEXT("vendor_name"), GpuDriverInfo.ProviderName);
GpuContext.Add(TEXT("driver_version"), GpuDriverInfo.UserDriverVersion);

Scope->SetContext(TEXT("gpu"), GpuContext);
if(Settings->SendDefaultPii)
{
Scope->SetExtraValue("Epic Account Id", SessionContext.EpicAccountId);
Scope->SetExtraValue("Login Id", SessionContext.LoginIdStr);
}
}

#endif
18 changes: 18 additions & 0 deletions plugin-dev/Source/Sentry/Private/SentrySubsystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "Misc/EngineVersion.h"
#include "Misc/CoreDelegates.h"
#include "Misc/App.h"
#include "GenericPlatform/GenericPlatformDriver.h"
#include "GenericPlatform/GenericPlatformMisc.h"

#include "Interface/SentrySubsystemInterface.h"
Expand Down Expand Up @@ -89,6 +90,11 @@ void USentrySubsystem::Initialize()
}

AddDefaultContext();

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

PromoteTags();
ConfigureBreadcrumbs();
}
Expand Down Expand Up @@ -288,6 +294,18 @@ void USentrySubsystem::AddDefaultContext()
SubsystemNativeImpl->SetContext(TEXT("Unreal Engine"), DefaultContext);
}

void USentrySubsystem::AddGpuContext()
{
FGPUDriverInfo GpuDriverInfo = FPlatformMisc::GetGPUDriverInfo(FPlatformMisc::GetPrimaryGPUBrand());

TMap<FString, FString> GpuContext;
GpuContext.Add(TEXT("name"), GpuDriverInfo.DeviceDescription);
GpuContext.Add(TEXT("vendor_name"), GpuDriverInfo.ProviderName);
GpuContext.Add(TEXT("driver_version"), GpuDriverInfo.UserDriverVersion);

SubsystemNativeImpl->SetContext(TEXT("gpu"), GpuContext);
}

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 @@ -234,6 +234,9 @@ class SENTRY_API USentrySubsystem : public UGameInstanceSubsystem
/** Adds default context data for all events captured by Sentry SDK. */
void AddDefaultContext();

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

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

Expand Down

0 comments on commit d253bd4

Please sign in to comment.