-
Notifications
You must be signed in to change notification settings - Fork 11
enhancement(antithesis): DogStatsD load generation #1782
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
Open
blt
wants to merge
1
commit into
main
Choose a base branch
from
blt/dogstatsd-load-generation
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+865
−122
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| //! Shared helpers for the Antithesis harness, used by the `src/bin/*` test | ||
| //! commands. | ||
|
|
||
| pub mod payload; | ||
| pub mod rand; |
This file contains hidden or 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,3 @@ | ||
| //! Payload generators for the protocols under test. | ||
|
|
||
| pub mod dogstatsd; |
This file contains hidden or 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,86 @@ | ||
| //! `DogStatsD` payload generation. | ||
|
|
||
| // Here's the basic idea. | ||
| // | ||
| // Dogstatsd is three message types: | ||
| // | ||
| // * metric | ||
| // * event | ||
| // * service check | ||
| // | ||
| // # Metrics | ||
| // | ||
| // <NAME>:<VALUE>|<TYPE>|@<SAMPLE_RATE>|#<TAG>,<TAG>...|c:<CONTAINER>|T<TS>|e:<EXT>|card:<CARD> | ||
| // | ||
| // Required: <NAME>:<VALUE>|<TYPE>. | ||
| // | ||
| // * <NAME> := [^:|\n]+ | ||
| // * <VALUE> := <NUMBER>(:<NUMBER>)* ':'-packed multi-value, non-set | ||
| // | [^|\n]+ raw string, set type | ||
| // * <NUMBER> := [+-]?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)? | [+-]?(inf|infinity|nan) | ||
| // * <TYPE> := c|g|ms|h|s|d count gauge timer histogram set distribution | ||
| // * <SAMPLE_RATE> := @<NUMBER> | ||
| // * <TAG> := [^,|\n]+ conventionally <KEY>:<VALUE>, the ':' is not required | ||
| // * <CONTAINER> := c:[^|\n]+ e.g. ci-<id>, in-<inode> | ||
| // * <TS> := T\d+ unix seconds | ||
| // * <EXT> := e:[^|\n]+ e.g. it-,cn-,pu- | ||
| // * <CARD> := card:[^|\n]+ recognized: none|low|orchestrator|high | ||
| // | ||
| // # Events | ||
| // | ||
| // _e{<TITLE_LEN>,<TEXT_LEN>}:<TITLE>|<TEXT>|d:<TS>|h:<HOST>|k:<AGGKEY>|p:<PRIO>|s:<SRC>|t:<ALERT>|#<TAGS> | ||
| // | ||
| // Required: _e{<TITLE_LEN>,<TEXT_LEN>}:<TITLE>|<TEXT>. c: / e: / card: are valid here too. | ||
| // | ||
| // * <TITLE_LEN>, | ||
| // <TEXT_LEN> := \d+ byte length of TITLE / TEXT | ||
| // * <TITLE>, | ||
| // <TEXT> := [^\n]{LEN} length-delimited, so '|' and ':' are allowed; '\\n' -> newline | ||
| // * <TS> := d:\d+ unix seconds | ||
| // * <HOST> := h:[^|\n]+ | ||
| // * <AGGKEY> := k:[^|\n]+ | ||
| // * <PRIO> := p:[^|\n]+ recognized: normal|low (else default) | ||
| // * <SRC> := s:[^|\n]+ | ||
| // * <ALERT> := t:[^|\n]+ recognized: error|warning|info|success (else default) | ||
| // * <TAGS> := #<TAG>(,<TAG>)* | ||
| // | ||
| // # Service checks | ||
| // | ||
| // _sc|<NAME>|<STATUS>|d:<TS>|h:<HOST>|#<TAG>,<TAG>...|m:<MESSAGE> | ||
| // | ||
| // Required: _sc|<NAME>|<STATUS>. c: / e: / card: are valid here too. | ||
| // | ||
| // * <NAME> := [^|\n]+ | ||
| // * <STATUS> := [0-3] OK warning critical unknown | ||
| // * <TS> := d:\d+ unix seconds | ||
| // * <HOST> := h:[^|\n]+ | ||
| // * <TAGS> := #<TAG>(,<TAG>)* | ||
| // * <MESSAGE> := m:[^|\n]+ | ||
|
|
||
| use antithesis_sdk::random::random_choice; | ||
| use rand::Rng; | ||
|
|
||
| mod common; | ||
| mod events; | ||
| mod metrics; | ||
| mod service_checks; | ||
|
|
||
| pub use common::{sample_vibe, Vibe}; | ||
|
|
||
| /// The three `DogStatsD` message types. | ||
| #[derive(Clone, Copy)] | ||
| enum Message { | ||
| Metric, | ||
| Event, | ||
| ServiceCheck, | ||
| } | ||
|
|
||
| /// Write one `DogStatsD` message of a random type to `buf` at the given vibe. | ||
| pub fn send<R: Rng + ?Sized>(rng: &mut R, buf: &mut Vec<u8>, vibe: Vibe) { | ||
| buf.clear(); | ||
| match random_choice(&[Message::Metric, Message::Event, Message::ServiceCheck]) { | ||
| Some(Message::Event) => events::write(rng, buf, vibe), | ||
| Some(Message::ServiceCheck) => service_checks::write(rng, buf, vibe), | ||
| _ => metrics::write(rng, buf, vibe), | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.