-
Notifications
You must be signed in to change notification settings - Fork 0
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
prepare for release #69
Merged
Merged
Changes from 6 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
f979e1f
prepare for release
cpiemontese 55d83d4
add actuall support for new macro
cpiemontese 4341b49
add macros with options
cpiemontese 37ac847
still messed up
cpiemontese 720d546
update docs
cpiemontese e250151
fix macro
cpiemontese 0207eef
bump dogstatsd version
ivoreis 6be778a
merge into event
cpiemontese 5961644
fix docs
cpiemontese 472f126
fix tests
cpiemontese 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
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,2 @@ | ||
[tools] | ||
rust = "1.74" |
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
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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM rust:1.72.0 | ||
FROM rust:1.74.0 | ||
|
||
WORKDIR /code | ||
|
||
|
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
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
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,41 @@ | ||
/// Send a custom event as a title and a body | ||
/// NOTE: Try to minimise variation in tag values (avoid things like timestamps or ids). See note in lib docs! | ||
#[macro_export] | ||
macro_rules! event_with_options { | ||
($stat:path, $text:expr) => { | ||
$crate::Datadog::event_with_options($stat.as_ref(), $text, $crate::EMPTY_TAGS, None); | ||
}; | ||
($stat:path, $text:expr, $options:expr) => { | ||
$crate::Datadog::event_with_options($stat.as_ref(), $text, $crate::EMPTY_TAGS, Some($options)); | ||
}; | ||
($stat:expr, $text:expr) => { | ||
$crate::Datadog::event_with_options($stat, $text, $crate::EMPTY_TAGS, None); | ||
}; | ||
($stat:expr, $text:expr, $options:expr) => { | ||
$crate::Datadog::event_with_options($stat, $text, $crate::EMPTY_TAGS, Some($options)); | ||
}; | ||
($stat:path, $text:expr; $( $key:literal => $value:literal ), *) => { | ||
$crate::Datadog::event_with_options($stat.as_ref(), $text, &[$(::core::concat!($key, ":", $value)), *], None); | ||
}; | ||
($stat:path, $text:expr, $options:expr; $( $key:literal => $value:literal ), *) => { | ||
$crate::Datadog::event_with_options($stat.as_ref(), $text, &[$(::core::concat!($key, ":", $value)), *], Some($options)); | ||
}; | ||
($stat:expr, $text:expr; $( $key:literal => $value:literal ), *) => { | ||
$crate::Datadog::event_with_options($stat, $text, &[$(::core::concat!($key, ":", $value)), *], None); | ||
}; | ||
($stat:expr, $text:expr, $options:expr; $( $key:literal => $value:literal ), *) => { | ||
$crate::Datadog::event_with_options($stat, $text, &[$(::core::concat!($key, ":", $value)), *], Some($options)); | ||
}; | ||
($stat:path, $text:expr; $( $key:expr => $value:expr ), *) => { | ||
$crate::Datadog::event_with_options($stat.as_ref(), $text, &[$(::std::format!("{}:{}", $key, $value).as_str()), *], None); | ||
}; | ||
($stat:path, $text:expr, $options:expr; $( $key:expr => $value:expr ), *) => { | ||
$crate::Datadog::event_with_options($stat.as_ref(), $text, &[$(::std::format!("{}:{}", $key, $value).as_str()), *], Some($options)); | ||
}; | ||
($stat:expr, $text:expr; $( $key:expr => $value:expr ), *) => { | ||
$crate::Datadog::event_with_options($stat, $text, &[$(::std::format!("{}:{}", $key, $value).as_str()), *], None); | ||
}; | ||
($stat:expr, $text:expr, $options:expr; $( $key:expr => $value:expr ), *) => { | ||
$crate::Datadog::event_with_options($stat, $text, &[$(::std::format!("{}:{}", $key, $value).as_str()), *], Some($options)); | ||
}; | ||
} |
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
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,91 @@ | ||
use dogstatsd::EventAlertType; | ||
use dogstatsd::EventOptions; | ||
use dogstatsd::EventPriority; | ||
|
||
use crate::event_with_options; | ||
use crate::tests::mocks; | ||
use crate::tests::TestEvent; | ||
use crate::Datadog; | ||
use crate::TagTrackerConfiguration; | ||
use crate::EMPTY_TAGS; | ||
|
||
#[test] | ||
pub fn event_with_options_with_literal() { | ||
let mock = mocks::event_with_options_mock("test", "test_value", &[], None); | ||
Datadog::new(mock, TagTrackerConfiguration::new()).do_event_with_options("test", "test_value", EMPTY_TAGS, None); | ||
} | ||
|
||
#[test] | ||
pub fn event_with_options_with_type() { | ||
let mock = mocks::event_with_options_mock("test1_event", "test_value", &[], None); | ||
Datadog::new(mock, TagTrackerConfiguration::new()).do_event_with_options( | ||
TestEvent::Test1, | ||
"test_value", | ||
EMPTY_TAGS, | ||
None, | ||
); | ||
} | ||
|
||
#[test] | ||
pub fn event_with_options_with_literal_and_tags() { | ||
let mock = mocks::event_with_options_mock("test", "test_value", &["added:tag", "env:test"], None); | ||
Datadog::new(mock, TagTrackerConfiguration::new()).do_event_with_options( | ||
"test", | ||
"test_value", | ||
vec!["added:tag".to_string()], | ||
None, | ||
); | ||
} | ||
|
||
#[test] | ||
pub fn event_with_options_with_type_and_tags() { | ||
let mock = mocks::event_with_options_mock("test1_event", "test_value", &["added:tag", "env:test"], None); | ||
Datadog::new(mock, TagTrackerConfiguration::new()).do_event_with_options( | ||
TestEvent::Test1, | ||
"test_value", | ||
vec!["added:tag".to_string()], | ||
None, | ||
); | ||
} | ||
|
||
#[test] | ||
pub fn event_with_options_with_options() { | ||
let options = Some( | ||
EventOptions::new() | ||
.with_alert_type(EventAlertType::Info) | ||
.with_priority(EventPriority::Low) | ||
.with_aggregation_key("aggregation_key") | ||
.with_source_type_name("source_type_name") | ||
.with_hostname("hostname") | ||
.with_timestamp(12341234), | ||
); | ||
|
||
let mock = mocks::event_with_options_mock("test1_event", "test_value", &["added:tag", "env:test"], options); | ||
Datadog::new(mock, TagTrackerConfiguration::new()).do_event_with_options( | ||
TestEvent::Test1, | ||
"test_value", | ||
vec!["added:tag".to_string()], | ||
options, | ||
); | ||
} | ||
|
||
#[test] | ||
pub fn test_macro() { | ||
let tag = String::from("tag"); | ||
// no tags | ||
event_with_options!("test", "test_value"); | ||
// no tags with options | ||
event_with_options!("test", "test_value", EventOptions::new()); | ||
// just literal tags | ||
event_with_options!("test", "test_value"; "literal" => 1); | ||
// just literal tags with options | ||
event_with_options!("test", "test_value", EventOptions::new(); "literal" => 1); | ||
// just expression tags | ||
event_with_options!("test", "test_value"; "expression" => tag); | ||
// just expression tags with options | ||
event_with_options!("test", "test_value", EventOptions::new(); "expression" => tag); | ||
// mixed tags | ||
event_with_options!("test", "test_value"; "literal" => 1, "expression" => tag); | ||
// mixed tags with options | ||
event_with_options!("test", "test_value", EventOptions::new(); "literal" => 1, "expression" => tag); | ||
} |
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
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WDYT about extending the event! Instead of creating a new one? It could receive the EventOptions as an argument and pass it to
$crate::Datadog::event_with_options
instead of$crate::Datadog::event
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was debating the two options, I think it may make sense to expose just one macro