func (api *API) do(req *http.Request) (resp *http.Response, err error) { req.Header.Add("X-Api-Key", api.APIKey) req.Header.Add("X-Agent-Version", version.VERSION) req.Header.Add("X-Revision", version.GITCOMMIT) req.Header.Set("User-Agent", version.UserAgent()) if api.Verbose { dump, err := httputil.DumpRequest(req, true) if err == nil { logger.Tracef("%s", dump) } } client := &http.Client{} // same as http.DefaultClient client.Timeout = apiRequestTimeout resp, err = client.Do(req) if err != nil { return nil, err } if api.Verbose { dump, err := httputil.DumpResponse(resp, true) if err == nil { logger.Tracef("%s", dump) } } return resp, nil }
// Collect XXX func Collect(specGenerators []Generator) map[string]interface{} { specs := make(map[string]interface{}) for _, g := range specGenerators { value, err := g.Generate() if err != nil { logger.Errorf("Failed to collect meta in %T (skip this spec): %s", g, err.Error()) continue } specs[g.Key()] = value } specs["agent-version"] = version.VERSION specs["agent-revision"] = version.GITCOMMIT specs["agent-name"] = version.UserAgent() return specs }