Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore!: Make route path as transaction name in gin performance #675

Merged
merged 11 commits into from
Sep 4, 2023
3 changes: 1 addition & 2 deletions gin/sentrygin.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package sentrygin

import (
"context"
"fmt"
"net"
"net/http"
"os"
Expand Down Expand Up @@ -61,7 +60,7 @@ func (h *handler) handle(c *gin.Context) {
}

transaction := sentry.StartTransaction(ctx,
fmt.Sprintf("%s %s", c.Request.Method, c.Request.URL.Path),
c.FullPath(),
cleptric marked this conversation as resolved.
Show resolved Hide resolved
options...,
)
defer func() {
Expand Down
18 changes: 9 additions & 9 deletions gin/sentrygin_test.go
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great to test different paths, like /panic, /panic/:id etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

c1edc11
This way I tried to show where request and router paths are in used

Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestIntegration(t *testing.T) {
WantTransaction *sentry.Event
}{
{
Path: "/panic",
Path: "/panic/:id",
Method: "GET",
WantStatus: 200,
Handler: func(c *gin.Context) {
Expand All @@ -40,9 +40,9 @@ func TestIntegration(t *testing.T) {
WantTransaction: &sentry.Event{
Level: sentry.LevelInfo,
Type: "transaction",
Transaction: "GET /panic",
Transaction: "/panic/:id",
Request: &sentry.Request{
URL: "/panic",
URL: "/panic/:id",
Method: "GET",
Headers: map[string]string{
"Accept-Encoding": "gzip",
Expand All @@ -55,7 +55,7 @@ func TestIntegration(t *testing.T) {
Level: sentry.LevelFatal,
Message: "test",
Request: &sentry.Request{
URL: "/panic",
URL: "/panic/:id",
Method: "GET",
Headers: map[string]string{
"Accept-Encoding": "gzip",
Expand All @@ -81,7 +81,7 @@ func TestIntegration(t *testing.T) {
WantTransaction: &sentry.Event{
Level: sentry.LevelInfo,
Type: "transaction",
Transaction: "POST /post",
Transaction: "/post",
Request: &sentry.Request{
URL: "/post",
Method: "POST",
Expand Down Expand Up @@ -121,7 +121,7 @@ func TestIntegration(t *testing.T) {
WantTransaction: &sentry.Event{
Level: sentry.LevelInfo,
Type: "transaction",
Transaction: "GET /get",
Transaction: "/get",
Request: &sentry.Request{
URL: "/get",
Method: "GET",
Expand Down Expand Up @@ -161,7 +161,7 @@ func TestIntegration(t *testing.T) {
WantTransaction: &sentry.Event{
Level: sentry.LevelInfo,
Type: "transaction",
Transaction: "POST /post/large",
Transaction: "/post/large",
Request: &sentry.Request{
URL: "/post/large",
Method: "POST",
Expand Down Expand Up @@ -201,7 +201,7 @@ func TestIntegration(t *testing.T) {
WantTransaction: &sentry.Event{
Level: sentry.LevelInfo,
Type: "transaction",
Transaction: "POST /post/body-ignored",
Transaction: "/post/body-ignored",
Request: &sentry.Request{
URL: "/post/body-ignored",
Method: "POST",
Expand Down Expand Up @@ -241,7 +241,7 @@ func TestIntegration(t *testing.T) {
WantTransaction: &sentry.Event{
Level: sentry.LevelInfo,
Type: "transaction",
Transaction: "GET /badreq",
Transaction: "/badreq",
Request: &sentry.Request{
URL: "/badreq",
Method: "GET",
Expand Down
Loading