Skip to content

Commit ac93ddf

Browse files
authored
fix: Optionally send --no-sentry when using managed plugins (#3762)
This fixes a bug where panics in plugins would be sent to Sentry even though telemetry-level was set to `none` at the CLI level. Related PR: cloudquery/plugin-sdk#363
1 parent c0064d1 commit ac93ddf

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

cli/cmd/clients.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,14 @@ func newDestinationClients(ctx context.Context, sourceSpec specs.Source, destina
2222
}()
2323

2424
for i, destinationSpec := range destinationsSpecs {
25-
destClients[i], err = clients.NewDestinationClient(ctx, destinationSpec.Registry, destinationSpec.Path, destinationSpec.Version,
25+
opts := []clients.DestinationClientOption{
2626
clients.WithDestinationLogger(log.Logger),
2727
clients.WithDestinationDirectory(cqDir),
28-
)
28+
}
29+
if disableSentry {
30+
opts = append(opts, clients.WithDestinationNoSentry())
31+
}
32+
destClients[i], err = clients.NewDestinationClient(ctx, destinationSpec.Registry, destinationSpec.Path, destinationSpec.Version, opts...)
2933
if err != nil {
3034
return nil, fmt.Errorf("failed to create destination plugin client for %s: %w", destinationSpec.Name, err)
3135
}

cli/cmd/root.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Open source data integration at scale.
2525
Find more information at:
2626
https://www.cloudquery.io`
2727

28+
disableSentry = false
2829
analyticsClient *AnalyticsClient
2930
)
3031

@@ -88,6 +89,8 @@ func NewCmdRoot() *cobra.Command {
8889
// we don't fail on sentry init errors as there might be no connection or sentry can be blocked.
8990
log.Warn().Err(err).Msg("failed to initialize sentry")
9091
}
92+
} else {
93+
disableSentry = true
9194
}
9295

9396
return nil

cli/cmd/sync.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,14 @@ func sync(cmd *cobra.Command, args []string) error {
7575
}
7676
destinationsSpecs = append(destinationsSpecs, *spec)
7777
}
78-
sourceClient, err := clients.NewSourceClient(ctx, sourceSpec.Registry, sourceSpec.Path, sourceSpec.Version,
78+
opts := []clients.SourceClientOption{
7979
clients.WithSourceLogger(log.Logger),
8080
clients.WithSourceDirectory(cqDir),
81-
)
81+
}
82+
if disableSentry {
83+
opts = append(opts, clients.WithSourceNoSentry())
84+
}
85+
sourceClient, err := clients.NewSourceClient(ctx, sourceSpec.Registry, sourceSpec.Path, sourceSpec.Version, opts...)
8286
if err != nil {
8387
return fmt.Errorf("failed to get source plugin client for %s: %w", sourceSpec.Name, err)
8488
}

0 commit comments

Comments
 (0)