From d3fb3eeaddefb208dcc332a151899a02db839c44 Mon Sep 17 00:00:00 2001 From: SteelPhase Date: Thu, 19 Aug 2021 18:07:23 -0400 Subject: [PATCH 1/3] convert to github.com/rabbitmq/amqp091-go --- examples/go.sum | 2 +- go.mod | 2 +- go.sum | 9 ++------- reporter/amqp/amqp.go | 15 +++++++-------- reporter/amqp/amqp_test.go | 9 +++++---- 5 files changed, 16 insertions(+), 21 deletions(-) diff --git a/examples/go.sum b/examples/go.sum index 34b28552..1747e275 100644 --- a/examples/go.sum +++ b/examples/go.sum @@ -41,8 +41,8 @@ github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1Cpa github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/rabbitmq/amqp091-go v0.0.0-20210812094702-b2a427eb7d17/go.mod h1:ogQDLSOACsLPsIq0NpbtiifNZi2YOz0VTJ0kHRghqbM= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= -github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= diff --git a/go.mod b/go.mod index 13df577e..805e091b 100644 --- a/go.mod +++ b/go.mod @@ -12,8 +12,8 @@ require ( github.com/onsi/ginkgo v1.7.0 github.com/onsi/gomega v1.4.3 github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1 // indirect + github.com/rabbitmq/amqp091-go v0.0.0-20210812094702-b2a427eb7d17 github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a // indirect - github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94 google.golang.org/grpc v1.30.0 google.golang.org/protobuf v1.25.0 ) diff --git a/go.sum b/go.sum index 695b989f..335cecc7 100644 --- a/go.sum +++ b/go.sum @@ -21,10 +21,8 @@ github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1m github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= @@ -55,10 +53,10 @@ github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1 h1:VGcrWe3yk6o+t7BdV github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/rabbitmq/amqp091-go v0.0.0-20210812094702-b2a427eb7d17 h1:3HQ5TTZU56EjMWPU0K0Nqz1aakOLQUwV4lZ6tNxtXvc= +github.com/rabbitmq/amqp091-go v0.0.0-20210812094702-b2a427eb7d17/go.mod h1:ogQDLSOACsLPsIq0NpbtiifNZi2YOz0VTJ0kHRghqbM= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a h1:9ZKAASQSHhDYGoxY8uLVpewe1GDZ2vu2Tr/vTdVAkFQ= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= -github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94 h1:0ngsPmuP6XIjiFRNFYlvKwSr5zff2v+uPHaffZ6/M4k= -github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -72,7 +70,6 @@ golang.org/x/net v0.0.0-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJV golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181108010431-42b317875d0f h1:Bl/8QSvNqXvPGPGXa2z5xUTmV7VDcZyvRZ+QQXkXTZQ= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -89,7 +86,6 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IV golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8 h1:Nw54tB0rB7hY/N0NQvRW8DG4Yk3Q6T9cu9RcFQDu1tc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY= @@ -97,7 +93,6 @@ google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEY google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= -google.golang.org/grpc v1.27.0 h1:rRYRFMVgRv6E0D70Skyfsr28tDXIuuPZyWGMPdMcnXg= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.30.0 h1:M5a8xTlYTxwMn5ZFkwhRabsygDY5G8TYLyQDBxJNAxE= google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= diff --git a/reporter/amqp/amqp.go b/reporter/amqp/amqp.go index 5aca7f15..bec3c5c0 100644 --- a/reporter/amqp/amqp.go +++ b/reporter/amqp/amqp.go @@ -9,10 +9,9 @@ import ( "log" "os" - "github.com/streadway/amqp" - "github.com/openzipkin/zipkin-go/model" "github.com/openzipkin/zipkin-go/reporter" + "github.com/rabbitmq/amqp091-go" ) // defaultRmqRoutingKey/Exchange/Kind sets the standard RabbitMQ queue our Reporter will publish on. @@ -25,8 +24,8 @@ const ( // rmqReporter implements Reporter by publishing spans to a RabbitMQ exchange type rmqReporter struct { e chan error - channel *amqp.Channel - conn *amqp.Connection + channel *amqp091.Channel + conn *amqp091.Connection exchange string queue string logger *log.Logger @@ -60,14 +59,14 @@ func Queue(queue string) ReporterOption { } // Channel sets the Channel used to send messages -func Channel(ch *amqp.Channel) ReporterOption { +func Channel(ch *amqp091.Channel) ReporterOption { return func(c *rmqReporter) { c.channel = ch } } // Connection sets the Connection used to send messages -func Connection(conn *amqp.Connection) ReporterOption { +func Connection(conn *amqp091.Connection) ReporterOption { return func(c *rmqReporter) { c.conn = conn } @@ -95,7 +94,7 @@ func NewReporter(address string, options ...ReporterOption) (reporter.Reporter, var err error if r.conn == nil { - r.conn, err = amqp.Dial(address) + r.conn, err = amqp091.Dial(address) if err != nil { return nil, err } @@ -134,7 +133,7 @@ func (r *rmqReporter) Send(s model.SpanModel) { return } - msg := amqp.Publishing{ + msg := amqp091.Publishing{ Body: m, } diff --git a/reporter/amqp/amqp_test.go b/reporter/amqp/amqp_test.go index 6a1b84c9..6ac262c8 100644 --- a/reporter/amqp/amqp_test.go +++ b/reporter/amqp/amqp_test.go @@ -1,3 +1,4 @@ +//go:build !windows // +build !windows package amqp_test @@ -9,7 +10,7 @@ import ( "github.com/openzipkin/zipkin-go/model" zipkinamqp "github.com/openzipkin/zipkin-go/reporter/amqp" - "github.com/streadway/amqp" + "github.com/rabbitmq/amqp091-go" ) var spans = []*model.SpanModel{ @@ -55,9 +56,9 @@ func TestRabbitClose(t *testing.T) { } } -func setupRabbit(t *testing.T, address string) (conn *amqp.Connection, ch *amqp.Channel, close func()) { +func setupRabbit(t *testing.T, address string) (conn *amqp091.Connection, ch *amqp091.Channel, close func()) { var err error - conn, err = amqp.Dial(address) + conn, err = amqp091.Dial(address) failOnError(t, err, "Failed to connect to RabbitMQ") ch, err = conn.Channel() @@ -70,7 +71,7 @@ func setupRabbit(t *testing.T, address string) (conn *amqp.Connection, ch *amqp. return } -func setupConsume(t *testing.T, ch *amqp.Channel) <-chan amqp.Delivery { +func setupConsume(t *testing.T, ch *amqp091.Channel) <-chan amqp091.Delivery { csm, err := ch.Consume( "zipkin", "", From 6b75ad747139d8a5f5751341423158e596ce94fd Mon Sep 17 00:00:00 2001 From: SteelPhase Date: Thu, 19 Aug 2021 18:16:07 -0400 Subject: [PATCH 2/3] use amqp alias to reduce change noise --- reporter/amqp/amqp.go | 14 +++++++------- reporter/amqp/amqp_test.go | 8 ++++---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/reporter/amqp/amqp.go b/reporter/amqp/amqp.go index bec3c5c0..db5bec8d 100644 --- a/reporter/amqp/amqp.go +++ b/reporter/amqp/amqp.go @@ -11,7 +11,7 @@ import ( "github.com/openzipkin/zipkin-go/model" "github.com/openzipkin/zipkin-go/reporter" - "github.com/rabbitmq/amqp091-go" + amqp "github.com/rabbitmq/amqp091-go" ) // defaultRmqRoutingKey/Exchange/Kind sets the standard RabbitMQ queue our Reporter will publish on. @@ -24,8 +24,8 @@ const ( // rmqReporter implements Reporter by publishing spans to a RabbitMQ exchange type rmqReporter struct { e chan error - channel *amqp091.Channel - conn *amqp091.Connection + channel *amqp.Channel + conn *amqp.Connection exchange string queue string logger *log.Logger @@ -59,14 +59,14 @@ func Queue(queue string) ReporterOption { } // Channel sets the Channel used to send messages -func Channel(ch *amqp091.Channel) ReporterOption { +func Channel(ch *amqp.Channel) ReporterOption { return func(c *rmqReporter) { c.channel = ch } } // Connection sets the Connection used to send messages -func Connection(conn *amqp091.Connection) ReporterOption { +func Connection(conn *amqp.Connection) ReporterOption { return func(c *rmqReporter) { c.conn = conn } @@ -94,7 +94,7 @@ func NewReporter(address string, options ...ReporterOption) (reporter.Reporter, var err error if r.conn == nil { - r.conn, err = amqp091.Dial(address) + r.conn, err = amqp.Dial(address) if err != nil { return nil, err } @@ -133,7 +133,7 @@ func (r *rmqReporter) Send(s model.SpanModel) { return } - msg := amqp091.Publishing{ + msg := amqp.Publishing{ Body: m, } diff --git a/reporter/amqp/amqp_test.go b/reporter/amqp/amqp_test.go index 6ac262c8..e0361d1f 100644 --- a/reporter/amqp/amqp_test.go +++ b/reporter/amqp/amqp_test.go @@ -10,7 +10,7 @@ import ( "github.com/openzipkin/zipkin-go/model" zipkinamqp "github.com/openzipkin/zipkin-go/reporter/amqp" - "github.com/rabbitmq/amqp091-go" + amqp "github.com/rabbitmq/amqp091-go" ) var spans = []*model.SpanModel{ @@ -56,9 +56,9 @@ func TestRabbitClose(t *testing.T) { } } -func setupRabbit(t *testing.T, address string) (conn *amqp091.Connection, ch *amqp091.Channel, close func()) { +func setupRabbit(t *testing.T, address string) (conn *amqp.Connection, ch *amqp.Channel, close func()) { var err error - conn, err = amqp091.Dial(address) + conn, err = amqp.Dial(address) failOnError(t, err, "Failed to connect to RabbitMQ") ch, err = conn.Channel() @@ -71,7 +71,7 @@ func setupRabbit(t *testing.T, address string) (conn *amqp091.Connection, ch *am return } -func setupConsume(t *testing.T, ch *amqp091.Channel) <-chan amqp091.Delivery { +func setupConsume(t *testing.T, ch *amqp.Channel) <-chan amqp.Delivery { csm, err := ch.Consume( "zipkin", "", From 12c2a6c35535bfd6bd4b62dfa2a644e44eaabe4c Mon Sep 17 00:00:00 2001 From: SteelPhase Date: Thu, 19 Aug 2021 18:17:08 -0400 Subject: [PATCH 3/3] fix import location --- reporter/amqp/amqp.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/reporter/amqp/amqp.go b/reporter/amqp/amqp.go index db5bec8d..410f97a2 100644 --- a/reporter/amqp/amqp.go +++ b/reporter/amqp/amqp.go @@ -9,9 +9,10 @@ import ( "log" "os" + amqp "github.com/rabbitmq/amqp091-go" + "github.com/openzipkin/zipkin-go/model" "github.com/openzipkin/zipkin-go/reporter" - amqp "github.com/rabbitmq/amqp091-go" ) // defaultRmqRoutingKey/Exchange/Kind sets the standard RabbitMQ queue our Reporter will publish on.