From 1efee8e46476ef8407ca06dd1d5aa28cd61c68bf Mon Sep 17 00:00:00 2001 From: Sergio Andres Virviescas Santana Date: Thu, 13 Jan 2022 11:25:08 +0100 Subject: [PATCH 01/11] fix: set response context with closer close --- module/apmfasthttp/closer.go | 10 +++++++--- module/apmfasthttp/context.go | 10 ++++------ module/apmfasthttp/go.mod | 2 +- module/apmfasthttp/go.sum | 8 ++++---- module/apmfasthttp/server.go | 2 -- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/module/apmfasthttp/closer.go b/module/apmfasthttp/closer.go index 1c732c42a..69ff924b8 100644 --- a/module/apmfasthttp/closer.go +++ b/module/apmfasthttp/closer.go @@ -18,14 +18,16 @@ package apmfasthttp // import "go.elastic.co/apm/module/apmfasthttp" import ( + "github.com/valyala/fasthttp" "go.elastic.co/apm" ) // newTxCloser returns a transaction closer. -func newTxCloser(tx *apm.Transaction, bc *apm.BodyCapturer) *txCloser { +func newTxCloser(ctx *fasthttp.RequestCtx, tx *apm.Transaction, bc *apm.BodyCapturer) *txCloser { return &txCloser{ - tx: tx, - bc: bc, + ctx: ctx, + tx: tx, + bc: bc, } } @@ -38,7 +40,9 @@ func newTxCloser(tx *apm.Transaction, bc *apm.BodyCapturer) *txCloser { // RequestHandler. Additionally, Close method is called on each value // implementing io.Closer before removing the value from ctx. func (c *txCloser) Close() error { + setResponseContext(c.ctx, c.tx, c.bc) c.tx.End() c.bc.Discard() + return nil } diff --git a/module/apmfasthttp/context.go b/module/apmfasthttp/context.go index fff4063ff..a20808264 100644 --- a/module/apmfasthttp/context.go +++ b/module/apmfasthttp/context.go @@ -63,13 +63,12 @@ func setRequestContext(ctx *fasthttp.RequestCtx, tracer *apm.Tracer, tx *apm.Tra } func setResponseContext(ctx *fasthttp.RequestCtx, tx *apm.Transaction, bc *apm.BodyCapturer) { - statusCode := ctx.Response.Header.StatusCode() - - tx.Result = apmhttp.StatusCodeResult(statusCode) if !tx.Sampled() { return } + statusCode := ctx.Response.Header.StatusCode() + headers := make(http.Header) ctx.Response.Header.VisitAll(func(k, v []byte) { sk := string(k) @@ -78,10 +77,9 @@ func setResponseContext(ctx *fasthttp.RequestCtx, tx *apm.Transaction, bc *apm.B headers.Set(sk, sv) }) + tx.Result = apmhttp.StatusCodeResult(statusCode) tx.Context.SetHTTPResponseHeaders(headers) tx.Context.SetHTTPStatusCode(statusCode) - - return } // StartTransactionWithBody returns a new Transaction with name, @@ -111,7 +109,7 @@ func StartTransactionWithBody( return nil, nil, err } - ctx.SetUserValue(txKey, newTxCloser(tx, bc)) + ctx.SetUserValue(txKey, newTxCloser(ctx, tx, bc)) return tx, bc, nil } diff --git a/module/apmfasthttp/go.mod b/module/apmfasthttp/go.mod index 66b262d69..db3af7d38 100644 --- a/module/apmfasthttp/go.mod +++ b/module/apmfasthttp/go.mod @@ -5,7 +5,7 @@ go 1.13 require ( github.com/stretchr/testify v1.6.1 github.com/valyala/bytebufferpool v1.0.0 - github.com/valyala/fasthttp v1.26.0 + github.com/valyala/fasthttp v1.32.0 go.elastic.co/apm v1.15.0 go.elastic.co/apm/module/apmhttp v1.15.0 ) diff --git a/module/apmfasthttp/go.sum b/module/apmfasthttp/go.sum index b0da2a7da..edbbbbd0f 100644 --- a/module/apmfasthttp/go.sum +++ b/module/apmfasthttp/go.sum @@ -18,8 +18,8 @@ github.com/jcchavezs/porto v0.1.0/go.mod h1:fESH0gzDHiutHRdX2hv27ojnOVFco37hg1W6 github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 h1:rp+c0RAYOWj8l6qbCUTSiRLG/iKnW3K3/QfPPuSsBt4= github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901/go.mod h1:Z86h9688Y0wesXCyonoVr47MasHilkuLMqGhRZ4Hpak= -github.com/klauspost/compress v1.12.2 h1:2KCfW3I9M7nSc5wOqXAlW2v2U6v+w6cbjvbfp+OykW8= -github.com/klauspost/compress v1.12.2/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= +github.com/klauspost/compress v1.13.4 h1:0zhec2I8zGnjWcKyLl6i3gPqKANCCn5e9xmviEEeX6s= +github.com/klauspost/compress v1.13.4/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -40,8 +40,8 @@ github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= -github.com/valyala/fasthttp v1.26.0 h1:k5Tooi31zPG/g8yS6o2RffRO2C9B9Kah9SY8j/S7058= -github.com/valyala/fasthttp v1.26.0/go.mod h1:cmWIqlu99AO/RKcp1HWaViTqc57FswJOfYYdPJBl8BA= +github.com/valyala/fasthttp v1.32.0 h1:keswgWzyKyNIIjz2a7JmCYHOOIkRp6HMx9oTV6QrZWY= +github.com/valyala/fasthttp v1.32.0/go.mod h1:2rsYD01CKFrjjsvFxx75KlEUNpWNBY9JWD3K/7o2Cus= github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.elastic.co/fastjson v1.1.0 h1:3MrGBWWVIxe/xvsbpghtkFoPciPhOCmjsR/HfwEeQR4= diff --git a/module/apmfasthttp/server.go b/module/apmfasthttp/server.go index 03fb8786b..14814906a 100644 --- a/module/apmfasthttp/server.go +++ b/module/apmfasthttp/server.go @@ -88,8 +88,6 @@ func (h *apmHandler) handler(ctx *fasthttp.RequestCtx) { }() h.requestHandler(ctx) - - setResponseContext(ctx, tx, bc) } // WithTracer returns a ServerOption which sets t as the tracer From e07a8ce7ea5bf6a565fac67eb1863b1d2f4b4fc0 Mon Sep 17 00:00:00 2001 From: Sergio Andres Virviescas Santana Date: Tue, 18 Jan 2022 11:37:30 +0100 Subject: [PATCH 02/11] feat: add tests --- module/apmfasthttp/server_test.go | 109 ++++++++++++++++++++++++++---- 1 file changed, 94 insertions(+), 15 deletions(-) diff --git a/module/apmfasthttp/server_test.go b/module/apmfasthttp/server_test.go index 8c0894fe7..edae78b76 100644 --- a/module/apmfasthttp/server_test.go +++ b/module/apmfasthttp/server_test.go @@ -18,6 +18,7 @@ package apmfasthttp_test import ( + "bufio" "io" "io/ioutil" "net" @@ -29,27 +30,23 @@ import ( "github.com/stretchr/testify/require" "github.com/valyala/fasthttp" + "go.elastic.co/apm/model" "go.elastic.co/apm/module/apmfasthttp" "go.elastic.co/apm/transport/transporttest" ) -func TestServerHTTPResponse(t *testing.T) { +func testServer(t *testing.T, s *fasthttp.Server, assertFunc func(model.Transaction, *http.Response)) { + t.Helper() + tracer, transport := transporttest.NewRecorderTracer() defer tracer.Close() - handler := func(ctx *fasthttp.RequestCtx) { - ctx.Error(fasthttp.StatusMessage(fasthttp.StatusUnauthorized), fasthttp.StatusUnauthorized) - } - handler = apmfasthttp.Wrap(handler, apmfasthttp.WithTracer(tracer)) shutdown := make(chan error) defer close(shutdown) ln, err := net.Listen("tcp", "127.0.0.1:") require.NoError(t, err) - s := &fasthttp.Server{ - Handler: handler, - Name: "test-server", - } + s.Handler = apmfasthttp.Wrap(s.Handler, apmfasthttp.WithTracer(tracer)) go func() { shutdown <- s.Serve(ln) @@ -60,7 +57,6 @@ func TestServerHTTPResponse(t *testing.T) { require.NoError(t, err) io.Copy(ioutil.Discard, resp.Body) // consume body to complete request handler resp.Body.Close() - assert.Equal(t, fasthttp.StatusUnauthorized, resp.StatusCode) tracer.Flush(nil) payloads := transport.Payloads() @@ -69,7 +65,7 @@ func TestServerHTTPResponse(t *testing.T) { // enqueued. Continue to call `tracer.Flush()` and wait for the // transaction to have ended. // This is unique to fasthttp's implementation. - timer := time.NewTimer(100 * time.Millisecond) + timer := time.NewTimer(200 * time.Millisecond) defer timer.Stop() for { select { @@ -85,12 +81,95 @@ func TestServerHTTPResponse(t *testing.T) { payloads = transport.Payloads() } - transaction := payloads.Transactions[0] - assert.Equal(t, "GET /", transaction.Name) - assert.Equal(t, "request", transaction.Type) - assert.Equal(t, "HTTP 4xx", transaction.Result) + assertFunc(payloads.Transactions[0], resp) // s.Serve returns on ln.Close() ln.Close() require.NoError(t, <-shutdown) } + +func TestServerHTTPResponse(t *testing.T) { + s := &fasthttp.Server{ + Handler: func(ctx *fasthttp.RequestCtx) { + ctx.Error(fasthttp.StatusMessage(fasthttp.StatusUnauthorized), fasthttp.StatusUnauthorized) + }, + Name: "test-server", + } + + assertFunc := func(transaction model.Transaction, resp *http.Response) { + expectedHeaders := model.Headers{ + {Key: "Content-Length", Values: []string{"12"}}, + {Key: "Content-Type", Values: []string{"text/plain; charset=utf-8"}}, + {Key: "Server", Values: []string{s.Name}}, + } + + assert.Equal(t, fasthttp.StatusUnauthorized, resp.StatusCode) + assert.Equal(t, "GET /", transaction.Name) + assert.Equal(t, "request", transaction.Type) + assert.Equal(t, "HTTP 4xx", transaction.Result) + assert.Equal(t, expectedHeaders, transaction.Context.Response.Headers) + } + + testServer(t, s, assertFunc) +} + +func TestServerHTTPResponseStream(t *testing.T) { + streamResponseDuration := time.Millisecond * 100 + + s := &fasthttp.Server{ + Handler: func(ctx *fasthttp.RequestCtx) { + ctx.SetBodyStreamWriter(func(w *bufio.Writer) { + w.WriteString("Hello world") + time.Sleep(streamResponseDuration) + }) + }, + Name: "test-server", + } + + assertFunc := func(transaction model.Transaction, resp *http.Response) { + expectedHeaders := model.Headers{ + {Key: "Content-Type", Values: []string{"text/plain; charset=utf-8"}}, + {Key: "Server", Values: []string{s.Name}}, + {Key: "Transfer-Encoding", Values: []string{"chunked"}}, + } + + assert.Equal(t, fasthttp.StatusOK, resp.StatusCode) + assert.Equal(t, "GET /", transaction.Name) + assert.Equal(t, "request", transaction.Type) + assert.Equal(t, "HTTP 2xx", transaction.Result) + assert.GreaterOrEqual(t, transaction.Duration, float64(streamResponseDuration.Milliseconds())) + assert.Equal(t, transaction.Context.Response.Headers, expectedHeaders) + } + + testServer(t, s, assertFunc) +} + +func TestServerHTTPResponseHijack(t *testing.T) { + hijackResponseDuration := time.Millisecond * 100 + + s := &fasthttp.Server{ + Handler: func(ctx *fasthttp.RequestCtx) { + ctx.Hijack(func(c net.Conn) { + time.Sleep(hijackResponseDuration) + }) + }, + Name: "test-server", + } + + assertFunc := func(transaction model.Transaction, resp *http.Response) { + expectedHeaders := model.Headers{ + {Key: "Content-Length", Values: []string{"0"}}, + {Key: "Content-Type", Values: []string{"text/plain; charset=utf-8"}}, + {Key: "Server", Values: []string{s.Name}}, + } + + assert.Equal(t, fasthttp.StatusOK, resp.StatusCode) + assert.Equal(t, "GET /", transaction.Name) + assert.Equal(t, "request", transaction.Type) + assert.Equal(t, "HTTP 2xx", transaction.Result) + assert.GreaterOrEqual(t, transaction.Duration, float64(hijackResponseDuration.Milliseconds())) + assert.Equal(t, transaction.Context.Response.Headers, expectedHeaders) + } + + testServer(t, s, assertFunc) +} From 7533cda5bbc70b85515e284f1de3d4dd09e42eeb Mon Sep 17 00:00:00 2001 From: Sergio Andres Virviescas Santana Date: Mon, 24 Jan 2022 10:08:31 +0100 Subject: [PATCH 03/11] tests: improvements --- module/apmfasthttp/server_test.go | 65 +++++++++++++++++++------------ 1 file changed, 40 insertions(+), 25 deletions(-) diff --git a/module/apmfasthttp/server_test.go b/module/apmfasthttp/server_test.go index edae78b76..67914d748 100644 --- a/module/apmfasthttp/server_test.go +++ b/module/apmfasthttp/server_test.go @@ -23,6 +23,7 @@ import ( "io/ioutil" "net" "net/http" + "sync" "testing" "time" @@ -35,7 +36,9 @@ import ( "go.elastic.co/apm/transport/transporttest" ) -func testServer(t *testing.T, s *fasthttp.Server, assertFunc func(model.Transaction, *http.Response)) { +type assertFunc func(model.Transaction, *http.Response) + +func testServer(t *testing.T, s *fasthttp.Server, wg *sync.WaitGroup, assertFn assertFunc) { t.Helper() tracer, transport := transporttest.NewRecorderTracer() @@ -43,6 +46,7 @@ func testServer(t *testing.T, s *fasthttp.Server, assertFunc func(model.Transact shutdown := make(chan error) defer close(shutdown) + ln, err := net.Listen("tcp", "127.0.0.1:") require.NoError(t, err) @@ -53,35 +57,39 @@ func testServer(t *testing.T, s *fasthttp.Server, assertFunc func(model.Transact }() addr := ln.Addr().String() + resp, err := http.Get("http://" + addr) require.NoError(t, err) - io.Copy(ioutil.Discard, resp.Body) // consume body to complete request handler + + _, _ = io.Copy(ioutil.Discard, resp.Body) // consume body to complete request handler resp.Body.Close() + + if wg != nil { + wg.Wait() + } + tracer.Flush(nil) payloads := transport.Payloads() - // the transaction is ended after the response body is fully written, - // so a single call to `tracer.Flush()` may not have an event yet - // enqueued. Continue to call `tracer.Flush()` and wait for the - // transaction to have ended. - // This is unique to fasthttp's implementation. - timer := time.NewTimer(200 * time.Millisecond) - defer timer.Stop() - for { - select { - case <-timer.C: - t.Fatal("timed out waiting for payload") - default: - } - if len(payloads.Transactions) > 0 { - break + count := 0 + for len(payloads.Transactions) == 0 { + // the transaction is ended after the response body is fully written, + // so a single call to `tracer.Flush()` may not have an event yet + // enqueued. Continue to call `tracer.Flush()` and wait for the + // transaction to have ended. + // This is unique to fasthttp's implementation. + if count > 10 { + t.Fatal("no transaction found") } - time.Sleep(10 * time.Millisecond) + + count++ + + time.Sleep(100 * time.Millisecond) tracer.Flush(nil) payloads = transport.Payloads() } - assertFunc(payloads.Transactions[0], resp) + assertFn(payloads.Transactions[0], resp) // s.Serve returns on ln.Close() ln.Close() @@ -96,7 +104,7 @@ func TestServerHTTPResponse(t *testing.T) { Name: "test-server", } - assertFunc := func(transaction model.Transaction, resp *http.Response) { + assertFn := func(transaction model.Transaction, resp *http.Response) { expectedHeaders := model.Headers{ {Key: "Content-Length", Values: []string{"12"}}, {Key: "Content-Type", Values: []string{"text/plain; charset=utf-8"}}, @@ -104,13 +112,14 @@ func TestServerHTTPResponse(t *testing.T) { } assert.Equal(t, fasthttp.StatusUnauthorized, resp.StatusCode) + assert.Equal(t, resp.StatusCode, transaction.Context.Response.StatusCode) assert.Equal(t, "GET /", transaction.Name) assert.Equal(t, "request", transaction.Type) assert.Equal(t, "HTTP 4xx", transaction.Result) assert.Equal(t, expectedHeaders, transaction.Context.Response.Headers) } - testServer(t, s, assertFunc) + testServer(t, s, nil, assertFn) } func TestServerHTTPResponseStream(t *testing.T) { @@ -126,7 +135,7 @@ func TestServerHTTPResponseStream(t *testing.T) { Name: "test-server", } - assertFunc := func(transaction model.Transaction, resp *http.Response) { + assertFn := func(transaction model.Transaction, resp *http.Response) { expectedHeaders := model.Headers{ {Key: "Content-Type", Values: []string{"text/plain; charset=utf-8"}}, {Key: "Server", Values: []string{s.Name}}, @@ -134,6 +143,7 @@ func TestServerHTTPResponseStream(t *testing.T) { } assert.Equal(t, fasthttp.StatusOK, resp.StatusCode) + assert.Equal(t, resp.StatusCode, transaction.Context.Response.StatusCode) assert.Equal(t, "GET /", transaction.Name) assert.Equal(t, "request", transaction.Type) assert.Equal(t, "HTTP 2xx", transaction.Result) @@ -141,22 +151,26 @@ func TestServerHTTPResponseStream(t *testing.T) { assert.Equal(t, transaction.Context.Response.Headers, expectedHeaders) } - testServer(t, s, assertFunc) + testServer(t, s, nil, assertFn) } func TestServerHTTPResponseHijack(t *testing.T) { hijackResponseDuration := time.Millisecond * 100 + wg := new(sync.WaitGroup) + wg.Add(1) + s := &fasthttp.Server{ Handler: func(ctx *fasthttp.RequestCtx) { ctx.Hijack(func(c net.Conn) { time.Sleep(hijackResponseDuration) + wg.Done() }) }, Name: "test-server", } - assertFunc := func(transaction model.Transaction, resp *http.Response) { + assertFn := func(transaction model.Transaction, resp *http.Response) { expectedHeaders := model.Headers{ {Key: "Content-Length", Values: []string{"0"}}, {Key: "Content-Type", Values: []string{"text/plain; charset=utf-8"}}, @@ -164,6 +178,7 @@ func TestServerHTTPResponseHijack(t *testing.T) { } assert.Equal(t, fasthttp.StatusOK, resp.StatusCode) + assert.Equal(t, resp.StatusCode, transaction.Context.Response.StatusCode) assert.Equal(t, "GET /", transaction.Name) assert.Equal(t, "request", transaction.Type) assert.Equal(t, "HTTP 2xx", transaction.Result) @@ -171,5 +186,5 @@ func TestServerHTTPResponseHijack(t *testing.T) { assert.Equal(t, transaction.Context.Response.Headers, expectedHeaders) } - testServer(t, s, assertFunc) + testServer(t, s, wg, assertFn) } From 9426e7d88dbb64dd84ec2832b61d5109d4fc797b Mon Sep 17 00:00:00 2001 From: Sergio Andres Virviescas Santana Date: Mon, 24 Jan 2022 10:09:53 +0100 Subject: [PATCH 04/11] tests: try last fasthttp version --- module/apmfasthttp/go.mod | 2 +- module/apmfasthttp/go.sum | 29 +++++++++++++++-------------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/module/apmfasthttp/go.mod b/module/apmfasthttp/go.mod index db3af7d38..151021c8d 100644 --- a/module/apmfasthttp/go.mod +++ b/module/apmfasthttp/go.mod @@ -5,7 +5,7 @@ go 1.13 require ( github.com/stretchr/testify v1.6.1 github.com/valyala/bytebufferpool v1.0.0 - github.com/valyala/fasthttp v1.32.0 + github.com/valyala/fasthttp v1.32.1-0.20220122035437-436977654aa1 go.elastic.co/apm v1.15.0 go.elastic.co/apm/module/apmhttp v1.15.0 ) diff --git a/module/apmfasthttp/go.sum b/module/apmfasthttp/go.sum index edbbbbd0f..561fcc22a 100644 --- a/module/apmfasthttp/go.sum +++ b/module/apmfasthttp/go.sum @@ -1,5 +1,5 @@ -github.com/andybalholm/brotli v1.0.2 h1:JKnhI/XQ75uFBTiuzXpzFrUriDPiZjlOSzh6wXogP0E= -github.com/andybalholm/brotli v1.0.2/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y= +github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY= +github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI= github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= @@ -18,8 +18,8 @@ github.com/jcchavezs/porto v0.1.0/go.mod h1:fESH0gzDHiutHRdX2hv27ojnOVFco37hg1W6 github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 h1:rp+c0RAYOWj8l6qbCUTSiRLG/iKnW3K3/QfPPuSsBt4= github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901/go.mod h1:Z86h9688Y0wesXCyonoVr47MasHilkuLMqGhRZ4Hpak= -github.com/klauspost/compress v1.13.4 h1:0zhec2I8zGnjWcKyLl6i3gPqKANCCn5e9xmviEEeX6s= -github.com/klauspost/compress v1.13.4/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= +github.com/klauspost/compress v1.14.1 h1:hLQYb23E8/fO+1u53d02A97a8UnsddcvYzq4ERRU4ds= +github.com/klauspost/compress v1.14.1/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -40,15 +40,15 @@ github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= -github.com/valyala/fasthttp v1.32.0 h1:keswgWzyKyNIIjz2a7JmCYHOOIkRp6HMx9oTV6QrZWY= -github.com/valyala/fasthttp v1.32.0/go.mod h1:2rsYD01CKFrjjsvFxx75KlEUNpWNBY9JWD3K/7o2Cus= +github.com/valyala/fasthttp v1.32.1-0.20220122035437-436977654aa1 h1:xgGC1/HE7lNNyyNgz5WV4gdpe9mQMkYbGgBtq9al1TI= +github.com/valyala/fasthttp v1.32.1-0.20220122035437-436977654aa1/go.mod h1:KJRK/MXx0J+yd0c5hlR+s1tIHD72sniU8ZJjl97LIw4= github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.elastic.co/fastjson v1.1.0 h1:3MrGBWWVIxe/xvsbpghtkFoPciPhOCmjsR/HfwEeQR4= go.elastic.co/fastjson v1.1.0/go.mod h1:boNGISWMjQsUPy/t6yqt2/1Wx4YNPSe+mZjlyw9vKKI= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8= +golang.org/x/crypto v0.0.0-20220112180741-5e0467b6c7ce/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5 h1:2M3HP5CCK1Si9FQhwnzYhXdG6DXeebvUHFpre8QvbyI= golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= @@ -58,9 +58,9 @@ golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210510120150-4163338589ed h1:p9UgmWI9wKpfYmgaV/IZKGdXc5qEK45tDwwwDyjS26I= -golang.org/x/net v0.0.0-20210510120150-4163338589ed/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20220111093109-d55c255bac03 h1:0FB83qp0AzVJm+0wcIlauAjJ+tNdh7jLuacRYCIVv7s= +golang.org/x/net v0.0.0-20220111093109-d55c255bac03/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -70,14 +70,15 @@ golang.org/x/sys v0.0.0-20191025021431-6c3a3bfe00ae/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210514084401-e8d321eab015 h1:hZR0X1kPW+nwyJ9xRxqZk1vx5RUObAPBdKVvXPDUH/E= -golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220111092808-5a964db01320 h1:0jf+tOCoZ3LyutmCOWpVni1chK4VfFLhRsDK7MhqGRY= +golang.org/x/sys v0.0.0-20220111092808-5a964db01320/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= From aa01881dcf3a1dea36af5611c93db2b7ff6f30a2 Mon Sep 17 00:00:00 2001 From: Sergio Andres Virviescas Santana Date: Mon, 24 Jan 2022 10:12:13 +0100 Subject: [PATCH 05/11] tests: fix typo --- module/apmfasthttp/server_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/apmfasthttp/server_test.go b/module/apmfasthttp/server_test.go index 67914d748..2b24a0aa0 100644 --- a/module/apmfasthttp/server_test.go +++ b/module/apmfasthttp/server_test.go @@ -79,7 +79,7 @@ func testServer(t *testing.T, s *fasthttp.Server, wg *sync.WaitGroup, assertFn a // transaction to have ended. // This is unique to fasthttp's implementation. if count > 10 { - t.Fatal("no transaction found") + t.Fatal("no transactions found") } count++ From d8dad116b51d507019150d242529faaf4a522c16 Mon Sep 17 00:00:00 2001 From: Sergio Andres Virviescas Santana Date: Thu, 27 Jan 2022 12:12:46 +0100 Subject: [PATCH 06/11] feat: upgrade fasthttp to v1.33.0 --- module/apmfasthttp/go.mod | 2 +- module/apmfasthttp/go.sum | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/module/apmfasthttp/go.mod b/module/apmfasthttp/go.mod index 151021c8d..c9665f64c 100644 --- a/module/apmfasthttp/go.mod +++ b/module/apmfasthttp/go.mod @@ -5,7 +5,7 @@ go 1.13 require ( github.com/stretchr/testify v1.6.1 github.com/valyala/bytebufferpool v1.0.0 - github.com/valyala/fasthttp v1.32.1-0.20220122035437-436977654aa1 + github.com/valyala/fasthttp v1.33.0 go.elastic.co/apm v1.15.0 go.elastic.co/apm/module/apmhttp v1.15.0 ) diff --git a/module/apmfasthttp/go.sum b/module/apmfasthttp/go.sum index 561fcc22a..8ad139c25 100644 --- a/module/apmfasthttp/go.sum +++ b/module/apmfasthttp/go.sum @@ -10,7 +10,6 @@ github.com/elastic/go-sysinfo v1.1.1 h1:ZVlaLDyhVkDfjwPGU55CQRCRolNpc7P0BbyhhQZQ github.com/elastic/go-sysinfo v1.1.1/go.mod h1:i1ZYdU10oLNfRzq4vq62BEwD2fH8KaWh6eh0ikPT9F0= github.com/elastic/go-windows v1.0.0 h1:qLURgZFkkrYyTTkvYpsZIgf83AUsdIHfvlJaqaZ7aSY= github.com/elastic/go-windows v1.0.0/go.mod h1:TsU0Nrp7/y3+VwE82FoZF8gC/XFg/Elz6CcloAxnPgU= -github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/go-cmp v0.3.1 h1:Xye71clBPdm5HgqGwUkwhbynsUJZhDbS20FvLhQ2izg= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/jcchavezs/porto v0.1.0 h1:Xmxxn25zQMmgE7/yHYmh19KcItG81hIwfbEEFnd6w/Q= @@ -40,8 +39,8 @@ github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= -github.com/valyala/fasthttp v1.32.1-0.20220122035437-436977654aa1 h1:xgGC1/HE7lNNyyNgz5WV4gdpe9mQMkYbGgBtq9al1TI= -github.com/valyala/fasthttp v1.32.1-0.20220122035437-436977654aa1/go.mod h1:KJRK/MXx0J+yd0c5hlR+s1tIHD72sniU8ZJjl97LIw4= +github.com/valyala/fasthttp v1.33.0 h1:mHBKd98J5NcXuBddgjvim1i3kWzlng1SzLhrnBOU9g8= +github.com/valyala/fasthttp v1.33.0/go.mod h1:KJRK/MXx0J+yd0c5hlR+s1tIHD72sniU8ZJjl97LIw4= github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.elastic.co/fastjson v1.1.0 h1:3MrGBWWVIxe/xvsbpghtkFoPciPhOCmjsR/HfwEeQR4= From d9124b84f970adc0fbaf8f6cecbb170274d01085 Mon Sep 17 00:00:00 2001 From: Sergio Andres Virviescas Santana Date: Thu, 3 Feb 2022 12:22:47 +0100 Subject: [PATCH 07/11] feat: add doc about RequestCtx --- module/apmfasthttp/context.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/module/apmfasthttp/context.go b/module/apmfasthttp/context.go index 5c08dee9d..49893ddcc 100644 --- a/module/apmfasthttp/context.go +++ b/module/apmfasthttp/context.go @@ -109,6 +109,11 @@ func StartTransactionWithBody( return nil, nil, err } + // NOTE: the fasthttp documentation states that references to RequestCtx + // must not be held after returning from RequestHandler. This is due to + // RequestCtx being pooled, and released after the RequestHandler returns. + // However, it is safe to reference and call RequestCtx in a closer, as the + // closer is invoked before releasing the RequestCtx back to the pool. ctx.SetUserValue(txKey, newTxCloser(ctx, tx, bc)) return tx, bc, nil From 3e5631e77059aaeb52111c937708c0c23df88039 Mon Sep 17 00:00:00 2001 From: Sergio Andres Virviescas Santana Date: Fri, 4 Feb 2022 10:07:07 +0100 Subject: [PATCH 08/11] fix: set result for sampled transactions --- module/apmfasthttp/context.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/module/apmfasthttp/context.go b/module/apmfasthttp/context.go index 49893ddcc..3db74dd51 100644 --- a/module/apmfasthttp/context.go +++ b/module/apmfasthttp/context.go @@ -63,12 +63,13 @@ func setRequestContext(ctx *fasthttp.RequestCtx, tracer *apm.Tracer, tx *apm.Tra } func setResponseContext(ctx *fasthttp.RequestCtx, tx *apm.Transaction, bc *apm.BodyCapturer) { + statusCode := ctx.Response.Header.StatusCode() + tx.Result = apmhttp.StatusCodeResult(statusCode) + if !tx.Sampled() { return } - statusCode := ctx.Response.Header.StatusCode() - headers := make(http.Header) ctx.Response.Header.VisitAll(func(k, v []byte) { sk := string(k) @@ -77,7 +78,6 @@ func setResponseContext(ctx *fasthttp.RequestCtx, tx *apm.Transaction, bc *apm.B headers.Set(sk, sv) }) - tx.Result = apmhttp.StatusCodeResult(statusCode) tx.Context.SetHTTPResponseHeaders(headers) tx.Context.SetHTTPStatusCode(statusCode) } From 980689f3111a2ef9fe7daebc86404f98b04f7d2e Mon Sep 17 00:00:00 2001 From: Sergio Andres Virviescas Santana Date: Fri, 4 Feb 2022 10:10:30 +0100 Subject: [PATCH 09/11] refactor: improve test --- module/apmfasthttp/server_test.go | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/module/apmfasthttp/server_test.go b/module/apmfasthttp/server_test.go index bfc99202c..ff73960c3 100644 --- a/module/apmfasthttp/server_test.go +++ b/module/apmfasthttp/server_test.go @@ -71,22 +71,23 @@ func testServer(t *testing.T, s *fasthttp.Server, wg *sync.WaitGroup, assertFn a tracer.Flush(nil) payloads := transport.Payloads() - count := 0 + // the transaction is ended after the response body is fully written, + // so a single call to `tracer.Flush()` may not have an event yet + // enqueued. Continue to call `tracer.Flush()` and wait for the + // transaction to have ended. + // This is unique to fasthttp's implementation. + timer := time.NewTimer(100 * time.Millisecond) + defer timer.Stop() + for len(payloads.Transactions) == 0 { - // the transaction is ended after the response body is fully written, - // so a single call to `tracer.Flush()` may not have an event yet - // enqueued. Continue to call `tracer.Flush()` and wait for the - // transaction to have ended. - // This is unique to fasthttp's implementation. - if count > 10 { - t.Fatal("no transactions found") + select { + case <-timer.C: + t.Fatal("timed out waiting for payload") + default: + time.Sleep(100 * time.Millisecond) + tracer.Flush(nil) + payloads = transport.Payloads() } - - count++ - - time.Sleep(100 * time.Millisecond) - tracer.Flush(nil) - payloads = transport.Payloads() } assertFn(payloads.Transactions[0], resp) From c96d18697c39b5834f7d0d37f07cdbe181df2f79 Mon Sep 17 00:00:00 2001 From: Sergio VS Date: Wed, 16 Feb 2022 17:24:30 +0100 Subject: [PATCH 10/11] fix: fmt and check --- module/apmfasthttp/closer.go | 1 + module/apmfiber/go.mod | 2 +- module/apmfiber/go.sum | 23 +++++++++++++++-------- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/module/apmfasthttp/closer.go b/module/apmfasthttp/closer.go index 87f8bb2b2..bd306054c 100644 --- a/module/apmfasthttp/closer.go +++ b/module/apmfasthttp/closer.go @@ -19,6 +19,7 @@ package apmfasthttp // import "go.elastic.co/apm/module/apmfasthttp/v2" import ( "github.com/valyala/fasthttp" + "go.elastic.co/apm/v2" ) diff --git a/module/apmfiber/go.mod b/module/apmfiber/go.mod index b8b464658..405d050c8 100644 --- a/module/apmfiber/go.mod +++ b/module/apmfiber/go.mod @@ -4,7 +4,7 @@ require ( github.com/gofiber/fiber/v2 v2.18.0 github.com/pkg/errors v0.9.1 github.com/stretchr/testify v1.7.0 - github.com/valyala/fasthttp v1.29.0 + github.com/valyala/fasthttp v1.33.0 go.elastic.co/apm/module/apmfasthttp/v2 v2.0.0 go.elastic.co/apm/module/apmhttp/v2 v2.0.0 go.elastic.co/apm/v2 v2.0.0 diff --git a/module/apmfiber/go.sum b/module/apmfiber/go.sum index 19250df28..7c8e15e06 100644 --- a/module/apmfiber/go.sum +++ b/module/apmfiber/go.sum @@ -1,5 +1,6 @@ -github.com/andybalholm/brotli v1.0.2 h1:JKnhI/XQ75uFBTiuzXpzFrUriDPiZjlOSzh6wXogP0E= github.com/andybalholm/brotli v1.0.2/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y= +github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY= +github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI= github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= @@ -20,9 +21,9 @@ github.com/jcchavezs/porto v0.1.0/go.mod h1:fESH0gzDHiutHRdX2hv27ojnOVFco37hg1W6 github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 h1:rp+c0RAYOWj8l6qbCUTSiRLG/iKnW3K3/QfPPuSsBt4= github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901/go.mod h1:Z86h9688Y0wesXCyonoVr47MasHilkuLMqGhRZ4Hpak= -github.com/klauspost/compress v1.12.2/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= -github.com/klauspost/compress v1.13.4 h1:0zhec2I8zGnjWcKyLl6i3gPqKANCCn5e9xmviEEeX6s= github.com/klauspost/compress v1.13.4/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= +github.com/klauspost/compress v1.14.1 h1:hLQYb23E8/fO+1u53d02A97a8UnsddcvYzq4ERRU4ds= +github.com/klauspost/compress v1.14.1/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -45,9 +46,9 @@ github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5Cc github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= -github.com/valyala/fasthttp v1.26.0/go.mod h1:cmWIqlu99AO/RKcp1HWaViTqc57FswJOfYYdPJBl8BA= -github.com/valyala/fasthttp v1.29.0 h1:F5GKpytwFk5OhCuRh6H+d4vZAcEeNAwPTdwQnm6IERY= github.com/valyala/fasthttp v1.29.0/go.mod h1:2rsYD01CKFrjjsvFxx75KlEUNpWNBY9JWD3K/7o2Cus= +github.com/valyala/fasthttp v1.33.0 h1:mHBKd98J5NcXuBddgjvim1i3kWzlng1SzLhrnBOU9g8= +github.com/valyala/fasthttp v1.33.0/go.mod h1:KJRK/MXx0J+yd0c5hlR+s1tIHD72sniU8ZJjl97LIw4= github.com/valyala/tcplisten v1.0.0 h1:rBHj/Xf+E1tRGZyWIWwJDiRY0zc1Js+CV5DqwacVSA8= github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -56,6 +57,7 @@ go.elastic.co/fastjson v1.1.0/go.mod h1:boNGISWMjQsUPy/t6yqt2/1Wx4YNPSe+mZjlyw9v golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8= +golang.org/x/crypto v0.0.0-20220112180741-5e0467b6c7ce/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5 h1:2M3HP5CCK1Si9FQhwnzYhXdG6DXeebvUHFpre8QvbyI= golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= @@ -66,8 +68,10 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210510120150-4163338589ed h1:p9UgmWI9wKpfYmgaV/IZKGdXc5qEK45tDwwwDyjS26I= golang.org/x/net v0.0.0-20210510120150-4163338589ed/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20220111093109-d55c255bac03 h1:0FB83qp0AzVJm+0wcIlauAjJ+tNdh7jLuacRYCIVv7s= +golang.org/x/net v0.0.0-20220111093109-d55c255bac03/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -77,14 +81,17 @@ golang.org/x/sys v0.0.0-20191025021431-6c3a3bfe00ae/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210514084401-e8d321eab015 h1:hZR0X1kPW+nwyJ9xRxqZk1vx5RUObAPBdKVvXPDUH/E= golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220111092808-5a964db01320 h1:0jf+tOCoZ3LyutmCOWpVni1chK4VfFLhRsDK7MhqGRY= +golang.org/x/sys v0.0.0-20220111092808-5a964db01320/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= From 73bf66dec65f712220647aac9731dc435abcba39 Mon Sep 17 00:00:00 2001 From: Sergio VS Date: Fri, 18 Feb 2022 17:32:25 +0100 Subject: [PATCH 11/11] fix(fiber): middleware test --- module/apmfiber/middleware_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/module/apmfiber/middleware_test.go b/module/apmfiber/middleware_test.go index da0ab2e1d..f21dd838f 100644 --- a/module/apmfiber/middleware_test.go +++ b/module/apmfiber/middleware_test.go @@ -154,6 +154,10 @@ func TestMiddleware(t *testing.T) { Response: &model.Response{ StatusCode: 200, Headers: model.Headers{ + { + Key: "Content-Length", + Values: []string{"13"}, + }, { Key: "Content-Type", Values: []string{"text/plain; charset=utf-8"},