Replace prometheus with a stub. sigh

This commit is contained in:
Kegan Dougal 2020-02-24 17:53:02 +00:00
parent 68cf00d0ce
commit 48c7e3c172
7 changed files with 73 additions and 4 deletions

View file

@ -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
View file

@ -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
View file

@ -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
View file

@ -0,0 +1,3 @@
module github.com/prometheus/client_golang
go 1.13

View 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
}

View 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{}
}

View 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)
})
}