Skip to content
Draft
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: 5 additions & 0 deletions src/instana/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ def set_trace_configurations(self) -> None:
"trace_correlation", True
)

if "INSTANA_ASYNCIO_TASK_CONTEXT_PROPAGATION" in os.environ:
config["asyncio_task_context_propagation"]["enabled"] = is_truthy(
os.environ["INSTANA_ASYNCIO_TASK_CONTEXT_PROPAGATION"]
)

self.set_disable_trace_configurations()
self.set_stack_trace_configurations()
self.set_span_filter_configurations()
Expand Down
17 changes: 17 additions & 0 deletions tests/test_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,23 @@ def test_tracing_filter_environment_variables(self) -> None:
],
}

def test_asyncio_task_context_propagation_default(self) -> None:
"""INSTANA_ASYNCIO_TASK_CONTEXT_PROPAGATION is False by default."""
self.base_options = BaseOptions()
assert config["asyncio_task_context_propagation"]["enabled"] is False

@patch.dict(os.environ, {"INSTANA_ASYNCIO_TASK_CONTEXT_PROPAGATION": "true"})
def test_asyncio_task_context_propagation_enabled_via_env(self) -> None:
"""INSTANA_ASYNCIO_TASK_CONTEXT_PROPAGATION=true enables the flag."""
self.base_options = BaseOptions()
assert config["asyncio_task_context_propagation"]["enabled"] is True

@patch.dict(os.environ, {"INSTANA_ASYNCIO_TASK_CONTEXT_PROPAGATION": "false"})
def test_asyncio_task_context_propagation_disabled_via_env(self) -> None:
"""INSTANA_ASYNCIO_TASK_CONTEXT_PROPAGATION=false keeps the flag disabled."""
self.base_options = BaseOptions()
assert config["asyncio_task_context_propagation"]["enabled"] is False


class TestStandardOptions:
@pytest.fixture(autouse=True)
Expand Down
Loading