Skip to content

Commit f496c28

Browse files
NR-348708: session attributes are added to log common block
1 parent 6b814a2 commit f496c28

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

Agent/Utilities/NRLogger.m

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,24 @@ - (NSMutableDictionary*) commonBlockDict {
330330
if (nativePlatform) [commonAttributes setObject:nativePlatform forKey:NRLogMessageInstrumentationCollectorKey];
331331
if (nrAppId) [commonAttributes setObject:nrAppId forKey:NRLogMessageAppIdKey];
332332

333+
334+
NSString* sessionAttributes = [[NewRelicAgentInternal sharedInstance].analyticsController sessionAttributeJSONString];
335+
if (sessionAttributes != nil && [sessionAttributes length] > 0) {
336+
NSDictionary* dictionary = [NSJSONSerialization JSONObjectWithData:[sessionAttributes dataUsingEncoding:NSUTF8StringEncoding]
337+
options:0
338+
error:nil];
339+
for (NSString *key in dictionary) {
340+
id value = [dictionary objectForKey:key];
341+
342+
343+
if (value) {
344+
[commonAttributes setObject:value forKey:key];
345+
}
346+
}
347+
}
348+
349+
350+
333351
return commonAttributes;
334352
}
335353

@@ -598,7 +616,6 @@ - (void) processNextUploadTask {
598616
NSData *formattedData = [self->uploadQueue firstObject];
599617

600618
if (self->debugLogs) {
601-
//NSString* logMessagesJson = [NSString stringWithFormat:@"[ %@ ]", [[NSString alloc] initWithData:formattedData encoding:NSUTF8StringEncoding]];
602619
NSArray* decode = [NSJSONSerialization JSONObjectWithData:formattedData
603620
options:0
604621
error:nil];
@@ -609,9 +626,6 @@ - (void) processNextUploadTask {
609626
NSMutableURLRequest* req = [NSMutableURLRequest requestWithURL:[NSURL URLWithString: self->logURL]];
610627
[req setValue:self->logIngestKey forHTTPHeaderField:@"X-App-License-Key"];
611628
[req setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
612-
613-
//NSString* contentEncoding = message.length <= 512 ? kNRMAIdentityHeader : kNRMAGZipHeader;
614-
615629
[req setValue:kNRMAGZipHeader forHTTPHeaderField:kNRMAContentEncodingHeader];
616630

617631
req.HTTPMethod = @"POST";

0 commit comments

Comments
 (0)