-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
integrations: Update Newrelic integrations. #29730
base: main
Are you sure you want to change the base?
integrations: Update Newrelic integrations. #29730
Conversation
Hello @PieterCK, it seems like you have referenced #29729 in your pull request description, but you have not referenced them in your commit message description(s). Referencing an issue in a commit message automatically closes the corresponding issue when the commit is merged, which makes the issue tracker easier to manage. Please run An example of a correctly-formatted commit:
To learn how to write a great commit message, please refer to our guide. |
00b60f3
to
0c638b8
Compare
0c638b8
to
09f9475
Compare
e5e4521
to
92c05bf
Compare
Thank you for the detailed description and screenshots! |
@laurynmm Are you up for doing the first round of review here? I skimmed the overview, but have not thought carefully about the details. |
92c05bf
to
0bdc1ec
Compare
fac05c8
to
58942a3
Compare
Update: Resolved conflict |
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.
@PieterCK - I did an initial review for this integration update. I didn't get through all of the change, but I figured you had enough feedback so far that you could go through my comments that I've got so far so this work can move forward.
Two notes not in review comments:
- The svg file seems big, especially when compared to the one it's replacing.
- The commit is from the original author, so you'll want to mark youself as the co-author. Or you'll want to update that so you're the author and mark the original author as a co-author.
Let me know if you have any questions about the above or about any of my comments. Thanks for taking on these extensive updates to this New Relic integration!
zerver/webhooks/newrelic/view.py
Outdated
check_union, | ||
) | ||
from zerver.lib.webhooks.common import check_send_webhook_message, unix_milliseconds_to_timestamp | ||
from zerver.models import UserProfile | ||
from zerver.webhooks.newrelic import IncidentPrioritiesItems, IncidentStates, IncidentTimeStamps |
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.
So, generally in our webhook integrations, these would be defined here in the view file.
zerver/webhooks/newrelic/view.py
Outdated
NOTIFICATION_HEADER = "{priority_symbol} {priority} **priority [issue]({incident_url}) has been **{status}** at** <time: {time_updated_str} >" | ||
|
||
NOTIFICATION_BODY_TEMPLATE = """ | ||
| :file: **Incident Details** | |
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.
For headers and titles in Zulip, we usually only capitalize the first word (e.g. Recent conversations). So here and throughout the templates, I'd update this to be **Incident details**
.
zerver/webhooks/newrelic/view.py
Outdated
TOPIC_TEMPLATE = "{state} {priority} priority" | ||
|
||
FALL_BACK_NOTIFICATION_TEMPLATE = """ | ||
```spoiler :danger: An [Incident](https://one.newrelic.com/alerts-ai) has been updated |
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.
Maybe simplify to :danger: [Incident](link) updated
zerver/webhooks/newrelic/view.py
Outdated
Try to reset the payload template to the default from | ||
New Relic if you're unsure. | ||
Please reach out to the team if you think this integration | ||
is outdated: [CZO](https://chat.zulip.org/#narrow/stream/127-integrations). |
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.
"CZO" is mostly used internally. It'd be better to use "the Zulip development community". Maybe ...
Please reach out in [the Zulip development community](link) if you think this integration is out-of-date.
Integration last updated: **{integration_last_updated}**
zerver/webhooks/newrelic/view.py
Outdated
> *Last updated: **{integration_last_updated}*** | ||
``` | ||
""" | ||
FALL_BACK_TOPIC_TEMPLATE = "Incident Alerts" |
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.
Again "Incident alerts" vs both words being capitalized.
zerver/webhooks/newrelic/view.py
Outdated
"incident_url": payload.get("issueUrl", "https://one.newrelic.com/alerts-ai").tame( | ||
check_string | ||
), | ||
"total_incidents": payload["totalIncidents"].tame(check_union([check_int, check_string])), |
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.
Is there an example fixture / payload where "totalIncidents"
is a string?
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.
zerver/webhooks/newrelic/view.py
Outdated
check_string | ||
), | ||
"total_incidents": payload["totalIncidents"].tame(check_union([check_int, check_string])), | ||
"state": payload.get("state").tame(check_string_in(IncidentStates.as_list(target="name"))), |
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 think this can just be a list of strings defined as a constant above.
zerver/webhooks/newrelic/view.py
Outdated
|
||
def get_iso_timestamp_str(payload: WildValue, event_type: IncidentTimeStamps) -> Optional[str]: | ||
unix_time = payload.get(event_type.value, "N/A").tame( | ||
check_none_or(check_union([check_int, check_string])) |
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.
Since "N/A" is being set as the default ... can this be None
?
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.
Yes, check_none_or
should be safe to remove.
zerver/webhooks/newrelic/view.py
Outdated
check_none_or(check_union([check_int, check_string])) | ||
) | ||
|
||
if unix_time == "N/A": |
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 seems like "N/A" might be returned as an actual value from the New Relic payload, correct? At least the generated fixtures have some with that string value.
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.
Yes they use the string "N/A" instead of None or false
zerver/webhooks/newrelic/view.py
Outdated
created_at = get_iso_timestamp_str(payload, IncidentTimeStamps.CREATED) | ||
closed_at = get_iso_timestamp_str(payload, IncidentTimeStamps.CLOSED) | ||
|
||
if acknowledged_at and updated_at == acknowledged_at: |
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.
What if both acknowledged_at
and updated_at
are None
? I think we need to assert or check that updated_at
isn't None
before assuming such.
8b3d932
to
4aa40a2
Compare
e4f66b2
to
3a9ef92
Compare
Add new features to the integration, updated media files such as logo and bot avatar, updated doc, updated test fixtures and deleted legacy codes. Fixes zulip#29729 Co-authored-by: Pieter CK <pieterceka123@gmail.com>
3a9ef92
to
22c700c
Compare
Hi @laurynmm, thanks for doing an initial code review for this PR. I've addressed your comments and updated the commit for this PR. Let me know if any recent changes fail to address your concerns. Looking forward to more reviews! |
π PR Overview
Originally, this PR aims to resume the work done on #27779 by applying suggested changes by reviewer in the original PR and developing new tests. However, the scope of the PR has widened due to the New Relic changes reported in #29729.
This PR's scope is now to adjust the whole Zulip New Relic integration for the newest New Relic updates. It also includes new tests, new notifications as well as added new capabilities to the integration.
Fixes: #29729
π οΈ Updates & New Features Implemented
Updated New Relic Logo & Bot Avatar:
Updated New Relic Doc
Restructured to better follow changes in #29592
Adjusted the doc for the New Relic "workflow and destinations" update
Included documentation for new features and updated payload
BLOCKER : I encountered an error when trying to include an example of New Relic payload in a code block in the docs 'Recommended Base Payload Template' section, which could add improvements to the integration if used by the user. CZO detailing the error.
New Feature: Support for New Relic Custom Payload
User can now include New Relic webhook custom fields in their New Relic Zulip notification.
The details and guide on how to use this feature is already written in the new doc under "Displaying Custom Fields" section. For technical details, this feature is handled in
generate_custom_field_message()
.notification with custom field "Your Custom Payload" :
relevant payload part for the notification above:
notification with a couple of incorrectly configured custom payload :
relevant payload part for the notification above:
Provided a "Recommended" base payload
The out of the box New Relic payloads is very minimal. To benefit from the newest features, a recommended base payload is provided in the integration doc.
default base payload:
provided base payload:
Reworked Notification Topic Name Format
Changed notification topic name format to enable user to follow alerts based on priority and incident state
Old (current) topic name format:
{alert_policies} {issue_id}
e.g: "(Golden Signals, Computer Health)(123-039-932-0321-393)"
New topic name format:
{state} {priority} priority
e.g: "Activated Critical Priority"
The rationale is to enable the user to follow specific streams they want based on incident priority and state. The old format was also created when Alert Policy was a single value and not a list, which it is now.
New Feature: Added "Fallback" Notification
Added a very minimal notification format and a warning informing the integration might be outdated or the user has tampered the payload too much (omitting required field).
fallback notification:
payload for the notification above:
Redesigned Integration Notifications
The new notification is designed to better present the updated and new payloads from recent New Relic update. It is also being discussed with a couple of other members and user: CZO
notification with the default new relic payload:
notification with the payload we recommend and provided:
variety of incident priority:
variety of incident priority (opened):
variety of incident states:
variety of incident actions beside Closed & Activated:
notification with some custom payload:
fallback notification:
π§βπ Issues & Concerns Encountered
table border in dark mode is almost invisible since the color is still black. Details in: CZO (ADDRESSED HERE: PR dark_theme_css: Fix border color for tables in message/chat.Β #29859)as mentioned earlier, attempting to render dictionary in a specific format inside a code block in doc .md will result in error. Details in: CZO (ADDRESSED HERE: Issue Fix error when rendering fenced code block with wierdly formated dictionary in doc.md fileΒ #29857 )π Helpful Resources
Self-review checklist
(variable names, code reuse, readability, etc.).
Communicate decisions, questions, and potential concerns.
Individual commits are ready for review (see commit discipline).
Completed manual review and testing of the following: