File tree Expand file tree Collapse file tree 8 files changed +53
-6
lines changed
Tests/Unit-Tests/NewRelicAgentTests/Analytics-Tests Expand file tree Collapse file tree 8 files changed +53
-6
lines changed Original file line number Diff line number Diff line change 16
16
17
17
@interface NRMAAnalytics : NSObject <NRMAHarvestAware>
18
18
- (void ) setMaxEventBufferTime : (unsigned int ) seconds ;
19
-
19
+ - ( NSUInteger ) getMaxEventBufferSize ;
20
20
- (void ) setMaxEventBufferSize : (unsigned int ) size ;
21
+ - (NSUInteger ) getMaxEventBufferTime ;
21
22
22
23
- (id ) initWithSessionStartTimeMS : (long long ) sessionStartTime ;
23
24
Original file line number Diff line number Diff line change @@ -81,22 +81,30 @@ @implementation NRMAAnalytics
81
81
}
82
82
83
83
- (void ) setMaxEventBufferSize : (unsigned int ) size {
84
+ [NRMAAgentConfiguration setMaxEventBufferSize: size];
84
85
if ([NRMAFlags shouldEnableNewEventSystem ]){
85
86
[_eventManager setMaxEventBufferSize: size];
86
87
}
87
88
else {
88
89
_analyticsController->setMaxEventBufferSize (size);
89
90
}
90
91
}
92
+ - (NSUInteger ) getMaxEventBufferSize {
93
+ return [_eventManager getMaxEventBufferSize ];
94
+ }
91
95
- (void ) setMaxEventBufferTime : (unsigned int )seconds
92
96
{
97
+ [NRMAAgentConfiguration setMaxEventBufferTime: seconds];
93
98
if ([NRMAFlags shouldEnableNewEventSystem ]){
94
99
[_eventManager setMaxEventBufferTimeInSeconds: seconds];
95
100
}
96
101
else {
97
102
_analyticsController->setMaxEventBufferTime (seconds);
98
103
}
99
104
}
105
+ - (NSUInteger ) getMaxEventBufferTime {
106
+ return [_eventManager getMaxEventBufferTimeInSeconds ];
107
+ }
100
108
101
109
- (id ) initWithSessionStartTimeMS : (long long ) sessionStartTime {
102
110
self = [super init ];
Original file line number Diff line number Diff line change @@ -20,7 +20,9 @@ NS_ASSUME_NONNULL_BEGIN
20
20
21
21
- (instancetype )initWithPersistentStore : (PersistentEventStore *)store ;
22
22
- (void )setMaxEventBufferSize : (NSUInteger )size ;
23
+ - (NSUInteger )getMaxEventBufferSize ;
23
24
- (void )setMaxEventBufferTimeInSeconds : (NSUInteger )seconds ;
25
+ - (NSUInteger )getMaxEventBufferTimeInSeconds ;
24
26
- (BOOL )didReachMaxQueueTime : (NSTimeInterval )currentTimeMilliseconds ;
25
27
- (BOOL )addEvent : (id <NRMAAnalyticEventProtocol>)event ;
26
28
- (void )empty ;
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ - (nonnull instancetype)initWithPersistentStore:(PersistentEventStore *)store {
37
37
self = [super init ];
38
38
if (self) {
39
39
events = [[NSMutableArray <NRMAAnalyticEventProtocol> alloc] init ];
40
- maxBufferSize = kDefaultBufferSize ;
40
+ maxBufferSize = [NRMAAgentConfiguration getMaxEventBufferSize ] ;
41
41
maxBufferTimeSeconds = [NRMAAgentConfiguration getMaxEventBufferTime ];
42
42
totalAttemptedInserts = 0 ;
43
43
oldestEventTimestamp = 0 ;
@@ -50,6 +50,10 @@ - (void)setMaxEventBufferSize:(NSUInteger)size {
50
50
maxBufferSize = size;
51
51
}
52
52
53
+ - (NSUInteger )getMaxEventBufferSize {
54
+ return maxBufferSize;
55
+ }
56
+
53
57
- (void )setMaxEventBufferTimeInSeconds : (NSUInteger )seconds {
54
58
if (seconds < kMinBufferTimeSeconds ) {
55
59
NRLOG_ERROR (@" Buffer Time cannot be less than %lu Seconds" , (unsigned long )kMinBufferTimeSeconds );
@@ -62,6 +66,10 @@ - (void)setMaxEventBufferTimeInSeconds:(NSUInteger)seconds {
62
66
maxBufferTimeSeconds = seconds;
63
67
}
64
68
69
+ - (NSUInteger )getMaxEventBufferTimeInSeconds {
70
+ return maxBufferTimeSeconds;
71
+ }
72
+
65
73
- (BOOL )didReachMaxQueueTime : (NSTimeInterval )currentTimeMilliseconds {
66
74
if (oldestEventTimestamp == 0 ) {
67
75
return false ;
Original file line number Diff line number Diff line change 44
44
+ (void ) setMaxEventBufferTime : (NSUInteger )seconds ;
45
45
+ (NSUInteger ) getMaxEventBufferTime ;
46
46
47
+ + (void ) setMaxEventBufferSize : (NSUInteger )size ;
48
+ + (NSUInteger ) getMaxEventBufferSize ;
47
49
@end
Original file line number Diff line number Diff line change 22
22
23
23
// Default max event buffer time is 10 minutes (600 seconds).
24
24
static NSUInteger __NRMA__maxEventBufferTime = 600 ;
25
+ static NSUInteger __NRMA__maxEventBufferSize = 1000 ;
25
26
26
27
@implementation NRMAAgentConfiguration
27
28
@@ -49,6 +50,13 @@ + (NSUInteger) getMaxEventBufferTime {
49
50
return __NRMA__maxEventBufferTime;
50
51
}
51
52
53
+ + (void ) setMaxEventBufferSize : (NSUInteger )size {
54
+ __NRMA__maxEventBufferSize = size;
55
+ }
56
+ + (NSUInteger ) getMaxEventBufferSize {
57
+ return __NRMA__maxEventBufferSize;
58
+ }
59
+
52
60
- (id ) initWithAppToken : (NRMAAppToken*)token
53
61
collectorAddress : (NSString *)collectorHost
54
62
crashAddress : (NSString *)crashHost {
Original file line number Diff line number Diff line change @@ -613,8 +613,6 @@ + (BOOL) recordBreadcrumb:(NSString* __nonnull)name
613
613
* harvest cycle.
614
614
*/
615
615
+ (void ) setMaxEventBufferTime:(unsigned int )seconds {
616
- [NRMAAgentConfiguration setMaxEventBufferTime: seconds];
617
-
618
616
[[NewRelicAgentInternal sharedInstance ].analyticsController setMaxEventBufferTime: seconds];
619
617
}
620
618
/*
Original file line number Diff line number Diff line change @@ -420,8 +420,6 @@ - (void) testJSONEscapeCharacters {
420
420
421
421
}
422
422
423
-
424
-
425
423
- (void ) testDuplicateStore {
426
424
// todo: reenable test (disabled for beta 1, no persistent store)
427
425
// NRMAAnalytics* analytics = [[NRMAAnalytics alloc] initWithSessionStartTimeMS:0];
@@ -1114,6 +1112,28 @@ - (void) testMidSessionHarvest {
1114
1112
// XCTAssertTrue(array.count == 0, @"dup events should have been cleared out on harvest before.");
1115
1113
}
1116
1114
1115
+ -(void )testSetMaxEventBufferSize {
1116
+ NRMAAnalytics* analytics = [[NRMAAnalytics alloc ] initWithSessionStartTimeMS: 0 ];
1117
+
1118
+ [analytics setMaxEventBufferSize: 2000 ];
1119
+
1120
+ XCTAssertEqual ([analytics getMaxEventBufferSize ], 2000 );
1121
+
1122
+ analytics = [[NRMAAnalytics alloc ] initWithSessionStartTimeMS: 0 ];
1123
+ XCTAssertEqual ([analytics getMaxEventBufferSize ], 2000 );
1124
+ }
1125
+
1126
+ -(void )testSetMaxEventBufferTime {
1127
+ NRMAAnalytics* analytics = [[NRMAAnalytics alloc ] initWithSessionStartTimeMS: 0 ];
1128
+
1129
+ [analytics setMaxEventBufferTime: 2000 ];
1130
+
1131
+ XCTAssertEqual ([analytics getMaxEventBufferTime ], 2000 );
1132
+
1133
+ analytics = [[NRMAAnalytics alloc ] initWithSessionStartTimeMS: 0 ];
1134
+ XCTAssertEqual ([analytics getMaxEventBufferTime ], 2000 );
1135
+ }
1136
+
1117
1137
- (void ) testBadInput {
1118
1138
NRMAAnalytics* analytics = [[NRMAAnalytics alloc ] initWithSessionStartTimeMS: 0 ];
1119
1139
BOOL result;
You can’t perform that action at this time.
0 commit comments