Skip to content

Commit

Permalink
fix: properly parent wrapper segments
Browse files Browse the repository at this point in the history
  • Loading branch information
ZNeumann committed Nov 16, 2023
1 parent 2920302 commit cd4ad8d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
8 changes: 7 additions & 1 deletion agent/fw_drupal.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,13 @@ NR_PHP_WRAPPER(nr_drupal_http_request_before) {
* after function properly
*/
NRPRG(drupal_http_request_segment)
= nr_segment_start(NRPRG(txn), NRTXN(segment_root), NULL);
= nr_segment_start(NRPRG(txn), NULL, NULL);
/*
* The new segment needs to have the wraprec data attached, so that
* fcall_end is able to properly dispatch to the after wrapper, as
* this new segment is now at the top of the segment stack.
*/
NRPRG(drupal_http_request_segment)->wraprec = auto_segment->wraprec;
}
}
NR_PHP_WRAPPER_END
Expand Down
6 changes: 6 additions & 0 deletions agent/php_execute.c
Original file line number Diff line number Diff line change
Expand Up @@ -2077,6 +2077,12 @@ static void nr_php_instrument_func_end(NR_EXECUTE_PROTO) {
return;
}

/*
* Reassign segment to the current segment, as some before/after wraprecs
* start and then stop a segment. If that happened, we want to ensure we
* get the now-current segment
*/
segment = nr_txn_get_current_segment(NRPRG(txn), NULL);
nr_php_execute_metadata_init(&metadata, NR_OP_ARRAY);
nr_php_execute_segment_end(segment, &metadata, create_metric);
nr_php_execute_metadata_release(&metadata);
Expand Down

0 comments on commit cd4ad8d

Please sign in to comment.