func NewService(c Config, l *log.Logger) *Service { client := client.New("") client.URL = c.URL return &Service{ client: client, logger: l, } }
// reportServer reports anonymous statistics about the system. func (s *Server) reportServer() { dis, err := s.MetaClient.Databases() if err != nil { log.Printf("failed to retrieve databases for reporting: %s", err.Error()) return } numDatabases := len(dis) numMeasurements := 0 numSeries := 0 // Only needed in the case of a data node if s.TSDBStore != nil { for _, di := range dis { d := s.TSDBStore.DatabaseIndex(di.Name) if d == nil { // No data in this store for this database. continue } m, s := d.MeasurementSeriesCounts() numMeasurements += m numSeries += s } } clusterID := s.MetaClient.ClusterID() if err != nil { log.Printf("failed to retrieve cluster ID for reporting: %s", err.Error()) return } cl := client.New("") usage := client.Usage{ Product: "influxdb", Data: []client.UsageData{ { Values: client.Values{ "os": runtime.GOOS, "arch": runtime.GOARCH, "version": s.buildInfo.Version, "server_id": fmt.Sprintf("%v", s.Node.ID), "cluster_id": fmt.Sprintf("%v", clusterID), "num_series": numSeries, "num_measurements": numMeasurements, "num_databases": numDatabases, "uptime": time.Since(startTime).Seconds(), }, }, }, } log.Printf("Sending anonymous usage statistics to m.influxdb.com") go cl.Save(usage) }