Skip to content
Merged
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
5 changes: 2 additions & 3 deletions ddtrace/internal/native/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,15 @@
from ._native import store_metadata # noqa: F401


def get_configuration_from_disk(
debug_logs: bool = False,
) -> Tuple[Dict[str, str], Dict[str, str], Dict[str, Optional[str]]]:
def get_configuration_from_disk() -> Tuple[Dict[str, str], Dict[str, str], Dict[str, Optional[str]]]:
"""
Retrieves the tracer configuration from disk. Calls the PyConfigurator object
to read the configuration from the disk using the libdatadog shared library
and returns the corresponding configuration
See https://github.com/DataDog/libdatadog/blob/06d2b6a19d7ec9f41b3bfd4ddf521585c55298f6/library-config/src/lib.rs
for more information on how the configuration is read from disk
"""
debug_logs = os.getenv("DD_TRACE_DEBUG", "false").lower().strip() in ("true", "1")
configurator = PyConfigurator(debug_logs)

# Check if the file override is provided via environment variables
Expand Down
32 changes: 32 additions & 0 deletions tests/internal/test_native.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,38 @@ def test_get_configuration_from_disk_managed_stable_config_priority():
assert config.version == "c", f"Expected DD_VERSION to be 'c' but got {config.version}"


@pytest.mark.subprocess(parametrize={"DD_TRACE_DEBUG": ["TRUE", "1"]}, err=None)
def test_get_configuration_debug_logs():
"""
Verify stable config debug log enablement
"""
import os
import sys
import tempfile

from tests.utils import call_program

# Create managed config
with tempfile.NamedTemporaryFile(suffix=".yaml", prefix="managed_config") as managed_config:
managed_config.write(
b"""
apm_configuration_default:
DD_VERSION: "c"
"""
)
managed_config.flush()

env = os.environ.copy()
env["DD_TRACE_DEBUG"] = "true"
env["_DD_SC_MANAGED_FILE_OVERRIDE"] = managed_config.name

_, err, status, _ = call_program(sys.executable, "-c", "import ddtrace", env=env)
assert status == 0, err
assert b"Read the following static config: StableConfig" in err
assert b'ConfigMap([(DdVersion, "c")]), tags: {}, rules: [] }' in err
assert b"configurator: Configurator { debug_logs: true }" in err


@pytest.mark.subprocess(parametrize={"DD_VERSION": ["b", None]})
def test_get_configuration_from_disk_local_config_priority(tmp_path):
"""
Expand Down
Loading