ArshiaZr commented on PR #43340: URL: https://github.com/apache/airflow/pull/43340#issuecomment-2453283898
## Rationale for Using Decorators Instead of Inheritance with Datadog Using `get_name` with the Datadog protocol is unnecessary since we don’t combine tags and the stat name when calling `DogStatsd` functions. The functions in `DogStatsd` (e.g., `increment`, `decrement`, `gauge`, `timing`) expect the metric name and tags separately, so there’s no need to modify or combine them beforehand. Even if tags need to be prepared, we already apply the `@prepare_metric_name_with_tags` decorator before `get_name`, which impacts only the values passed to `get_name` and not the final metric name used in `DogStatsd` calls. Therefore, making `SafeDogStatsdLogger` a subclass of `StatsLogger` doesn’t add any functional value here. Instead, adding `@prepare_metric_name_with_tags` to each function in `SafeDogStatsdLogger` keeps the code organized and consistent without requiring inheritance specifically for Datadog. This approach provides clarity while keeping `SafeDogStatsdLogger` focused solely on Datadog-specific logic. Additionally, I added the `@prepare_stat_with_tags` decorator for a more consistent way of validating tags, allowing for cleaner code by centralizing tag preparation and validation across all metric functions. @ashb @ferruzzi if you have any other suggestions just let me know -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
