aws-xray icon indicating copy to clipboard operation
aws-xray copied to clipboard

Add support for setting redacted keys via global

Open roborourke opened this issue 2 years ago • 8 comments

This solves the issue of the filter not being available for the first trace sent which happens prior to WP bootstrapping.

Usage:

// In .config/load-early.php
$xray_redact_keys = [ '$_POST' => [ 'key1', 'key2' ] ];

Relates to #80

roborourke avatar May 10 '23 15:05 roborourke

If everything is sent so early in the request cycle, what's the use of the aws_xray.redact_metadata_keys filter anyway? If we're providing a filter to redact keys, it should work consistently. Could we remove $_POST and other superglobals from the initial trace, and only send them later when apply_filters is available?

kovshenin avatar May 12 '23 13:05 kovshenin

@kovshenin fair point, could remove it as part of this update? @joehoyle what was the goal with sending all the metadata with the early request too? Is it necessary?

roborourke avatar May 12 '23 13:05 roborourke

But if we're going to remove it as part of this update, then this update is no longer necessary :) We no longer need an additional way to influence the redacting if we can use the existing filter reliably. If we do, however, need these as part of the initial X-Ray dump, then I'm fine with the global approach.

kovshenin avatar May 14 '23 10:05 kovshenin

@kovshenin depends if we consider this a bug, if we do need the metadata in the initial trace and it's going to be backported then it should retain the filter too.

roborourke avatar May 16 '23 14:05 roborourke

The end trace can fail, so the idea is to send the data with the in_progress trace as a "get the data tracked as reliably as possible". I wonder if actually though we should look at just loading xray after the user's altis config has been loaded. I don't see much downside with doing that, as it's unlikely to impact request timing too much.

joehoyle avatar May 16 '23 14:05 joehoyle

I wonder if actually though we should look at just loading xray after the user's altis config has been loaded. I don't see much downside with doing that, as it's unlikely to impact request timing too much.

Presumably we're also starting the Excimer profile at that point though, so we'd miss flamegraph data for anything before that?

rmccue avatar May 16 '23 14:05 rmccue

Yes, though the "distance" between when we currently load it vs after the config is very small I think. Hence I think it's a small tradeoff

joehoyle avatar May 16 '23 14:05 joehoyle

Presumably we can do something a bit more nuanced though: start Excimer as soon as possible, but defer the first push of metadata until we've loaded those early bits.

rmccue avatar May 16 '23 14:05 rmccue