diff --git a/logger/go.mod b/logger/go.mod index 7dcf5e0..d431b35 100644 --- a/logger/go.mod +++ b/logger/go.mod @@ -3,16 +3,18 @@ module github.com/blacklane/go-libs/logger go 1.17 require ( - github.com/blacklane/go-libs/tracking v0.2.1 - github.com/blacklane/go-libs/x/events v0.0.5 - github.com/google/go-cmp v0.5.5 + github.com/blacklane/go-libs/tracking v0.3.0 + github.com/blacklane/go-libs/x/events v0.2.0 + github.com/google/go-cmp v0.5.6 github.com/rs/zerolog v1.20.0 ) require ( github.com/confluentinc/confluent-kafka-go v1.4.2 // indirect github.com/golang/protobuf v1.4.2 // indirect - github.com/google/uuid v1.1.1 // indirect + github.com/google/uuid v1.2.0 // indirect + go.opentelemetry.io/otel v1.0.0 // indirect + go.opentelemetry.io/otel/trace v1.0.0 // indirect golang.org/x/net v0.0.0-20200625001655-4c5254603344 // indirect golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d // indirect google.golang.org/appengine v1.6.6 // indirect diff --git a/logger/go.sum b/logger/go.sum index ff2fdf7..18a8fdd 100644 --- a/logger/go.sum +++ b/logger/go.sum @@ -1,19 +1,16 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/blacklane/go-libs/logger v0.2.0/go.mod h1:cF10lTGctsI9dlYO1Splz2isIEDKYVakibH6vUFU6dQ= -github.com/blacklane/go-libs/tracking v0.0.1/go.mod h1:mnDJmT2e0oqtVY5qoQNSrdP5kPMe/XOpNQ3WeVNiM7U= -github.com/blacklane/go-libs/tracking v0.2.1 h1:rGpVB5Eiv1Ert9iAjCzEb55GX6ocNLxDxL7fQBN1tx0= -github.com/blacklane/go-libs/tracking v0.2.1/go.mod h1:l9W5ytCjN/aej7NqC2D+ayC0AmQxfjZikmIAVKWPdN4= -github.com/blacklane/go-libs/x/events v0.0.0-20200729083625-bff51d3ec664/go.mod h1:9XVqU/pwOlbeFpSzzFIGm+iSWXmIYiTJyvOL38XoIzQ= -github.com/blacklane/go-libs/x/events v0.0.5 h1:qnCwYlzeMYXll2KDIzRHYLoIzz1EYaQv3xNVvPq6Liw= -github.com/blacklane/go-libs/x/events v0.0.5/go.mod h1:9XVqU/pwOlbeFpSzzFIGm+iSWXmIYiTJyvOL38XoIzQ= -github.com/caarlos0/env v3.5.0+incompatible/go.mod h1:tdCsowwCzMLdkqRYDlHpZCp2UooDD3MspDBjZ2AD02Y= +github.com/blacklane/go-libs/tracking v0.3.0 h1:5i15OUGx/ic3OkmQbTekBTt022JalmCk61a984WjJvQ= +github.com/blacklane/go-libs/tracking v0.3.0/go.mod h1:dnAkF4VXm3e2kU0gQaiDh+jEJqs/IX3I0Hc7RKYoHZw= +github.com/blacklane/go-libs/x/events v0.2.0 h1:whwo2Pl9uXcTe6W+x3SIbOo+8BzcARCzl+QTdwgYRVQ= +github.com/blacklane/go-libs/x/events v0.2.0/go.mod h1:lM0yg2m3azl5C7y1P3oQp2mu7V0TXkRjrXCE5woSZa8= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/confluentinc/confluent-kafka-go v1.4.2 h1:13EK9RTujF7lVkvHQ5Hbu6bM+Yfrq8L0MkJNnjHSd4Q= github.com/confluentinc/confluent-kafka-go v1.4.2/go.mod h1:u2zNLny2xq+5rWeTQjFHbDzzNuba4P1vo31r9r4uAdg= github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= @@ -35,20 +32,25 @@ github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= +github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= +github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.2.0 h1:qJYtXnJRWmpe7m/3XlyhrsLrEURqHRM2kxzoxXqyUDs= +github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= -github.com/rs/zerolog v1.18.0/go.mod h1:9nvC1axdVrAHcu/s9taAVfBuIdTZLVQmKQyvrUjF5+I= github.com/rs/zerolog v1.20.0 h1:38k9hgtUBdxFwE34yS8rTHmHBa4eN16E4DJlv177LNs= github.com/rs/zerolog v1.20.0/go.mod h1:IzD0RJ65iWH0w97OQQebJEvTZYvsCUm9WVLWBQrJRjo= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +go.opentelemetry.io/otel v1.0.0 h1:qTTn6x71GVBvoafHK/yaRUmFzI4LcONZD0/kXxl5PHI= +go.opentelemetry.io/otel v1.0.0/go.mod h1:AjRVh9A5/5DE7S+mZtTR6t8vpKKryam+0lREnfmS4cg= +go.opentelemetry.io/otel/trace v1.0.0 h1:TSBr8GTEtKevYMG/2d21M989r5WJYVimhTHBKVEZuh4= +go.opentelemetry.io/otel/trace v1.0.0/go.mod h1:PXTWqayeFUlJV1YDNhsJYB184+IvAH814St6o6ajzIs= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -108,6 +110,7 @@ google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpAD google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/logger/middleware/http_test.go b/logger/middleware/http_test.go index 41de263..695ad65 100644 --- a/logger/middleware/http_test.go +++ b/logger/middleware/http_test.go @@ -8,7 +8,6 @@ import ( "testing" "time" - "github.com/blacklane/go-libs/tracking/middleware" "github.com/google/go-cmp/cmp" "github.com/blacklane/go-libs/logger" @@ -27,7 +26,7 @@ func (m chain) apply(handler http.Handler) http.Handler { } func TestHTTPRequestLogger(t *testing.T) { - want := `{"level":"info","application":"TestHTTPRequestLogger","host":"example.com","ip":"localhost","params":"","path":"/do_not_skip","request_id":"a_known_id","tracking_id":"a_known_id","user_agent":"","verb":"GET","http_status":200,"duration_ms":0,"timestamp":"2009-11-10T23:00:00.000Z","message":"GET /do_not_skip"}` + "\n" + want := `{"level":"info","application":"TestHTTPRequestLogger","host":"example.com","ip":"localhost","params":"","path":"/do_not_skip","request_id":"","tracking_id":"","user_agent":"","verb":"GET","http_status":200,"duration_ms":0,"timestamp":"2009-11-10T23:00:00.000Z","message":"GET /do_not_skip"}` + "\n" // Set current time function so we can control the request duration logger.SetNowFunc(func() time.Time { @@ -48,7 +47,7 @@ func TestHTTPRequestLogger(t *testing.T) { rLog.Header.Set(internal.HeaderRequestID, "a_known_id") log := logger.New(buf, "TestHTTPRequestLogger") - ms := chain{middleware.TrackingID, HTTPAddLogger(log), HTTPRequestLogger(skipRoutes)} + ms := chain{HTTPAddLogger(log), HTTPRequestLogger(skipRoutes)} h := ms.apply(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.Write([]byte(``)) }))