Skip to content

Commit 94cfca3

Browse files
Merge pull request #129 from sil-org/feature/add-sentry-tags
Add tags for Sentry
2 parents 8d2a809 + 971e255 commit 94cfca3

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,13 @@ but only one is needed.
5959

6060
## Sentry
6161

62-
Sentry can be added by adding the Sentry DSN into `Runtime` > `SentryDSN`. This can be obtained from the project settings in Sentry. The `Runtime` > `Environment` can also be set to specify the environment, such as `production`, `staging`, or `development`.
62+
Sentry can be added by adding the Sentry DSN into `Runtime` > `SentryDSN`. This can be obtained from the project settings in Sentry. The `Runtime` > `Environment` can also be set to specify the environment, such as `production`, `staging`, or `development`. Tags can also be added by setting the `Tags` object. For example, the following will add a `sync` tag set to `example` for each Sentry error:
63+
64+
```
65+
"SentryTags": {
66+
"sync": "example"
67+
},
68+
```
6369

6470
## Pagination
6571

internal/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ type RuntimeConfig struct {
3737
DryRunMode bool
3838
Environment string
3939
SentryDSN string
40+
SentryTags map[string]string
4041
Verbosity int
4142
}
4243

lambda-example/src/config.example.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
"DryRunMode": false,
44
"Environment": "production",
55
"SentryDSN": "",
6+
"SentryTags": {
7+
"sync": "example"
8+
},
69
"Verbosity": 1
710
},
811
"Source": {

sync.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func RunSync(configFile string) error {
3737
}
3838

3939
if config.Runtime.SentryDSN != "" {
40-
initSentry(config.Runtime.SentryDSN, config.Runtime.Environment)
40+
initSentry(config.Runtime)
4141
}
4242

4343
// Instantiate Source
@@ -137,10 +137,11 @@ func handleSyncError(logger *log.Logger, err, alert error) error {
137137
return alert
138138
}
139139

140-
func initSentry(dsn, env string) {
140+
func initSentry(config internal.RuntimeConfig) {
141141
err := sentry.Init(sentry.ClientOptions{
142-
Dsn: dsn,
143-
Environment: env,
142+
Dsn: config.SentryDSN,
143+
Environment: config.Environment,
144+
Tags: config.SentryTags,
144145
})
145146
if err != nil {
146147
log.Printf("sentry.Init failure: %s", err)

0 commit comments

Comments
 (0)