Skip to content
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

Adding weblog tests for TRACE_CLIENT_IP_ENABLED Configuration #3657

Merged
merged 8 commits into from
Dec 13, 2024
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
1 change: 1 addition & 0 deletions manifests/cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ tests/:
test_stats.py:
Test_Client_Stats: missing_feature
test_config_consistency.py:
Test_Config_ClientIPHeaderEnabled_False: v0.2.2
Test_Config_ClientIPHeader_Configured: missing_feature (DD_TRACE_CLIENT_IP_HEADER not implemented)
Test_Config_ClientIPHeader_Precedence: missing_feature (http.client_ip is not supported)
Test_Config_ClientTagQueryString_Configured: missing_feature
Expand Down
1 change: 1 addition & 0 deletions manifests/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,7 @@ tests/:
test_miscs.py:
Test_Miscs: missing_feature
test_config_consistency.py:
Test_Config_ClientIPHeaderEnabled_False: v3.6.1
Test_Config_ClientIPHeader_Configured: v3.4.1
Test_Config_ClientIPHeader_Precedence: v3.4.1
Test_Config_ClientTagQueryString_Configured: missing_feature (configuration DNE)
Expand Down
1 change: 1 addition & 0 deletions manifests/golang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,7 @@ tests/:
Test_MultipartUpload: missing_feature
Test_PutObject: missing_feature
test_config_consistency.py:
Test_Config_ClientIPHeaderEnabled_False: v1.70.1
Test_Config_ClientIPHeader_Configured: v1.60.0
Test_Config_ClientIPHeader_Precedence: v1.69.0
Test_Config_ClientTagQueryString_Configured: missing_feature (supports DD_TRACE_HTTP_URL_QUERY_STRING_DISABLED)
Expand Down
1 change: 1 addition & 0 deletions manifests/java.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1529,6 +1529,7 @@ tests/:
Test_Mock: v0.0.99
Test_NotReleased: missing_feature
test_config_consistency.py:
Test_Config_ClientIPHeaderEnabled_False: v1.43.0
Test_Config_ClientIPHeader_Configured: missing_feature
Test_Config_ClientIPHeader_Precedence: missing_feature (does not support x-forwarded header)
Test_Config_ClientTagQueryString_Configured:
Expand Down
1 change: 1 addition & 0 deletions manifests/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,7 @@ tests/:
test_stats.py:
Test_Client_Stats: missing_feature
test_config_consistency.py:
Test_Config_ClientIPHeaderEnabled_False: *ref_5_27_0
Test_Config_ClientIPHeader_Configured: *ref_3_13_0
Test_Config_ClientIPHeader_Precedence: *ref_3_19_0
Test_Config_ClientTagQueryString_Configured: missing_feature (adding query string to http.url is not supported)
Expand Down
1 change: 1 addition & 0 deletions manifests/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ tests/:
test_stats.py:
Test_Client_Stats: missing_feature
test_config_consistency.py:
Test_Config_ClientIPHeaderEnabled_False: v1.5.1
Test_Config_ClientIPHeader_Configured: v1.4.0
Test_Config_ClientIPHeader_Precedence: v1.4.0
Test_Config_ClientTagQueryString_Configured: missing_feature (supports dd_trace_http_url_query_param_allowed instead)
Expand Down
1 change: 1 addition & 0 deletions manifests/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,7 @@ tests/:
test_miscs.py:
Test_Miscs: missing_feature
test_config_consistency.py:
Test_Config_ClientIPHeaderEnabled_False: v2.17.3
Test_Config_ClientIPHeader_Configured: v2.12.0
Test_Config_ClientIPHeader_Precedence: v2.12.0
Test_Config_ClientTagQueryString_Configured: v2.15.0
Expand Down
1 change: 1 addition & 0 deletions manifests/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@ tests/:
test_stats.py:
Test_Client_Stats: missing_feature
test_config_consistency.py:
Test_Config_ClientIPHeaderEnabled_False: v2.8.0
Test_Config_ClientIPHeader_Configured: v2.3.0
Test_Config_ClientIPHeader_Precedence: v2.3.0
Test_Config_ClientTagQueryString_Configured: missing_feature (does not support redacting query string via envar)
Expand Down
18 changes: 18 additions & 0 deletions tests/test_config_consistency.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,23 @@ def test_ip_headers_sent_in_one_request(self):
assert _get_span_by_tags(trace, expected_tags), f"Span with tags {expected_tags} not found in {trace}"


@scenarios.tracing_config_nondefault_3
@features.tracing_configuration_consistency
class Test_Config_ClientIPHeaderEnabled_False:
"""Verify headers containing ips are not tagged when by default, even with DD_TRACE_CLIENT_IP_HEADER=custom-ip-header"""

def setup_ip_headers_sent_in_one_request(self):
self.req = weblog.get(
"/make_distant_call", params={"url": "http://weblog:7777"}, headers={"custom-ip-header": "5.6.7.9"}
)

def test_ip_headers_sent_in_one_request(self):
spans = [span for _, _, span in interfaces.library.get_spans(self.req, full_trace=True)]
logger.info(spans)
expected_tags = {"http.client_ip": "5.6.7.9"}
assert _get_span_by_tags(spans, expected_tags) == {}


@scenarios.tracing_config_nondefault
@features.tracing_configuration_consistency
class Test_Config_ClientIPHeader_Precedence:
Expand Down Expand Up @@ -292,6 +309,7 @@ def _get_span_by_tags(spans, tags):

if k not in meta:
logger.debug(f"Span {span['span_id']} does not have tag {k}")
break
elif meta[k] != v:
logger.debug(f"Span {span['span_id']} has tag {k}={meta[k]} instead of {v}")
break
Expand Down
6 changes: 5 additions & 1 deletion utils/_context/_scenarios/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,11 @@ def all_endtoend_scenarios(test_object):
)
tracing_config_nondefault_3 = EndToEndScenario(
"TRACING_CONFIG_NONDEFAULT_3",
weblog_env={"DD_TRACE_HTTP_CLIENT_TAG_QUERY_STRING": "false"},
weblog_env={
"DD_TRACE_HTTP_CLIENT_TAG_QUERY_STRING": "false",
"DD_TRACE_CLIENT_IP_HEADER": "custom-ip-header",
},
appsec_enabled=False,
doc="",
scenario_groups=[ScenarioGroup.TRACING_CONFIG],
)
Expand Down
Loading