Skip to content
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

[SLT-152] feat(opbot): descending traces timestamp support #3092

Merged
merged 9 commits into from
Sep 17, 2024
13 changes: 11 additions & 2 deletions contrib/opbot/botmd/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"log"
"math/big"
"regexp"
"sort"
"strings"
"sync"
"time"
Expand Down Expand Up @@ -55,8 +56,8 @@
"trace transaction_id:0x1234 serviceName:rfq",
},
Handler: func(ctx *slacker.CommandContext) {
tags := stripLinks(ctx.Request().Param("tags"))
splitTags := strings.Split(tags, " ")
tags := strings.ToLower(stripLinks(ctx.Request().Param("tags")))
splitTags := strings.Split(tags, " ")[:2]

Check warning on line 60 in contrib/opbot/botmd/commands.go

View check run for this annotation

Codecov / codecov/patch

contrib/opbot/botmd/commands.go#L59-L60

Added lines #L59 - L60 were not covered by tests
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

The code changes to standardize tag inputs and limit the number of tags are approved.

Consider adding test coverage.

The static analysis tool indicates that these lines are not covered by tests.

Do you want me to generate test cases for these lines or open a GitHub issue to track this task?

Tools
GitHub Check: codecov/patch

[warning] 59-60: contrib/opbot/botmd/commands.go#L59-L60
Added lines #L59 - L60 were not covered by tests

if len(splitTags) == 0 {
_, err := ctx.Response().Reply("please provide tags in a key:value format")
if err != nil {
Expand All @@ -65,6 +66,8 @@
return
}

isDescending := strings.Contains(tags, "desc") || strings.Contains(tags, "dsc") || strings.Contains(tags, "d")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

The code change to introduce the isDescending variable is approved.

Consider adding test coverage.

The static analysis tool indicates that this line is not covered by tests.

Do you want me to generate test cases for this line or open a GitHub issue to track this task?


Check warning on line 70 in contrib/opbot/botmd/commands.go

View check run for this annotation

Codecov / codecov/patch

contrib/opbot/botmd/commands.go#L70

Added line #L70 was not covered by tests
searchMap := make(map[string]string)
for _, combinedTag := range splitTags {
tag := strings.Split(combinedTag, ":")
Expand Down Expand Up @@ -105,6 +108,12 @@
return
}

if isDescending {
sort.Slice(traceList, func(i, j int) bool {
return traceList[i].Timestamp.After(traceList[j].Timestamp)
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

The code changes to sort the traceList in descending order are approved.

Consider adding test coverage.

The static analysis tool indicates that these lines are not covered by tests.

Do you want me to generate test cases for these lines or open a GitHub issue to track this task?

Tools
GitHub Check: codecov/patch

[warning] 109-113: contrib/opbot/botmd/commands.go#L109-L113
Added lines #L109 - L113 were not covered by tests

}

Check warning on line 115 in contrib/opbot/botmd/commands.go

View check run for this annotation

Codecov / codecov/patch

contrib/opbot/botmd/commands.go#L112-L115

Added lines #L112 - L115 were not covered by tests
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

The code changes to sort the traceList in descending order are approved.

Consider adding test coverage.

The static analysis tool indicates that these lines are not covered by tests.

Do you want me to generate test cases for these lines or open a GitHub issue to track this task?

Tools
GitHub Check: codecov/patch

[warning] 112-115: contrib/opbot/botmd/commands.go#L112-L115
Added lines #L112 - L115 were not covered by tests


slackBlocks := []slack.Block{slack.NewHeaderBlock(slack.NewTextBlockObject(slack.PlainTextType, fmt.Sprintf("Traces for %s", tags), false, false))}

for _, results := range traceList {
Expand Down
Loading