Skip to content

Commit

Permalink
Do not include http data on CLI
Browse files Browse the repository at this point in the history
Fixes #72
  • Loading branch information
roborourke committed Jul 24, 2020
1 parent 557b9bc commit 5d26122
Showing 1 changed file with 23 additions and 14 deletions.
37 changes: 23 additions & 14 deletions inc/namespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -332,15 +332,20 @@ function get_in_progress_trace() : array {
'version' => defined( 'HM_DEPLOYMENT_REVISION' ) ? HM_DEPLOYMENT_REVISION : 'dev',
],
'origin' => 'AWS::EC2::Instance',
'http' => [
'in_progress' => true,
];

// Add HTTP data if this not a CLI request.
if ( php_sapi_name() !== 'cli' ) {
$trace['http'] = [
'request' => [
'method' => $_SERVER['REQUEST_METHOD'],
'url' => ( empty( $_SERVER['HTTPS'] ) ? 'http' : 'https' ) . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'],
'client_ip' => $_SERVER['REMOTE_ADDR'],
],
],
'in_progress' => true,
];
];
}

$metadata = [
'$_GET' => $_GET,
'$_POST' => $_POST,
Expand Down Expand Up @@ -383,16 +388,6 @@ function get_end_trace() : array {
'version' => defined( 'HM_DEPLOYMENT_REVISION' ) ? HM_DEPLOYMENT_REVISION : 'dev',
],
'origin' => 'AWS::EC2::Instance',
'http' => [
'request' => [
'method' => $_SERVER['REQUEST_METHOD'],
'url' => ( empty( $_SERVER['HTTPS'] ) ? 'http' : 'https' ) . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'],
'client_ip' => $_SERVER['REMOTE_ADDR'],
],
'response' => [
'status' => http_response_code(),
],
],
'fault' => $is_fatal,
'error' => $has_non_fatal_errors,
'cause' => $hm_platform_xray_errors ? [
Expand All @@ -414,6 +409,20 @@ function ( $error ) {
'in_progress' => false,
];

// Add HTTP data if this not a CLI request.
if ( php_sapi_name() !== 'cli' ) {
$trace['http'] = [
'request' => [
'method' => $_SERVER['REQUEST_METHOD'],
'url' => ( empty( $_SERVER['HTTPS'] ) ? 'http' : 'https' ) . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'],
'client_ip' => $_SERVER['REMOTE_ADDR'],
],
'response' => [
'status' => http_response_code(),
],
];
}

$metadata = [
'$_GET' => $_GET,
'$_POST' => $_POST,
Expand Down

0 comments on commit 5d26122

Please sign in to comment.