amoghrajesh commented on code in PR #56187:
URL: https://github.com/apache/airflow/pull/56187#discussion_r2587813959
##########
pyproject.toml:
##########
@@ -93,9 +93,6 @@ packages = []
"all-task-sdk" = [
"apache-airflow-task-sdk[all]"
]
-"sentry" = [
- "apache-airflow-task-sdk[sentry]"
-]
Review Comment:
Why this change?
##########
airflow-core/tests/unit/observability/metrics/test_stats.py:
##########
@@ -169,11 +176,37 @@ def
test_load_allow_and_block_list_validator_loads_only_allow_list_validator(sel
("metrics", "metrics_block_list"): "name1,name2",
}
):
- importlib.reload(airflow.stats)
- assert type(airflow.stats.Stats.metrics_validator) is
PatternAllowListValidator
- assert airflow.stats.Stats.metrics_validator.validate_list ==
("name1", "name2")
+ importlib.reload(airflow.observability.stats)
+ assert type(airflow.observability.stats.Stats.metrics_validator)
is PatternAllowListValidator
+ assert
airflow.observability.stats.Stats.metrics_validator.validate_list == (
+ "name1",
+ "name2",
+ )
# Avoid side-effects
- importlib.reload(airflow.stats)
+ importlib.reload(airflow.observability.stats)
+
+ def test_deprecation_warning_for_old_path(self):
+ # TODO: remove this test once the deprecation warning is removed.
+ import warnings
+
+ from airflow.observability.stats import Stats
+ from airflow.utils.deprecation_tools import DeprecatedImportWarning
+
+ # Clear any cached value.
+ airflow.__dict__.pop("Stats", None)
+
+ # Old path should warn.
+ warning_pattern = "Import 'Stats' directly from the airflow module is
deprecated"
+ with pytest.warns(DeprecatedImportWarning, match=warning_pattern):
+ assert getattr(airflow, "Stats") is Stats
+
+ # Clear cache again.
+ airflow.__dict__.pop("Stats", None)
+
+ # There shouldn't be a warning.
+ with warnings.catch_warnings():
+ warnings.simplefilter("error", DeprecatedImportWarning)
+ assert getattr(airflow.observability.stats, "Stats") is Stats
Review Comment:
Not needed, let's remove it.
There is no real value in testing something that is going away :)
##########
shared/observability/pyproject.toml:
##########
@@ -0,0 +1,65 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+[project]
+name = "apache-airflow-shared-observability"
+description = "Shared observability code for Airflow distributions"
+version = "0.0"
+classifiers = [
+ "Private :: Do Not Upload",
+]
+
+dependencies = [
+ "pendulum>=3.1.0",
+ "structlog>=25.4.0",
+]
+
+[project.optional-dependencies]
+"otel" = [
+ "opentelemetry-api>=1.27.0",
+ "opentelemetry-exporter-otlp>=1.27.0",
+ "opentelemetry-proto<9999,>=1.27.0",
+]
+"statsd" = [
+ "statsd>=3.3.0",
+]
+"datadog" = [
+ "datadog>=0.50.0",
+]
+"all" = ["apache-airflow-shared-observability[otel,statsd,datadog]"]
+
+[dependency-groups]
+dev = [
+ "apache-airflow-devel-common",
+ "apache-airflow-shared-configuration",
Review Comment:
We don't need this?
##########
airflow-core/src/airflow/__init__.py:
##########
@@ -89,6 +89,7 @@
# Deprecated lazy imports
"AirflowException": (".exceptions", "AirflowException", True),
"Dataset": (".sdk", "Asset", True),
+ "Stats": (".observability.stats", "Stats", True),
Review Comment:
Metrics is not really needed, but let's add it for safety I'd say.
##########
airflow-core/pyproject.toml:
##########
@@ -187,7 +187,7 @@ dependencies = [
"statsd>=3.3.0",
]
"all" = [
- "apache-airflow-core[graphviz,kerberos,otel,statsd]"
+ "apache-airflow-core[async,graphviz,kerberos,memray,otel,statsd]"
Review Comment:
This change is unrelated? Why do we need it?
##########
task-sdk/pyproject.toml:
##########
@@ -83,7 +83,18 @@ dependencies = [
"sentry" = [
"sentry-sdk>=2.30.0",
]
-"all" = ["apache-airflow-task-sdk[sentry]"]
+"otel" = [
+ "opentelemetry-api>=1.27.0",
+ "opentelemetry-exporter-otlp>=1.27.0",
+ "opentelemetry-proto<9999,>=1.27.0",
+]
+"statsd" = [
+ "statsd>=3.3.0",
+]
+"datadog" = [
+ "datadog>=0.50.0",
+]
+"all" = ["apache-airflow-task-sdk[sentry,otel,statsd,datadog]"]
Review Comment:
Looks ok
--
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]