From f8218e2b9985458df05a4df8aeeb3a15d9914d3d Mon Sep 17 00:00:00 2001 From: Reinaldy Rafli Date: Sat, 17 Feb 2024 09:11:33 +0700 Subject: [PATCH 1/3] feat(starfish): add attribute to span data --- gin/sentrygin.go | 1 + http/sentryhttp.go | 1 + 2 files changed, 2 insertions(+) diff --git a/gin/sentrygin.go b/gin/sentrygin.go index 387699109..79abbf595 100644 --- a/gin/sentrygin.go +++ b/gin/sentrygin.go @@ -83,6 +83,7 @@ func (h *handler) handle(c *gin.Context) { fmt.Sprintf("%s %s", c.Request.Method, transactionName), options..., ) + transaction.SetData("http.request.method", c.Request.Method) defer func() { transaction.Status = sentry.HTTPtoSpanStatus(c.Writer.Status()) transaction.Finish() diff --git a/http/sentryhttp.go b/http/sentryhttp.go index d581fd029..739e6a34b 100644 --- a/http/sentryhttp.go +++ b/http/sentryhttp.go @@ -105,6 +105,7 @@ func (h *Handler) handle(handler http.Handler) http.HandlerFunc { fmt.Sprintf("%s %s", r.Method, r.URL.Path), options..., ) + transaction.SetData("http.request.method", r.Method) defer transaction.Finish() // TODO(tracing): if the next handler.ServeHTTP panics, store // information on the transaction accordingly (status, tag, From 0e83d55459519842d62d035941ee890a37658109 Mon Sep 17 00:00:00 2001 From: Reinaldy Rafli Date: Sat, 17 Feb 2024 09:20:39 +0700 Subject: [PATCH 2/3] test: add Extra field on gin tests --- gin/sentrygin_test.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gin/sentrygin_test.go b/gin/sentrygin_test.go index e959716d5..4663f2037 100644 --- a/gin/sentrygin_test.go +++ b/gin/sentrygin_test.go @@ -53,6 +53,7 @@ func TestIntegration(t *testing.T) { }, }, TransactionInfo: &sentry.TransactionInfo{Source: "route"}, + Extra: map[string]interface{}{"http.request.method": string("GET")}, }, WantEvent: &sentry.Event{ Level: sentry.LevelFatal, @@ -86,6 +87,7 @@ func TestIntegration(t *testing.T) { }, }, TransactionInfo: &sentry.TransactionInfo{Source: "url"}, + Extra: map[string]interface{}{"http.request.method": string("GET")}, }, WantEvent: nil, }, @@ -119,6 +121,7 @@ func TestIntegration(t *testing.T) { }, }, TransactionInfo: &sentry.TransactionInfo{Source: "route"}, + Extra: map[string]interface{}{"http.request.method": string("POST")}, }, WantEvent: &sentry.Event{ Level: sentry.LevelInfo, @@ -158,6 +161,7 @@ func TestIntegration(t *testing.T) { }, }, TransactionInfo: &sentry.TransactionInfo{Source: "route"}, + Extra: map[string]interface{}{"http.request.method": string("GET")}, }, WantEvent: &sentry.Event{ Level: sentry.LevelInfo, @@ -200,6 +204,7 @@ func TestIntegration(t *testing.T) { }, }, TransactionInfo: &sentry.TransactionInfo{Source: "route"}, + Extra: map[string]interface{}{"http.request.method": string("POST")}, }, WantEvent: &sentry.Event{ Level: sentry.LevelInfo, @@ -243,6 +248,7 @@ func TestIntegration(t *testing.T) { }, }, TransactionInfo: &sentry.TransactionInfo{Source: "route"}, + Extra: map[string]interface{}{"http.request.method": string("POST")}, }, WantEvent: &sentry.Event{ Level: sentry.LevelInfo, @@ -281,6 +287,7 @@ func TestIntegration(t *testing.T) { }, }, TransactionInfo: &sentry.TransactionInfo{Source: "route"}, + Extra: map[string]interface{}{"http.request.method": string("GET")}, }, WantEvent: nil, }, From 907457a38e2340c97abcb8f45136b9d1b8dc945e Mon Sep 17 00:00:00 2001 From: Reinaldy Rafli Date: Tue, 26 Mar 2024 20:13:49 +0700 Subject: [PATCH 3/3] chore: add changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c21aa40c0..2d994af6a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - Accept `interface{}` for span data values ([#784](https://github.com/getsentry/sentry-go/pull/784)) - Automatic transactions for Echo integration ([#722](https://github.com/getsentry/sentry-go/pull/722)) +- Add `http.request.method` attribute for performance span data ([#786](https://github.com/getsentry/sentry-go/pull/786)) ## 0.27.0