Skip to content

Commit ceeef9b

Browse files
authored
fix makefile and log (OpenAtomFoundation#1714)
* fix makefile and log * fix makefile and log * fix makefile
1 parent 999a4fd commit ceeef9b

11 files changed

Lines changed: 45 additions & 21 deletions

File tree

tools/pika_exporter/Makefile

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
# export PATH := $(PATH):$(GOPATH)/bin
66

7-
UNAME := $(shell uname)
7+
OS := $(shell uname)
8+
ARCH := $(shell uname -m)
89
# for mac
910
BRANCH := $(shell git branch | sed 's/* \(.*\)/\1/p')
1011
# for Linux
@@ -63,10 +64,18 @@ export TEST_COVER
6364
all: build
6465

6566
build: deps
66-
ifeq ($(UNAME), Linux)
67-
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o bin/$(PROJNAME)
68-
else ifeq ($(UNAME), Darwin)
69-
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o bin/$(PROJNAME)
67+
ifeq ($(OS), Linux)
68+
ifeq ($(ARCH), x86_64)
69+
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o bin/$(PROJNAME)
70+
else ifeq ($(ARCH), arm6411)
71+
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o bin/$(PROJNAME)
72+
endif
73+
else ifeq ($(OS), Darwin)
74+
ifeq ($(ARCH), x86_64)
75+
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o bin/$(PROJNAME)
76+
else ifeq ($(ARCH), arm64)
77+
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o bin/$(PROJNAME)
78+
endif
7079
endif
7180

7281
deps: generateVer

tools/pika_exporter/exporter/metrics/command_exec_count.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ var collectCommandExecCountMetrics = map[string]MetricConfig{
1616
Parser: &regexParser{
1717
name: "command_exec_count_command",
1818
source: "commands_count",
19-
reg: regexp.MustCompile(`(\r|\n)*(?P<command>[^:]+):(?P<count>[\d]*)`),
19+
reg: regexp.MustCompile(`(\r|\n)*(?P<command>[^:]+):(?P<count>[\d]*)`),
2020
Parser: &normalParser{},
2121
},
2222
},

tools/pika_exporter/exporter/metrics/parser.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ func (p *timeParser) Parse(m MetricMeta, c Collector, opt ParseOption) {
210210
} else {
211211
t, err := convertTimeToUnix(v)
212212
if err != nil {
213-
log.Warnf("time is '0' and cannot be parsed", err)
213+
log.Warnf("time is '0' and cannot be parsed", err)
214214
}
215215
metric.Value = float64(t)
216216
}
@@ -264,7 +264,8 @@ func mustNewVersionConstraint(version string) *semver.Constraints {
264264
func convertTimeToUnix(ts string) (int64, error) {
265265
t, err := time.Parse(time.RFC3339, ts)
266266
if err != nil {
267-
return 0, err
267+
log.Warnf("format time failed, ts: %d, err: %v", ts, err)
268+
return 0, nil
268269
}
269270
return t.Unix(), nil
270271
}

tools/pika_exporter/exporter/parser_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ package exporter
22

33
import (
44
"fmt"
5+
"testing"
6+
57
"github.com/Masterminds/semver"
8+
"github.com/stretchr/testify/assert"
9+
610
"github.com/OpenAtomFoundation/pika/tools/pika_exporter/exporter/metrics"
711
"github.com/OpenAtomFoundation/pika/tools/pika_exporter/exporter/test"
8-
"github.com/stretchr/testify/assert"
9-
"testing"
1012
)
1113

1214
func mustNewVersionConstraint(version string) *semver.Constraints {

tools/pika_exporter/exporter/pika.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ import (
1010

1111
"github.com/OpenAtomFoundation/pika/tools/pika_exporter/discovery"
1212

13-
"github.com/OpenAtomFoundation/pika/tools/pika_exporter/exporter/metrics"
1413
"github.com/prometheus/client_golang/prometheus"
1514
log "github.com/sirupsen/logrus"
15+
16+
"github.com/OpenAtomFoundation/pika/tools/pika_exporter/exporter/metrics"
1617
)
1718

1819
type dbKeyPair struct {

tools/pika_exporter/exporter/pika_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package exporter
22

33
import (
4-
"github.com/OpenAtomFoundation/pika/tools/pika_exporter/discovery"
4+
"testing"
5+
56
"github.com/prometheus/client_golang/prometheus"
67
"github.com/stretchr/testify/assert"
7-
"testing"
8+
9+
"github.com/OpenAtomFoundation/pika/tools/pika_exporter/discovery"
810
)
911

1012
type fakeDiscovery struct {

tools/pika_exporter/exporter/test/v3.3.5_master.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,4 @@ db0 Strings_keys=83922112, expires=0, invalid_keys=0
8888
db0 Hashes_keys=4887344, expires=0, invalid_keys=0
8989
db0 Lists_keys=1, expires=0, invalid_keys=0
9090
db0 Zsets_keys=1, expires=0, invalid_keys=0
91-
db0 Sets_keys=0, expires=0, invalid_keys=1`
91+
db0 Sets_keys=0, expires=0, invalid_keys=1`

tools/pika_exporter/exporter/test/v3.3.5_slave.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,4 @@ db0 Strings_keys=1000, expires=0, invalid_keys=0
8989
db0 Hashes_keys=0, expires=0, invalid_keys=0
9090
db0 Lists_keys=0, expires=0, invalid_keys=0
9191
db0 Zsets_keys=0, expires=100, invalid_keys=0
92-
db0 Sets_keys=0, expires=0, invalid_keys=0`
92+
db0 Sets_keys=0, expires=0, invalid_keys=0`

tools/pika_exporter/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ require (
2222
github.com/prometheus/common v0.42.0 // indirect
2323
github.com/prometheus/procfs v0.9.0 // indirect
2424
github.com/rogpeppe/go-internal v1.10.0 // indirect
25-
golang.org/x/sys v0.6.0 // indirect
25+
golang.org/x/sys v0.10.0 // indirect
2626
google.golang.org/protobuf v1.30.0 // indirect
2727
gopkg.in/yaml.v3 v3.0.1 // indirect
2828
)

tools/pika_exporter/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ
4646
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
4747
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
4848
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
49-
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
50-
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
49+
golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA=
50+
golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
5151
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
5252
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
5353
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=

0 commit comments

Comments
 (0)