Skip to content

Commit c1e95ef

Browse files
Fix NRMAHarvester defaults.
1 parent 0d876ec commit c1e95ef

File tree

2 files changed

+46
-6
lines changed

2 files changed

+46
-6
lines changed

Agent/Harvester/DataStore/NRMAHarvesterConfiguration.m

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,48 @@ - (id) initWithDictionary:(NSDictionary*)dict
1515
self = [super init];
1616
if (self) {
1717
self.application_token = [dict valueForKey:kNRMA_LICENSE_KEY];
18-
self.collect_network_errors = [[dict valueForKey:kNRMA_COLLECT_NETWORK_ERRORS] boolValue];
18+
19+
if ([dict objectForKey:kNRMA_COLLECT_NETWORK_ERRORS]) {
20+
self.collect_network_errors = [[dict valueForKey:kNRMA_COLLECT_NETWORK_ERRORS] boolValue];
21+
}
22+
else {
23+
self.collect_network_errors = true;
24+
}
25+
1926
self.cross_process_id = [dict valueForKey:kNRMA_CROSS_PROCESS_ID];
20-
self.data_report_period = [[dict valueForKey:kNRMA_DATA_REPORT_PERIOD] intValue];
27+
28+
if ([dict objectForKey:kNRMA_DATA_REPORT_PERIOD]) {
29+
self.data_report_period = [[dict valueForKey:kNRMA_DATA_REPORT_PERIOD] intValue];
30+
}
31+
else {
32+
self.data_report_period = NRMA_DEFAULT_REPORT_PERIOD;
33+
}
34+
2135
self.data_token = [[NRMADataToken alloc] init];
2236
self.data_token.clusterAgentId = [[[dict valueForKey:kNRMA_DATA_TOKEN] objectAtIndex:0] longLongValue];
2337
self.data_token.realAgentId = [[[dict valueForKey:kNRMA_DATA_TOKEN] objectAtIndex:1] longLongValue];
24-
self.error_limit = [[dict valueForKey:kNRMA_ERROR_LIMIT] intValue];
25-
self.report_max_transaction_age = [[dict valueForKey:kNRMA_REPORT_MAX_TRANSACTION_AGE] intValue];
26-
self.report_max_transaction_count = [[dict valueForKey:kNRMA_REPORT_MAX_TRANSACTION_COUNT]intValue];
38+
if ([dict objectForKey:kNRMA_ERROR_LIMIT]) {
39+
40+
self.error_limit = [[dict valueForKey:kNRMA_ERROR_LIMIT] intValue];
41+
}
42+
else {
43+
self.error_limit = NRMA_DEFAULT_ERROR_LIMIT;
44+
}
45+
46+
if ([dict objectForKey:kNRMA_REPORT_MAX_TRANSACTION_AGE]) {
47+
48+
self.report_max_transaction_age = [[dict valueForKey:kNRMA_REPORT_MAX_TRANSACTION_AGE] intValue];
49+
}
50+
else {
51+
self.report_max_transaction_age = NRMA_DEFAULT_MAX_TRANSACTION_AGE;
52+
}
53+
if ([dict objectForKey:kNRMA_REPORT_MAX_TRANSACTION_COUNT]) {
54+
self.report_max_transaction_count = [[dict valueForKey:kNRMA_REPORT_MAX_TRANSACTION_COUNT]intValue];
55+
}
56+
else {
57+
self.report_max_transaction_count = NRMA_DEFAULT_MAX_TRANSACTION_COUNT;
58+
}
59+
2760
self.response_body_limit = [[dict valueForKey:kNRMA_RESPONSE_BODY_LIMIT] intValue];
2861
self.server_timestamp = [[dict valueForKey:kNRMA_SERVER_TIMESTAMP] longLongValue];
2962
self.stack_trace_limit = [[dict valueForKey:kNRMA_STACK_TRACE_LIMIT] intValue];
@@ -145,7 +178,9 @@ - (NSUInteger) hash
145178
result = 31 * result + (unsigned int)self.account_id;
146179
result = 31 * result + (unsigned int)self.application_id;
147180
result = 31 * result + self.encoding_key.hash;
148-
181+
// Is this a chill addition?
182+
result = 31 * result + self.trusted_account_key.hash;
183+
149184
return result;
150185
}
151186
@end

Tests/Unit-Tests/NewRelicAgentTests/Harvester-Tests/NRHarvesterTest.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,11 @@ - (void) testHarvestConfiguration
163163
XCTAssertTrue([config isEqual:[[NRMAHarvesterConfiguration alloc] initWithDictionary:[config asDictionary]]], @"test asDictionary and initWithDictionary is correct");
164164
}
165165

166+
- (void) testBadHarvestConfiguration {
167+
// add a test that tests what happens if the kNRMA_REPORT_MAX_TRANSACTION_COUNT is missing
168+
}
169+
170+
166171
- (void) testActivityTraceConfiguration
167172
{
168173
NSArray* at_capture;

0 commit comments

Comments
 (0)