Skip to content

Commit

Permalink
missing response time in docker provider
Browse files Browse the repository at this point in the history
  • Loading branch information
umputun committed Feb 6, 2022
1 parent a6e41b3 commit b5e3919
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 5 additions & 3 deletions app/status/external/docker_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type DockerProvider struct {
// i.e. docker:///var/run/docker.sock?containers=foo,bar
func (d *DockerProvider) Status(req Request) (*Response, error) {

st := time.Now()
u := strings.Replace(req.URL, "docker://", "tcp://", 1)
if strings.HasPrefix(req.URL, "docker:///") { // i.e. docker:///var/run/docker.sock
u = strings.Replace(req.URL, "docker://", "unix://", 1)
Expand Down Expand Up @@ -68,9 +69,10 @@ func (d *DockerProvider) Status(req Request) (*Response, error) {
}

result := Response{
Name: req.Name,
StatusCode: resp.StatusCode,
Body: dkinfo,
Name: req.Name,
StatusCode: resp.StatusCode,
Body: dkinfo,
ResponseTime: time.Since(st).Milliseconds(),
}
return &result, nil
}
Expand Down
1 change: 1 addition & 0 deletions app/status/external/docker_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func TestDockerProvider_Status(t *testing.T) {
resp, err := p.Status(Request{Name: "d1", URL: strings.Replace(ts.URL, "http://", "tcp://", 1)})
require.NoError(t, err)
assert.Equal(t, 200, resp.StatusCode)
assert.True(t, resp.ResponseTime > 1, resp.ResponseTime)
}

func TestDockerProvider_StatusWithRequired(t *testing.T) {
Expand Down

0 comments on commit b5e3919

Please sign in to comment.