Created
March 13, 2015 18:12
-
-
Save alex/0e3834ab35b406a6e69c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/agent.go b/agent.go | |
index bcc6d74..5188ace 100644 | |
--- a/agent.go | |
+++ b/agent.go | |
@@ -122,11 +122,16 @@ type RequestResult struct { | |
} | |
// PerformRequest makes a request to VBMS and returns summarized results | |
-func PerformRequest(config *Config) RequestResult { | |
+func PerformRequest(logger *logrus.Logger, config *Config) RequestResult { | |
client := &http.Client{ | |
Timeout: RequestTimeout, | |
} | |
start := time.Now() | |
+ | |
+ logger.WithFields(logrus.Fields{ | |
+ "url": config.VBMSURL, | |
+ }).Info("request.start") | |
+ | |
response, err := client.Get(config.VBMSURL) | |
status := 0 | |
if err == nil { | |
@@ -135,6 +140,11 @@ func PerformRequest(config *Config) RequestResult { | |
ioutil.ReadAll(response.Body) | |
} | |
elapsed := time.Now().Sub(start) | |
+ | |
+ logger.WithFields(logrus.Fields{ | |
+ "url": config.VBMSURL, | |
+ }).Info("request.completed") | |
+ | |
return RequestResult{ | |
Success: err == nil, | |
StatusCode: status, | |
@@ -151,7 +161,7 @@ func RecordResult(config *Config, result RequestResult) { | |
// LaunchPoller starts the thing which polls for changes | |
func LaunchPoller(logger *logrus.Logger, config *Config) { | |
for _ = range time.Tick(PollFrequency) { | |
- result := PerformRequest(config) | |
+ result := PerformRequest(logger, config) | |
RecordResult(config, result) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment