Skip to content

Commit

Permalink
Trace HTTP responses even in the case of errors
Browse files Browse the repository at this point in the history
This closes long standing issues #297 and #553.
  • Loading branch information
olivere committed Jul 18, 2017
1 parent 8f4f2ff commit 99e76ec
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ Naoya Tsutsumi [@tutuming](https://github.com/tutuming)
Nicholas Wolff [@nwolff](https://github.com/nwolff)
Nick K [@utrack](https://github.com/utrack)
Nick Whyte [@nickw444](https://github.com/nickw444)
Nicolae Vartolomei [@nvartolomei](https://github.com/nvartolomei)
Orne Brocaar [@brocaar](https://github.com/brocaar)
Pete C [@peteclark-ft](https://github.com/peteclark-ft)
Radoslaw Wesolowski [r--w](https://github.com/r--w)
Expand Down
2 changes: 1 addition & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (

const (
// Version is the current version of Elastic.
Version = "5.0.41"
Version = "5.0.42"

// DefaultURL is the default endpoint of Elasticsearch on the local machine.
// It is used e.g. when initializing a new Client without a specific URL.
Expand Down
16 changes: 16 additions & 0 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -973,6 +973,22 @@ func TestPerformRequestWithLoggerAndTracer(t *testing.T) {
t.Errorf("expected tracer output; got: %q", tgot)
}
}
func TestPerformRequestWithTracerOnError(t *testing.T) {
var tw bytes.Buffer
tout := log.New(&tw, "TRACER ", log.LstdFlags)

client, err := NewClient(SetTraceLog(tout), SetSniff(false))
if err != nil {
t.Fatal(err)
}

client.PerformRequest(context.TODO(), "GET", "/no-such-index", nil, nil)

tgot := tw.String()
if tgot == "" {
t.Errorf("expected tracer output; got: %q", tgot)
}
}

type customLogger struct {
out bytes.Buffer
Expand Down

0 comments on commit 99e76ec

Please sign in to comment.