Skip to content

Commit

Permalink
Merge pull request #13 from shiimaxx/not-bundle-in-showTop
Browse files Browse the repository at this point in the history
Do not use bundle name in "TOP n Slow Requests"
  • Loading branch information
matsuu committed Sep 10, 2018
2 parents 4764247 + 46989b7 commit 7aa2687
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bufio"
"flag"
"fmt"
"github.com/BurntSushi/toml"
"io"
"math"
"os"
Expand All @@ -14,6 +13,8 @@ import (
"strconv"
"strings"
"sync"

"github.com/BurntSushi/toml"
)

type tomlConfig struct {
Expand Down Expand Up @@ -93,6 +94,7 @@ type ByTime []*Time

type Time struct {
Url string
OriginUrl string
Time float64
StatusCode int
}
Expand Down Expand Up @@ -273,7 +275,7 @@ func showTop(allTimes []*Time) {
topWidth := getIntegerDigitWidth(allTimes[0].Time) + 1 + config.EffectiveDigit
f := fmt.Sprintf("%%%dd %%%d.%df %%s\n", iWidth, topWidth, config.EffectiveDigit)
for i := 0; i < slowCount; i++ {
fmt.Printf(f, i+1, allTimes[i].Time, allTimes[i].Url)
fmt.Printf(f, i+1, allTimes[i].Time, allTimes[i].OriginUrl)
}
}

Expand Down Expand Up @@ -369,6 +371,7 @@ func main() {
if len(submatch) > 0 {
s := submatch[0]
url := s[config.RequestIndex]
originUrl := url
for name, re := range urlNormalizeRegexps {
if re.MatchString(url) {
url = name
Expand All @@ -385,7 +388,7 @@ func main() {
if err != nil {
statusCode = 0
}
ch <- &Time{Url: url, Time: time, StatusCode: statusCode}
ch <- &Time{Url: url, OriginUrl: originUrl, Time: time, StatusCode: statusCode}
}
}(line)
}
Expand Down

0 comments on commit 7aa2687

Please sign in to comment.