Skip to content

Commit d48274e

Browse files
committed
master | add sentry tracer
1 parent 41a29e1 commit d48274e

File tree

17 files changed

+80
-26
lines changed

17 files changed

+80
-26
lines changed

.github/workflows/deploy.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666
token: ${{ secrets.repo_api_token }}
6767
repository: bloock/managed-services-actions
6868
event-type: deploy_managed_api_dev
69-
client-payload: '{"version": "${{ needs.push.outputs.version }}"}'
69+
client-payload: '{"version": "${{ needs.push.outputs.version }}", "environment": "development"}'
7070

7171
deploy-pro:
7272
name: Deploy PRO
@@ -80,4 +80,4 @@ jobs:
8080
token: ${{ secrets.repo_api_token }}
8181
repository: bloock/managed-services-actions
8282
event-type: deploy_managed_api_pro
83-
client-payload: '{"version": "${{ needs.push.outputs.version }}"}'
83+
client-payload: '{"version": "${{ needs.push.outputs.version }}", "environment": "production"}'

cmd/main.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import (
66
"github.com/bloock/bloock-managed-api/internal/platform/repository/sql/connection"
77
"github.com/bloock/bloock-managed-api/internal/platform/worker"
88
"github.com/bloock/bloock-managed-api/pkg"
9+
"github.com/getsentry/sentry-go"
10+
"log"
911
"sync"
1012

1113
"github.com/bloock/bloock-managed-api/internal/config"
@@ -20,6 +22,28 @@ func main() {
2022

2123
logger := pkg.InitLogger(config.Configuration.Api.DebugMode)
2224

25+
// Initialize tracer if set
26+
if config.Configuration.Tracing.Enabled {
27+
options := sentry.ClientOptions{
28+
Dsn: config.Configuration.Tracing.TracerConnUrl,
29+
Environment: config.Configuration.Tracing.AppEnvironment,
30+
Release: config.Configuration.Tracing.AppVersion,
31+
}
32+
if config.Configuration.Tracing.AppEnvironment == "production" {
33+
options.EnableTracing = true
34+
options.TracesSampleRate = 1.0
35+
options.TracesSampler = func(ctx sentry.SamplingContext) float64 {
36+
if ctx.Span.Op == "http.server" {
37+
return 1.0
38+
}
39+
return 0.0
40+
}
41+
}
42+
if err = sentry.Init(options); err != nil {
43+
log.Fatal(err.Error())
44+
}
45+
}
46+
2347
wg := sync.WaitGroup{}
2448
wg.Add(1)
2549

go.mod

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ require (
66
entgo.io/ent v0.12.4
77
github.com/bloock/bloock-sdk-go/v2 v2.9.6
88
github.com/cenkalti/backoff/v4 v4.2.1
9+
github.com/getsentry/sentry-go v0.29.0
910
github.com/gin-contrib/cors v1.7.2
1011
github.com/gin-contrib/logger v0.2.6
1112
github.com/gin-gonic/gin v1.9.1
@@ -71,15 +72,15 @@ require (
7172
github.com/jackc/puddle/v2 v2.2.1 // indirect
7273
github.com/jmespath/go-jmespath v0.4.0 // indirect
7374
github.com/json-iterator/go v1.1.12 // indirect
74-
github.com/klauspost/compress v1.15.11 // indirect
75+
github.com/klauspost/compress v1.17.7 // indirect
7576
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
7677
github.com/leodido/go-urn v1.4.0 // indirect
7778
github.com/magiconair/properties v1.8.7 // indirect
7879
github.com/mattn/go-colorable v0.1.13 // indirect
7980
github.com/mattn/go-isatty v0.0.20 // indirect
8081
github.com/mitchellh/go-homedir v1.1.0 // indirect
8182
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
82-
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 // indirect
83+
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
8384
github.com/mitchellh/mapstructure v1.5.0 // indirect
8485
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
8586
github.com/modern-go/reflect2 v1.0.2 // indirect

go.sum

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,8 @@ github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4
271271
github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
272272
github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0=
273273
github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk=
274+
github.com/getsentry/sentry-go v0.29.0 h1:YtWluuCFg9OfcqnaujpY918N/AhCCwarIDWOYSBAjCA=
275+
github.com/getsentry/sentry-go v0.29.0/go.mod h1:jhPesDAL0Q0W2+2YEuVOvdWmVtdsr1+jtBrlDEVWwLY=
274276
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
275277
github.com/gin-contrib/cors v1.7.2 h1:oLDHxdg8W/XDoN/8zamqk/Drgt4oVZDvaV0YmvVICQw=
276278
github.com/gin-contrib/cors v1.7.2/go.mod h1:SUJVARKgQ40dmrzgXEVxj2m7Ig1v1qIboQkPDTQ9t2E=
@@ -282,6 +284,8 @@ github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg=
282284
github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU=
283285
github.com/go-co-op/gocron v1.37.0 h1:ZYDJGtQ4OMhTLKOKMIch+/CY70Brbb1dGdooLEhh7b0=
284286
github.com/go-co-op/gocron v1.37.0/go.mod h1:3L/n6BkO7ABj+TrfSVXLRzsP26zmikL4ISkLQ0O8iNY=
287+
github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA=
288+
github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og=
285289
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
286290
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
287291
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
@@ -447,8 +451,9 @@ github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHm
447451
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
448452
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
449453
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
450-
github.com/klauspost/compress v1.15.11 h1:Lcadnb3RKGin4FYM/orgq0qde+nc15E5Cbqg4B9Sx9c=
451454
github.com/klauspost/compress v1.15.11/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM=
455+
github.com/klauspost/compress v1.17.7 h1:ehO88t2UGzQK66LMdE8tibEd1ErmzZjNEqWkjLAKQQg=
456+
github.com/klauspost/compress v1.17.7/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
452457
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
453458
github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM=
454459
github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
@@ -487,8 +492,8 @@ github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG
487492
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
488493
github.com/mitchellh/go-testing-interface v1.14.1 h1:jrgshOhYAUVNMAJiKbEu7EqAwgJJ2JqpQmpLJOu07cU=
489494
github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp04twqAjfvlZyCfX3sDjEym8=
490-
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 h1:DpOJ2HYzCv8LZP15IdmG+YdwD2luVPHITV96TkirNBM=
491-
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo=
495+
github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0=
496+
github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0=
492497
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
493498
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
494499
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
@@ -499,7 +504,10 @@ github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjY
499504
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
500505
github.com/pelletier/go-toml/v2 v2.2.1 h1:9TA9+T8+8CUCO2+WYnDLCgrYi9+omqKXyjDtosvtEhg=
501506
github.com/pelletier/go-toml/v2 v2.2.1/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
507+
github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4=
508+
github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8=
502509
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
510+
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
503511
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
504512
github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg=
505513
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=

internal/config/config.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,13 @@ type IntegrityConfig struct {
7373
MaxProofMessageSize int `mapstructure:"max_proof_message_size" default:"1000"`
7474
}
7575

76+
type TracingConfig struct {
77+
Enabled bool `mapstructure:"enabled" default:"false"`
78+
TracerConnUrl string `mapstructure:"tracer_conn_url" default:""`
79+
AppEnvironment string `mapstructure:"app_environment" default:""`
80+
AppVersion string `mapstructure:"app_version" default:""`
81+
}
82+
7683
type Config struct {
7784
Api APIConfig
7885
Auth AuthConfig
@@ -83,6 +90,7 @@ type Config struct {
8390
Encryption EncryptionConfig
8491
Storage StorageConfig
8592
Integrity IntegrityConfig
93+
Tracing TracingConfig
8694
}
8795

8896
var Configuration = Config{}

internal/platform/rest/error/api_error.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package api_error
22

3-
import "net/http"
3+
import (
4+
"github.com/bloock/bloock-managed-api/internal/config"
5+
"github.com/getsentry/sentry-go"
6+
"net/http"
7+
)
48

59
type APIError struct {
610
Status int `json:"status"`
@@ -20,6 +24,9 @@ func NewBadRequestAPIError(message string) *APIError {
2024
func NewUnauthorizedAPIError(message string) *APIError {
2125
return &APIError{Status: http.StatusUnauthorized, Message: message}
2226
}
23-
func NewInternalServerAPIError(message string) *APIError {
24-
return &APIError{Status: http.StatusInternalServerError, Message: message}
27+
func NewInternalServerAPIError(error error) *APIError {
28+
if config.Configuration.Tracing.Enabled {
29+
sentry.CaptureException(error)
30+
}
31+
return &APIError{Status: http.StatusInternalServerError, Message: error.Error()}
2532
}

internal/platform/rest/handler/aggregate/put_aggregate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func PutAggregate(l zerolog.Logger, ent *connection.EntConnection) gin.HandlerFu
2525
ctx.JSON(badAPIError.Status, badAPIError)
2626
return
2727
}
28-
serverAPIError := api_error.NewInternalServerAPIError(err.Error())
28+
serverAPIError := api_error.NewInternalServerAPIError(err)
2929
ctx.JSON(serverAPIError.Status, serverAPIError)
3030
return
3131
}

internal/platform/rest/handler/debug.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func Debug() gin.HandlerFunc {
3737

3838
file, err := io.ReadAll(fileReader)
3939
if err != nil {
40-
serverAPIError := api_error.NewInternalServerAPIError(err.Error())
40+
serverAPIError := api_error.NewInternalServerAPIError(err)
4141
ctx.JSON(serverAPIError.Status, serverAPIError)
4242
return
4343
}

internal/platform/rest/handler/process/get_file_by_hash.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ func GetFileByHash(l zerolog.Logger, ent *connection.EntConnection) gin.HandlerF
2828
ctx.JSON(notFoundAPIError.Status, notFoundAPIError)
2929
return
3030
}
31-
serverAPIError := api_error.NewInternalServerAPIError(err.Error())
31+
serverAPIError := api_error.NewInternalServerAPIError(err)
3232
ctx.JSON(serverAPIError.Status, serverAPIError)
3333
return
3434
}
3535

3636
if _, err = ctx.Writer.Write(fileBytes); err != nil {
37-
serverAPIError := api_error.NewInternalServerAPIError(err.Error())
37+
serverAPIError := api_error.NewInternalServerAPIError(err)
3838
ctx.JSON(serverAPIError.Status, serverAPIError)
3939
return
4040
}

internal/platform/rest/handler/process/get_file_by_process_id.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func GetFileByProcessID(l zerolog.Logger, ent *connection.EntConnection) gin.Han
3232
ctx.JSON(notFoundAPIError.Status, notFoundAPIError)
3333
return
3434
}
35-
serverAPIError := api_error.NewInternalServerAPIError(err.Error())
35+
serverAPIError := api_error.NewInternalServerAPIError(err)
3636
ctx.JSON(serverAPIError.Status, serverAPIError)
3737
return
3838
}
@@ -45,13 +45,13 @@ func GetFileByProcessID(l zerolog.Logger, ent *connection.EntConnection) gin.Han
4545
ctx.JSON(notFoundAPIError.Status, notFoundAPIError)
4646
return
4747
}
48-
serverAPIError := api_error.NewInternalServerAPIError(err.Error())
48+
serverAPIError := api_error.NewInternalServerAPIError(err)
4949
ctx.JSON(serverAPIError.Status, serverAPIError)
5050
return
5151
}
5252

5353
if _, err = ctx.Writer.Write(fileBytes); err != nil {
54-
serverAPIError := api_error.NewInternalServerAPIError(err.Error())
54+
serverAPIError := api_error.NewInternalServerAPIError(err)
5555
ctx.JSON(serverAPIError.Status, serverAPIError)
5656
return
5757
}

internal/platform/rest/handler/process/get_process_by_id.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func GetProcessByID(l zerolog.Logger, ent *connection.EntConnection) gin.Handler
3333
ctx.JSON(notFoundAPIError.Status, notFoundAPIError)
3434
return
3535
}
36-
serverAPIError := api_error.NewInternalServerAPIError(err.Error())
36+
serverAPIError := api_error.NewInternalServerAPIError(err)
3737
ctx.JSON(serverAPIError.Status, serverAPIError)
3838
return
3939
}

internal/platform/rest/handler/process/list_process.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func ListProcess(l zerolog.Logger, ent *connection.EntConnection) gin.HandlerFun
2929
service := process.NewListProcess(ctx, l, ent)
3030
listProcess, pagination, err := service.List(ctx, pq)
3131
if err != nil {
32-
serverAPIError := api_error.NewInternalServerAPIError(err.Error())
32+
serverAPIError := api_error.NewInternalServerAPIError(err)
3333
ctx.JSON(serverAPIError.Status, serverAPIError)
3434
return
3535
}

internal/platform/rest/handler/process/post_process.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func PostProcess(l zerolog.Logger, ent *connection.EntConnection) gin.HandlerFun
7979
ctx.JSON(badRequestAPIError.Status, badRequestAPIError)
8080
return
8181
}
82-
serverAPIError := api_error.NewInternalServerAPIError(err.Error())
82+
serverAPIError := api_error.NewInternalServerAPIError(err)
8383
ctx.JSON(serverAPIError.Status, serverAPIError)
8484
return
8585
}

internal/platform/rest/handler/proof/get_proof.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func GetProof(l zerolog.Logger, ent *connection.EntConnection, maxProofMessageSi
6060
ctx.JSON(badRequestAPIError.Status, badRequestAPIError)
6161
return
6262
}
63-
serverAPIError := api_error.NewInternalServerAPIError(err.Error())
63+
serverAPIError := api_error.NewInternalServerAPIError(err)
6464
ctx.JSON(serverAPIError.Status, serverAPIError)
6565
return
6666
}

internal/platform/rest/handler/webhook/post_receive_webhook.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package webhook
22

33
import (
44
"encoding/json"
5+
"errors"
56
"github.com/bloock/bloock-managed-api/internal/platform/repository/sql/connection"
67
"io"
78
"net/http"
@@ -46,7 +47,7 @@ func PostReceiveWebhook(l zerolog.Logger, ent *connection.EntConnection) gin.Han
4647
return func(ctx *gin.Context) {
4748
buf, err := io.ReadAll(ctx.Request.Body)
4849
if err != nil {
49-
webhookErr := api_error.NewInternalServerAPIError("error while reading webhook body")
50+
webhookErr := api_error.NewInternalServerAPIError(errors.New("error while reading webhook body"))
5051
ctx.JSON(webhookErr.Status, webhookErr)
5152
return
5253
}
@@ -62,7 +63,7 @@ func PostReceiveWebhook(l zerolog.Logger, ent *connection.EntConnection) gin.Han
6263
webhookClient := client.NewWebhookClient()
6364
ok, err := webhookClient.VerifyWebhookSignature(buf, bloockSignature, config.Configuration.Bloock.WebhookSecretKey, false)
6465
if err != nil {
65-
serverAPIError := api_error.NewInternalServerAPIError(err.Error())
66+
serverAPIError := api_error.NewInternalServerAPIError(err)
6667
ctx.JSON(serverAPIError.Status, serverAPIError)
6768
return
6869
}
@@ -75,15 +76,15 @@ func PostReceiveWebhook(l zerolog.Logger, ent *connection.EntConnection) gin.Han
7576
notifyService := notify.NewServiceNotifier(ctx, l, ent)
7677
aggregateHash, err := notifyService.Notify(ctx, webhookRequest.Data.Id)
7778
if err != nil {
78-
serverAPIError := api_error.NewInternalServerAPIError(err.Error())
79+
serverAPIError := api_error.NewInternalServerAPIError(err)
7980
ctx.JSON(serverAPIError.Status, serverAPIError)
8081
return
8182
}
8283

8384
go func() {
8485
notifyAggregateService := notify.NewServiceAggregateNotifier(ctx, l, ent)
8586
if err = notifyAggregateService.Notify(ctx, aggregateHash); err != nil {
86-
serverAPIError := api_error.NewInternalServerAPIError(err.Error())
87+
serverAPIError := api_error.NewInternalServerAPIError(err)
8788
ctx.JSON(serverAPIError.Status, serverAPIError)
8889
return
8990
}

internal/platform/rest/middleware/error_middleware.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package middleware
22

33
import (
4+
"errors"
45
api_error "github.com/bloock/bloock-managed-api/internal/platform/rest/error"
56
"github.com/gin-gonic/gin"
67
)
@@ -22,7 +23,7 @@ func errorMiddleware(errType gin.ErrorType) gin.HandlerFunc {
2223
case *api_error.APIError:
2324
parsedError = *v
2425
default:
25-
parsedError = *api_error.NewInternalServerAPIError("Internal Server Error")
26+
parsedError = *api_error.NewInternalServerAPIError(errors.New("Internal Server Error"))
2627
}
2728

2829
c.AbortWithStatusJSON(parsedError.Status, parsedError)

internal/platform/rest/server.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"github.com/bloock/bloock-managed-api/internal/platform/rest/handler/proof"
1111
"github.com/bloock/bloock-managed-api/internal/platform/rest/handler/webhook"
1212
"github.com/bloock/bloock-managed-api/internal/platform/rest/middleware"
13+
sentrygin "github.com/getsentry/sentry-go/gin"
1314
"github.com/gin-contrib/cors"
1415
"github.com/gin-contrib/logger"
1516
"github.com/gin-gonic/gin"
@@ -55,6 +56,9 @@ func NewServer(l zerolog.Logger, ent *connection.EntConnection, maxProofMessageS
5556
}),
5657
))
5758
router.Use(middleware.MetricsMiddleware())
59+
if config.Configuration.Tracing.Enabled {
60+
router.Use(sentrygin.New(sentrygin.Options{Repanic: true}))
61+
}
5862

5963
router.GET("/metrics", gin.WrapH(promhttp.Handler()))
6064

0 commit comments

Comments
 (0)