Skip to content

Commit

Permalink
fix: adapted disableServer config in server tracer
Browse files Browse the repository at this point in the history
  • Loading branch information
AH-dark committed Sep 29, 2023
1 parent a784486 commit c6f3c75
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,17 @@ func NewServerTracer(addr, path string, options ...Option) stats.Tracer {
opt.apply(cfg)
}

cfg.serveMux.Handle(path, promhttp.HandlerFor(cfg.registry, promhttp.HandlerOpts{
ErrorHandling: promhttp.ContinueOnError,
Registry: cfg.registry,
}))
go func() {
if err := http.ListenAndServe(addr, cfg.serveMux); err != nil {
log.Fatal("Unable to start a promhttp server, err: " + err.Error())
}
}()
if !cfg.disableServer {
cfg.serveMux.Handle(path, promhttp.HandlerFor(cfg.registry, promhttp.HandlerOpts{
ErrorHandling: promhttp.ContinueOnError,
Registry: cfg.registry,
}))
go func() {
if err := http.ListenAndServe(addr, cfg.serveMux); err != nil {
log.Fatal("Unable to start a promhttp server, err: " + err.Error())
}
}()
}

serverHandledCounter := prom.NewCounterVec(
prom.CounterOpts{
Expand Down

0 comments on commit c6f3c75

Please sign in to comment.