Skip to content

Commit

Permalink
disruption: print request/response details to stdout when request fails
Browse files Browse the repository at this point in the history
  • Loading branch information
vrutkovs committed Nov 12, 2024
1 parent be39fc8 commit 8d5ab56
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions pkg/disruption/backend/sampler/producer_consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package sampler
import (
"context"
"fmt"
"os"

"github.com/openshift/origin/pkg/disruption/backend"
"github.com/openshift/origin/pkg/disruption/sampler"
Expand Down Expand Up @@ -57,6 +58,21 @@ func (pc *producerConsumer) Produce(stop context.Context, sampleID uint64) (inte

resp, err := pc.client.Do(req)
if err != nil {
fmt.Fprintln(os.Stdout, "---")
fmt.Fprintf(os.Stdout, "Request URL: %s\n", req.URL)
fmt.Fprintf(os.Stdout, "Request Host: %s\n", req.Host)
fmt.Fprintln(os.Stdout, "Request Headers:")
for k, v := range req.Header {
fmt.Fprintf(os.Stdout, " %s: %v\n", k, v)
}
fmt.Fprintf(os.Stdout, "Response status: %s\n", resp.Status)
fmt.Fprintln(os.Stdout, "Response Headers:")
for k, v := range resp.Header {
fmt.Fprintf(os.Stdout, " %s: %v\n", k, v)
}
fmt.Fprintf(os.Stdout, "Response body: %d\n", resp.Body)
fmt.Fprintln(os.Stdout, "---")

return rr, pc.checker.CheckError(err)
}
rr.Response = resp
Expand Down

0 comments on commit 8d5ab56

Please sign in to comment.