Skip to content

Commit b993055

Browse files
authored
chore(antithesis): Add two new Pyld properties (#1960)
## Summary <!-- Please provide a brief summary about what this PR does. This should help the reviewers give feedback faster and with higher quality. --> This commit adds two new properties to the intake model: * Pyld23 -- per-tag byte cap * Pyld24 -- per-series total tagset byte cap Not terribly complicated code and I've set the constants to conform to intake guidelines. ## Change Type - [ ] Bug fix - [ ] New feature - [x] Non-functional (chore, refactoring, docs) - [ ] Performance ## How did you test this PR? <!-- Please how you tested these changes here --> ## References <!-- Please list any issues closed by this PR. --> <!-- - Closes: <issue link> --> <!-- Any other issues or PRs relevant to this PR? Feel free to list them here. -->
1 parent 0f41368 commit b993055

4 files changed

Lines changed: 37 additions & 1 deletion

File tree

test/antithesis/intake/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ per-org caps with defaults 100 and 500 respectively.
5151
| Pyld20 | MetricPoint | Value Not-NaN | `value` is not NaN |
5252
| Pyld21 | MetricPoint | Timestamp Future Bound | `timestamp <= intake_now + 600s` |
5353
| Pyld22 | Bytes | Content-Length | `Content-Length` absent or value equals body byte count |
54+
| Pyld23 | MetricSeries | Tag Length | each tag `<= 200` bytes (`MaxTagLength`) |
55+
| Pyld24 | MetricSeries | Tag Set Size | total tag bytes per series `<= 100 KiB` (`MaxTagSetSize`) |
5456

5557
### Differential context capture
5658

test/antithesis/intake/src/properties/payload/constants.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,9 @@
33
44
/// `serializer_max_series_points_per_payload` default (Pyld08 / Pyld15).
55
pub(crate) const MAX_POINTS_PER_PAYLOAD: usize = 10_000;
6+
7+
/// `MaxTagLength` default (Pyld23). Per-tag byte cap.
8+
pub(crate) const MAX_TAG_LENGTH_BYTES: usize = 200;
9+
10+
/// `MaxTagSetSize` default (Pyld24). Per-series total tag-set byte cap.
11+
pub(crate) const MAX_TAG_SET_SIZE_BYTES: usize = 100 * 1024;

test/antithesis/intake/src/properties/payload/series.rs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use datadog_protos::metrics::metric_payload::MetricSeries;
55
use datadog_protos::metrics::MetricType;
66
use serde_json::json;
77

8-
use super::constants::MAX_POINTS_PER_PAYLOAD;
8+
use super::constants::{MAX_POINTS_PER_PAYLOAD, MAX_TAG_LENGTH_BYTES, MAX_TAG_SET_SIZE_BYTES};
99
use crate::capture::Target;
1010

1111
/// `MaxTags(orgID)` default (Pyld13).
@@ -134,3 +134,29 @@ pub(crate) fn origin(target: Target, ms: &MetricSeries) {
134134
&json!({ "lane": target, "metric": ms.metric(), "out_of_domain": out })
135135
);
136136
}
137+
138+
/// Pyld23 -- each tag at most `MAX_TAG_LENGTH_BYTES` bytes.
139+
pub(crate) fn tag_length(target: Target, ms: &MetricSeries) {
140+
let over = ms
141+
.tags
142+
.iter()
143+
.map(String::len)
144+
.max()
145+
.filter(|&len| len > MAX_TAG_LENGTH_BYTES);
146+
assert_always!(
147+
over.is_none(),
148+
"Pyld23.tag_length",
149+
&json!({ "lane": target, "metric": ms.metric(), "max_tag_bytes": MAX_TAG_LENGTH_BYTES, "observed": over })
150+
);
151+
}
152+
153+
/// Pyld24 -- total tag-set bytes per series at most `MAX_TAG_SET_SIZE_BYTES`.
154+
pub(crate) fn tag_set_size(target: Target, ms: &MetricSeries) {
155+
let total: usize = ms.tags.iter().map(String::len).sum();
156+
let over = (total > MAX_TAG_SET_SIZE_BYTES).then_some(total);
157+
assert_always!(
158+
over.is_none(),
159+
"Pyld24.tag_set_size",
160+
&json!({ "lane": target, "metric": ms.metric(), "max_set_bytes": MAX_TAG_SET_SIZE_BYTES, "observed": over })
161+
);
162+
}

test/antithesis/intake/src/series_observation.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ fn evaluate_series(target: Target, ms: &MetricSeries, now_secs: i64) {
7979
series::metric_length(target, ms);
8080
series::metric_alphabetic(target, ms);
8181
series::tag_count(target, ms);
82+
series::tag_length(target, ms);
83+
series::tag_set_size(target, ms);
8284
point::value_not_nan(target, ms);
8385
point::future_bound(target, ms, now_secs);
8486
}

0 commit comments

Comments
 (0)