Skip to content

Commit

Permalink
Merge pull request #2980 from DataDog/zach.montoya/config-error-statu…
Browse files Browse the repository at this point in the history
…ses/apmapi-349

[Tracing] Add feature/scenarios for tracing configuration consistency and implement tests for DD_TRACE_HTTP_SERVER_ERROR_STATUSES
  • Loading branch information
zacharycmontoya committed Sep 10, 2024
2 parents a7570cd + c8165d8 commit cff748e
Show file tree
Hide file tree
Showing 14 changed files with 132 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/run-end-to-end.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ jobs:
run: ./run.sh LIBRARY_CONF_CUSTOM_HEADER_TAGS_INVALID
env:
DD_API_KEY: ${{ secrets.DD_API_KEY }}
- name: Run TRACING_CONFIG_NONDEFAULT scenario
if: always() && steps.build.outcome == 'success' && contains(inputs.scenarios, '"TRACING_CONFIG_NONDEFAULT"')
run: ./run.sh TRACING_CONFIG_NONDEFAULT
env:
DD_API_KEY: ${{ secrets.DD_API_KEY }}
- name: Run REMOTE_CONFIG_MOCKED_BACKEND_ASM_FEATURES scenario
if: always() && steps.build.outcome == 'success' && contains(inputs.scenarios, '"REMOTE_CONFIG_MOCKED_BACKEND_ASM_FEATURES"')
run: ./run.sh REMOTE_CONFIG_MOCKED_BACKEND_ASM_FEATURES
Expand Down
10 changes: 10 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@
"justMyCode": true,
"python": "${workspaceFolder}/venv/bin/python"
},
{
"name": "Run TRACING_CONFIG_NONDEFAULT scenario",
"type": "python",
"request": "launch",
"module": "pytest",
"args": ["-S", "TRACING_CONFIG_NONDEFAULT", "-p", "no:warnings"],
"console": "integratedTerminal",
"justMyCode": true,
"python": "${workspaceFolder}/venv/bin/python"
},
{
"name": "Run PROFILING scenario",
"type": "python",
Expand Down
3 changes: 3 additions & 0 deletions manifests/cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ tests/:
stats/:
test_miscs.py:
Test_Miscs: missing_feature
test_config_consistency.py:
Test_Config_HttpServerErrorStatuses_Default: missing_feature
Test_Config_HttpServerErrorStatuses_FeatureFlagCustom: missing_feature
test_distributed.py:
Test_DistributedHttp: missing_feature
test_identify.py: irrelevant
Expand Down
3 changes: 3 additions & 0 deletions manifests/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,9 @@ tests/:
Test_RemoteConfigurationUpdateSequenceFeaturesNoCache: irrelevant (cache is implemented)
Test_RemoteConfigurationUpdateSequenceLiveDebugging: v2.15.0
Test_RemoteConfigurationUpdateSequenceLiveDebuggingNoCache: irrelevant (cache is implemented)
test_config_consistency.py:
Test_Config_HttpServerErrorStatuses_Default: missing_feature
Test_Config_HttpServerErrorStatuses_FeatureFlagCustom: missing_feature
test_data_integrity.py:
Test_LibraryHeaders: v2.46.0
test_distributed.py:
Expand Down
3 changes: 3 additions & 0 deletions manifests/golang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,9 @@ tests/:
Test_RemoteConfigurationUpdateSequenceFeaturesNoCache: irrelevant (cache is implemented)
Test_RemoteConfigurationUpdateSequenceLiveDebugging: missing_feature
Test_RemoteConfigurationUpdateSequenceLiveDebuggingNoCache: irrelevant (cache is implemented)
test_config_consistency.py:
Test_Config_HttpServerErrorStatuses_Default: missing_feature
Test_Config_HttpServerErrorStatuses_FeatureFlagCustom: missing_feature
test_data_integrity.py:
Test_LibraryHeaders: v1.60.0.dev0
test_distributed.py:
Expand Down
3 changes: 3 additions & 0 deletions manifests/java.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1218,6 +1218,9 @@ tests/:
test_json_report.py:
Test_Mock: v0.0.99
Test_NotReleased: missing_feature
test_config_consistency.py:
Test_Config_HttpServerErrorStatuses_Default: missing_feature
Test_Config_HttpServerErrorStatuses_FeatureFlagCustom: missing_feature
test_data_integrity.py:
Test_LibraryHeaders: v1.29.0
test_distributed.py:
Expand Down
3 changes: 3 additions & 0 deletions manifests/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,9 @@ tests/:
Test_RemoteConfigurationUpdateSequenceFeaturesNoCache: irrelevant (cache is implemented)
Test_RemoteConfigurationUpdateSequenceLiveDebugging: *ref_5_16_0 #actual version unknown
Test_RemoteConfigurationUpdateSequenceLiveDebuggingNoCache: irrelevant (cache is implemented)
test_config_consistency.py:
Test_Config_HttpServerErrorStatuses_Default: missing_feature
Test_Config_HttpServerErrorStatuses_FeatureFlagCustom: missing_feature
test_distributed.py:
Test_DistributedHttp: missing_feature
test_identify.py:
Expand Down
3 changes: 3 additions & 0 deletions manifests/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,9 @@ tests/:
stats/:
test_miscs.py:
Test_Miscs: missing_feature
test_config_consistency.py:
Test_Config_HttpServerErrorStatuses_Default: missing_feature
Test_Config_HttpServerErrorStatuses_FeatureFlagCustom: missing_feature
test_distributed.py:
Test_DistributedHttp: missing_feature
test_identify.py:
Expand Down
3 changes: 3 additions & 0 deletions manifests/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,9 @@ tests/:
Test_RemoteConfigurationUpdateSequenceFeaturesNoCache: irrelevant (cache is implemented)
Test_RemoteConfigurationUpdateSequenceLiveDebugging: v2.8.0.dev
Test_RemoteConfigurationUpdateSequenceLiveDebuggingNoCache: missing_feature
test_config_consistency.py:
Test_Config_HttpServerErrorStatuses_Default: missing_feature
Test_Config_HttpServerErrorStatuses_FeatureFlagCustom: missing_feature
test_data_integrity.py:
Test_LibraryHeaders: v2.7.0
test_distributed.py:
Expand Down
3 changes: 3 additions & 0 deletions manifests/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,9 @@ tests/:
stats/:
test_miscs.py:
Test_Miscs: missing_feature
test_config_consistency.py:
Test_Config_HttpServerErrorStatuses_Default: missing_feature
Test_Config_HttpServerErrorStatuses_FeatureFlagCustom: missing_feature
test_distributed.py:
Test_DistributedHttp: missing_feature
test_identify.py:
Expand Down
6 changes: 6 additions & 0 deletions scenario_groups.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ TELEMETRY_SCENARIOS: &telemetry_scenarios
- TELEMETRY_METRIC_GENERATION_DISABLED
- TELEMETRY_METRIC_GENERATION_ENABLED

# Scenarios covering tracing configurations
TRACING_CONFIG_SCENARIOS: &tracing_config_scenarios
- TRACING_CONFIG_NONDEFAULT

# Scenarios to run before a tracer release, basically, all stable scenarios
TRACER_RELEASE_SCENARIOS:
- DEFAULT
Expand All @@ -48,6 +52,7 @@ TRACER_RELEASE_SCENARIOS:
- *appsec_scenarios
- *remote_config_scenarios
- *telemetry_scenarios
- *tracing_config_scenarios

# Scenarios to run on tracers PR.
# Those scenarios are the one that offer the best probability-to-catch-bug/time-to-run ratio
Expand All @@ -57,6 +62,7 @@ TRACER_ESSENTIAL_SCENARIOS:
- APPSEC_API_SECURITY_RC
- REMOTE_CONFIG_MOCKED_BACKEND_ASM_FEATURES
- INTEGRATIONS
- *tracing_config_scenarios

# Scenarios that rely on backend (and thus, may be a little bit hard to avoid flakyness)
APM_TRACING_E2E_SCENARIOS:
Expand Down
73 changes: 73 additions & 0 deletions tests/test_config_consistency.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Unless explicitly stated otherwise all files in this repository are licensed under the the Apache License Version 2.0.
# This product includes software developed at Datadog (https://www.datadoghq.com/).
# Copyright 2022 Datadog, Inc.

from utils import weblog, interfaces, scenarios, features


@scenarios.default
@features.tracing_configuration_consistency
class Test_Config_HttpServerErrorStatuses_Default:
""" Verify behavior of http clients and distributed traces """

def setup_status_code_400(self):
self.r = weblog.get("/status?code=400")

def test_status_code_400(self):

assert self.r.status_code == 400

interfaces.library.assert_trace_exists(self.r)
spans = interfaces.agent.get_spans_list(self.r)
assert len(spans) == 1, "Agent received the incorrect amount of spans"

assert spans[0]["type"] == "web"
assert spans[0]["meta"]["http.status_code"] == "400"
assert "error" not in spans[0] or spans[0]["error"] == 0

def setup_status_code_500(self):
self.r = weblog.get("/status?code=500")

def test_status_code_500(self):
assert self.r.status_code == 500

interfaces.library.assert_trace_exists(self.r)
spans = interfaces.agent.get_spans_list(self.r)
assert len(spans) == 1, "Agent received the incorrect amount of spans"

assert spans[0]["meta"]["http.status_code"] == "500"
assert spans[0]["error"] == 1


@scenarios.tracing_config_nondefault
@features.tracing_configuration_consistency
class Test_Config_HttpServerErrorStatuses_FeatureFlagCustom:
""" Verify behavior of http clients and distributed traces """

def setup_status_code_200(self):
self.r = weblog.get("/status?code=200")

def test_status_code_200(self):
assert self.r.status_code == 200

interfaces.library.assert_trace_exists(self.r)
spans = interfaces.agent.get_spans_list(self.r)
assert len(spans) == 1, "Agent received the incorrect amount of spans"

assert spans[0]["type"] == "web"
assert spans[0]["meta"]["http.status_code"] == "200"
assert spans[0]["error"] == 1

def setup_status_code_202(self):
self.r = weblog.get("/status?code=202")

def test_status_code_202(self):
assert self.r.status_code == 202

interfaces.library.assert_trace_exists(self.r)
spans = interfaces.agent.get_spans_list(self.r)
assert len(spans) == 1, "Agent received the incorrect amount of spans"

assert spans[0]["type"] == "web"
assert spans[0]["meta"]["http.status_code"] == "202"
assert spans[0]["error"] == 1
4 changes: 4 additions & 0 deletions utils/_context/_scenarios/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,10 @@ def all_endtoend_scenarios(test_object):
doc="Scenario with custom headers for DD_TRACE_HEADER_TAGS that libraries should reject",
)

tracing_config_nondefault = EndToEndScenario(
"TRACING_CONFIG_NONDEFAULT", weblog_env={"DD_TRACE_HTTP_SERVER_ERROR_STATUSES": "200-201,202"}, doc="",
)

parametric = ParametricScenario("PARAMETRIC", doc="WIP")

debugger_probes_status = EndToEndScenario(
Expand Down
10 changes: 10 additions & 0 deletions utils/_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -2356,3 +2356,13 @@ def iast_source_path_parameter(test_object):
"""
pytest.mark.features(feature_id=324)(test_object)
return test_object

@staticmethod
def tracing_configuration_consistency(test_object):
"""
Enforces standardized behaviors for configurations across the tracing libraries.
https://feature-parity.us1.prod.dog/#/?feature=325
"""
pytest.mark.features(feature_id=325)(test_object)
return test_object

0 comments on commit cff748e

Please sign in to comment.