summaryrefslogtreecommitdiff
path: root/internal/gitlabnet/client.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/gitlabnet/client.go')
-rw-r--r--internal/gitlabnet/client.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/internal/gitlabnet/client.go b/internal/gitlabnet/client.go
index bb8655a..7c8f431 100644
--- a/internal/gitlabnet/client.go
+++ b/internal/gitlabnet/client.go
@@ -8,8 +8,11 @@ import (
"io"
"net/http"
"strings"
+ "time"
+ log "github.com/sirupsen/logrus"
"gitlab.com/gitlab-org/gitlab-shell/internal/config"
+ "gitlab.com/gitlab-org/gitlab-shell/internal/logger"
)
const (
@@ -111,15 +114,26 @@ func (c *GitlabClient) DoRequest(method, path string, data interface{}) (*http.R
request.Header.Add("Content-Type", "application/json")
request.Close = true
+ start := time.Now()
response, err := c.httpClient.Do(request)
+ fields := log.Fields{
+ "method": method,
+ "url": request.URL.String(),
+ "duration_ms": logger.ElapsedTime(start),
+ }
+
if err != nil {
+ log.WithError(err).WithFields(fields).Error("Internal API unreachable")
return nil, fmt.Errorf("Internal API unreachable")
}
if err := parseError(response); err != nil {
+ log.WithError(err).WithFields(fields).Error("Internal API error")
return nil, err
}
+ log.WithFields(fields).Info("Finished HTTP request")
+
return response, nil
}