You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
given the plugin enqueues flamegraph.js using plugin_dir_url i'm confused as to how loading the plugin via composer in the vendor directory would ever fully work?
I ended up proxying those requests in my mu-plugin to save having to manually copy flamegraph.js into the plugins dir - crude - but it works :)
<?php
/**
* Plugin Name: Load AWS X-Ray
* Plugin URI: SNIP
* Description: An autoloader that enables AWS X-Ray tracing for WordPress.
* Version: 1.0.3
* Author: Colm Troy
* Author URI: https://www.commercegurus.com
* License: GPLv2
*/
$has_profiler = class_exists( 'ExcimerProfiler' ) || function_exists( 'xhprof_sample_enable' );
if ( $has_profiler ) {
$base_path = realpath( __DIR__ . '/../../../vendor/humanmade/aws-xray' );
if ( ! $base_path ) {
error_log( 'AWS X-Ray base path not found. Expected path: ' . __DIR__ . '/../../../vendor/humanmade/aws-xray' );
return;
}
$namespace_file = $base_path . '/inc/namespace.php';
$plugin_file = $base_path . '/plugin.php';
if ( file_exists( $namespace_file ) ) {
require_once $namespace_file;
} else {
error_log( 'Namespace file does not exist' );
return;
}
if ( file_exists( $plugin_file ) ) {
require_once $plugin_file;
} else {
error_log( 'Plugin file does not exist' );
return;
}
if ( function_exists( '\HM\Platform\XRay\bootstrap' ) ) {
\HM\Platform\XRay\bootstrap();
} else {
error_log( 'AWS X-Ray bootstrap function not found' );
}
if ( function_exists( '\HM\Platform\XRay\Query_Monitor\bootstrap' ) ) {
\HM\Platform\XRay\Query_Monitor\bootstrap();
} else {
error_log( 'AWS X-Ray Query Monitor bootstrap function not found' );
}
// Serve flamegraph.js file
add_action(
'init',
function () use ( $base_path ) {
if ( isset( $_GET['aws_xray_flamegraph'] ) ) {
$flamegraph_path = $base_path . '/assets/flamegraph.js';
if ( file_exists( $flamegraph_path ) ) {
header( 'Content-Type: application/javascript' );
readfile( $flamegraph_path );
exit;
}
}
}
);
// Enqueue the flamegraph.js file
add_action(
'wp_enqueue_scripts',
function () {
wp_enqueue_script(
'aws-xray-flamegraph',
add_query_arg( 'aws_xray_flamegraph', '1', home_url( '/' ) ),
array(),
'1.0.3',
true
);
}
);
// Enqueue for admin pages as well
add_action(
'admin_enqueue_scripts',
function () {
wp_enqueue_script(
'aws-xray-flamegraph',
add_query_arg( 'aws_xray_flamegraph', '1', home_url( '/' ) ),
array(),
'1.0.3',
true
);
}
);
}
So I guess my main question is, is there a proper install guide for this plugin? I'm sure I probably didn't need to jump through the hoops above to get this up and running.
Thanks.
The text was updated successfully, but these errors were encountered:
The other thing to note is that we also serve static assets directly from the /vendor folder with nginx. So the flamegraph.js works from there without needing to jump through any hoops.
Howdy folks,
I really enjoyed your recent video!
I struggled to get this plugin up and running in my local dev environment and have a few questions.
Here are the steps I took to get things up and running. My WP directory structure is based on Bedrock
composer require humanmade/aws-xray
which adds the plugin to/vendor/humanmade/aws-xray
A few things of note below.
plugin_dir_url
i'm confused as to how loading the plugin via composer in the vendor directory would ever fully work?I ended up proxying those requests in my mu-plugin to save having to manually copy flamegraph.js into the plugins dir - crude - but it works :)
So I guess my main question is, is there a proper install guide for this plugin? I'm sure I probably didn't need to jump through the hoops above to get this up and running.
Thanks.
The text was updated successfully, but these errors were encountered: