-
Notifications
You must be signed in to change notification settings - Fork 416
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
{"baseBranch":"main","baseCommit":"a664aab0a9d53e8dbb874d68933613de4cbecb1d","createdAt":"2024-11-21T13:37:42.446817Z","gitlabPipelineId":"49608212","headSha":"cc649bcf7f8fcdb0af4dc1ea756cb518dc80d0ca","id":"3a79c945-094b-4dca-bb41-dee25b810447","priority":"200","pullRequestNumber":"11478","queuedAt":"2024-11-22T11:03:16.085110Z","status":"STATUS_QUEUED","temporalExecutionRunId":"1d25c0cb-6e3e-4d11-9203-719c130128e5","temporalExecutionWorkflowId":"ea5769d3-80b5-4a91-9d26-1f34fb7406a0_38"}
- Loading branch information
Showing
3 changed files
with
135 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
6 changes: 6 additions & 0 deletions
6
releasenotes/notes/ci_visibility-get_agent_default_env-bf4a11283dccdf87.yaml
This file contains 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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
fixes: | ||
- | | ||
CI Visibility: fixes an issue where the CIVisbility service would incorrectly default the tracer env to ``None`` | ||
in EVP proxy mode if ``DD_ENV`` was not specified but the agent had a default environment set to a value other | ||
than ``none`` (eg: using ``DD_APM_ENV`` in the agent's environment). |
This file contains 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 |
---|---|---|
|
@@ -353,6 +353,8 @@ def test_civisibility_api_client_agentless_env_config_success(self, env_vars, ex | |
configurations["custom"] = _expected_config.pop("custom_configurations") | ||
if "dd_service" not in _expected_config: | ||
_expected_config["dd_service"] = "dd-test-py" | ||
if "dd_env" not in _expected_config: | ||
_expected_config["dd_env"] = "none" | ||
|
||
git_data = GitData("[email protected]:TestDog/dd-test-py.git", "notmainbranch", "mytestcommitsha1234") | ||
with _ci_override_env(_env_vars, full_clear=True), _patch_env_for_testing(): | ||
|
@@ -425,6 +427,7 @@ def test_civisibility_api_client_evp_proxy_config_success(self, env_vars, expect | |
configurations=configurations, | ||
git_data=git_data, | ||
agent_url="http://patchedagenturl:6218", | ||
dd_env="none", | ||
**_expected_config, | ||
) | ||
CIVisibility.enable() | ||
|
@@ -435,3 +438,106 @@ def test_civisibility_api_client_evp_proxy_config_success(self, env_vars, expect | |
assert CIVisibility._instance._api_client.__dict__ == expected_client.__dict__ | ||
finally: | ||
CIVisibility.disable() | ||
|
||
def test_civisibility_api_client_evp_respects_agent_default_config(self): | ||
"""Tests that, if no DD_ENV is provided in EVP mode, the agent's default env is used""" | ||
agent_info_response = json.loads( | ||
""" | ||
{ | ||
"version": "7.49.1", | ||
"git_commit": "1790cab", | ||
"endpoints": [ | ||
"/v0.3/traces", | ||
"/v0.3/services", | ||
"/v0.4/traces", | ||
"/v0.4/services", | ||
"/v0.5/traces", | ||
"/v0.7/traces", | ||
"/profiling/v1/input", | ||
"/telemetry/proxy/", | ||
"/v0.6/stats", | ||
"/v0.1/pipeline_stats", | ||
"/evp_proxy/v1/", | ||
"/evp_proxy/v2/", | ||
"/evp_proxy/v3/", | ||
"/debugger/v1/input", | ||
"/debugger/v1/diagnostics", | ||
"/symdb/v1/input", | ||
"/dogstatsd/v1/proxy", | ||
"/dogstatsd/v2/proxy", | ||
"/v0.7/config", | ||
"/config/set" | ||
], | ||
"client_drop_p0s": true, | ||
"span_meta_structs": true, | ||
"long_running_spans": true, | ||
"config": { | ||
"default_env": "not_the_default_default_env", | ||
"target_tps": 10, | ||
"max_eps": 200, | ||
"receiver_port": 8126, | ||
"receiver_socket": "", | ||
"connection_limit": 0, | ||
"receiver_timeout": 0, | ||
"max_request_bytes": 26214400, | ||
"statsd_port": 8125, | ||
"max_memory": 0, | ||
"max_cpu": 0, | ||
"analyzed_spans_by_service": {}, | ||
"obfuscation": { | ||
"elastic_search": true, | ||
"mongo": true, | ||
"sql_exec_plan": false, | ||
"sql_exec_plan_normalize": false, | ||
"http": { | ||
"remove_query_string": false, | ||
"remove_path_digits": false | ||
}, | ||
"remove_stack_traces": false, | ||
"redis": { | ||
"Enabled": true, | ||
"RemoveAllArgs": false | ||
}, | ||
"memcached": { | ||
"Enabled": true, | ||
"KeepCommand": false | ||
} | ||
} | ||
} | ||
} | ||
""" | ||
) | ||
|
||
configurations = { | ||
"os.architecture": "testarch64", | ||
"os.platform": "Not Actually Linux", | ||
"os.version": "1.2.3-test", | ||
"runtime.name": "CPythonTest", | ||
"runtime.version": "1.2.3", | ||
} | ||
|
||
git_data = GitData("[email protected]:TestDog/dd-test-py.git", "notmainbranch", "mytestcommitsha1234") | ||
with _ci_override_env(full_clear=True), _patch_env_for_testing(), mock.patch( | ||
"ddtrace.internal.ci_visibility.recorder.CIVisibility._agent_evp_proxy_is_available", return_value=True | ||
), mock.patch("ddtrace.internal.agent.info", return_value=agent_info_response), mock.patch( | ||
"ddtrace.internal.agent.get_trace_url", return_value="http://shouldntbeused:6218" | ||
), mock.patch( | ||
"ddtrace.internal.ci_visibility.recorder.ddtrace.tracer._agent_url", "http://patchedagenturl:6218" | ||
): | ||
try: | ||
expected_client = EVPProxyTestVisibilityAPIClient( | ||
itr_skipping_level=ITR_SKIPPING_LEVEL.TEST, | ||
configurations=configurations, | ||
git_data=git_data, | ||
agent_url="http://patchedagenturl:6218", | ||
dd_env="not_the_default_default_env", | ||
dd_service="dd-test-py", | ||
) | ||
CIVisibility.enable() | ||
assert CIVisibility.enabled is True | ||
assert CIVisibility._instance is not None | ||
assert CIVisibility._instance._api_client is not None | ||
|
||
assert CIVisibility._instance._api_client.__dict__ == expected_client.__dict__ | ||
finally: | ||
CIVisibility.disable() |