File tree Expand file tree Collapse file tree 3 files changed +15
-1
lines changed Expand file tree Collapse file tree 3 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import (
1212
1313 "github.com/prometheus/client_golang/prometheus"
1414 "github.com/rs/zerolog"
15+ "github.com/rs/zerolog/log"
1516
1617 "github.com/Shopify/toxiproxy/v2"
1718 "github.com/Shopify/toxiproxy/v2/collectors"
@@ -68,6 +69,7 @@ func run(cli cliArguments) {
6869 }
6970
7071 logger := setupLogger ()
72+ log .Logger = logger
7173
7274 rand .Seed (cli .seed )
7375
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ go run ../test/e2e/endpoint.go 2>&1 | sed -e 's/^/[web] /' &
3737
3838echo " === Starting Toxiproxy"
3939
40- LOG_LEVEL=debug $server -proxy-metrics -runtime-metrics 2>&1 | sed -e ' s/^/[toxiproxy] /' &
40+ LOG_LEVEL=trace $server -proxy-metrics -runtime-metrics 2>&1 | sed -e ' s/^/[toxiproxy] /' &
4141
4242echo " === Wait when services are available"
4343
Original file line number Diff line number Diff line change 11package toxics
22
33import (
4+ "fmt"
45 "time"
56
7+ "github.com/rs/zerolog/log"
8+
69 "github.com/Shopify/toxiproxy/v2/stream"
710)
811
@@ -13,10 +16,17 @@ type BandwidthToxic struct {
1316}
1417
1518func (t * BandwidthToxic ) Pipe (stub * ToxicStub ) {
19+ logger := log .With ().
20+ Str ("component" , "BandwidthToxic" ).
21+ Str ("method" , "Pipe" ).
22+ Str ("toxic_type" , "bandwidth" ).
23+ Str ("addr" , fmt .Sprintf ("%p" , t )).
24+ Logger ()
1625 var sleep time.Duration = 0
1726 for {
1827 select {
1928 case <- stub .Interrupt :
29+ logger .Trace ().Msg ("BandwidthToxic was interrupted" )
2030 return
2131 case p := <- stub .Input :
2232 if p == nil {
@@ -39,6 +49,7 @@ func (t *BandwidthToxic) Pipe(stub *ToxicStub) {
3949 p .Data = p .Data [t .Rate * 100 :]
4050 sleep -= 100 * time .Millisecond
4151 case <- stub .Interrupt :
52+ logger .Trace ().Msg ("BandwidthToxic was interrupted during writing data" )
4253 stub .Output <- p // Don't drop any data on the floor
4354 return
4455 }
@@ -50,6 +61,7 @@ func (t *BandwidthToxic) Pipe(stub *ToxicStub) {
5061 sleep -= time .Since (start )
5162 stub .Output <- p
5263 case <- stub .Interrupt :
64+ logger .Trace ().Msg ("BandwidthToxic was interrupted during writing data" )
5365 stub .Output <- p // Don't drop any data on the floor
5466 return
5567 }
You can’t perform that action at this time.
0 commit comments