bugout-dev / humbug

Get usage metrics and crash reports for your API, library, or command line tool.
Apache License 2.0
38 stars 6 forks source link

Support of blacklisted keys for feature reports #95

Closed kompotkot closed 1 year ago

kompotkot commented 1 year ago

Changes

During reporter creation specify list of blacklisted_keys like:

humbug_reporter = HumbugReporter(
    ...
    blacklisted_keys=["token", "created_at"]
)

After it all @humbug_reporter.record_call automatically remove blacklisted keys from arguments.

Also, if blacklisted keys required in report, it could be set manually to ignore blacklist with humbug_reporter.feature_report(..., blacklist_apply=False)

How to test these changes?

Added test cases and tested locally with API.

Related issues

istranic commented 1 year ago

Hey @zomglings Not sure if this is already in the PR, but it would be nice to make the key comparison case-insensitive, and also make it so any key contains the "token" substring is excluded.

zomglings commented 1 year ago

For example, this is what @istranic 's blacklist_fn would look like:

def activeloop_parameter_blacklist_fn(parameters: Dict[str, Any]) -> Dict[str, Any]:
    return {k:v for k, v in paramters.items() if "token" in k.lower()}

He could instantiate reporter as:

ActiveloopReporter = HumbugReporter(..., blacklist_fn=activeloop_parameters_blacklist_fn)
zomglings commented 1 year ago

@kompotkot : Suggest some changes: https://github.com/bugout-dev/humbug/pull/96