Skip to content

Commit 12ae350

Browse files
committed
4
1 parent 776eb4c commit 12ae350

File tree

28 files changed

+799
-4195
lines changed

28 files changed

+799
-4195
lines changed

components/ide-metrics-api/generate.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ local_java_protoc() {
5050
--java_out=java/src/main/java \
5151
./*.proto
5252
# remove trailing spaces
53-
find "$COMPONENTS_DIR"/ide-metrics-api/java/src/main/java/io/gitpod/ide_metrics/api -maxdepth 1 -name "*.java" -exec sed -i -e "s/[[:space:]]*$//" {} \;
53+
find "$COMPONENTS_DIR"/ide-metrics-api/java/src/main/java/io/gitpod/idemetrics/api -maxdepth 1 -name "*.java" -exec sed -i -e "s/[[:space:]]*$//" {} \;
5454
}
5555

5656
install_dependencies

components/ide-metrics-api/go/config/config.go

+34-13
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,33 @@
55
package config
66

77
import (
8+
"bytes"
9+
"encoding/json"
10+
"os"
11+
812
"github.com/gitpod-io/gitpod/common-go/grpc"
13+
"golang.org/x/xerrors"
914
)
1015

16+
type LabelAllowList struct {
17+
Name string `json:"name"`
18+
AllowValues []string `json:"allowValues"`
19+
}
20+
1121
type ServiceConfiguration struct {
1222
Server struct {
1323
Port int `json:"port"`
1424
RateLimits map[string]grpc.RateLimit `json:"ratelimits"`
1525
CounterMetrics []struct {
16-
Name string `json:"name"`
17-
Help string `json:"help"`
18-
Labels []struct {
19-
Name string `json:"name"`
20-
AllowValues []string `json:"allowValues"`
21-
}
26+
Name string `json:"name"`
27+
Help string `json:"help"`
28+
Labels []LabelAllowList `json:"labels"`
2229
} `json:"counterMetrics"`
2330
HistogramMetrics []struct {
24-
Name string `json:"name"`
25-
Help string `json:"help"`
26-
Labels []struct {
27-
Name string `json:"name"`
28-
AllowValues []string `json:"allowValues"`
29-
}
30-
Buckets []float64 `json:"buckets"`
31+
Name string `json:"name"`
32+
Help string `json:"help"`
33+
Labels []LabelAllowList `json:"labels"`
34+
Buckets []float64 `json:"buckets"`
3135
} `json:"histogramMetrics"`
3236
} `json:"server"`
3337

@@ -39,3 +43,20 @@ type ServiceConfiguration struct {
3943
Addr string `json:"addr"`
4044
} `json:"prometheus"`
4145
}
46+
47+
func Read(fn string) (*ServiceConfiguration, error) {
48+
ctnt, err := os.ReadFile(fn)
49+
if err != nil {
50+
return nil, xerrors.Errorf("cannot read config file: %w", err)
51+
}
52+
53+
var cfg ServiceConfiguration
54+
dec := json.NewDecoder(bytes.NewReader(ctnt))
55+
dec.DisallowUnknownFields()
56+
err = dec.Decode(&cfg)
57+
if err != nil {
58+
return nil, xerrors.Errorf("cannot parse config file: %w", err)
59+
}
60+
61+
return &cfg, nil
62+
}

components/ide-metrics-api/go/go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ require (
2828
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 // indirect
2929
golang.org/x/text v0.3.7 // indirect
3030
golang.org/x/time v0.0.0-20191024005414-555d28b269f0 // indirect
31-
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
31+
golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f // indirect
3232
)
3333

3434
replace github.com/gitpod-io/gitpod/common-go => ../../common-go // leeway

components/ide-metrics-api/go/go.sum

+2
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,8 @@ golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8T
426426
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
427427
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
428428
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
429+
golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f h1:uF6paiQQebLeSXkrTqHqz0MXhXXS1KgF41eUdBNvxK0=
430+
golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8=
429431
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
430432
google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M=
431433
google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=

components/ide-metrics-api/go/metrics.pb.go renamed to components/ide-metrics-api/go/idemetrics.pb.go

+91-91
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/ide-metrics-api/go/metrics_grpc.pb.go renamed to components/ide-metrics-api/go/idemetrics_grpc.pb.go

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)