Skip to content

Commit

Permalink
Backport NR-234826
Browse files Browse the repository at this point in the history
  • Loading branch information
cdillard-NewRelic committed Dec 10, 2024
1 parent 71c95be commit a8b4d3f
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions Agent/Instrumentation/NSURLSession/NRMAURLSessionTaskOverride.m
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,28 @@ void NRMAOverride__urlSessionTask_SetState(NSURLSessionTask* task, SEL _cmd, NSU
if ([NRMAURLSessionTaskOverride isSupportedTaskType: task]) {
// Checking for NEW_RELIC_CROSS_PROCESS_ID_HEADER_KEY in the headers here. The data usually isn't link to the task yet here so, if that header exists we are handling the task elsewhere and have a better chance of getting the data so we don't need to record it here.
NSURLRequest *currentRequest = task.currentRequest;
if(currentRequest != nil && [currentRequest valueForHTTPHeaderField:NEW_RELIC_CROSS_PROCESS_ID_HEADER_KEY] != nil) {

if (currentRequest == nil) {
return;
}


if ([currentRequest valueForHTTPHeaderField:NEW_RELIC_CROSS_PROCESS_ID_HEADER_KEY] != nil) {
return;
}

NSURL *url = [currentRequest URL];
if (url != nil &&
newState != NSURLSessionTaskStateRunning && task.state == NSURLSessionTaskStateRunning) {

// Added this section to add Distributed Tracing traceId\trace.id, guid,id and payload.
//1
NSMutableURLRequest* mutableRequest = [NRMAHTTPUtilities addCrossProcessIdentifier:currentRequest];
mutableRequest = [NRMAHTTPUtilities addConnectivityHeaderAndPayload:mutableRequest];

NRMAPayloadContainer* payload = [NRMAHTTPUtilities addConnectivityHeader:mutableRequest];
[NRMAHTTPUtilities attachPayload:payload
to:task.originalRequest];

// get response code
NSUInteger responseCode = [NRMAURLSessionTaskOverride statusCode:task.response];
if (responseCode != -1) {
Expand Down

0 comments on commit a8b4d3f

Please sign in to comment.