Skip to content

Commit e2c417e

Browse files
authored
feat(cli): Disable sentry in development (#1939)
Disables sentry in dev Also, doing some piggyback and creating some better error message so we can ignore user errors in the server side (sentry) --- Use the following steps to ensure your PR is ready to be reviewed - [ ] Read the [contribution guidelines](../blob/main/CONTRIBUTING.md) 🧑‍🎓 - [ ] Test locally on your own infrastructure - [ ] Run `go fmt` to format your code 🖊 - [ ] Lint your changes via `golangci-lint run` 🚨 (install golangci-lint [here](https://golangci-lint.run/usage/install/#local-installation)) - [ ] Update or add tests 🧪 - [ ] Ensure the status checks below are successful ✅
1 parent 491aa66 commit e2c417e

2 files changed

Lines changed: 20 additions & 21 deletions

File tree

cli/cmd/generate.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ func genSource(cmd *cobra.Command, path string, pm *plugins.PluginManager, regis
122122
}
123123
err = writeSource(configPath, sourceSpec)
124124
if err != nil {
125-
return fmt.Errorf("failed to write file: %w", err)
125+
return fmt.Errorf("failed to write source to file: %w", err)
126126
}
127127
fmt.Println("Source plugin config successfully written to " + configPath)
128128
return nil
@@ -166,7 +166,7 @@ func genDestination(cmd *cobra.Command, path string, pm *plugins.PluginManager,
166166
}
167167
err = writeDestination(configPath, destSpec)
168168
if err != nil {
169-
return fmt.Errorf("failed to write file: %w", err)
169+
return fmt.Errorf("failed to write destination to file: %w", err)
170170
}
171171
fmt.Println("Destination plugin config successfully written to " + configPath)
172172
return nil

cli/cmd/root.go

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -72,33 +72,32 @@ func NewCmdRoot() *cobra.Command {
7272

7373
mw := io.MultiWriter(writers...)
7474
log.Logger = zerolog.New(mw).Level(zerologLevel).With().Str("module", "cli").Timestamp().Logger()
75-
err = sentry.Init(sentry.ClientOptions{
76-
Debug: false,
77-
Dsn: sentryDsn,
78-
Release: "cloudquery@" + Version,
79-
// https://docs.sentry.io/platforms/go/configuration/options/#removing-default-integrations
80-
Integrations: func(integrations []sentry.Integration) []sentry.Integration {
81-
var filteredIntegrations []sentry.Integration
82-
for _, integration := range integrations {
83-
if integration.Name() == "Modules" {
84-
continue
75+
if sentryDsn != "" && Version != "development" {
76+
if err := sentry.Init(sentry.ClientOptions{
77+
Debug: false,
78+
Dsn: sentryDsn,
79+
Release: "cloudquery@" + Version,
80+
// https://docs.sentry.io/platforms/go/configuration/options/#removing-default-integrations
81+
Integrations: func(integrations []sentry.Integration) []sentry.Integration {
82+
var filteredIntegrations []sentry.Integration
83+
for _, integration := range integrations {
84+
if integration.Name() == "Modules" {
85+
continue
86+
}
87+
filteredIntegrations = append(filteredIntegrations, integration)
8588
}
86-
filteredIntegrations = append(filteredIntegrations, integration)
87-
}
88-
return filteredIntegrations
89-
},
90-
})
91-
if err != nil {
92-
log.Error().Err(err).Msg("error initializing sentry")
89+
return filteredIntegrations
90+
},
91+
}); err != nil {
92+
return err
93+
}
9394
}
94-
9595
return nil
9696
},
9797
PersistentPostRun: func(cmd *cobra.Command, args []string) {
9898
if logFile != nil {
9999
logFile.Close()
100100
}
101-
// analytics.Close()
102101
},
103102
}
104103

0 commit comments

Comments
 (0)