Skip to content

Commit

Permalink
Check if log2logstash is defined before calling it
Browse files Browse the repository at this point in the history
  • Loading branch information
luismulinari committed Oct 5, 2023
1 parent b115332 commit f75d518
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,23 @@ public function sql_query_log( $query ): void {
]
);

if ( ! function_exists( '\Automattic\VIP\Logstash\log2logstash' ) ) {
return;
}

$backtrace = function_exists( 'wp_debug_backtrace_summary' ) ? wp_debug_backtrace_summary( null, 4, false ) : []; // phpcs:ignore
\Automattic\VIP\Logstash\log2logstash(
[
'severity' => 'debug',
'feature' => 'potential_multi_dataset_queries',
'message' => 'Potential multi dataset query detected',
'blog_id' => get_current_blog_id(),
'extra' => [
'uri' => isset( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( $_SERVER['REQUEST_URI'] ) : '',
'http_method' => isset( $_SERVER['REQUEST_METHOD'] ) ? sanitize_text_field( $_SERVER['REQUEST_METHOD'] ) : '',
'backtrace' => $backtrace,
'uri' => isset( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( $_SERVER['REQUEST_URI'] ) : '',
'http_method' => isset( $_SERVER['REQUEST_METHOD'] ) ? sanitize_text_field( $_SERVER['REQUEST_METHOD'] ) : '',
'backtrace' => $backtrace,
'last_global_table' => $last_global_table,
'last_blog_table' => $last_blog_table,
'blog_ids_count' => $blog_ids_count,
],
]
);
Expand Down

0 comments on commit f75d518

Please sign in to comment.