mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-16 11:23:11 -06:00
Replace prometheus with a stub. sigh
This commit is contained in:
parent
68cf00d0ce
commit
48c7e3c172
|
|
@ -16,6 +16,7 @@ package main
|
|||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/matrix-org/dendrite/appservice"
|
||||
|
|
@ -33,12 +34,15 @@ import (
|
|||
"github.com/matrix-org/dendrite/typingserver"
|
||||
"github.com/matrix-org/dendrite/typingserver/cache"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
_ "github.com/matrix-org/go-sqlite3-js"
|
||||
)
|
||||
|
||||
func init() {
|
||||
fmt.Println("dendrite.js starting...")
|
||||
}
|
||||
|
||||
var (
|
||||
httpBindAddr = flag.String("http-bind-address", ":8008", "The HTTP listening port for the server")
|
||||
httpsBindAddr = flag.String("https-bind-address", ":8448", "The HTTPS listening port for the server")
|
||||
|
|
@ -76,9 +80,6 @@ func main() {
|
|||
|
||||
httpHandler := common.WrapHandlerInCORS(base.APIMux)
|
||||
|
||||
// Set up the API endpoints we handle. /metrics is for prometheus, and is
|
||||
// not wrapped by CORS, while everything else is
|
||||
http.Handle("/metrics", promhttp.Handler())
|
||||
http.Handle("/", httpHandler)
|
||||
|
||||
// Expose the matrix APIs directly rather than putting them under a /api path.
|
||||
|
|
|
|||
2
go.mod
2
go.mod
|
|
@ -2,6 +2,8 @@ module github.com/matrix-org/dendrite
|
|||
|
||||
replace github.com/lib/pq => github.com/matrix-org/pq v1.3.2
|
||||
|
||||
replace github.com/prometheus/client_golang => ./prometheus
|
||||
|
||||
require (
|
||||
github.com/DataDog/zstd v1.4.4 // indirect
|
||||
github.com/Shopify/toxiproxy v2.1.4+incompatible // indirect
|
||||
|
|
|
|||
1
go.sum
1
go.sum
|
|
@ -178,6 +178,7 @@ golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5h
|
|||
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894 h1:Cz4ceDQGXuKRnVBDTS23GTn/pU5OE2C0WrNTOYK1Uuc=
|
||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191010194322-b09406accb47 h1:/XfQ9z7ib8eEJX2hdgFTZJ/ntt0swNk5oYBziWeTCvY=
|
||||
golang.org/x/sys v0.0.0-20191010194322-b09406accb47/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
|
|
|
|||
3
prometheus/go.mod
Normal file
3
prometheus/go.mod
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
module github.com/prometheus/client_golang
|
||||
|
||||
go 1.13
|
||||
7
prometheus/prometheus/promauto/promauto.go
Normal file
7
prometheus/prometheus/promauto/promauto.go
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
package promauto
|
||||
|
||||
import "github.com/prometheus/client_golang/prometheus"
|
||||
|
||||
func NewCounterVec(opts prometheus.CounterOpts, arr []string) *prometheus.CounterVec {
|
||||
return nil
|
||||
}
|
||||
38
prometheus/prometheus/prometheus.go
Normal file
38
prometheus/prometheus/prometheus.go
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
package prometheus
|
||||
|
||||
type CounterOpts struct {
|
||||
Name string
|
||||
Help string
|
||||
}
|
||||
type SummaryOpts struct {
|
||||
Namespace string
|
||||
Subsystem string
|
||||
Name string
|
||||
Help string
|
||||
}
|
||||
|
||||
type CounterVec struct{}
|
||||
|
||||
type Collector interface {
|
||||
WithLabelValues(a string, b string) Collector
|
||||
Observe(c float64)
|
||||
Inc()
|
||||
}
|
||||
|
||||
type col struct{}
|
||||
|
||||
func (c col) WithLabelValues(a, b string) Collector {
|
||||
return c
|
||||
}
|
||||
func (c col) Observe(d float64) {}
|
||||
func (c col) Inc() {}
|
||||
|
||||
func NewSummaryVec(opts SummaryOpts, arr []string) Collector {
|
||||
return col{}
|
||||
}
|
||||
|
||||
func MustRegister(...Collector) {}
|
||||
|
||||
func NewCounter(opt CounterOpts) col {
|
||||
return col{}
|
||||
}
|
||||
17
prometheus/prometheus/promhttp/promhttp.go
Normal file
17
prometheus/prometheus/promhttp/promhttp.go
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
package promhttp
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
func InstrumentHandlerCounter(v *prometheus.CounterVec, next http.Handler) http.HandlerFunc {
|
||||
return next.ServeHTTP
|
||||
}
|
||||
|
||||
func Handler() http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(400)
|
||||
})
|
||||
}
|
||||
Loading…
Reference in a new issue