Skip to content

Commit 1d87a9a

Browse files
authored
Merge pull request #57 from gatewayd-io/enable-sentry
Enable sentry
2 parents ce07ce6 + df661b3 commit 1d87a9a

File tree

6 files changed

+49
-1
lines changed

6 files changed

+49
-1
lines changed

.golangci.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,28 @@ linters:
2323
- musttag
2424
- nosnakecase
2525
- wrapcheck
26+
- golint
27+
- scopelint
28+
- interfacer
29+
- varcheck
30+
- deadcode
31+
- ifshort
32+
- structcheck
33+
linters-settings:
34+
depguard:
35+
rules:
36+
main:
37+
files:
38+
- $all
39+
- "!$test"
40+
allow:
41+
- $gostd
42+
- "github.com/gatewayd-io/gatewayd-plugin-sdk"
43+
- "github.com/gatewayd-io/gatewayd-plugin-cache"
44+
- "github.com/prometheus/client_golang"
45+
- "github.com/hashicorp/go-plugin"
46+
- "github.com/hashicorp/go-hclog"
47+
- "github.com/go-redis/redis/v8"
48+
- "github.com/getsentry/sentry-go"
49+
- "github.com/spf13/cast"
50+
- "github.com/go-co-op/gocron"

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,7 @@ make build-dev
2929
```
3030

3131
Running the above command causes the `go mod tidy` and `go build` to run for compiling and generating the plugin binary in the current directory, named `gatewayd-plugin-cache`.
32+
33+
## Sentry
34+
35+
This plugin uses [Sentry](https://sentry.io) for error tracking. Sentry can be configured using the `SENTRY_DSN` environment variable. If `SENTRY_DSN` is not set, Sentry will not be used.

gatewayd_plugin.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,5 @@ plugins:
2929
- PERIODIC_INVALIDATOR_START_DELAY=1m
3030
- API_ADDRESS=localhost:18080
3131
- EXIT_ON_STARTUP_ERROR=False
32+
- SENTRY_DSN=https://70eb1abcd32e41acbdfc17bc3407a543@o4504550475038720.ingest.sentry.io/4505342961123328
3233
checksum: 3988e10aefce2cd9b30888eddd2ec93a431c9018a695aea1cea0dac46ba91cae

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ go 1.20
55
require (
66
github.com/alicebob/miniredis/v2 v2.30.1
77
github.com/gatewayd-io/gatewayd-plugin-sdk v0.0.19
8+
github.com/getsentry/sentry-go v0.21.0
89
github.com/go-co-op/gocron v1.19.0
910
github.com/go-redis/redis/v8 v8.11.5
1011
github.com/hashicorp/go-hclog v1.5.0

go.sum

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@ github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3
2121
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
2222
github.com/gatewayd-io/gatewayd-plugin-sdk v0.0.19 h1:SoYoeYggzsfNn2R7ycGAOM/EAflvlkikNBQhYntcqFs=
2323
github.com/gatewayd-io/gatewayd-plugin-sdk v0.0.19/go.mod h1:qnxOD6QQQ7OWqa1JdGMLGtlvmFkK8Xf7eH0qUD1N0n0=
24+
github.com/getsentry/sentry-go v0.21.0 h1:c9l5F1nPF30JIppulk4veau90PK6Smu3abgVtVQWon4=
25+
github.com/getsentry/sentry-go v0.21.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY=
2426
github.com/go-co-op/gocron v1.19.0 h1:XlPLqNnxnKblmCRLdfcWV1UgbukQaU54QdNeR1jtgak=
2527
github.com/go-co-op/gocron v1.19.0/go.mod h1:UqVyvM90I1q/R1qGEX6cBORI6WArLuEgYlbncLMvzRM=
28+
github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA=
2629
github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI=
2730
github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo=
2831
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
@@ -75,6 +78,8 @@ github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
7578
github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE=
7679
github.com/pganalyze/pg_query_go/v2 v2.2.0 h1:OW+reH+ZY7jdEuPyuLGlf1m7dLbE+fDudKXhLs0Ttpk=
7780
github.com/pganalyze/pg_query_go/v2 v2.2.0/go.mod h1:XAxmVqz1tEGqizcQ3YSdN90vCOHBWjJi8URL1er5+cA=
81+
github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4=
82+
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
7883
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
7984
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
8085
github.com/prometheus/client_golang v1.14.0 h1:nJdhIvne2eSX/XRAFV9PcvFFRbrjbcTUj0VP62TMhnw=
@@ -103,7 +108,7 @@ github.com/yuin/gopher-lua v1.1.0/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7
103108
github.com/zenizh/go-capturer v0.0.0-20211219060012-52ea6c8fed04 h1:qXafrlZL1WsJW5OokjraLLRURHiw0OzKHD/RNdspp4w=
104109
github.com/zenizh/go-capturer v0.0.0-20211219060012-52ea6c8fed04/go.mod h1:FiwNQxz6hGoNFBC4nIx+CxZhI3nne5RmIOlT/MXcSD4=
105110
go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A=
106-
golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc=
111+
golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A=
107112
golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ=
108113
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
109114
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=

main.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,32 @@ package main
33
import (
44
"context"
55
"flag"
6+
"log"
67
"os"
78

89
"github.com/gatewayd-io/gatewayd-plugin-cache/plugin"
910
sdkConfig "github.com/gatewayd-io/gatewayd-plugin-sdk/config"
1011
"github.com/gatewayd-io/gatewayd-plugin-sdk/logging"
1112
"github.com/gatewayd-io/gatewayd-plugin-sdk/metrics"
1213
p "github.com/gatewayd-io/gatewayd-plugin-sdk/plugin"
14+
"github.com/getsentry/sentry-go"
1315
"github.com/go-redis/redis/v8"
1416
"github.com/hashicorp/go-hclog"
1517
goplugin "github.com/hashicorp/go-plugin"
1618
"github.com/spf13/cast"
1719
)
1820

1921
func main() {
22+
sentryDSN := sdkConfig.GetEnv("SENTRY_DSN", "")
23+
// Initialize Sentry SDK
24+
err := sentry.Init(sentry.ClientOptions{
25+
Dsn: sentryDSN,
26+
TracesSampleRate: 1.0,
27+
})
28+
if err != nil {
29+
log.Fatalf("Failed to initialize Sentry SDK: %s", err.Error())
30+
}
31+
2032
// Parse command line flags, passed by GatewayD via the plugin config
2133
logLevel := flag.String("log-level", "info", "Log level")
2234
flag.Parse()

0 commit comments

Comments
 (0)