From 87252f21eb5f47c57ead1388bc211e2fb6ed5a60 Mon Sep 17 00:00:00 2001 From: Nick Dowell Date: Wed, 6 Apr 2022 15:23:55 +0100 Subject: [PATCH] Add Config.MaxReportedThreads --- CHANGELOG.md | 2 ++ .../Android/AndroidPlatformConfiguration.cpp | 1 + .../Bugsnag/Private/Android/JNIUtilities.cpp | 1 + .../Source/Bugsnag/Private/Android/JNIUtilities.h | 1 + .../Source/Bugsnag/Public/BugsnagConfiguration.h | 15 +++++++++++++++ .../TestFixture/Scenarios/NotifyScenario.cpp | 2 ++ features/handled_errors.feature | 1 + 7 files changed, 23 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 56343107..6961f4a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ Changelog ## TBD +* Adds the `MaxReportedThreads` configuration property (Android only.) + [#144](https://github.com/bugsnag/bugsnag-unreal/pull/144) * Updates the bugsnag-android dependency from v5.19.2 to [v5.22.0](https://github.com/bugsnag/bugsnag-android/blob/master/CHANGELOG.md#5220-2022-03-31) * Updates the bugsnag-cocoa dependency from v6.16.1 to [v6.16.6](https://github.com/bugsnag/bugsnag-cocoa/blob/master/CHANGELOG.md#6166-2022-04-06) diff --git a/Plugins/Bugsnag/Source/Bugsnag/Private/Android/AndroidPlatformConfiguration.cpp b/Plugins/Bugsnag/Source/Bugsnag/Private/Android/AndroidPlatformConfiguration.cpp index f4e4419e..5ff3581d 100644 --- a/Plugins/Bugsnag/Source/Bugsnag/Private/Android/AndroidPlatformConfiguration.cpp +++ b/Plugins/Bugsnag/Source/Bugsnag/Private/Android/AndroidPlatformConfiguration.cpp @@ -89,6 +89,7 @@ jobject FAndroidPlatformConfiguration::Parse(JNIEnv* Env, jniCallWithObjects(Env, jConfig, Cache->ConfigSetMaxBreadcrumbs, Config->GetMaxBreadcrumbs()); jniCallWithObjects(Env, jConfig, Cache->ConfigSetMaxPersistedEvents, Config->GetMaxPersistedEvents()); jniCallWithObjects(Env, jConfig, Cache->ConfigSetMaxPersistedSessions, Config->GetMaxPersistedSessions()); + jniCallWithObjects(Env, jConfig, Cache->ConfigSetMaxReportedThreads, Config->GetMaxReportedThreads()); jniCallWithBool(Env, jConfig, Cache->ConfigSetPersistUser, Config->GetPersistUser()); if (Config->GetRedactedKeys().Num()) { diff --git a/Plugins/Bugsnag/Source/Bugsnag/Private/Android/JNIUtilities.cpp b/Plugins/Bugsnag/Source/Bugsnag/Private/Android/JNIUtilities.cpp index 01dbb19b..eee8b4b9 100644 --- a/Plugins/Bugsnag/Source/Bugsnag/Private/Android/JNIUtilities.cpp +++ b/Plugins/Bugsnag/Source/Bugsnag/Private/Android/JNIUtilities.cpp @@ -192,6 +192,7 @@ bool FAndroidPlatformJNI::LoadReferenceCache(JNIEnv* env, JNIReferenceCache* cac CacheInstanceJavaMethod(env, cache->ConfigSetMaxBreadcrumbs, cache->ConfigClass, "setMaxBreadcrumbs", "(I)V"); CacheInstanceJavaMethod(env, cache->ConfigSetMaxPersistedEvents, cache->ConfigClass, "setMaxPersistedEvents", "(I)V"); CacheInstanceJavaMethod(env, cache->ConfigSetMaxPersistedSessions, cache->ConfigClass, "setMaxPersistedSessions", "(I)V"); + CacheInstanceJavaMethod(env, cache->ConfigSetMaxReportedThreads, cache->ConfigClass, "setMaxReportedThreads", "(I)V"); CacheInstanceJavaMethod(env, cache->ConfigSetPersistenceDirectory, cache->ConfigClass, "setPersistenceDirectory", "(Ljava/io/File;)V"); CacheInstanceJavaMethod(env, cache->ConfigSetPersistUser, cache->ConfigClass, "setPersistUser", "(Z)V"); CacheInstanceJavaMethod(env, cache->ConfigSetProjectPackages, cache->ConfigClass, "setProjectPackages", "(Ljava/util/Set;)V"); diff --git a/Plugins/Bugsnag/Source/Bugsnag/Private/Android/JNIUtilities.h b/Plugins/Bugsnag/Source/Bugsnag/Private/Android/JNIUtilities.h index fb6d4786..10200ea5 100644 --- a/Plugins/Bugsnag/Source/Bugsnag/Private/Android/JNIUtilities.h +++ b/Plugins/Bugsnag/Source/Bugsnag/Private/Android/JNIUtilities.h @@ -133,6 +133,7 @@ typedef struct jmethodID ConfigSetMaxBreadcrumbs; jmethodID ConfigSetMaxPersistedEvents; jmethodID ConfigSetMaxPersistedSessions; + jmethodID ConfigSetMaxReportedThreads; jmethodID ConfigSetPersistenceDirectory; jmethodID ConfigSetPersistUser; jmethodID ConfigSetProjectPackages; diff --git a/Plugins/Bugsnag/Source/Bugsnag/Public/BugsnagConfiguration.h b/Plugins/Bugsnag/Source/Bugsnag/Public/BugsnagConfiguration.h index d142e9bf..0f7a24ab 100644 --- a/Plugins/Bugsnag/Source/Bugsnag/Public/BugsnagConfiguration.h +++ b/Plugins/Bugsnag/Source/Bugsnag/Public/BugsnagConfiguration.h @@ -272,6 +272,20 @@ class BUGSNAG_API FBugsnagConfiguration final : public IBugsnagFeatureFlagStore, */ void SetMaxPersistedSessions(uint32 Value) { MaxPersistedSessions = Value; }; + /** + * The maximum number of Android JVM threads that will be reported with an event. + * + * Once the threshold is reached, all remaining threads will be omitted. + * + * By default, up to 200 threads are reported. + */ + uint32 GetMaxReportedThreads() const { return MaxReportedThreads; } + + /** + * @param Value The maximum number of threads. + */ + void SetMaxReportedThreads(uint32 Value) { MaxReportedThreads = Value; } + /** * Whether User information should be persisted to disk between application runs. * @@ -557,6 +571,7 @@ class BUGSNAG_API FBugsnagConfiguration final : public IBugsnagFeatureFlagStore, uint32 MaxBreadcrumbs = 50; uint32 MaxPersistedEvents = 32; uint32 MaxPersistedSessions = 128; + uint32 MaxReportedThreads = 200; bool bPersistUser = true; FBugsnagUser User; TOptional ReleaseStage; diff --git a/features/fixtures/generic/Source/TestFixture/Scenarios/NotifyScenario.cpp b/features/fixtures/generic/Source/TestFixture/Scenarios/NotifyScenario.cpp index 02964395..42bec8d1 100644 --- a/features/fixtures/generic/Source/TestFixture/Scenarios/NotifyScenario.cpp +++ b/features/fixtures/generic/Source/TestFixture/Scenarios/NotifyScenario.cpp @@ -42,6 +42,8 @@ class NotifyScenario : public Scenario return true; }); + Configuration->SetMaxReportedThreads(3); + // sent in event payload Configuration->SetProjectPackages({TEXT("com.example.package")}); } diff --git a/features/handled_errors.feature b/features/handled_errors.feature index a99fc972..339274a6 100644 --- a/features/handled_errors.feature +++ b/features/handled_errors.feature @@ -5,6 +5,7 @@ Feature: Reporting handled errors And I wait to receive an error Then the error is valid for the error reporting API version "4.0" for the "Unreal Bugsnag Notifier" notifier And the error payload field "events.0.threads" is a non-empty array + And on Android, the error payload field "events.0.threads" is an array with 4 elements And the error payload field "notifier.dependencies.0.name" is not null And the error payload field "notifier.dependencies.0.url" is not null And the error payload field "notifier.dependencies.0.version" is not null