hussein-awala commented on code in PR #36250:
URL: https://github.com/apache/airflow/pull/36250#discussion_r1451021416


##########
airflow/config_templates/config.yml:
##########
@@ -944,6 +944,14 @@ metrics:
   description: |
     StatsD (https://github.com/etsy/statsd) integration settings.
   options:
+    metrics_use_pattern_match:
+      description: |
+        If true, metrics_allow_list and metrics_block_list will use regex 
pattern matching
+        anywhere within the metric name instead of only prefix matching at the 
start of the name.
+      version_added: 2.7.4

Review Comment:
   Since it's a new feature, we need to wait for the next minor release:
   ```suggestion
         version_added: 2.9.0
   ```



##########
airflow/metrics/validators.py:
##########
@@ -85,6 +85,42 @@ class MetricNameLengthExemptionWarning(Warning):
 BACK_COMPAT_METRIC_NAMES: set[Pattern[str]] = {re2.compile(name) for name in 
BACK_COMPAT_METRIC_NAME_PATTERNS}
 
 OTEL_NAME_MAX_LENGTH = 63
+DEFAULT_VALIDATOR_TYPE = "allow"
+
+
+def get_validator() -> ListValidator:
+    validators = {
+        "basic": {"allow": AllowListValidator, "block": BlockListValidator},
+        "pattern": {"allow": PatternAllowListValidator, "block": 
PatternBlockListValidator},
+    }
+    metric_lists = {
+        "allow": (metric_allow_list := conf.get("metrics", 
"metrics_allow_list", fallback=None)),
+        "block": (metric_block_list := conf.get("metrics", 
"metrics_block_list", fallback=None)),
+    }
+
+    use_pattern = conf.getboolean("metrics", "metrics_use_pattern_match", 
fallback=False)
+    validator_type = "pattern" if use_pattern else "basic"
+
+    if not use_pattern:
+        warnings.warn(
+            "The basic metric validator will be deprecated in the future in 
favor of pattern-matching.  "
+            "You can try this now by setting config option 
metrics_use_pattern_match to True.",
+            AirflowProviderDeprecationWarning,

Review Comment:
   This is a part of Airflow core, you cannot use 
`AirflowProviderDeprecationWarning` warning:
   ```suggestion
               RemovedInAirflow3Warning,
   ```



-- 
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]

Reply via email to