-
Notifications
You must be signed in to change notification settings - Fork 67
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
refactor: change alert parts calculations #1084
base: master
Are you sure you want to change the base?
Conversation
ATTENTION: - slack tests failed - need to refactor tg message formatter
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #1084 +/- ##
===========================================
- Coverage 66.85% 52.64% -14.21%
===========================================
Files 219 287 +68
Lines 12778 16593 +3815
===========================================
+ Hits 8543 8736 +193
- Misses 3684 7303 +3619
- Partials 551 554 +3 ☔ View full report in Codecov by Sentry. |
senders/calc_message_parts.go
Outdated
|
||
fairMaxLen := maxChars / 3 | ||
|
||
if tagsLen > fairMaxLen && descLen <= fairMaxLen && eventsLen <= fairMaxLen { |
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.
давайте этот большой иф на свитч перепишем?
и условия вынесем в функции, имена которых нам будут понятно отвечеть, что это за условия?
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.
Поправил. Стало лучше?
senders/calc_message_parts.go
Outdated
return tagsLen, descLen, eventsLen | ||
} | ||
|
||
fairMaxLen := maxChars / 3 |
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.
3?
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.
Теперь да. Между тегами, описанием и метриками
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.
не, ты не понял, что такое три?))
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.
Не думаю, что хорошая идея эту штуку в константу тащить...
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.
messagePartsNum
и коммент, описывающий
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.
Поправил
message.WriteString(desc) | ||
message.WriteString(eventsString) | ||
return message.String() | ||
return title + tagsStr + "\n" + desc + eventsString |
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.
а почему переписал на такую форму?
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.
Ну я так понимаю, что при наших объёмах разницы сильно не будет, а так это в одну строчку свернулось.
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.
хм ну лан
senders/calc_message_parts.go
Outdated
case firstAndSecondIsGreaterThanGivenLenAndOtherLessOrEqual(fairMaxLen, descLen, eventsLen, tagsLen): | ||
// split free space from tags fairly between description and events | ||
spaceFromTags := fairMaxLen - tagsLen | ||
descNewLen = fairMaxLen + spaceFromTags/2 |
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.
spaceFromTags/2
2 в константу - по коду ниже она тож имеется
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.
поправил
Change the rule for calculating alert parts if they are too big
There is no limits on tag length and tags count, so users can use a lot of long tags. In such case the function that resizes alert parts got bad data, which results to wrong calculations and panic in notifier.
This PR offers new function for resizing alert parts. Now the space is distributed between tags, trigger description and events block. If possible, space is given to description and events.
This PR affects the following senders: