diff --git a/middleware/http/transport.go b/middleware/http/transport.go index af029186..6fd2972d 100644 --- a/middleware/http/transport.go +++ b/middleware/http/transport.go @@ -56,7 +56,7 @@ type transport struct { defaultTags map[string]string errHandler ErrHandler errResponseReader *ErrResponseReader - logger *log.Logger + logger zipkin.Logger requestSampler RequestSamplerFunc remoteEndpoint *model.Endpoint } @@ -115,6 +115,13 @@ func TransportLogger(l *log.Logger) TransportOption { } } +// TransportZipkinLogger allows to plug a logger into the transport +func TransportZipkinLogger(l zipkin.Logger) TransportOption { + return func(t *transport) { + t.logger = l + } +} + // TransportRequestSampler allows one to set the sampling decision based on // the details found in the http.Request. It has preference over the existing // sampling decision contained in the context. The function returns a *bool, diff --git a/reporter/amqp/amqp.go b/reporter/amqp/amqp.go index 5aca7f15..ff146388 100644 --- a/reporter/amqp/amqp.go +++ b/reporter/amqp/amqp.go @@ -11,6 +11,7 @@ import ( "github.com/streadway/amqp" + "github.com/openzipkin/zipkin-go" "github.com/openzipkin/zipkin-go/model" "github.com/openzipkin/zipkin-go/reporter" ) @@ -29,7 +30,7 @@ type rmqReporter struct { conn *amqp.Connection exchange string queue string - logger *log.Logger + logger zipkin.Logger } // ReporterOption sets a parameter for the rmqReporter @@ -43,6 +44,14 @@ func Logger(logger *log.Logger) ReporterOption { } } +// GenericLogger sets the logger used to report errors in the collection +// process. +func GenericLogger(logger zipkin.Logger) ReporterOption { + return func(c *rmqReporter) { + c.logger = logger + } +} + // Exchange sets the Exchange used to send messages ( // see https://github.com/openzipkin/zipkin/tree/master/zipkin-collector/rabbitmq // if want to change default routing key or exchange diff --git a/reporter/http/http.go b/reporter/http/http.go index a01f6899..69816f18 100644 --- a/reporter/http/http.go +++ b/reporter/http/http.go @@ -26,6 +26,7 @@ import ( "sync" "time" + "github.com/openzipkin/zipkin-go" "github.com/openzipkin/zipkin-go/model" "github.com/openzipkin/zipkin-go/reporter" ) @@ -47,7 +48,7 @@ type HTTPDoer interface { type httpReporter struct { url string client HTTPDoer - logger *log.Logger + logger zipkin.Logger batchInterval time.Duration batchSize int maxBacklog int @@ -233,6 +234,12 @@ func Logger(l *log.Logger) ReporterOption { return func(r *httpReporter) { r.logger = l } } +// GenericLogger sets the logger used to report errors in the collection +// process. +func GenericLogger(l zipkin.Logger) ReporterOption { + return func(r *httpReporter) { r.logger = l } +} + // Serializer sets the serialization function to use for sending span data to // Zipkin. func Serializer(serializer reporter.SpanSerializer) ReporterOption { diff --git a/reporter/kafka/kafka.go b/reporter/kafka/kafka.go index e4ca50ce..8130759f 100644 --- a/reporter/kafka/kafka.go +++ b/reporter/kafka/kafka.go @@ -22,6 +22,7 @@ import ( "os" "github.com/Shopify/sarama" + "github.com/openzipkin/zipkin-go" "github.com/openzipkin/zipkin-go/model" "github.com/openzipkin/zipkin-go/reporter" ) @@ -35,7 +36,7 @@ const defaultKafkaTopic = "zipkin" // broker. type kafkaReporter struct { producer sarama.AsyncProducer - logger *log.Logger + logger zipkin.Logger topic string serializer reporter.SpanSerializer } @@ -51,6 +52,14 @@ func Logger(logger *log.Logger) ReporterOption { } } +// GenericLogger sets the logger used to report errors in the collection +// process. +func GenericLogger(logger zipkin.Logger) ReporterOption { + return func(c *kafkaReporter) { + c.logger = logger + } +} + // Producer sets the producer used to produce to Kafka. For tweaking // the reporting settings (e.g. reporting timeout or authentication) // check the sarama.Config struct.