From dfcb637962ef7942f923cb0660592e1bbfc716d4 Mon Sep 17 00:00:00 2001 From: Raphael Simon Date: Sun, 7 Jan 2024 11:32:05 -0800 Subject: [PATCH 1/2] Add deprecation notices for functionality that is superseded by OpenTelemetry. See the Clue project https://github.com/goadesign/clue for more robust alternatives. --- http/middleware/capture.go | 7 +++++++ http/middleware/doc.go | 25 ++++--------------------- http/middleware/log.go | 8 ++++++++ http/middleware/requestid.go | 4 ++++ http/middleware/trace.go | 3 +++ http/middleware/xray/doc.go | 7 ++++++- 6 files changed, 32 insertions(+), 22 deletions(-) diff --git a/http/middleware/capture.go b/http/middleware/capture.go index 75bca603db..018f5b3324 100644 --- a/http/middleware/capture.go +++ b/http/middleware/capture.go @@ -10,6 +10,9 @@ import ( // ResponseCapture is a http.ResponseWriter which captures the response status // code and content length. +// +// Deprecated: this type is deprecated and will be removed in a future version +// of Goa. type ResponseCapture struct { http.ResponseWriter StatusCode int @@ -17,6 +20,10 @@ type ResponseCapture struct { } // CaptureResponse creates a ResponseCapture that wraps the given ResponseWriter. +// +// Deprecated: Use OpenTelemetry instead, see for example +// github.com/goadesign/clue. This function will be removed in a future version +// of Goa. func CaptureResponse(w http.ResponseWriter) *ResponseCapture { return &ResponseCapture{ResponseWriter: w} } diff --git a/http/middleware/doc.go b/http/middleware/doc.go index 86f5ffcd8e..6d0ea82b3a 100644 --- a/http/middleware/doc.go +++ b/http/middleware/doc.go @@ -1,23 +1,6 @@ -/*Package middleware contains HTTP middlewares that wrap a HTTP handler to -provide additional functionality. - -The package contains the following middlewares: - - * Logging server middleware for logging requests and responses. - * Request ID server middleware to include a unique request ID on receiving - a HTTP request. - * Tracing middleware for server and client. - * AWS X-Ray middleware for server and client that produce X-Ray segments. - -Example to use the server middleware: - - var handler http.Handler = goahttp.NewMuxer() - handler = middleware.RequestID()(handler) - -Example to use the client middleware: - - var doer goahttp.Doer = &http.Client{} - doer = xray.WrapDoer(doer) - +/* +Package middleware contains HTTP middlewares that wrap a HTTP handler to provide +ancilliary functionality such as capturing HTTP details into the request +context or printing debug information on incoming requests. */ package middleware diff --git a/http/middleware/log.go b/http/middleware/log.go index b8ad5a7d20..dd10f7885f 100644 --- a/http/middleware/log.go +++ b/http/middleware/log.go @@ -19,6 +19,10 @@ import ( // X-Forwarded-For HTTP header or - absent of that - the originating IP. The // middleware also logs the response HTTP status code, body length (in bytes) and // timing information. +// +// Deprecated: use OpenTelemetry instead, see for example +// github.com/goadesign/clue. This function will be removed in a future version +// of Goa. func Log(l middleware.Logger) func(h http.Handler) http.Handler { return func(h http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { @@ -30,6 +34,10 @@ func Log(l middleware.Logger) func(h http.Handler) http.Handler { // LogContext returns a middleware that logs the incoming requests similarly to // Log. LogContext calls the given function with the request context to extract // the logger. +// +// Deprecated: use OpenTelemetry instead, see for example +// github.com/goadesign/clue. This function will be removed in a future version +// of Goa. func LogContext(logFromCtx func(context.Context) middleware.Logger) func(http.Handler) http.Handler { return func(h http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { diff --git a/http/middleware/requestid.go b/http/middleware/requestid.go index d5897f1532..e33eb00c86 100644 --- a/http/middleware/requestid.go +++ b/http/middleware/requestid.go @@ -23,6 +23,10 @@ import ( // // // enable options for using "Custom-Id" header. // service.Use(middleware.RequestID(middleware.RequestIDHeaderOption("Custom-Id")) +// +// Deprecated: use OpenTelemetry instead, see for example +// github.com/goadesign/clue. This function will be removed in a future version +// of Goa. func RequestID(options ...middleware.RequestIDOption) func(http.Handler) http.Handler { o := middleware.NewRequestIDOptions(options...) useReqID := o.IsUseRequestID() diff --git a/http/middleware/trace.go b/http/middleware/trace.go index cddeda051a..7690c8fa1e 100644 --- a/http/middleware/trace.go +++ b/http/middleware/trace.go @@ -32,6 +32,9 @@ const ( // Trace returns a trace middleware that initializes the trace information in // the request context. +// Deprecated: use OpenTelemetry instead, see for example +// https://github.com/goadesign/clue. This function will be removed in a future +// version of Goa. func Trace(opts ...middleware.TraceOption) func(http.Handler) http.Handler { o := middleware.NewTraceOptions(opts...) sampler := o.NewSampler() diff --git a/http/middleware/xray/doc.go b/http/middleware/xray/doc.go index 749d3bba9e..447bfb4c4f 100644 --- a/http/middleware/xray/doc.go +++ b/http/middleware/xray/doc.go @@ -1,4 +1,5 @@ -/*Package xray contains middleware that creates AWS X-Ray segments from the +/* +Package xray contains middleware that creates AWS X-Ray segments from the HTTP requests and responses and send the segments to an AWS X-ray daemon. The server middleware works by extracting the trace information from the @@ -10,5 +11,9 @@ version or record an error. The client middleware wraps the client Doer and works by extracing the segment from the request context. It creates a new sub-segment and updates the request context with the latest segment before making the request. + +Deprecated: use OpenTelemetry instead, see for example +https://github.com/goadesign/clue. This package will be removed in a future +version of Goa. */ package xray From a95cfb2161fa985b59d98c0e49c20e0d3ce58eb0 Mon Sep 17 00:00:00 2001 From: Raphael Simon Date: Sun, 7 Jan 2024 11:32:39 -0800 Subject: [PATCH 2/2] Update dependencies --- go.mod | 10 +++++----- go.sum | 20 ++++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/go.mod b/go.mod index 1ddd0a41b4..498fba8d79 100644 --- a/go.mod +++ b/go.mod @@ -7,15 +7,15 @@ require ( github.com/dimfeld/httppath v0.0.0-20170720192232-ee938bf73598 github.com/getkin/kin-openapi v0.122.0 github.com/go-chi/chi/v5 v5.0.11 - github.com/google/uuid v1.4.0 + github.com/google/uuid v1.5.0 github.com/gorilla/websocket v1.5.1 github.com/manveru/faker v0.0.0-20171103152722-9fbc68a78c4d github.com/pkg/errors v0.9.1 github.com/sergi/go-diff v1.3.1 github.com/stretchr/testify v1.8.4 golang.org/x/text v0.14.0 - golang.org/x/tools v0.16.0 - google.golang.org/grpc v1.59.0 + golang.org/x/tools v0.16.1 + google.golang.org/grpc v1.60.1 google.golang.org/protobuf v1.32.0 gopkg.in/yaml.v3 v3.0.1 ) @@ -34,6 +34,6 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect golang.org/x/mod v0.14.0 // indirect golang.org/x/net v0.19.0 // indirect - golang.org/x/sys v0.15.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20231127180814-3a041ad873d4 // indirect + golang.org/x/sys v0.16.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240102182953-50ed04b92917 // indirect ) diff --git a/go.sum b/go.sum index 55c09677ae..dd708458ce 100644 --- a/go.sum +++ b/go.sum @@ -21,8 +21,8 @@ github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4= -github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU= +github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY= github.com/invopop/yaml v0.2.0 h1:7zky/qH+O0DwAyoobXUqvVBwgBFRxKoQ/3FjcVpjTMY= @@ -67,17 +67,17 @@ golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c= golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U= golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE= -golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= -golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= +golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/tools v0.16.0 h1:GO788SKMRunPIBCXiQyo2AaexLstOrVhuAL5YwsckQM= -golang.org/x/tools v0.16.0/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0= +golang.org/x/tools v0.16.1 h1:TLyB3WofjdOEepBHAU20JdNC1Zbg87elYofWYAY5oZA= +golang.org/x/tools v0.16.1/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/genproto/googleapis/rpc v0.0.0-20231127180814-3a041ad873d4 h1:DC7wcm+i+P1rN3Ff07vL+OndGg5OhNddHyTA+ocPqYE= -google.golang.org/genproto/googleapis/rpc v0.0.0-20231127180814-3a041ad873d4/go.mod h1:eJVxU6o+4G1PSczBr85xmyvSNYAKvAYgkub40YGomFM= -google.golang.org/grpc v1.59.0 h1:Z5Iec2pjwb+LEOqzpB2MR12/eKFhDPhuqW91O+4bwUk= -google.golang.org/grpc v1.59.0/go.mod h1:aUPDwccQo6OTjy7Hct4AfBPD1GptF4fyUjIkQ9YtF98= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240102182953-50ed04b92917 h1:6G8oQ016D88m1xAKljMlBOOGWDZkes4kMhgGFlf8WcQ= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240102182953-50ed04b92917/go.mod h1:xtjpI3tXFPP051KaWnhvxkiubL/6dJ18vLVf7q2pTOU= +google.golang.org/grpc v1.60.1 h1:26+wFr+cNqSGFcOXcabYC0lUVJVRa2Sb2ortSK7VrEU= +google.golang.org/grpc v1.60.1/go.mod h1:OlCHIeLYqSSsLi6i49B5QGdzaMZK9+M7LXN2FKz4eGM= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I=