Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/rapidata/rapidata_client/config/logging_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/rapidata/rapidata_client/config/rapidata_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
11 changes: 11 additions & 0 deletions tests/rapidata_client/config/test_otlp_default.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Loading