This is an automated email from the ASF dual-hosted git repository.

jason810496 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 5df209d1835 Isolate otel config-priority test from ambient OTEL env 
vars (#75842)
5df209d1835 is described below

commit 5df209d1835a3dd9a14e6b08c07e1b36740beee4
Author: Rahul Vats <[email protected]>
AuthorDate: Wed Oct 28 12:59:28 2026 +0530

    Isolate otel config-priority test from ambient OTEL env vars (#75842)
    
    * Isolate otel config-priority test from ambient OTEL env vars
    
    test_config_priorities asserts that the Airflow config host/port is used
    when a case provides no OTEL endpoint env var. It applied only the case's
    provided_env_vars on top of the ambient environment, so any OTEL_* var
    already exported by the runner leaked in. RunsOn CI runners export
    OTEL_EXPORTER_OTLP_ENDPOINT (resolving to 127.0.0.1:4318), which wins over
    the Airflow config and failed the six config-priority cases on both main
    and the release branches.
    
    Clear all OTEL_* env vars before applying provided_env_vars so the test
    only sees its own inputs regardless of the runner environment.
    
    * Move OTEL_* clearing into a class-scoped autouse fixture
    
    Per review: clear ambient OTEL_* vars for every test in TestOtelMetrics
    rather than only test_config_priorities.
---
 .../tests/observability/metrics/test_otel_logger.py              | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git 
a/shared/observability/tests/observability/metrics/test_otel_logger.py 
b/shared/observability/tests/observability/metrics/test_otel_logger.py
index cc821771372..9e5e3bc9fa3 100644
--- a/shared/observability/tests/observability/metrics/test_otel_logger.py
+++ b/shared/observability/tests/observability/metrics/test_otel_logger.py
@@ -88,6 +88,15 @@ def reset_meter_provider():
 
 
 class TestOtelMetrics:
+    @pytest.fixture(autouse=True)
+    def _clear_otel_env(self, monkeypatch):
+        # CI runners (e.g. RunsOn) export OTEL_EXPORTER_OTLP_ENDPOINT, which 
otherwise wins
+        # over the Airflow config host/port and leaks into the config-priority 
assertions.
+        # Clear all OTEL_* vars so each test only sees the env it sets itself.
+        for name in list(os.environ):
+            if name.startswith("OTEL_"):
+                monkeypatch.delenv(name, raising=False)
+
     def setup_method(self):
         self.meter = mock.Mock(MeterProvider)
         self.stats = SafeOtelLogger(otel_provider=self.meter)

Reply via email to