Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Agent/Analytics/NRMAEventManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#import "NRMAAgentConfiguration.h"

static const NSUInteger kDefaultBufferSize = 1000;
static const NSUInteger kDefaultBufferTimeSeconds = 600; // 10 Minutes
static const NSUInteger kDefaultBufferTimeSeconds = 60; // 60 seconds
static const NSUInteger kMinBufferTimeSeconds = 60; // 60 seconds
static const NSUInteger kBufferTimeSecondsLeeway = 60; // 60 seconds

Expand Down Expand Up @@ -63,7 +63,6 @@ - (void)setMaxEventBufferTimeInSeconds:(NSUInteger)seconds {
NRLOG_AGENT_WARNING(@"Buffer Time should not be longer than %lu seconds", (unsigned long)kDefaultBufferTimeSeconds);
maxBufferTimeSeconds = kDefaultBufferTimeSeconds;
}

maxBufferTimeSeconds = seconds;
}

Expand Down
2 changes: 2 additions & 0 deletions Agent/General/NewRelicAgentInternal.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ NS_ASSUME_NONNULL_BEGIN

- (NSDate*) getAppSessionStartDate;
- (NSString* _Nullable) getUserId;
- (void) setMaxEventBufferTime:(unsigned int)seconds;
- (void) setMaxEventPoolSize:(unsigned int)size;

- (void) applicationWillEnterForeground;
- (void) sessionStartInitialization;
Expand Down
18 changes: 18 additions & 0 deletions Agent/General/NewRelicAgentInternal.m
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,24 @@ + (void)setURLTransformer:(NRMAURLTransformer *)transformer {
+ (NRMAURLTransformer *)getURLTransformer {
return urlTransformer;
}
- (void) setMaxEventBufferTime:(unsigned int)seconds {
[NRMATaskQueue queue:[[NRMAMetric alloc] initWithName:kNRSupportabilityPrefix@"/API/setMaxBufferTime"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not seeing these metrics show up, you should change it to use the deferredMetrics like in the NRMASupportMetricHelper.m class.

+ (void) enqueueMaxEventBufferTimeMetric {
    @synchronized (deferredMetrics) {
        [deferredMetrics addObject:[[NRMAMetric alloc] initWithName:kNRSupportabilityPrefix@"/API/setMaxBufferTime"
                                                              value:@1
                                                              scope:nil]];
    }
}

value:@1
scope:@""]];
[NRMASupportMetricHelper enqueueMaxBufferTimeConfiguration:seconds];


[self.analyticsController setMaxEventBufferTime:seconds];
NRLOG_AGENT_DEBUG(@"Event buffer time was set to custom value: %d", seconds);

}
- (void) setMaxEventPoolSize:(unsigned int)size {
[NRMASupportMetricHelper enqueueBufferPoolSizeConfiguration:size];
// TODO clean up references to poolsize/buffersize. Lets pick one and stick with it throughout our code.
// Note: the name for the metric representing "PoolSize" will change throught the code. Occasianally referenced as 'PoolSize' or 'BufferSize'
[self.analyticsController setMaxEventBufferSize:size];
NRLOG_AGENT_DEBUG(@"Event Pool was set to custom value: %d", size);
}
- (void) dealloc {
NSLog(@"NewRelicAgentInternal -dealloc");
}
Expand Down Expand Up @@ -1101,6 +1118,7 @@ + (void) shutdown {
// If the agent is connected, it should have no problem performing an adhoc harvest right now containing Shutdown support metric.
[NRMASupportMetricHelper enqueueStopAgentMetric];


[NRMAHarvestController harvestNow];

// * ACTUAL SHUT DOWN *//
Expand Down
5 changes: 3 additions & 2 deletions Agent/Harvester/DataStore/NRMAAgentConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
static NRMAApplicationPlatform __NRMA__applicationPlatform = NRMAPlatform_Native;
static NSString* __NRMA__applicationPlatformVersion = nil;

// Default max event buffer time is 10 minutes (600 seconds).
static NSUInteger __NRMA__maxEventBufferTime = 600;
// Default max event buffer time is 1 minute (60 seconds).
static NSUInteger __NRMA__maxEventBufferTime = 60;
static NSUInteger __NRMA__maxEventBufferSize = 1000;
static NSUInteger __NRMA__maxOfflineStorageSize = 100000000; // 100 mb

Expand All @@ -46,6 +46,7 @@ + (void) setPlatformVersion:(NSString*)platformVersion

+ (void) setMaxEventBufferTime:(NSUInteger)seconds {
__NRMA__maxEventBufferTime = seconds;

}
+ (NSUInteger) getMaxEventBufferTime {
return __NRMA__maxEventBufferTime;
Expand Down
3 changes: 3 additions & 0 deletions Agent/Measurements/NRMASupportMetricHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ static NSMutableArray *deferredMetrics;
+ (void) enqueueUpgradeMetric;
+ (void) enqueueStopAgentMetric;
+ (void) enqueueConfigurationUpdateMetric;
+ (void) enqueueBufferPoolSizeConfiguration:(unsigned int)size;
+ (void) enqueueMaxBufferTimeConfiguration:(unsigned int)seconds;

+ (void) processDeferredMetrics;
+ (void) enqueueOfflinePayloadMetric:(long)size;

Expand Down
25 changes: 24 additions & 1 deletion Agent/Measurements/NRMASupportMetricHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,31 @@ + (void) enqueueConfigurationUpdateMetric {
}
}

// Logging
+ (void) enqueueMaxBufferTimeConfiguration:(unsigned int)seconds {
NSString* nativePlatform = [NewRelicInternalUtils osName];

@synchronized (deferredMetrics) {
[deferredMetrics addObject:[[NRMAMetric alloc] initWithName:[NSString stringWithFormat:@"Supportability/Mobile/%@/API/setMaxBufferTime", nativePlatform]
value:[NSNumber numberWithUnsignedInt:seconds]
scope:@""
produceUnscoped:YES
additionalValue:nil]];
}
}

+ (void) enqueueBufferPoolSizeConfiguration:(unsigned int)size {
NSString* nativePlatform = [NewRelicInternalUtils osName];

@synchronized (deferredMetrics) {
[deferredMetrics addObject:[[NRMAMetric alloc] initWithName:[NSString stringWithFormat:@"Supportability/Mobile/%@/API/setMaxEventPoolSize", nativePlatform]
value:[NSNumber numberWithUnsignedInt:size]
scope:@""
produceUnscoped:YES
additionalValue:nil]];
}
}

// Logging
+ (void) enqueueLogSuccessMetric:(long)size {
NSString* nativePlatform = [NewRelicInternalUtils osName];
NSString* platform = [NewRelicInternalUtils stringFromNRMAApplicationPlatform:[NRMAAgentConfiguration connectionInformation].deviceInformation.platform];
Expand Down
6 changes: 4 additions & 2 deletions Agent/Public/NewRelic.m
Original file line number Diff line number Diff line change
Expand Up @@ -739,15 +739,17 @@ + (BOOL) recordBreadcrumb:(NSString* __nonnull)name
* harvest cycle.
*/
+ (void) setMaxEventBufferTime:(unsigned int)seconds {
[[NewRelicAgentInternal sharedInstance].analyticsController setMaxEventBufferTime:seconds];
[[NewRelicAgentInternal sharedInstance] setMaxEventBufferTime:seconds];

}

/*
* this method sets the maximum number of events buffered by the agent.
* this means: once this many events have been recorded, new events have a statistical chance of overwriting
* previously recorded events in the buffer.
*/
+ (void) setMaxEventPoolSize:(unsigned int)size {
[[NewRelicAgentInternal sharedInstance].analyticsController setMaxEventBufferSize:size];
[[NewRelicAgentInternal sharedInstance] setMaxEventPoolSize:size];
}

/*
Expand Down
6 changes: 3 additions & 3 deletions Test Harness/NRTestApp/NRAPI-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
<plist version="1.0">
<dict>
<key>crashCollectorAddress</key>
<string></string>
<string>staging-mobile-crash.newrelic.com</string>
<key>collectorAddress</key>
<string></string>
<string>staging-mobile-collector.newrelic.com</string>
<key>NRAPIKey</key>
<string></string>
<string>AA17fe6658e601c9f10eefc8f808c0763461b532d2-NRMA</string>
</dict>
</plist>
4 changes: 2 additions & 2 deletions Test Harness/NRTestApp/NRTestApp/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
NewRelic.addSessionReplayMaskViewClass("SecureLabel")
NewRelic.addSessionReplayUnmaskViewClass("UnsecureLabel")

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

// if ProcessInfo.processInfo.environment["UITesting"] != nil {
// if ProcessInfo.processInfo.environment["DeleteConnect"] != nil {
Expand Down
28 changes: 14 additions & 14 deletions Test Harness/NRTestApp/NRTestApp/Navigation/MainCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ import SwiftUI
// Using the coordinator pattern for navigation
class MainCoordinator: Coordinator {
var navigationController: UINavigationController

init(navigationController: UINavigationController) {
self.navigationController = navigationController
}

// Called at the start of the application
func start() {
let vc = ViewControllerProvider.viewController
vc.coordinator = self

navigationController.pushViewController(vc, animated: false)
}

func showImageViewController(image: UIImage) {
#if os(iOS)
if #available(iOS 14.0, *) {
Expand All @@ -33,44 +33,44 @@ class MainCoordinator: Coordinator {
}
#endif
}

func showUtilitiesViewController() {
let utilitiesViewController = ViewControllerProvider.utilitiesViewController
navigationController.pushViewController(utilitiesViewController, animated: true)
}

func showWebViewController() {
#if os(iOS)
let webViewController = ViewControllerProvider.webViewController
navigationController.pushViewController(webViewController, animated: true)
#endif
}

func showTextMaskingController() {
let webViewController = ViewControllerProvider.textMaskingViewController
navigationController.pushViewController(webViewController, animated: true)
}

func showCollectionController() {
let collectionViewController = ViewControllerProvider.collectionViewController
navigationController.pushViewController(collectionViewController, animated: true)
}

func showInfiniteScrollController() {
let infiniteViewController = ViewControllerProvider.infiniteViewController
navigationController.pushViewController(infiniteViewController, animated: true)
}

func showInfiniteImageScrollController() {
let infiniteViewController = ViewControllerProvider.infiniteImageViewController
navigationController.pushViewController(infiniteViewController, animated: true)
}

func showDiffTestController() {
let diffTestViewController = ViewControllerProvider.diffTestViewController
navigationController.pushViewController(diffTestViewController, animated: true)
}

func showPerformanceContentView() {
#if os(iOS)
if #available(iOS 15.0, *) {
Expand All @@ -90,7 +90,7 @@ class MainCoordinator: Coordinator {
let confidentialViewController = ViewControllerProvider.confidentialViewController
navigationController.pushViewController(confidentialViewController, animated: true)
}

func showSwiftUITestView() {
#if os(iOS)
if #available(iOS 15.0, *) {
Expand All @@ -100,7 +100,7 @@ class MainCoordinator: Coordinator {
}
#endif
}

func showSwiftUIViewRepresentableTestView() {
#if os(iOS)
if #available(iOS 15.0, *) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace NewRelic {

EventBufferConfig() = default;
public:
static const unsigned int kMaxEventBufferTimeSecDefault = 600;
static const unsigned int kMaxEventBufferTimeSecDefault = 60 ;
static const unsigned int kMaxEventBufferSizeDefault = 1000;
static EventBufferConfig& getInstance();
void setMaxEventBufferTime(unsigned int);
Expand Down
1 change: 1 addition & 0 deletions libMobileAgent/src/Analytics/src/EventManager.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ bool EventManager::didReachMaxQueueTime(unsigned long long currentTimestamp_ms)

void EventManager::setMaxBufferSize(unsigned int size) {
EventBufferConfig::getInstance().setMaxEventBufferSize(size);

}

void EventManager::empty() {
Expand Down