Skip to content

Commit e35b3fa

Browse files
authored
Merge branch 'develop' into offlineStoragePOC
2 parents a87bd97 + b22af29 commit e35b3fa

File tree

47 files changed

+3407
-10
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+3407
-10
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ CMakeFiles/
77
Makefile
88
Testing/
99
build/
10+
examples/cocoapods/CocoapodsExample/Pods/
1011

1112
# idea project files
1213
# Xcode
@@ -87,4 +88,3 @@ fastlane/test_output
8788

8889
iOSInjectionProject/
8990
.DS_Store
90-

Agent/Harvester/DataStore/NRMAHarvesterConfiguration.m

Lines changed: 62 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,70 @@ - (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 = NRMA_DEFAULT_COLLECT_NETWORK_ERRORS;
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];
27-
self.response_body_limit = [[dict valueForKey:kNRMA_RESPONSE_BODY_LIMIT] intValue];
38+
39+
if ([dict objectForKey:kNRMA_ERROR_LIMIT]) {
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+
60+
if ([dict objectForKey:kNRMA_RESPONSE_BODY_LIMIT]) {
61+
self.response_body_limit = [[dict valueForKey:kNRMA_RESPONSE_BODY_LIMIT] intValue];
62+
}
63+
else {
64+
self.response_body_limit = NRMA_DEFAULT_RESPONSE_BODY_LIMIT;
65+
}
66+
2867
self.server_timestamp = [[dict valueForKey:kNRMA_SERVER_TIMESTAMP] longLongValue];
29-
self.stack_trace_limit = [[dict valueForKey:kNRMA_STACK_TRACE_LIMIT] intValue];
30-
self.activity_trace_max_size =[[dict valueForKey:kNRMA_AT_MAX_SIZE] intValue];
68+
69+
if ([dict objectForKey:kNRMA_STACK_TRACE_LIMIT]) {
70+
self.stack_trace_limit = [[dict valueForKey:kNRMA_STACK_TRACE_LIMIT] intValue];
71+
}
72+
else {
73+
self.stack_trace_limit = NRMA_DEFAULT_STACK_TRACE_LIMIT;
74+
}
75+
if ([dict objectForKey:kNRMA_AT_MAX_SIZE]) {
76+
self.activity_trace_max_size =[[dict valueForKey:kNRMA_AT_MAX_SIZE] intValue];
77+
}
78+
else {
79+
self.activity_trace_max_size = NRMA_DEFAULT_ACTIVITY_TRACE_MAX_SIZE;
80+
}
81+
3182
self.at_capture = [[NRMATraceConfigurations alloc] initWithArray:[dict valueForKey:kNRMA_AT_CAPTURE]];
3283
self.activity_trace_min_utilization = [[dict valueForKey:KNRMA_AT_MIN_UTILIZATION] doubleValue];
3384
self.encoding_key = [dict valueForKey:kNRMA_ENCODING_KEY];
@@ -145,7 +196,9 @@ - (NSUInteger) hash
145196
result = 31 * result + (unsigned int)self.account_id;
146197
result = 31 * result + (unsigned int)self.application_id;
147198
result = 31 * result + self.encoding_key.hash;
148-
199+
// Is this a chill addition?
200+
result = 31 * result + self.trusted_account_key.hash;
201+
149202
return result;
150203
}
151204
@end

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

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

165+
- (void) testBadHarvestConfiguration {
166+
167+
// Test what happens if any value is missing from passed dictionary
168+
169+
NRMAHarvesterConfiguration* config = [[NRMAHarvesterConfiguration alloc] initWithDictionary:[NSDictionary dictionary]];
170+
XCTAssertEqual(NRMA_DEFAULT_REPORT_PERIOD, config.data_report_period, @"A bad dictionary should parse default report period to its default.");
171+
// if kNRMA_COLLECT_NETWORK_ERRORS is missing.
172+
XCTAssertEqual(true, config.collect_network_errors, @"A bad dictionary should parse default report period to its default.");
173+
// if kNRMA_ERROR_LIMIT is missing
174+
XCTAssertEqual(NRMA_DEFAULT_ERROR_LIMIT, config.error_limit, @"A bad dictionary should parse default error limit to its default.");
175+
// if kNRMA_REPORT_MAX_TRANSACTION_AGE is missing
176+
XCTAssertEqual(NRMA_DEFAULT_MAX_TRANSACTION_AGE, config.report_max_transaction_age, @"A bad dictionary should parse default max transaction aget limit to its default.");
177+
// if kNRMA_REPORT_MAX_TRANSACTION_COUNT is missing
178+
XCTAssertEqual(NRMA_DEFAULT_MAX_TRANSACTION_COUNT, config.report_max_transaction_count, @"A bad dictionary should parse max transactions to its default.");
179+
// if kNRMA_RESPONSE_BODY_LIMIT is missing
180+
XCTAssertEqual(NRMA_DEFAULT_RESPONSE_BODY_LIMIT, config.response_body_limit, @"A bad dictionary should parse response body limit to its default.");
181+
// if kNRMA_STACK_TRACE_LIMIT is missing
182+
XCTAssertEqual(NRMA_DEFAULT_STACK_TRACE_LIMIT, config.stack_trace_limit, @"A bad dictionary should parse response body limit to its default.");
183+
// if kNRMA_AT_MAX_SIZE is missing
184+
XCTAssertEqual(NRMA_DEFAULT_ACTIVITY_TRACE_MAX_SIZE, config.activity_trace_max_size, @"A bad dictionary should parse activity trace max size limit to its default.");
185+
}
186+
165187
- (void) testActivityTraceConfiguration
166188
{
167189
NSArray* at_capture;

0 commit comments

Comments
 (0)