-
Notifications
You must be signed in to change notification settings - Fork 14
Test Stable Config support for extended configs #5357
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 26 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
0cb11db
Introduce extended_configs test with dd_tags
mtoffl01 35996f7
Correct placement of annotation
mtoffl01 6de8166
Enable test for dotnet, python; include test log msg for debugging
mtoffl01 84e7856
remove print; expose config inside the test assertion
mtoffl01 b6c40e3
Merge branch 'main' into mtoff/scfg-all-configs
mtoffl01 27874b7
Use propagation_style for another input
mtoffl01 f4b0908
Introduce telemetry test for extended_configs
mtoffl01 21a11bf
change dd_tags input to exclude brackets
mtoffl01 4fcb3dc
Change tags to not use brackets in telemetry test
mtoffl01 beaa171
run linter
mtoffl01 286a640
Modify expected tags value for dotnet
mtoffl01 51021f7
change tags value for php
mtoffl01 4c6ee6f
Make extended_config telemetry test more verbose on failure
mtoffl01 0b2f111
Merge branch 'main' into mtoff/scfg-all-configs
mtoffl01 a8751a2
Change telemetry order to use propagation_style for fleet override
mtoffl01 f3c9b99
map tags to DD_TAGS for dotnet telemetry
mtoffl01 e281615
map tags to DD_TAGS for python telemetry
mtoffl01 6401306
map propagation_style for python and dotnet
mtoffl01 3dabf60
swap python and dotnet for telemetry mapping - propagation style
mtoffl01 fc65384
Add entry for php telemetry mapping
mtoffl01 916e25d
Add entry for ruby telemetry mapping
mtoffl01 5ffdeb7
run liner
mtoffl01 2648b8f
Use inject and extract propagation style keys for python and ruby
mtoffl01 c37fcab
Split config test into 'default' and 'rules'
mtoffl01 f1759a6
mark telemetry test with bug for ruby
mtoffl01 f0b51e7
merge main/ resolve conflicts
mtoffl01 9e50750
Merge branch 'main' into mtoff/scfg-all-configs
mtoffl01 3041acd
Merge branch 'main' into mtoff/scfg-all-configs
mtoffl01 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,7 +9,7 @@ | |
|
|
||
| from .conftest import StableConfigWriter | ||
| from utils.telemetry_utils import TelemetryUtils | ||
| from utils import context, scenarios, rfc, features, missing_feature, irrelevant, logger | ||
| from utils import context, scenarios, rfc, features, missing_feature, irrelevant, logger, bug | ||
|
|
||
|
|
||
| telemetry_name_mapping = { | ||
|
|
@@ -82,6 +82,15 @@ | |
| "ruby": "DD_TRACE_DEBUG", | ||
| "python": "DD_TRACE_DEBUG", | ||
| }, | ||
| "tags": { | ||
| "java": "trace_tags", | ||
| "dotnet": "DD_TAGS", | ||
| "python": "DD_TAGS", | ||
| }, | ||
| "trace_propagation_style": { | ||
| "dotnet": "DD_TRACE_PROPAGATION_STYLE", | ||
| "php": "trace.propagation_style", | ||
| }, | ||
| } | ||
|
|
||
|
|
||
|
|
@@ -105,6 +114,48 @@ def _find_configuration_by_origin(config_list: list[dict], origin: str) -> dict | |
| return None | ||
|
|
||
|
|
||
| def _check_propagation_style_with_inject_and_extract( | ||
| test_agent, configuration_by_name: dict, expected_origin: str, library_name: str | ||
| ) -> None: | ||
| """Check both inject and extract propagation style keys for languages that report them separately. | ||
|
|
||
| Some libraries report propagation style using separate inject and extract keys | ||
| instead of a single combined key. This function validates that both keys exist with the | ||
| expected origin and have non-empty values. | ||
|
|
||
| Raises an AssertionError if either key is missing, has wrong origin, or has empty value | ||
| """ | ||
| # Define the inject and extract key names for each language | ||
| if library_name == "python": | ||
| inject_key = "DD_TRACE_PROPAGATION_STYLE_INJECT" | ||
| extract_key = "DD_TRACE_PROPAGATION_STYLE_EXTRACT" | ||
| elif library_name == "ruby": | ||
| inject_key = "tracing.propagation_style_inject" | ||
| extract_key = "tracing.propagation_style_extract" | ||
| else: | ||
| raise ValueError(f"Unsupported library for inject/extract propagation style: {library_name}") | ||
|
|
||
| # Check inject key | ||
| inject_item = test_agent.get_telemetry_config_by_origin(configuration_by_name, inject_key, expected_origin) | ||
| assert ( | ||
| inject_item is not None | ||
| ), f"No configuration found for '{inject_key}' with origin '{expected_origin}'. Full configuration_by_name: {configuration_by_name}" | ||
| assert ( | ||
| inject_item["origin"] == expected_origin | ||
| ), f"Origin mismatch for {inject_item}. Expected origin: '{expected_origin}', Actual origin: '{inject_item.get('origin', '<missing>')}'" | ||
| assert inject_item["value"], f"Expected non-empty value for '{inject_key}'" | ||
|
|
||
| # Check extract key | ||
| extract_item = test_agent.get_telemetry_config_by_origin(configuration_by_name, extract_key, expected_origin) | ||
| assert ( | ||
| extract_item is not None | ||
| ), f"No configuration found for '{extract_key}' with origin '{expected_origin}'. Full configuration_by_name: {configuration_by_name}" | ||
| assert ( | ||
| extract_item["origin"] == expected_origin | ||
| ), f"Origin mismatch for {extract_item}. Expected origin: '{expected_origin}', Actual origin: '{extract_item.get('origin', '<missing>')}'" | ||
| assert extract_item["value"], f"Expected non-empty value for '{extract_key}'" | ||
|
|
||
|
|
||
| @scenarios.parametric | ||
| @rfc("https://docs.google.com/document/d/1In4TfVBbKEztLzYg4g0si5H56uzAbYB3OfqzRGP2xhg/edit") | ||
| @features.telemetry_app_started_event | ||
|
|
@@ -690,6 +741,142 @@ def test_stable_configuration_config_id( | |
| assert telemetry_item["origin"] == "local_stable_config" | ||
| assert "config_id" not in telemetry_item or telemetry_item["config_id"] is None | ||
|
|
||
| @pytest.mark.parametrize( | ||
| ("local_cfg", "library_env", "fleet_cfg", "expected_origins"), | ||
| [ | ||
| ( | ||
| { | ||
| "DD_TRACE_PROPAGATION_STYLE": "tracecontext", | ||
| "DD_TAGS": "tag1:value1,tag2:value2", | ||
| }, | ||
| { | ||
| "DD_TELEMETRY_HEARTBEAT_INTERVAL": "0.1", # Decrease the heartbeat/poll intervals to speed up the tests | ||
| }, | ||
| { | ||
| "DD_TRACE_PROPAGATION_STYLE": "datadog", | ||
| }, | ||
| { | ||
| "tags": "local_stable_config", | ||
| "trace_propagation_style": "fleet_stable_config", | ||
| }, | ||
| ) | ||
| ], | ||
| ) | ||
| @missing_feature( | ||
| context.library in ["cpp", "golang", "nodejs"], | ||
| reason="extended configs are not supported", | ||
| ) | ||
| @bug(context.library == "python", reason="APMAPI-1630") | ||
| @bug(context.library == "ruby", reason="APMAPI-1631") | ||
| def test_stable_configuration_origin_extended_configs_good_use_case( | ||
| self, local_cfg, library_env, fleet_cfg, test_agent, test_library, expected_origins | ||
| ): | ||
| """Test that extended configuration options (tags, propagation style) report their origin correctly. | ||
|
|
||
| This test verifies that complex configuration values like tag arrays and propagation | ||
| styles are properly tracked with their configuration origin (local vs fleet stable config). | ||
| """ | ||
| with test_library: | ||
| self.write_stable_config( | ||
| { | ||
| "apm_configuration_default": local_cfg, | ||
| }, | ||
| "/etc/datadog-agent/application_monitoring.yaml", | ||
| test_library, | ||
| ) | ||
| self.write_stable_config( | ||
| { | ||
| "apm_configuration_default": fleet_cfg, | ||
| }, | ||
| "/etc/datadog-agent/managed/datadog-agent/stable/application_monitoring.yaml", | ||
| test_library, | ||
| ) | ||
| # Sleep between telemetry events to ensure they are recorded with different timestamps, to later reorder them. | ||
| # seq_id can't be used to sort because payloads are sent from different tracer sessions. | ||
| time.sleep(1) | ||
| test_library.container_restart() | ||
| test_library.dd_start_span("test") | ||
| configuration_by_name = test_agent.wait_for_telemetry_configurations() | ||
| for cfg_name, expected_origin in expected_origins.items(): | ||
| apm_telemetry_name = _mapped_telemetry_name(context, cfg_name) | ||
| telemetry_item = test_agent.get_telemetry_config_by_origin( | ||
| configuration_by_name, apm_telemetry_name, expected_origin | ||
| ) | ||
| assert ( | ||
| telemetry_item is not None | ||
| ), f"No configuration found for '{apm_telemetry_name}' with origin '{expected_origin}'. Full configuration_by_name: {configuration_by_name}" | ||
|
|
||
| actual_origin = telemetry_item.get("origin", "<missing>") | ||
| assert ( | ||
| telemetry_item["origin"] == expected_origin | ||
| ), f"Origin mismatch for {telemetry_item}. Expected origin: '{expected_origin}', Actual origin: '{actual_origin}'" | ||
| assert telemetry_item["value"] | ||
|
|
||
| @pytest.mark.parametrize( | ||
| ("local_cfg", "library_env", "fleet_cfg", "expected_origins"), | ||
| [ | ||
| ( | ||
| { | ||
| "DD_TRACE_PROPAGATION_STYLE": "tracecontext", | ||
| "DD_TAGS": "tag1:value1,tag2:value2", | ||
| }, | ||
| { | ||
| "DD_TELEMETRY_HEARTBEAT_INTERVAL": "0.1", # Decrease the heartbeat/poll intervals to speed up the tests | ||
| }, | ||
| { | ||
| "DD_TRACE_PROPAGATION_STYLE": "datadog", | ||
| }, | ||
| { | ||
| "tags": "local_stable_config", | ||
| "trace_propagation_style": "fleet_stable_config", | ||
| }, | ||
| ) | ||
| ], | ||
| ) | ||
| @missing_feature( | ||
| context.library in ["cpp", "golang", "nodejs"], | ||
| reason="extended configs are not supported", | ||
| ) | ||
| @bug(context.library == "ruby", reason="APMAPI-1650") | ||
| @irrelevant(context.library in ["java", "php", "dotnet"], reason="temporary use case for python and ruby") | ||
| def test_stable_configuration_origin_extended_configs_temporary_use_case( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll ask the reason why we don't report the tags and why we report the extract/inject config instead of the main one when only the main one is set |
||
| self, local_cfg, library_env, fleet_cfg, test_agent, test_library, expected_origins | ||
| ): | ||
| """Test that extended configuration options (tags, propagation style) report their origin correctly. | ||
|
|
||
| This test verifies that complex configuration values like tag arrays and propagation | ||
| styles are properly tracked with their configuration origin (local vs fleet stable config). | ||
| """ | ||
| with test_library: | ||
| self.write_stable_config( | ||
| { | ||
| "apm_configuration_default": local_cfg, | ||
| }, | ||
| "/etc/datadog-agent/application_monitoring.yaml", | ||
| test_library, | ||
| ) | ||
| self.write_stable_config( | ||
| { | ||
| "apm_configuration_default": fleet_cfg, | ||
| }, | ||
| "/etc/datadog-agent/managed/datadog-agent/stable/application_monitoring.yaml", | ||
| test_library, | ||
| ) | ||
| # Sleep between telemetry events to ensure they are recorded with different timestamps, to later reorder them. | ||
| # seq_id can't be used to sort because payloads are sent from different tracer sessions. | ||
| time.sleep(1) | ||
| test_library.container_restart() | ||
| test_library.dd_start_span("test") | ||
| configuration_by_name = test_agent.wait_for_telemetry_configurations() | ||
| for cfg_name, expected_origin in expected_origins.items(): | ||
| # Python and Ruby only report inject and extract keys for trace_propagation_style | ||
| if cfg_name == "trace_propagation_style" and context.library.name in ["python", "ruby"]: | ||
| _check_propagation_style_with_inject_and_extract( | ||
| test_agent, configuration_by_name, expected_origin, context.library.name | ||
| ) | ||
| if cfg_name == "tags" and context.library.name in ["ruby"]: | ||
| continue | ||
|
|
||
|
|
||
| DEFAULT_ENVVARS = { | ||
| # Decrease the heartbeat/poll intervals to speed up the tests | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be removed once related ruby fix is merged (in progress)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DataDog/dd-trace-rb#4963 has been merged, this line can be removed (tested locally)