From 9096fbcba13f98fbade890f599794e849d33aee2 Mon Sep 17 00:00:00 2001 From: George MacRorie Date: Tue, 19 Nov 2019 13:34:21 +0100 Subject: [PATCH 1/2] feat(tracing): dont trace spans with full URL path names in ExtractFromHTTPRequest --- go.mod | 2 + go.sum | 4 +- http/router.go | 1 + kit/tracing/tracing.go | 26 ++++++++--- kit/tracing/tracing_test.go | 91 +++++++++++++++++++++++++++++++++++++ 5 files changed, 115 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index 4801415acea..bfd9b679b3f 100644 --- a/go.mod +++ b/go.mod @@ -113,3 +113,5 @@ replace github.com/Sirupsen/logrus => github.com/sirupsen/logrus v1.2.0 replace github.com/influxdata/platform => /dev/null replace github.com/goreleaser/goreleaser => github.com/influxdata/goreleaser v0.97.0-influx + +replace github.com/julienschmidt/httprouter => github.com/georgemac/httprouter v1.3.1-0.20191121142037-34e411acc501 diff --git a/go.sum b/go.sum index 23d58ea438e..cd56ed1f4b2 100644 --- a/go.sum +++ b/go.sum @@ -115,6 +115,8 @@ github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568 h1:BHsljHzVlRcyQhjr github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= 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/georgemac/httprouter v1.3.1-0.20191121142037-34e411acc501 h1:eSe2KTNWsu40zA8mT/lJ7y+XnthfQ5umHyHUiLXnKb8= +github.com/georgemac/httprouter v1.3.1-0.20191121142037-34e411acc501/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= github.com/getkin/kin-openapi v0.2.0 h1:PbHHtYZpjKwZtGlIyELgA2DploRrsaXztoNNx9HjwNY= github.com/getkin/kin-openapi v0.2.0/go.mod h1:V1z9xl9oF5Wt7v32ne4FmiF1alpS4dM6mNzoywPOXlk= github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= @@ -269,8 +271,6 @@ github.com/jsternberg/zap-logfmt v1.2.0 h1:1v+PK4/B48cy8cfQbxL4FmmNZrjnIMr2BsnyE github.com/jsternberg/zap-logfmt v1.2.0/go.mod h1:kz+1CUmCutPWABnNkOu9hOHKdT2q3TDYCcsFy9hpqb0= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= -github.com/julienschmidt/httprouter v1.2.0 h1:TDTW5Yz1mjftljbcKqRcrYhd4XeOoI98t+9HbQbYf7g= -github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/jwilder/encoding v0.0.0-20170811194829-b4e1701a28ef h1:2jNeR4YUziVtswNP9sEFAI913cVrzH85T+8Q6LpYbT0= github.com/jwilder/encoding v0.0.0-20170811194829-b4e1701a28ef/go.mod h1:Ct9fl0F6iIOGgxJ5npU/IUOhOhqlVrGjyIZc8/MagT0= github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88 h1:uC1QfSlInpQF+M0ao65imhwqKnz3Q2z/d8PWZRMQvDM= diff --git a/http/router.go b/http/router.go index 348fcd3dd16..93dfdc1ded8 100644 --- a/http/router.go +++ b/http/router.go @@ -22,6 +22,7 @@ func NewRouter(h platform.HTTPErrorHandler) *httprouter.Router { router.NotFound = http.HandlerFunc(b.notFound) router.MethodNotAllowed = http.HandlerFunc(b.methodNotAllowed) router.PanicHandler = b.panic + router.AddMatchedRouteToContext = true return router } diff --git a/kit/tracing/tracing.go b/kit/tracing/tracing.go index e3f9deb56d3..9bbbfea89f6 100644 --- a/kit/tracing/tracing.go +++ b/kit/tracing/tracing.go @@ -7,6 +7,7 @@ import ( "runtime" "strings" + "github.com/julienschmidt/httprouter" "github.com/opentracing/opentracing-go" "github.com/opentracing/opentracing-go/ext" "github.com/opentracing/opentracing-go/log" @@ -50,15 +51,26 @@ func InjectToHTTPRequest(span opentracing.Span, req *http.Request) { func ExtractFromHTTPRequest(req *http.Request, handlerName string) (opentracing.Span, *http.Request) { spanContext, err := opentracing.GlobalTracer().Extract(opentracing.HTTPHeaders, opentracing.HTTPHeadersCarrier(req.Header)) if err != nil { - span, ctx := opentracing.StartSpanFromContext(req.Context(), handlerName+":"+req.URL.Path) - LogError(span, err) - req = req.WithContext(ctx) - return span, req + span, ctx := opentracing.StartSpanFromContext(req.Context(), "request") + annotateSpan(span, handlerName, req) + + _ = LogError(span, err) + + return span, req.WithContext(ctx) } - span := opentracing.StartSpan(handlerName+":"+req.URL.Path, opentracing.ChildOf(spanContext), ext.RPCServerOption(spanContext)) - req = req.WithContext(opentracing.ContextWithSpan(req.Context(), span)) - return span, req + span := opentracing.StartSpan("request", opentracing.ChildOf(spanContext), ext.RPCServerOption(spanContext)) + annotateSpan(span, handlerName, req) + + return span, req.WithContext(opentracing.ContextWithSpan(req.Context(), span)) +} + +func annotateSpan(span opentracing.Span, handlerName string, req *http.Request) { + if route := httprouter.MatchedRouteFromContext(req.Context()); route != "" { + span.SetTag("route", route) + } + span.SetTag("handler", handlerName) + span.LogKV("path", req.URL.Path) } // StartSpanFromContext is an improved opentracing.StartSpanFromContext. diff --git a/kit/tracing/tracing_test.go b/kit/tracing/tracing_test.go index 26bb20e710c..5a7a09a7a92 100644 --- a/kit/tracing/tracing_test.go +++ b/kit/tracing/tracing_test.go @@ -4,9 +4,11 @@ import ( "context" "fmt" "net/http" + "net/url" "runtime" "testing" + "github.com/julienschmidt/httprouter" "github.com/opentracing/opentracing-go" "github.com/opentracing/opentracing-go/mocktracer" ) @@ -37,6 +39,83 @@ func TestInjectAndExtractHTTPRequest(t *testing.T) { } } +func TestExtractHTTPRequest(t *testing.T) { + var ( + tracer = mocktracer.New() + oldTracer = opentracing.GlobalTracer() + ctx = context.Background() + ) + + opentracing.SetGlobalTracer(tracer) + defer opentracing.SetGlobalTracer(oldTracer) + + for _, test := range []struct { + name string + handlerName string + path string + ctx context.Context + tags map[string]interface{} + }{ + { + name: "happy path", + handlerName: "WriteHandler", + ctx: context.WithValue(ctx, httprouter.MatchedRouteKey, "/api/v2/write"), + path: "/api/v2/write", + tags: map[string]interface{}{ + "route": "/api/v2/write", + "handler": "WriteHandler", + }, + }, + { + name: "happy path bucket handler", + handlerName: "BucketHandler", + ctx: context.WithValue(ctx, httprouter.MatchedRouteKey, "/api/v2/buckets/:bucket_id"), + path: "/api/v2/buckets/12345", + tags: map[string]interface{}{ + "route": "/api/v2/buckets/:bucket_id", + "handler": "BucketHandler", + }, + }, + { + name: "empty path", + handlerName: "Home", + ctx: ctx, + tags: map[string]interface{}{ + "handler": "Home", + }, + }, + } { + t.Run(test.name, func(t *testing.T) { + request, err := http.NewRequest(http.MethodPost, "http://localhost"+test.path, nil) + if err != nil { + t.Fatal(err) + } + + span := tracer.StartSpan("operation name") + + InjectToHTTPRequest(span, request) + gotSpan, _ := ExtractFromHTTPRequest(request.WithContext(test.ctx), test.handlerName) + + if op := gotSpan.(*mocktracer.MockSpan).OperationName; op != "request" { + t.Fatalf("operation name %q != request", op) + } + + tags := gotSpan.(*mocktracer.MockSpan).Tags() + for k, v := range test.tags { + found, ok := tags[k] + if !ok { + t.Errorf("tag not found in span %q", k) + continue + } + + if found != v { + t.Errorf("expected %v, found %v for tag %q", v, found, k) + } + } + }) + } +} + func TestStartSpanFromContext(t *testing.T) { tracer := mocktracer.New() @@ -219,3 +298,15 @@ func BenchmarkOpentracing_StartSpan_child(b *testing.B) { _ = opentracing.StartSpan("operation name", opentracing.ChildOf(parentSpan.Context())) } } + +func BenchmarkOpentracing_ExtractFromHTTPRequest(b *testing.B) { + b.ReportAllocs() + + req := &http.Request{ + URL: &url.URL{Path: "/api/v2/organization/12345"}, + } + + for n := 0; n < b.N; n++ { + _, _ = ExtractFromHTTPRequest(req, "OrganizationHandler") + } +} From f909d9ef39ebb3422a715f46885a034da79724c8 Mon Sep 17 00:00:00 2001 From: George MacRorie Date: Fri, 22 Nov 2019 11:58:21 +0100 Subject: [PATCH 2/2] chore(multiple): replace all occurrences of julienschmidt/httprouter with influxdata/httprouter --- chronograf/server/annotations_test.go | 2 +- chronograf/server/cells.go | 2 +- chronograf/server/cells_test.go | 2 +- chronograf/server/databases.go | 2 +- chronograf/server/databases_test.go | 2 +- chronograf/server/influx_test.go | 2 +- chronograf/server/mux.go | 2 +- chronograf/server/permissions_test.go | 2 +- chronograf/server/queries_test.go | 2 +- chronograf/server/sources_test.go | 2 +- go.mod | 4 +--- go.sum | 5 +++-- http/auth_service.go | 2 +- http/auth_test.go | 2 +- http/authentication_middleware.go | 2 +- http/bucket_service.go | 2 +- http/bucket_test.go | 2 +- http/check_service.go | 2 +- http/check_test.go | 2 +- http/chronograf_handler.go | 2 +- http/dashboard_service.go | 2 +- http/dashboard_test.go | 2 +- http/delete_handler.go | 2 +- http/document_service.go | 2 +- http/document_test.go | 2 +- http/label_service.go | 2 +- http/label_test.go | 2 +- http/notification_endpoint.go | 2 +- http/notification_endpoint_test.go | 2 +- http/notification_rule.go | 2 +- http/onboarding.go | 2 +- http/org_service.go | 2 +- http/query_handler.go | 2 +- http/router.go | 2 +- http/scraper_service.go | 2 +- http/scraper_service_test.go | 2 +- http/session_handler.go | 2 +- http/source_service.go | 2 +- http/task_service.go | 2 +- http/task_service_test.go | 2 +- http/telegraf.go | 2 +- http/usage_service.go | 2 +- http/user_resource_mapping_service.go | 2 +- http/user_resource_mapping_test.go | 2 +- http/user_service.go | 2 +- http/variable_service.go | 2 +- http/variable_test.go | 2 +- http/write_handler.go | 2 +- kit/tracing/tracing.go | 2 +- kit/tracing/tracing_test.go | 2 +- task/backend/analytical_storage.go | 4 ++-- 51 files changed, 54 insertions(+), 55 deletions(-) diff --git a/chronograf/server/annotations_test.go b/chronograf/server/annotations_test.go index dde895e03dc..b5ca0c8f4c9 100644 --- a/chronograf/server/annotations_test.go +++ b/chronograf/server/annotations_test.go @@ -10,7 +10,7 @@ import ( "github.com/influxdata/influxdb/chronograf" "github.com/influxdata/influxdb/chronograf/mocks" - "github.com/julienschmidt/httprouter" + "github.com/influxdata/httprouter" ) func TestService_Annotations(t *testing.T) { diff --git a/chronograf/server/cells.go b/chronograf/server/cells.go index 916ebbcf3bb..28dd94e1f92 100644 --- a/chronograf/server/cells.go +++ b/chronograf/server/cells.go @@ -5,9 +5,9 @@ import ( "fmt" "net/http" + "github.com/influxdata/httprouter" "github.com/influxdata/influxdb/chronograf" idgen "github.com/influxdata/influxdb/chronograf/id" - "github.com/julienschmidt/httprouter" ) const ( diff --git a/chronograf/server/cells_test.go b/chronograf/server/cells_test.go index c4e5fc3f81a..a7288179c1d 100644 --- a/chronograf/server/cells_test.go +++ b/chronograf/server/cells_test.go @@ -15,7 +15,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/influxdata/influxdb/chronograf" "github.com/influxdata/influxdb/chronograf/mocks" - "github.com/julienschmidt/httprouter" + "github.com/influxdata/httprouter" ) func Test_Cells_CorrectAxis(t *testing.T) { diff --git a/chronograf/server/databases.go b/chronograf/server/databases.go index 577ff431d99..d34a3076766 100644 --- a/chronograf/server/databases.go +++ b/chronograf/server/databases.go @@ -8,8 +8,8 @@ import ( "net/url" "strconv" + "github.com/influxdata/httprouter" "github.com/influxdata/influxdb/chronograf" - "github.com/julienschmidt/httprouter" ) const ( diff --git a/chronograf/server/databases_test.go b/chronograf/server/databases_test.go index c625c98e640..993865a4dcb 100644 --- a/chronograf/server/databases_test.go +++ b/chronograf/server/databases_test.go @@ -10,7 +10,7 @@ import ( "github.com/influxdata/influxdb/chronograf" "github.com/influxdata/influxdb/chronograf/mocks" - "github.com/julienschmidt/httprouter" + "github.com/influxdata/httprouter" ) func TestService_GetDatabases(t *testing.T) { diff --git a/chronograf/server/influx_test.go b/chronograf/server/influx_test.go index e4318877e11..a2c650212b7 100644 --- a/chronograf/server/influx_test.go +++ b/chronograf/server/influx_test.go @@ -10,7 +10,7 @@ import ( "github.com/influxdata/influxdb/chronograf" "github.com/influxdata/influxdb/chronograf/mocks" - "github.com/julienschmidt/httprouter" + "github.com/influxdata/httprouter" ) func TestService_Influx(t *testing.T) { diff --git a/chronograf/server/mux.go b/chronograf/server/mux.go index e46a9b7f99d..2295ca7c866 100644 --- a/chronograf/server/mux.go +++ b/chronograf/server/mux.go @@ -12,10 +12,10 @@ import ( "github.com/NYTimes/gziphandler" "github.com/bouk/httprouter" + jhttprouter "github.com/influxdata/httprouter" "github.com/influxdata/influxdb/chronograf" "github.com/influxdata/influxdb/chronograf/oauth2" "github.com/influxdata/influxdb/chronograf/roles" - jhttprouter "github.com/julienschmidt/httprouter" ) const ( diff --git a/chronograf/server/permissions_test.go b/chronograf/server/permissions_test.go index ae7331da6e8..a0b2b228b23 100644 --- a/chronograf/server/permissions_test.go +++ b/chronograf/server/permissions_test.go @@ -10,7 +10,7 @@ import ( "github.com/influxdata/influxdb/chronograf" "github.com/influxdata/influxdb/chronograf/mocks" - "github.com/julienschmidt/httprouter" + "github.com/influxdata/httprouter" ) func TestService_Permissions(t *testing.T) { diff --git a/chronograf/server/queries_test.go b/chronograf/server/queries_test.go index 406443118af..faeda4b2cec 100644 --- a/chronograf/server/queries_test.go +++ b/chronograf/server/queries_test.go @@ -9,7 +9,7 @@ import ( "github.com/influxdata/influxdb/chronograf" "github.com/influxdata/influxdb/chronograf/mocks" - "github.com/julienschmidt/httprouter" + "github.com/influxdata/httprouter" ) func TestService_Queries(t *testing.T) { diff --git a/chronograf/server/sources_test.go b/chronograf/server/sources_test.go index f1eeb5da015..fbede81bcd0 100644 --- a/chronograf/server/sources_test.go +++ b/chronograf/server/sources_test.go @@ -13,7 +13,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/influxdata/influxdb/chronograf" "github.com/influxdata/influxdb/chronograf/mocks" - "github.com/julienschmidt/httprouter" + "github.com/influxdata/httprouter" ) func Test_ValidSourceRequest(t *testing.T) { diff --git a/go.mod b/go.mod index bfd9b679b3f..440a6474e4c 100644 --- a/go.mod +++ b/go.mod @@ -42,11 +42,11 @@ require ( github.com/hashicorp/vault/api v1.0.2 github.com/influxdata/cron v0.0.0-20191112133922-ad5847cfab62 github.com/influxdata/flux v0.54.0 + github.com/influxdata/httprouter v1.3.1-0.20191122104820-ee83e2772f69 github.com/influxdata/influxql v0.0.0-20180925231337-1cbfca8e56b6 github.com/influxdata/usage-client v0.0.0-20160829180054-6d3895376368 github.com/jessevdk/go-flags v1.4.0 github.com/jsternberg/zap-logfmt v1.2.0 - github.com/julienschmidt/httprouter v1.2.0 github.com/jwilder/encoding v0.0.0-20170811194829-b4e1701a28ef github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88 // indirect github.com/kevinburke/go-bindata v3.11.0+incompatible @@ -113,5 +113,3 @@ replace github.com/Sirupsen/logrus => github.com/sirupsen/logrus v1.2.0 replace github.com/influxdata/platform => /dev/null replace github.com/goreleaser/goreleaser => github.com/influxdata/goreleaser v0.97.0-influx - -replace github.com/julienschmidt/httprouter => github.com/georgemac/httprouter v1.3.1-0.20191121142037-34e411acc501 diff --git a/go.sum b/go.sum index cd56ed1f4b2..62a22351eaa 100644 --- a/go.sum +++ b/go.sum @@ -115,8 +115,6 @@ github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568 h1:BHsljHzVlRcyQhjr github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= 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/georgemac/httprouter v1.3.1-0.20191121142037-34e411acc501 h1:eSe2KTNWsu40zA8mT/lJ7y+XnthfQ5umHyHUiLXnKb8= -github.com/georgemac/httprouter v1.3.1-0.20191121142037-34e411acc501/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= github.com/getkin/kin-openapi v0.2.0 h1:PbHHtYZpjKwZtGlIyELgA2DploRrsaXztoNNx9HjwNY= github.com/getkin/kin-openapi v0.2.0/go.mod h1:V1z9xl9oF5Wt7v32ne4FmiF1alpS4dM6mNzoywPOXlk= github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= @@ -249,6 +247,8 @@ github.com/influxdata/flux v0.54.0 h1:DjAkGoPkgHLDPEn1jSuOpsH4QgcjmSBkRuxSAaQCj1 github.com/influxdata/flux v0.54.0/go.mod h1:ZFf4F0c8ACFP/5BkfCwk9I/vUwcByr0vMdLxwgOk57E= github.com/influxdata/goreleaser v0.97.0-influx h1:jT5OrcW7WfS0e2QxfwmTBjhLvpIC9CDLRhNgZJyhj8s= github.com/influxdata/goreleaser v0.97.0-influx/go.mod h1:MnjA0e0Uq6ISqjG1WxxMAl+3VS1QYjILSWVnMYDxasE= +github.com/influxdata/httprouter v1.3.1-0.20191122104820-ee83e2772f69 h1:WQsmW0fXO4ZE/lFGIE84G6rIV5SJN3P3sjIXAP1a8eU= +github.com/influxdata/httprouter v1.3.1-0.20191122104820-ee83e2772f69/go.mod h1:pwymjR6SrP3gD3pRj9RJwdl1j5s3doEEV8gS4X9qSzA= github.com/influxdata/influxql v0.0.0-20180925231337-1cbfca8e56b6 h1:CFx+pP90q/qg3spoiZjf8donE4WpAdjeJfPOcoNqkWo= github.com/influxdata/influxql v0.0.0-20180925231337-1cbfca8e56b6/go.mod h1:KpVI7okXjK6PRi3Z5B+mtKZli+R1DnZgb3N+tzevNgo= github.com/influxdata/line-protocol v0.0.0-20180522152040-32c6aa80de5e h1:/o3vQtpWJhvnIbXley4/jwzzqNeigJK9z+LZcJZ9zfM= @@ -271,6 +271,7 @@ github.com/jsternberg/zap-logfmt v1.2.0 h1:1v+PK4/B48cy8cfQbxL4FmmNZrjnIMr2BsnyE github.com/jsternberg/zap-logfmt v1.2.0/go.mod h1:kz+1CUmCutPWABnNkOu9hOHKdT2q3TDYCcsFy9hpqb0= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= +github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/jwilder/encoding v0.0.0-20170811194829-b4e1701a28ef h1:2jNeR4YUziVtswNP9sEFAI913cVrzH85T+8Q6LpYbT0= github.com/jwilder/encoding v0.0.0-20170811194829-b4e1701a28ef/go.mod h1:Ct9fl0F6iIOGgxJ5npU/IUOhOhqlVrGjyIZc8/MagT0= github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88 h1:uC1QfSlInpQF+M0ao65imhwqKnz3Q2z/d8PWZRMQvDM= diff --git a/http/auth_service.go b/http/auth_service.go index 794c2c4c1c6..50e666e82fa 100644 --- a/http/auth_service.go +++ b/http/auth_service.go @@ -12,9 +12,9 @@ import ( "go.uber.org/zap" + "github.com/influxdata/httprouter" platform "github.com/influxdata/influxdb" platcontext "github.com/influxdata/influxdb/context" - "github.com/julienschmidt/httprouter" ) // AuthorizationBackend is all services and associated parameters required to construct diff --git a/http/auth_test.go b/http/auth_test.go index 608a927a81b..4fe6bdd8b3d 100644 --- a/http/auth_test.go +++ b/http/auth_test.go @@ -18,7 +18,7 @@ import ( "github.com/influxdata/influxdb/kv" "github.com/influxdata/influxdb/mock" platformtesting "github.com/influxdata/influxdb/testing" - "github.com/julienschmidt/httprouter" + "github.com/influxdata/httprouter" ) // NewMockAuthorizationBackend returns a AuthorizationBackend with mock services. diff --git a/http/authentication_middleware.go b/http/authentication_middleware.go index f900c3b71b2..f916977db2c 100644 --- a/http/authentication_middleware.go +++ b/http/authentication_middleware.go @@ -7,10 +7,10 @@ import ( "net/http" "time" + "github.com/influxdata/httprouter" platform "github.com/influxdata/influxdb" platcontext "github.com/influxdata/influxdb/context" "github.com/influxdata/influxdb/jsonweb" - "github.com/julienschmidt/httprouter" "go.uber.org/zap" ) diff --git a/http/bucket_service.go b/http/bucket_service.go index f8bdf6ad8cf..ee91b78da59 100644 --- a/http/bucket_service.go +++ b/http/bucket_service.go @@ -9,7 +9,7 @@ import ( "path" "time" - "github.com/julienschmidt/httprouter" + "github.com/influxdata/httprouter" "go.uber.org/zap" "github.com/influxdata/influxdb" diff --git a/http/bucket_test.go b/http/bucket_test.go index ab79ee3bc6a..aa306792c17 100644 --- a/http/bucket_test.go +++ b/http/bucket_test.go @@ -16,7 +16,7 @@ import ( "github.com/influxdata/influxdb/kv" "github.com/influxdata/influxdb/mock" platformtesting "github.com/influxdata/influxdb/testing" - "github.com/julienschmidt/httprouter" + "github.com/influxdata/httprouter" "go.uber.org/zap" ) diff --git a/http/check_service.go b/http/check_service.go index 96de8d3b8e1..4df31305a58 100644 --- a/http/check_service.go +++ b/http/check_service.go @@ -7,10 +7,10 @@ import ( "fmt" "net/http" + "github.com/influxdata/httprouter" "github.com/influxdata/influxdb" pctx "github.com/influxdata/influxdb/context" "github.com/influxdata/influxdb/notification/check" - "github.com/julienschmidt/httprouter" "go.uber.org/zap" ) diff --git a/http/check_test.go b/http/check_test.go index dc543c3ef08..9968c1887bc 100644 --- a/http/check_test.go +++ b/http/check_test.go @@ -18,7 +18,7 @@ import ( "github.com/influxdata/influxdb/mock" "github.com/influxdata/influxdb/notification/check" influxTesting "github.com/influxdata/influxdb/testing" - "github.com/julienschmidt/httprouter" + "github.com/influxdata/httprouter" "go.uber.org/zap" ) diff --git a/http/chronograf_handler.go b/http/chronograf_handler.go index ca8aa211c77..7cf9a5150ba 100644 --- a/http/chronograf_handler.go +++ b/http/chronograf_handler.go @@ -4,9 +4,9 @@ import ( "net/http" "github.com/NYTimes/gziphandler" + "github.com/influxdata/httprouter" "github.com/influxdata/influxdb" "github.com/influxdata/influxdb/chronograf/server" - "github.com/julienschmidt/httprouter" ) // ChronografHandler is an http handler for serving chronograf chronografs. diff --git a/http/dashboard_service.go b/http/dashboard_service.go index bc1da6b7b5f..547d00cc8ce 100644 --- a/http/dashboard_service.go +++ b/http/dashboard_service.go @@ -8,8 +8,8 @@ import ( "net/http" "path" + "github.com/influxdata/httprouter" platform "github.com/influxdata/influxdb" - "github.com/julienschmidt/httprouter" "go.uber.org/zap" ) diff --git a/http/dashboard_test.go b/http/dashboard_test.go index ddf012cafdf..599af89c534 100644 --- a/http/dashboard_test.go +++ b/http/dashboard_test.go @@ -18,7 +18,7 @@ import ( "github.com/influxdata/influxdb/inmem" "github.com/influxdata/influxdb/mock" platformtesting "github.com/influxdata/influxdb/testing" - "github.com/julienschmidt/httprouter" + "github.com/influxdata/httprouter" "github.com/yudai/gojsondiff" "github.com/yudai/gojsondiff/formatter" ) diff --git a/http/delete_handler.go b/http/delete_handler.go index f48488937ad..72e959edd85 100644 --- a/http/delete_handler.go +++ b/http/delete_handler.go @@ -8,11 +8,11 @@ import ( http "net/http" "time" + "github.com/influxdata/httprouter" "github.com/influxdata/influxdb" pcontext "github.com/influxdata/influxdb/context" "github.com/influxdata/influxdb/kit/tracing" "github.com/influxdata/influxdb/predicate" - "github.com/julienschmidt/httprouter" "go.uber.org/zap" ) diff --git a/http/document_service.go b/http/document_service.go index a9041a9f0f4..488be21e7d2 100644 --- a/http/document_service.go +++ b/http/document_service.go @@ -6,9 +6,9 @@ import ( "fmt" "net/http" + "github.com/influxdata/httprouter" "github.com/influxdata/influxdb" pcontext "github.com/influxdata/influxdb/context" - "github.com/julienschmidt/httprouter" "go.uber.org/zap" ) diff --git a/http/document_test.go b/http/document_test.go index d65e6f00e15..75076f59047 100644 --- a/http/document_test.go +++ b/http/document_test.go @@ -14,7 +14,7 @@ import ( pcontext "github.com/influxdata/influxdb/context" "github.com/influxdata/influxdb/mock" influxtesting "github.com/influxdata/influxdb/testing" - "github.com/julienschmidt/httprouter" + "github.com/influxdata/httprouter" "go.uber.org/zap" ) diff --git a/http/label_service.go b/http/label_service.go index 75d223ee31d..292b4aa96fc 100644 --- a/http/label_service.go +++ b/http/label_service.go @@ -11,8 +11,8 @@ import ( "go.uber.org/zap" + "github.com/influxdata/httprouter" "github.com/influxdata/influxdb" - "github.com/julienschmidt/httprouter" ) // LabelHandler represents an HTTP API handler for labels diff --git a/http/label_test.go b/http/label_test.go index b8f39d64a17..e2b8c652e34 100644 --- a/http/label_test.go +++ b/http/label_test.go @@ -13,7 +13,7 @@ import ( platform "github.com/influxdata/influxdb" "github.com/influxdata/influxdb/mock" platformtesting "github.com/influxdata/influxdb/testing" - "github.com/julienschmidt/httprouter" + "github.com/influxdata/httprouter" ) func TestService_handleGetLabels(t *testing.T) { diff --git a/http/notification_endpoint.go b/http/notification_endpoint.go index e1499b15576..350e57203c6 100644 --- a/http/notification_endpoint.go +++ b/http/notification_endpoint.go @@ -7,10 +7,10 @@ import ( "fmt" "net/http" + "github.com/influxdata/httprouter" "github.com/influxdata/influxdb" pctx "github.com/influxdata/influxdb/context" "github.com/influxdata/influxdb/notification/endpoint" - "github.com/julienschmidt/httprouter" "go.uber.org/zap" ) diff --git a/http/notification_endpoint_test.go b/http/notification_endpoint_test.go index 7e089d66d1e..87013b2aefc 100644 --- a/http/notification_endpoint_test.go +++ b/http/notification_endpoint_test.go @@ -17,7 +17,7 @@ import ( "github.com/influxdata/influxdb/mock" "github.com/influxdata/influxdb/notification/endpoint" influxTesting "github.com/influxdata/influxdb/testing" - "github.com/julienschmidt/httprouter" + "github.com/influxdata/httprouter" "go.uber.org/zap" ) diff --git a/http/notification_rule.go b/http/notification_rule.go index c54e61a7d0d..ee2f854f23d 100644 --- a/http/notification_rule.go +++ b/http/notification_rule.go @@ -7,10 +7,10 @@ import ( "fmt" "net/http" + "github.com/influxdata/httprouter" "github.com/influxdata/influxdb" pctx "github.com/influxdata/influxdb/context" "github.com/influxdata/influxdb/notification/rule" - "github.com/julienschmidt/httprouter" "go.uber.org/zap" ) diff --git a/http/onboarding.go b/http/onboarding.go index 740230be5d9..e27236516d5 100644 --- a/http/onboarding.go +++ b/http/onboarding.go @@ -7,8 +7,8 @@ import ( "fmt" "net/http" + "github.com/influxdata/httprouter" platform "github.com/influxdata/influxdb" - "github.com/julienschmidt/httprouter" "go.uber.org/zap" ) diff --git a/http/org_service.go b/http/org_service.go index b69b21d9b75..c6cb217f675 100644 --- a/http/org_service.go +++ b/http/org_service.go @@ -8,7 +8,7 @@ import ( "net/http" "path" - "github.com/julienschmidt/httprouter" + "github.com/influxdata/httprouter" "go.uber.org/zap" "github.com/influxdata/influxdb" diff --git a/http/query_handler.go b/http/query_handler.go index ae25dce4369..2a529894eb5 100644 --- a/http/query_handler.go +++ b/http/query_handler.go @@ -18,13 +18,13 @@ import ( "github.com/influxdata/flux/csv" "github.com/influxdata/flux/iocounter" "github.com/influxdata/flux/parser" + "github.com/influxdata/httprouter" "github.com/influxdata/influxdb" pcontext "github.com/influxdata/influxdb/context" "github.com/influxdata/influxdb/http/metric" "github.com/influxdata/influxdb/kit/check" "github.com/influxdata/influxdb/kit/tracing" "github.com/influxdata/influxdb/query" - "github.com/julienschmidt/httprouter" "github.com/pkg/errors" prom "github.com/prometheus/client_golang/prometheus" "go.uber.org/zap" diff --git a/http/router.go b/http/router.go index 93dfdc1ded8..b771f27fa2f 100644 --- a/http/router.go +++ b/http/router.go @@ -8,9 +8,9 @@ import ( "sync" "github.com/go-chi/chi" + "github.com/influxdata/httprouter" platform "github.com/influxdata/influxdb" influxlogger "github.com/influxdata/influxdb/logger" - "github.com/julienschmidt/httprouter" "go.uber.org/zap" "go.uber.org/zap/zapcore" ) diff --git a/http/scraper_service.go b/http/scraper_service.go index 4da0c31d94c..b96a51e7f00 100644 --- a/http/scraper_service.go +++ b/http/scraper_service.go @@ -8,9 +8,9 @@ import ( "net/http" "path" + "github.com/influxdata/httprouter" "github.com/influxdata/influxdb" pctx "github.com/influxdata/influxdb/context" - "github.com/julienschmidt/httprouter" "go.uber.org/zap" ) diff --git a/http/scraper_service_test.go b/http/scraper_service_test.go index aeaa90ab303..40f8842912c 100644 --- a/http/scraper_service_test.go +++ b/http/scraper_service_test.go @@ -18,7 +18,7 @@ import ( "github.com/influxdata/influxdb/inmem" "github.com/influxdata/influxdb/mock" platformtesting "github.com/influxdata/influxdb/testing" - "github.com/julienschmidt/httprouter" + "github.com/influxdata/httprouter" ) const ( diff --git a/http/session_handler.go b/http/session_handler.go index 4eb06e8a389..de7edbb5941 100644 --- a/http/session_handler.go +++ b/http/session_handler.go @@ -4,8 +4,8 @@ import ( "context" "net/http" + "github.com/influxdata/httprouter" platform "github.com/influxdata/influxdb" - "github.com/julienschmidt/httprouter" "go.uber.org/zap" ) diff --git a/http/source_service.go b/http/source_service.go index a4f0e1d5c65..183fe4b469f 100644 --- a/http/source_service.go +++ b/http/source_service.go @@ -12,10 +12,10 @@ import ( "github.com/influxdata/flux/csv" "github.com/influxdata/flux/lang" "github.com/influxdata/flux/repl" + "github.com/influxdata/httprouter" platform "github.com/influxdata/influxdb" "github.com/influxdata/influxdb/query" "github.com/influxdata/influxdb/query/influxql" - "github.com/julienschmidt/httprouter" "go.uber.org/zap" ) diff --git a/http/task_service.go b/http/task_service.go index 09fcc7dc3ec..71fc5fd8d9a 100644 --- a/http/task_service.go +++ b/http/task_service.go @@ -13,12 +13,12 @@ import ( "strings" "time" + "github.com/influxdata/httprouter" "github.com/influxdata/influxdb" pcontext "github.com/influxdata/influxdb/context" "github.com/influxdata/influxdb/kit/tracing" "github.com/influxdata/influxdb/kv" "github.com/influxdata/influxdb/task/backend" - "github.com/julienschmidt/httprouter" "go.uber.org/zap" ) diff --git a/http/task_service_test.go b/http/task_service_test.go index b54477cd7de..b6849dded02 100644 --- a/http/task_service_test.go +++ b/http/task_service_test.go @@ -20,7 +20,7 @@ import ( _ "github.com/influxdata/influxdb/query/builtin" "github.com/influxdata/influxdb/task/backend" platformtesting "github.com/influxdata/influxdb/testing" - "github.com/julienschmidt/httprouter" + "github.com/influxdata/httprouter" "go.uber.org/zap" "go.uber.org/zap/zaptest" ) diff --git a/http/telegraf.go b/http/telegraf.go index a5db7b71e64..dd7c6b86965 100644 --- a/http/telegraf.go +++ b/http/telegraf.go @@ -8,10 +8,10 @@ import ( "strings" "github.com/golang/gddo/httputil" + "github.com/influxdata/httprouter" platform "github.com/influxdata/influxdb" pctx "github.com/influxdata/influxdb/context" "github.com/influxdata/influxdb/telegraf/plugins" - "github.com/julienschmidt/httprouter" "go.uber.org/zap" ) diff --git a/http/usage_service.go b/http/usage_service.go index abd9646151e..f24539b665e 100644 --- a/http/usage_service.go +++ b/http/usage_service.go @@ -6,8 +6,8 @@ import ( "net/http" "time" + "github.com/influxdata/httprouter" platform "github.com/influxdata/influxdb" - "github.com/julienschmidt/httprouter" "go.uber.org/zap" ) diff --git a/http/user_resource_mapping_service.go b/http/user_resource_mapping_service.go index 550aee6800f..1da5d72aa82 100644 --- a/http/user_resource_mapping_service.go +++ b/http/user_resource_mapping_service.go @@ -10,8 +10,8 @@ import ( "go.uber.org/zap" + "github.com/influxdata/httprouter" "github.com/influxdata/influxdb" - "github.com/julienschmidt/httprouter" ) // UserResourceMappingService is the struct of urm service diff --git a/http/user_resource_mapping_test.go b/http/user_resource_mapping_test.go index e64abd56e3c..64d3aa4d929 100644 --- a/http/user_resource_mapping_test.go +++ b/http/user_resource_mapping_test.go @@ -14,7 +14,7 @@ import ( platform "github.com/influxdata/influxdb" "github.com/influxdata/influxdb/mock" - "github.com/julienschmidt/httprouter" + "github.com/influxdata/httprouter" ) func TestUserResourceMappingService_GetMembersHandler(t *testing.T) { diff --git a/http/user_service.go b/http/user_service.go index fcba855bcb5..841287da9bd 100644 --- a/http/user_service.go +++ b/http/user_service.go @@ -8,9 +8,9 @@ import ( "net/http" "path" + "github.com/influxdata/httprouter" "github.com/influxdata/influxdb" icontext "github.com/influxdata/influxdb/context" - "github.com/julienschmidt/httprouter" "go.uber.org/zap" ) diff --git a/http/variable_service.go b/http/variable_service.go index 5d37e62e904..037939214d3 100644 --- a/http/variable_service.go +++ b/http/variable_service.go @@ -8,8 +8,8 @@ import ( "net/http" "path" + "github.com/influxdata/httprouter" platform "github.com/influxdata/influxdb" - "github.com/julienschmidt/httprouter" "go.uber.org/zap" ) diff --git a/http/variable_test.go b/http/variable_test.go index c8dbdd79513..616f2346f46 100644 --- a/http/variable_test.go +++ b/http/variable_test.go @@ -16,7 +16,7 @@ import ( platform "github.com/influxdata/influxdb" "github.com/influxdata/influxdb/mock" platformtesting "github.com/influxdata/influxdb/testing" - "github.com/julienschmidt/httprouter" + "github.com/influxdata/httprouter" ) var faketime = time.Date(2006, 5, 4, 1, 2, 3, 0, time.UTC) diff --git a/http/write_handler.go b/http/write_handler.go index c0897a130e2..6819c8a86e6 100644 --- a/http/write_handler.go +++ b/http/write_handler.go @@ -9,8 +9,8 @@ import ( "net/http" "time" + "github.com/influxdata/httprouter" "github.com/influxdata/influxdb/http/metric" - "github.com/julienschmidt/httprouter" "go.uber.org/zap" "github.com/influxdata/influxdb" diff --git a/kit/tracing/tracing.go b/kit/tracing/tracing.go index 9bbbfea89f6..1887d8751b6 100644 --- a/kit/tracing/tracing.go +++ b/kit/tracing/tracing.go @@ -7,7 +7,7 @@ import ( "runtime" "strings" - "github.com/julienschmidt/httprouter" + "github.com/influxdata/httprouter" "github.com/opentracing/opentracing-go" "github.com/opentracing/opentracing-go/ext" "github.com/opentracing/opentracing-go/log" diff --git a/kit/tracing/tracing_test.go b/kit/tracing/tracing_test.go index 5a7a09a7a92..a5e1f1d55ed 100644 --- a/kit/tracing/tracing_test.go +++ b/kit/tracing/tracing_test.go @@ -8,7 +8,7 @@ import ( "runtime" "testing" - "github.com/julienschmidt/httprouter" + "github.com/influxdata/httprouter" "github.com/opentracing/opentracing-go" "github.com/opentracing/opentracing-go/mocktracer" ) diff --git a/task/backend/analytical_storage.go b/task/backend/analytical_storage.go index 659a0e4f92f..644cd7f4f9c 100644 --- a/task/backend/analytical_storage.go +++ b/task/backend/analytical_storage.go @@ -173,7 +173,7 @@ func (as *AnalyticalStorage) FindRuns(ctx context.Context, filter influxdb.RunFi ID: sb.ID, OrgID: task.OrganizationID, Permissions: []influxdb.Permission{ - influxdb.Permission{ + { Action: influxdb.ReadAction, Resource: influxdb.Resource{ Type: influxdb.BucketsResourceType, @@ -269,7 +269,7 @@ func (as *AnalyticalStorage) FindRunByID(ctx context.Context, taskID, runID infl Status: influxdb.Active, OrgID: task.OrganizationID, Permissions: []influxdb.Permission{ - influxdb.Permission{ + { Action: influxdb.ReadAction, Resource: influxdb.Resource{ Type: influxdb.BucketsResourceType,