Skip to content

Commit d9a74bd

Browse files
avara1986gnufede
andauthored
feat(asm): disable distribution metrics (#5529)
Disable ASM distribution metrics report ## Checklist - [x] Change(s) are motivated and described in the PR description. - [x] Testing strategy is described if automated tests are not included in the PR. - [x] Risk is outlined (performance impact, potential for breakage, maintainability, etc). - [x] Change is maintainable (easy to change, telemetry, documentation). - [x] [Library release note guidelines](https://ddtrace.readthedocs.io/en/stable/contributing.html#Release-Note-Guidelines) are followed. - [x] Documentation is included (in-code, generated user docs, [public corp docs](https://github.com/DataDog/documentation/)). - [x] PR description includes explicit acknowledgement/acceptance of the performance implications of this PR as reported in the benchmarks PR comment. ## Reviewer Checklist - [x] Title is accurate. - [x] No unnecessary changes are introduced. - [x] Description motivates each change. - [x] Avoids breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes unless absolutely necessary. - [x] Testing strategy adequately addresses listed risk(s). - [x] Change is maintainable (easy to change, telemetry, documentation). - [x] Release note makes sense to a user of the library. - [x] Reviewer has explicitly acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment. --------- Co-authored-by: Federico Mon <[email protected]>
1 parent 036c389 commit d9a74bd

File tree

3 files changed

+0
-32
lines changed

3 files changed

+0
-32
lines changed

ddtrace/appsec/_metrics.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -79,23 +79,6 @@ def _set_waf_request_metrics():
7979
if has_info and list_result_info[0].version:
8080
common_tags["event_rules_version"] = list_result_info[0].version
8181

82-
if list_results:
83-
# runtime is the result in microseconds. Update to milliseconds
84-
ddwaf_result_runtime = sum(float(ddwaf_result.runtime) for ddwaf_result in list_results)
85-
ddwaf_result_total_runtime = sum(float(ddwaf_result.runtime) for ddwaf_result in list_results)
86-
telemetry_metrics_writer.add_distribution_metric(
87-
TELEMETRY_NAMESPACE_TAG_APPSEC,
88-
"waf.duration",
89-
float(ddwaf_result_runtime / 1e3),
90-
tags=common_tags,
91-
)
92-
telemetry_metrics_writer.add_distribution_metric(
93-
TELEMETRY_NAMESPACE_TAG_APPSEC,
94-
"waf.duration_ext",
95-
float(ddwaf_result_total_runtime / 1e3),
96-
tags=common_tags,
97-
)
98-
9982
tags_request = {
10083
"rule_triggered": is_triggered,
10184
"request_blocked": is_blocked,
@@ -108,7 +91,6 @@ def _set_waf_request_metrics():
10891
1.0,
10992
tags=tags_request,
11093
)
111-
# TODO: add log metric to report info.failed and info.errors
11294
except Exception:
11395
log.warning("Error reporting ASM WAF requests metrics", exc_info=True)
11496
finally:

tests/appsec/test_telemety.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ def test_metrics_when_appsec_runs(mock_telemetry_metrics_writer, tracer):
9797
Config(),
9898
)
9999
_assert_generate_metrics(mock_telemetry_metrics_writer._namespace._metrics_data)
100-
_assert_distributions_metrics(mock_telemetry_metrics_writer._namespace._metrics_data)
101100

102101

103102
def test_metrics_when_appsec_attack(mock_telemetry_metrics_writer, tracer):
@@ -109,7 +108,6 @@ def test_metrics_when_appsec_attack(mock_telemetry_metrics_writer, tracer):
109108
with tracer.trace("test", span_type=SpanTypes.WEB) as span:
110109
set_http_meta(span, Config(), request_cookies={"attack": "1' or '1' = '1'"})
111110
_assert_generate_metrics(mock_telemetry_metrics_writer._namespace._metrics_data, is_rule_triggered=True)
112-
_assert_distributions_metrics(mock_telemetry_metrics_writer._namespace._metrics_data, is_rule_triggered=True)
113111

114112

115113
def test_metrics_when_appsec_block(mock_telemetry_metrics_writer, tracer):
@@ -128,9 +126,6 @@ def test_metrics_when_appsec_block(mock_telemetry_metrics_writer, tracer):
128126
_assert_generate_metrics(
129127
mock_telemetry_metrics_writer._namespace._metrics_data, is_rule_triggered=True, is_blocked_request=True
130128
)
131-
_assert_distributions_metrics(
132-
mock_telemetry_metrics_writer._namespace._metrics_data, is_rule_triggered=True, is_blocked_request=True
133-
)
134129

135130

136131
def test_log_metric_error_ddwaf_init(mock_logs_telemetry_metrics_writer):

tests/contrib/flask/test_flask_appsec_telemetry.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from ddtrace.internal.constants import APPSEC_BLOCKED_RESPONSE_JSON
99
from tests.appsec.test_processor import RULES_GOOD_PATH
1010
from tests.appsec.test_processor import _BLOCKED_IP
11-
from tests.appsec.test_telemety import _assert_distributions_metrics
1211
from tests.appsec.test_telemety import _assert_generate_metrics
1312
from tests.appsec.test_telemety import mock_telemetry_metrics_writer # noqa: F401
1413
from tests.contrib.flask import BaseFlaskTestCase
@@ -39,9 +38,6 @@ def test_telemetry_metrics_block(self):
3938
_assert_generate_metrics(
4039
self.mock_telemetry_metrics_writer._namespace._metrics_data, is_rule_triggered=True, is_blocked_request=True
4140
)
42-
_assert_distributions_metrics(
43-
self.mock_telemetry_metrics_writer._namespace._metrics_data, is_rule_triggered=True, is_blocked_request=True
44-
)
4541

4642
def test_telemetry_metrics_attack(self):
4743
with override_global_config(dict(_appsec_enabled=True, _telemetry_metrics_enabled=True)):
@@ -58,8 +54,3 @@ def test_telemetry_metrics_attack(self):
5854
is_rule_triggered=True,
5955
is_blocked_request=False,
6056
)
61-
_assert_distributions_metrics(
62-
self.mock_telemetry_metrics_writer._namespace._metrics_data,
63-
is_rule_triggered=True,
64-
is_blocked_request=False,
65-
)

0 commit comments

Comments
 (0)