Skip to content

Commit 5387dca

Browse files
committedNov 7, 2024
feat: enable prometheus metrics endpoint
1 parent c420320 commit 5387dca

File tree

10 files changed

+136
-255
lines changed

10 files changed

+136
-255
lines changed
 

‎govoyage/Dockerfile

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM golang:1.23-alpine AS builder
2+
RUN apk add -U tzdata
3+
RUN apk --update add ca-certificates
4+
WORKDIR /app
5+
COPY . .
6+
COPY ../go.* .
7+
RUN go mod tidy
8+
RUN make app-linux
9+
10+
11+
FROM scratch
12+
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
13+
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
14+
COPY --from=builder /etc/passwd /etc/passwd
15+
COPY --from=builder /etc/group /etc/group
16+
COPY --from=builder /app/bin/govoyage-server .
17+
EXPOSE 8080 8090
18+
CMD ["/govoyage-server"]

‎govoyage/cmd/server/server.go

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515

1616
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
1717
"github.com/prometheus/client_golang/prometheus"
18+
"github.com/prometheus/client_golang/prometheus/promhttp"
1819
"github.com/swaggest/swgui/v5emb"
1920
clientv3 "go.etcd.io/etcd/client/v3"
2021
"go.etcd.io/etcd/server/v3/proxy/grpcproxy"
@@ -190,6 +191,9 @@ func registerService(addr string) error {
190191
func runHTTPServer() *http.ServeMux {
191192
mux := http.NewServeMux()
192193

194+
// * Register metrics endpoint
195+
mux.Handle("/metrics", promhttp.Handler())
196+
193197
// * Register index handler
194198
mux.HandleFunc("/index", func(w http.ResponseWriter, r *http.Request) {
195199
w.Write([]byte(index))

‎govoyage/pbgen/common.pb.go

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

‎govoyage/pbgen/greet.pb.go

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

‎govoyage/pbgen/greet.pb.gw.go

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

0 commit comments

Comments
 (0)