From 211285d11249305550710c9bbf1477ca88f719e6 Mon Sep 17 00:00:00 2001 From: RapidPoseidon Date: Fri, 25 Sep 2026 04:10:18 +0000 Subject: [PATCH] fix(config): stop test runs exporting traces Constructing any LoggingConfig pushed its settings to the global tracer and logger, so a standalone LoggingConfig(enable_otlp=True) re-enabled OTLP for the whole process. Only the global rapidata_config.logging now notifies the handlers; the conftest resync from #913 stays as a test-side backstop. Co-Authored-By: Claude Opus 5.5 Co-Authored-By: luca@rapidata.ai <25279790+LucStr@users.noreply.github.com> --- src/rapidata/rapidata_client/config/logging_config.py | 4 ---- .../rapidata_client/config/rapidata_config.py | 2 ++ tests/conftest.py | 4 ++-- tests/rapidata_client/config/test_otlp_default.py | 11 +++++++++++ 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/rapidata/rapidata_client/config/logging_config.py b/src/rapidata/rapidata_client/config/logging_config.py index e092295b71..479bf1d574 100644 --- a/src/rapidata/rapidata_client/config/logging_config.py +++ b/src/rapidata/rapidata_client/config/logging_config.py @@ -72,10 +72,6 @@ def _apply_env_vars(cls, data: Any) -> Any: enable_otlp: bool = Field(default_factory=_default_enable_otlp) environment: str = Field(default="rapidata.ai") - def __init__(self, **kwargs): - super().__init__(**kwargs) - self._notify_handlers() - def __setattr__(self, name: str, value) -> None: super().__setattr__(name, value) # Sync enable_otlp to env var so child processes (e.g. Ray workers) inherit it diff --git a/src/rapidata/rapidata_client/config/rapidata_config.py b/src/rapidata/rapidata_client/config/rapidata_config.py index 499540eac8..8bc05e328c 100644 --- a/src/rapidata/rapidata_client/config/rapidata_config.py +++ b/src/rapidata/rapidata_client/config/rapidata_config.py @@ -42,3 +42,5 @@ def _apply_env_vars(cls, data: Any) -> Any: rapidata_config = RapidataConfig() +# Only the global config drives the shared logger/tracer; a standalone LoggingConfig must not. +rapidata_config.logging._notify_handlers() diff --git a/tests/conftest.py b/tests/conftest.py index 716a974cc2..7f43112674 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -56,6 +56,6 @@ def agent_sandbox(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> Path: @pytest.fixture(autouse=True) def _resync_tracer_to_global_config(): yield - # Constructing any LoggingConfig broadcasts to the global tracer, so a test that - # builds one with enable_otlp=True would re-enable export for every later test. + # Re-applies the global config so a test that pointed the shared tracer elsewhere + # cannot leave export enabled for the tests after it. rapidata_config.logging._notify_handlers() diff --git a/tests/rapidata_client/config/test_otlp_default.py b/tests/rapidata_client/config/test_otlp_default.py index b3a0d65cb8..fedcd1fa0c 100644 --- a/tests/rapidata_client/config/test_otlp_default.py +++ b/tests/rapidata_client/config/test_otlp_default.py @@ -10,6 +10,7 @@ import pytest +from rapidata.rapidata_client.config import tracer from rapidata.rapidata_client.config.logging_config import ( LoggingConfig, _default_enable_otlp, @@ -49,3 +50,13 @@ def test_explicit_true_overrides_the_pytest_default(monkeypatch: pytest.MonkeyPa monkeypatch.delenv("RAPIDATA_DISABLE_OTLP", raising=False) assert LoggingConfig(enable_otlp=True).enable_otlp is True + + +def test_standalone_config_does_not_enable_the_global_tracer( + monkeypatch: pytest.MonkeyPatch, +): + monkeypatch.delenv("RAPIDATA_DISABLE_OTLP", raising=False) + + LoggingConfig(enable_otlp=True) + + assert tracer._enabled is False