-
Notifications
You must be signed in to change notification settings - Fork 69
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
Adding ability to automatically close incident in PagerDuty #486
base: master
Are you sure you want to change the base?
Conversation
…ra decided that alert is resolved(send OK status). This change conform incident lifecycle, that described in https://v2.developer.pagerduty.com/docs/send-an-event-events-api-v2
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.
Please, fix tests to pass CI
You have failing tests. Please fix it before we can merge your PR into master. CI log:
|
@tantra35 Would you like to fix tests for this PR? |
@litleleprikon we will try |
@litleleprikon how we can launch
|
@tantra35 which version of go are you using? |
@litleleprikon we use 1.13 |
@tantra35 I do not know why you are not able to run linter but my general advice will be to use docker container to run linter |
@@ -61,10 +62,16 @@ func (sender *Sender) buildEvent(events moira.NotificationEvents, contact moira. | |||
Details: details, | |||
} | |||
|
|||
action := "trigger" |
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.
May we move this string literals to constants?
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.
Hm, I doesn't understand, why this needed? In official library which you use (https://github.com/PagerDuty/go-pagerduty), those doesn't defined as constants, so it's very strange to invent abstractions if the authors of official library did not provide them themselves
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 just do not like string literals and magic numbers placed in random places in the code. The reason to place this values in constants is that it will be easier to change values in one place if pagerduty will change their API. I know that right now this values are placed only in two places but in future we can have more complex condition of action choose.
@@ -43,6 +43,7 @@ func TestBuildEvent(t *testing.T) { | |||
baseExpected := pagerduty.V2Event{ | |||
RoutingKey: contact.Value, | |||
Action: "trigger", | |||
DedupKey: "TriggerID", |
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 would like to see more complex example of switching states between trigger
and resolved
in tests
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.
@litleleprikon Sorry but i can't imagine wthat you want:-), can you clarify? Dedupkey
is simple trigger id, it doesn't add additional logic
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.
It is not about the DeduceKey
it's about whole tests I just found a first change in tests file to add my comment. My point is that we want to see that action set correctly and this lead us to this additional tests:
- with trigger in
ERROR
state and action set totrigger
- with trigger in
OK
state and action set toresolve
- with trigger in
NODATA
state - with trigger in
WARN
state
In two last cases the action will be trigger
but is it the right state?
@@ -61,10 +62,16 @@ func (sender *Sender) buildEvent(events moira.NotificationEvents, contact moira. | |||
Details: details, | |||
} | |||
|
|||
action := "trigger" |
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 just do not like string literals and magic numbers placed in random places in the code. The reason to place this values in constants is that it will be easier to change values in one place if pagerduty will change their API. I know that right now this values are placed only in two places but in future we can have more complex condition of action choose.
Hi @tantra35 this PR is almost ready to be merged into master. Would you like to rebase on a new master and fix issues? |
@tantra35 please complete this PR. Personally, we are really looking forward to the appearance of this PR in the master branch. Thanks. |
Adding ability to automatically close incident in PagerDuty when moira decided that alert is resolved(send OK status).
This change conform incident lifecycle, that described in https://v2.developer.pagerduty.com/docs/send-an-event-events-api-v2
For playing with api link below can be used:
https://v2.developer.pagerduty.com/docs/send-an-event-events-api-v2