villebro commented on a change in pull request #9519: [dashboard] New, add statsd incr to the API URL: https://github.com/apache/incubator-superset/pull/9519#discussion_r408724392
########## File path: superset/views/base_api.py ########## @@ -33,6 +36,21 @@ } +def statsd_metrics(f): + """ + Handle sending all statsd metrics from the REST API + """ + + def wraps(self, *args: Any, **kwargs: Any) -> Response: + start = default_timer() + response = f(self, *args, **kwargs) + stop = default_timer() + self.send_stats_metrics(response, f.__name__, stop - start) Review comment: This `start`+`stop` block with `stop - start` is repeated four times in this PR. This might be overkill, but for DRYness sake we might want to create a timing decorator that returns the duration and response from the function call. I'm sure there are other places in the codebase where we could leverage it, too. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
