Skip to content

Instantly share code, notes, and snippets.

@joehoyle
Created November 19, 2016 20:54
Show Gist options
  • Save joehoyle/8060b28a62f19f78dc9f06499d7ce1bc to your computer and use it in GitHub Desktop.
Save joehoyle/8060b28a62f19f78dc9f06499d7ce1bc to your computer and use it in GitHub Desktop.
<?php
global $wp_filter;
if ( ! $wp_filter ) {
$wp_filter = array(
'parse_request' => array(),
'rest_post_dispatch' => array(),
);
}
// set the newrelic values to the matched query
$wp_filter['parse_request'][0] = array(
'newrelic' => array(
'function' => function( WP $wp ) {
if ( extension_loaded( 'newrelic' ) ) {
newrelic_name_transaction( $wp->matched_rule );
}
},
'accepted_args' => 1,
),
);
$wp_filter['rest_post_dispatch'][0] = array(
'newrelic' => array(
'function' => function( $result ) {
if ( extension_loaded( 'newrelic' ) ) {
newrelic_name_transaction( '/wp-json' . $result->get_matched_route() );
}
return $result;
},
'accepted_args' => 1,
),
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment