Skip to content

Commit

Permalink
added prometheus metrics exporter
Browse files Browse the repository at this point in the history
  • Loading branch information
somnathbm committed Nov 27, 2024
1 parent c702a69 commit 3d68d13
Show file tree
Hide file tree
Showing 3 changed files with 476 additions and 4 deletions.
11 changes: 11 additions & 0 deletions src/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,23 @@ import (

"github.com/gin-gonic/gin"

"github.com/penglongli/gin-metrics/ginmetrics"

"hms_patient_mgmt_svc/models"
)

func Api() {
server := gin.Default()

// get global monitor object
monitor := ginmetrics.GetMonitor()

// set metric path
monitor.SetMetricPath("/metrics")

// use the monitor
monitor.Use(server)

// for service liveness check
server.GET("/healthy", func(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{
Expand Down
19 changes: 15 additions & 4 deletions src/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ go 1.22.0
toolchain go1.22.9

require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/bits-and-blooms/bitset v1.2.0 // indirect
github.com/bytedance/sonic v1.11.6 // indirect
github.com/bytedance/sonic/loader v0.1.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cloudwego/base64x v0.1.4 // indirect
github.com/cloudwego/iasm v0.2.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
Expand All @@ -16,6 +19,7 @@ require (
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.20.0 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/joho/godotenv v1.5.1 // indirect
Expand All @@ -24,9 +28,16 @@ require (
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/penglongli/gin-metrics v0.1.12 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_golang v1.12.0 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.32.1 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.12 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
Expand All @@ -36,11 +47,11 @@ require (
go.mongodb.org/mongo-driver v1.17.1 // indirect
go.mongodb.org/mongo-driver/v2 v2.0.0-beta2 // indirect
golang.org/x/arch v0.8.0 // indirect
golang.org/x/crypto v0.27.0 // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/crypto v0.28.0 // indirect
golang.org/x/net v0.30.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/text v0.18.0 // indirect
golang.org/x/sys v0.26.0 // indirect
golang.org/x/text v0.19.0 // indirect
google.golang.org/protobuf v1.34.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 3d68d13

Please sign in to comment.