Skip to content

Commit

Permalink
Changing offline to only care about the persisted reports to eliminat…
Browse files Browse the repository at this point in the history
…e missed or duplicated reports
  • Loading branch information
mbruin-NR committed Jan 29, 2024
1 parent e300cfa commit a87bd97
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 14 deletions.
19 changes: 11 additions & 8 deletions Agent/HandledException/NRMAHandledExceptions.mm
Original file line number Diff line number Diff line change
Expand Up @@ -131,17 +131,20 @@ - (instancetype) initWithAnalyticsController:(NRMAAnalytics*)analytics
}

- (void) onHarvest {
NRMAReachability* r = [NewRelicInternalUtils reachability];
@synchronized(r) {
NRMANetworkStatus status = [r currentReachabilityStatus];
if (status != NotReachable) { // Because we support offline mode check if we're online before sending the handled exceptions reports
if(!_controller->publish()) { // If there are no reports in the controller to publish we still want to try and send persisted reports before we clear.
[self processAndPublishPersistedReports];
} else {
_store->clear();
if([NRMAFlags shouldEnableOfflineStorage]) {
NRMAReachability* r = [NewRelicInternalUtils reachability];
@synchronized(r) {
NRMANetworkStatus status = [r currentReachabilityStatus];
if (status != NotReachable) {
[self processAndPublishPersistedReports]; // When using offline we always want to send from persisted because the keyContext doesn't persist.
_controller->resetKeyContext();
_publisher->retry();
}
}
} else {
_controller->publish();
_store->clear();
_publisher->retry();
}
}

Expand Down
2 changes: 1 addition & 1 deletion Test Harness/NRTestApp/NRTestApp/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}

NewRelic.setMaxEventPoolSize(5000)
NewRelic.setMaxEventBufferTime(600)
NewRelic.setMaxEventBufferTime(60)

NewRelic.logVerbose("NewRelic.start was called.")
return true
Expand Down
4 changes: 3 additions & 1 deletion libMobileAgent/src/Hex/include/Hex/HexController.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ namespace NewRelic {

void submit(std::shared_ptr<Report::HexReport> report);

bool publish();
void publish();

void resetKeyContext();

void setSessionId(const char* sessionId);

Expand Down
9 changes: 5 additions & 4 deletions libMobileAgent/src/Hex/src/HexController.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include "Hex/HexPublisher.hpp"
#include "Hex/HexController.hpp"


using namespace NewRelic::Hex;

HexController::HexController(std::shared_ptr<const AnalyticsController>& analytics,
Expand Down Expand Up @@ -83,15 +82,17 @@ std::shared_ptr<HexReportContext> HexController::detachKeyContext() {
return context;
}

void HexController::resetKeyContext() {
std::unique_lock<std::mutex> resetLock(_keyContextMutex);
_keyContext = std::make_shared<HexReportContext>(_applicationInfo, _analytics->getAttributeValidator());
}

bool HexController::publish() {
void HexController::publish() {
auto context = detachKeyContext();
if (context->reports() > 0) {
context->finalize();
_publisher->publish(context);
return true;
}
return false;
}

void HexController::submit(std::shared_ptr<Report::HexReport> report) {
Expand Down

0 comments on commit a87bd97

Please sign in to comment.