diff options
Diffstat (limited to 'server/collector.go')
-rw-r--r-- | server/collector.go | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/server/collector.go b/server/collector.go index 583a1999..59f945be 100644 --- a/server/collector.go +++ b/server/collector.go @@ -111,11 +111,11 @@ func path2data(path *table.Path) (map[string]interface{}, map[string]string) { } if err := bgp.FlatUpdate(tags, path.GetNlri().Flat()); err != nil { - log.Error(err) + log.WithFields(log.Fields{"Type": "collector", "Error": err}).Error("NLRI FlatUpdate failed") } for _, p := range path.GetPathAttrs() { if err := bgp.FlatUpdate(tags, p.Flat()); err != nil { - log.Error(err) + log.WithFields(log.Fields{"Type": "collector", "Error": err}).Error("PathAttr FlatUpdate failed") } } return fields, tags @@ -173,15 +173,15 @@ func (c *Collector) loop() { switch msg := ev.(type) { case *WatchEventUpdate: if err := c.writeUpdate(msg); err != nil { - log.Error(err) + log.WithFields(log.Fields{"Type": "collector", "Error": err}).Error("Failed to write update event message") } case *WatchEventPeerState: if err := c.writePeer(msg); err != nil { - log.Error(err) + log.WithFields(log.Fields{"Type": "collector", "Error": err}).Error("Failed to write state changed event message") } case *WatchEventAdjIn: if err := c.writeTable(msg); err != nil { - log.Error(err) + log.WithFields(log.Fields{"Type": "collector", "Error": err}).Error("Failed to write Adj-In event message") } } } @@ -199,12 +199,13 @@ func NewCollector(s *BgpServer, url, dbName string, interval uint64) (*Collector _, _, err = c.Ping(0) if err != nil { log.Error("can not connect to InfluxDB") + log.WithFields(log.Fields{"Type": "collector", "Error": err}).Error("Failed to connect to InfluxDB") return nil, err } q := client.NewQuery("CREATE DATABASE "+dbName, "", "") if response, err := c.Query(q); err != nil || response.Error() != nil { - log.Error("can not create database " + dbName) + log.WithFields(log.Fields{"Type": "collector", "Error": err}).Errorf("Failed to create database:%s", dbName) return nil, err } |