Skip to content

Commit

Permalink
fix: panic when probe fails
Browse files Browse the repository at this point in the history
  • Loading branch information
hrenard committed Aug 12, 2022
1 parent a2e9df7 commit 20e04da
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
7 changes: 3 additions & 4 deletions pkg/jicofo/jicofo.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@ import (

"github.com/jitsi-contrib/jitsi-exporter/pkg/generic"
"github.com/prometheus/client_golang/prometheus"
"github.com/sirupsen/logrus"
log "github.com/sirupsen/logrus"
"github.com/tidwall/gjson"
)

type prober struct {
client *http.Client
target string
log *logrus.Logger
}

func NewProber(client *http.Client, target string) generic.Prober {
Expand All @@ -37,14 +36,14 @@ func (p *prober) Labels() []string {
func (c *prober) Probe() (string, bool) {
resp, err := c.client.Get(c.target)
if err != nil {
c.log.Error(err)
log.Error(err)
return "", false
}
defer resp.Body.Close()

data, err := io.ReadAll(resp.Body)
if err != nil {
c.log.Error(err)
log.Error(err)
return "", false
}

Expand Down
7 changes: 3 additions & 4 deletions pkg/jvb/jvb.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ import (

"github.com/jitsi-contrib/jitsi-exporter/pkg/generic"
"github.com/prometheus/client_golang/prometheus"
"github.com/sirupsen/logrus"
log "github.com/sirupsen/logrus"
)

type prober struct {
client *http.Client
target string
log *logrus.Logger
}

func NewProber(client *http.Client, target string) generic.Prober {
Expand All @@ -37,14 +36,14 @@ func (p *prober) Labels() []string {
func (c *prober) Probe() (string, bool) {
resp, err := c.client.Get(c.target)
if err != nil {
c.log.Error(err)
log.Error(err)
return "", false
}
defer resp.Body.Close()

data, err := io.ReadAll(resp.Body)
if err != nil {
c.log.Error(err)
log.Error(err)
return "", false
}

Expand Down

0 comments on commit 20e04da

Please sign in to comment.