diff --git a/examples/simple_plugin/go.mod b/examples/simple_plugin/go.mod index f2d3d0f331..6bc305de0e 100644 --- a/examples/simple_plugin/go.mod +++ b/examples/simple_plugin/go.mod @@ -33,7 +33,6 @@ require ( github.com/fatih/structs v1.1.0 // indirect github.com/flosch/pongo2/v4 v4.0.2 // indirect github.com/gabriel-vasile/mimetype v1.4.3 // indirect - github.com/getsentry/sentry-go v0.28.0 // indirect github.com/ghodss/yaml v1.0.0 // indirect github.com/gin-contrib/sse v0.1.0 // indirect github.com/gin-gonic/gin v1.9.1 // indirect diff --git a/examples/simple_plugin/go.sum b/examples/simple_plugin/go.sum index 611372f0b4..26bd627690 100644 --- a/examples/simple_plugin/go.sum +++ b/examples/simple_plugin/go.sum @@ -66,16 +66,12 @@ github.com/flosch/pongo2/v4 v4.0.2 h1:gv+5Pe3vaSVmiJvh/BZa82b7/00YUGm0PIyVVLop0H github.com/flosch/pongo2/v4 v4.0.2/go.mod h1:B5ObFANs/36VwxxlgKpdchIJHMvHB562PW+BWPhwZD8= github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0= github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk= -github.com/getsentry/sentry-go v0.28.0 h1:7Rqx9M3ythTKy2J6uZLHmc8Sz9OGgIlseuO1iBX/s0M= -github.com/getsentry/sentry-go v0.28.0/go.mod h1:1fQZ+7l7eeJ3wYi82q5Hg8GqAPgefRq+FP/QhafYVgg= github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg= github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU= -github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= -github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= @@ -190,9 +186,6 @@ github.com/pelletier/go-toml/v2 v2.0.8 h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZ github.com/pelletier/go-toml/v2 v2.0.8/go.mod h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNcZljzZR9VXg+4= github.com/pierrec/lz4/v4 v4.1.21 h1:yOVMLb6qSIDP67pl/5F7RepeKYu/VmTyEXvuMI5d9mQ= github.com/pierrec/lz4/v4 v4.1.21/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= -github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= -github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= -github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= diff --git a/go.mod b/go.mod index 51ae3efc41..13a6163064 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,6 @@ require ( github.com/cloudquery/cloudquery-api-go v1.11.3 github.com/cloudquery/plugin-pb-go v1.19.19 github.com/cloudquery/plugin-sdk/v2 v2.7.0 - github.com/getsentry/sentry-go v0.28.0 github.com/goccy/go-json v0.10.3 github.com/google/go-cmp v0.6.0 github.com/google/uuid v1.6.0 diff --git a/go.sum b/go.sum index ba68c9ed06..9e53f5a478 100644 --- a/go.sum +++ b/go.sum @@ -66,16 +66,12 @@ github.com/flosch/pongo2/v4 v4.0.2 h1:gv+5Pe3vaSVmiJvh/BZa82b7/00YUGm0PIyVVLop0H github.com/flosch/pongo2/v4 v4.0.2/go.mod h1:B5ObFANs/36VwxxlgKpdchIJHMvHB562PW+BWPhwZD8= github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0= github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk= -github.com/getsentry/sentry-go v0.28.0 h1:7Rqx9M3ythTKy2J6uZLHmc8Sz9OGgIlseuO1iBX/s0M= -github.com/getsentry/sentry-go v0.28.0/go.mod h1:1fQZ+7l7eeJ3wYi82q5Hg8GqAPgefRq+FP/QhafYVgg= github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg= github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU= -github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= -github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= @@ -190,9 +186,6 @@ github.com/pelletier/go-toml/v2 v2.0.8 h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZ github.com/pelletier/go-toml/v2 v2.0.8/go.mod h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNcZljzZR9VXg+4= github.com/pierrec/lz4/v4 v4.1.21 h1:yOVMLb6qSIDP67pl/5F7RepeKYu/VmTyEXvuMI5d9mQ= github.com/pierrec/lz4/v4 v4.1.21/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= -github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= -github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= -github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= diff --git a/internal/servers/plugin/v3/plugin.go b/internal/servers/plugin/v3/plugin.go index 5ecdf6bc95..b5c222fd1b 100644 --- a/internal/servers/plugin/v3/plugin.go +++ b/internal/servers/plugin/v3/plugin.go @@ -25,7 +25,6 @@ type Server struct { Plugin *plugin.Plugin Logger zerolog.Logger Directory string - NoSentry bool } func (s *Server) GetTables(ctx context.Context, req *pb.GetTables_Request) (*pb.GetTables_Response, error) { diff --git a/scheduler/scheduler.go b/scheduler/scheduler.go index e37fb99581..32a8902ebb 100644 --- a/scheduler/scheduler.go +++ b/scheduler/scheduler.go @@ -10,11 +10,9 @@ import ( "time" "github.com/apache/arrow/go/v16/arrow" - "github.com/cloudquery/plugin-sdk/v4/caser" "github.com/cloudquery/plugin-sdk/v4/message" "github.com/cloudquery/plugin-sdk/v4/schema" - "github.com/getsentry/sentry-go" "github.com/rs/zerolog" "github.com/thoas/go-funk" "go.opentelemetry.io/otel" @@ -235,7 +233,6 @@ func (s *syncClient) logTablesMetrics(tables schema.Tables, client Client) { } func (s *syncClient) resolveResource(ctx context.Context, table *schema.Table, client schema.ClientMeta, parent *schema.Resource, item any) *schema.Resource { - var validationErr *schema.ValidationError ctx, cancel := context.WithTimeout(ctx, 10*time.Minute) defer cancel() resource := schema.NewResourceData(table, parent, item) @@ -248,22 +245,12 @@ func (s *syncClient) resolveResource(ctx context.Context, table *schema.Table, c stack := fmt.Sprintf("%s\n%s", err, string(debug.Stack())) logger.Error().Interface("error", err).TimeDiff("duration", time.Now(), objectStartTime).Str("stack", stack).Msg("resource resolver finished with panic") atomic.AddUint64(&tableMetrics.Panics, 1) - sentry.WithScope(func(scope *sentry.Scope) { - scope.SetTag("table", table.Name) - sentry.CurrentHub().CaptureMessage(stack) - }) } }() if table.PreResourceResolver != nil { if err := table.PreResourceResolver(ctx, client, resource); err != nil { logger.Error().Err(err).Msg("pre resource resolver failed") atomic.AddUint64(&tableMetrics.Errors, 1) - if errors.As(err, &validationErr) { - sentry.WithScope(func(scope *sentry.Scope) { - scope.SetTag("table", table.Name) - sentry.CurrentHub().CaptureMessage(validationErr.MaskedError()) - }) - } return nil } } @@ -276,12 +263,6 @@ func (s *syncClient) resolveResource(ctx context.Context, table *schema.Table, c if err := table.PostResourceResolver(ctx, client, resource); err != nil { logger.Error().Stack().Err(err).Msg("post resource resolver finished with error") atomic.AddUint64(&tableMetrics.Errors, 1) - if errors.As(err, &validationErr) { - sentry.WithScope(func(scope *sentry.Scope) { - scope.SetTag("table", table.Name) - sentry.CurrentHub().CaptureMessage(validationErr.MaskedError()) - }) - } } } atomic.AddUint64(&tableMetrics.Resources, 1) @@ -289,18 +270,12 @@ func (s *syncClient) resolveResource(ctx context.Context, table *schema.Table, c } func (s *syncClient) resolveColumn(ctx context.Context, logger zerolog.Logger, tableMetrics *TableClientMetrics, client schema.ClientMeta, resource *schema.Resource, c schema.Column) { - var validationErr *schema.ValidationError columnStartTime := time.Now() defer func() { if err := recover(); err != nil { stack := fmt.Sprintf("%s\n%s", err, string(debug.Stack())) logger.Error().Str("column", c.Name).Interface("error", err).TimeDiff("duration", time.Now(), columnStartTime).Str("stack", stack).Msg("column resolver finished with panic") atomic.AddUint64(&tableMetrics.Panics, 1) - sentry.WithScope(func(scope *sentry.Scope) { - scope.SetTag("table", resource.Table.Name) - scope.SetTag("column", c.Name) - sentry.CurrentHub().CaptureMessage(stack) - }) } }() @@ -308,13 +283,6 @@ func (s *syncClient) resolveColumn(ctx context.Context, logger zerolog.Logger, t if err := c.Resolver(ctx, client, resource, c); err != nil { logger.Error().Err(err).Msg("column resolver finished with error") atomic.AddUint64(&tableMetrics.Errors, 1) - if errors.As(err, &validationErr) { - sentry.WithScope(func(scope *sentry.Scope) { - scope.SetTag("table", resource.Table.Name) - scope.SetTag("column", c.Name) - sentry.CurrentHub().CaptureMessage(validationErr.MaskedError()) - }) - } } } else { // base use case: try to get column with CamelCase name @@ -324,13 +292,6 @@ func (s *syncClient) resolveColumn(ctx context.Context, logger zerolog.Logger, t if err != nil { logger.Error().Err(err).Msg("column resolver finished with error") atomic.AddUint64(&tableMetrics.Errors, 1) - if errors.As(err, &validationErr) { - sentry.WithScope(func(scope *sentry.Scope) { - scope.SetTag("table", resource.Table.Name) - scope.SetTag("column", c.Name) - sentry.CurrentHub().CaptureMessage(validationErr.MaskedError()) - }) - } } } } diff --git a/scheduler/scheduler_dfs.go b/scheduler/scheduler_dfs.go index 2de334f87a..9bf4d710f8 100644 --- a/scheduler/scheduler_dfs.go +++ b/scheduler/scheduler_dfs.go @@ -2,7 +2,6 @@ package scheduler import ( "context" - "errors" "fmt" "runtime/debug" "sync" @@ -10,7 +9,6 @@ import ( "github.com/cloudquery/plugin-sdk/v4/helpers" "github.com/cloudquery/plugin-sdk/v4/schema" - "github.com/getsentry/sentry-go" "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/attribute" "golang.org/x/sync/semaphore" @@ -33,10 +31,6 @@ func (s *syncClient) syncDfs(ctx context.Context, resolvedResources chan<- *sche if _, ok := seenClients[c.ID()]; !ok { seenClients[c.ID()] = true } else { - sentry.WithScope(func(scope *sentry.Scope) { - scope.SetTag("table", table.Name) - sentry.CurrentHub().CaptureMessage("duplicate client ID in " + table.Name) - }) s.logger.Warn().Str("client", c.ID()).Str("table", table.Name).Msg("multiplex returned duplicate client") } } @@ -76,7 +70,6 @@ func (s *syncClient) resolveTableDfs(ctx context.Context, table *schema.Table, c ctx, span := otel.Tracer(otelName).Start(ctx, "resolveTableDfs_"+table.Name) span.SetAttributes(attribute.Key("client-id").String(client.ID())) defer span.End() - var validationErr *schema.ValidationError clientName := client.ID() logger := s.logger.With().Str("table", table.Name).Str("client", clientName).Logger() @@ -90,10 +83,6 @@ func (s *syncClient) resolveTableDfs(ctx context.Context, table *schema.Table, c defer func() { if err := recover(); err != nil { stack := fmt.Sprintf("%s\n%s", err, string(debug.Stack())) - sentry.WithScope(func(scope *sentry.Scope) { - scope.SetTag("table", table.Name) - sentry.CurrentHub().CaptureMessage(stack) - }) logger.Error().Interface("error", err).Str("stack", stack).Msg("table resolver finished with panic") atomic.AddUint64(&tableMetrics.Panics, 1) } @@ -102,12 +91,6 @@ func (s *syncClient) resolveTableDfs(ctx context.Context, table *schema.Table, c if err := table.Resolver(ctx, client, parent, res); err != nil { logger.Error().Err(err).Msg("table resolver finished with error") atomic.AddUint64(&tableMetrics.Errors, 1) - if errors.As(err, &validationErr) { - sentry.WithScope(func(scope *sentry.Scope) { - scope.SetTag("table", table.Name) - sentry.CurrentHub().CaptureMessage(validationErr.MaskedError()) - }) - } return } }() @@ -132,7 +115,6 @@ func (s *syncClient) resolveResourcesDfs(ctx context.Context, table *schema.Tabl go func() { defer close(resourcesChan) var wg sync.WaitGroup - sentValidationErrors := sync.Map{} for i := range resourcesSlice { i := i resourceConcurrencyKey := table.Name + "-" + client.ID() + "-" + "resource" @@ -168,28 +150,12 @@ func (s *syncClient) resolveResourcesDfs(ctx context.Context, table *schema.Tabl if err := resolvedResource.CalculateCQID(s.deterministicCQID); err != nil { tableMetrics := s.metrics.TableClient[table.Name][client.ID()] s.logger.Error().Err(err).Str("table", table.Name).Str("client", client.ID()).Msg("resource resolver finished with primary key calculation error") - if _, found := sentValidationErrors.LoadOrStore(table.Name, struct{}{}); !found { - // send resource validation errors to Sentry only once per table, - // to avoid sending too many duplicate messages - sentry.WithScope(func(scope *sentry.Scope) { - scope.SetTag("table", table.Name) - sentry.CurrentHub().CaptureMessage(err.Error()) - }) - } atomic.AddUint64(&tableMetrics.Errors, 1) return } if err := resolvedResource.Validate(); err != nil { tableMetrics := s.metrics.TableClient[table.Name][client.ID()] s.logger.Error().Err(err).Str("table", table.Name).Str("client", client.ID()).Msg("resource resolver finished with validation error") - if _, found := sentValidationErrors.LoadOrStore(table.Name, struct{}{}); !found { - // send resource validation errors to Sentry only once per table, - // to avoid sending too many duplicate messages - sentry.WithScope(func(scope *sentry.Scope) { - scope.SetTag("table", table.Name) - sentry.CurrentHub().CaptureMessage(err.Error()) - }) - } atomic.AddUint64(&tableMetrics.Errors, 1) return } diff --git a/serve/plugin.go b/serve/plugin.go index 10c8195bfc..0d9e9b67a2 100644 --- a/serve/plugin.go +++ b/serve/plugin.go @@ -29,12 +29,10 @@ import ( serverDestinationV0 "github.com/cloudquery/plugin-sdk/v4/internal/servers/destination/v0" serverDestinationV1 "github.com/cloudquery/plugin-sdk/v4/internal/servers/destination/v1" serversv3 "github.com/cloudquery/plugin-sdk/v4/internal/servers/plugin/v3" - "github.com/getsentry/sentry-go" "github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/logging" "github.com/rs/zerolog" "github.com/rs/zerolog/log" "github.com/spf13/cobra" - "github.com/thoas/go-funk" "google.golang.org/grpc" "google.golang.org/grpc/test/bufconn" ) @@ -43,7 +41,6 @@ type PluginServe struct { plugin *plugin.Plugin args []string destinationV0V1Server bool - sentryDSN string testListener bool testListenerConn *bufconn.Listener versions []int @@ -51,12 +48,6 @@ type PluginServe struct { type PluginOption func(*PluginServe) -func WithPluginSentryDSN(dsn string) PluginOption { - return func(s *PluginServe) { - s.sentryDSN = dsn - } -} - // WithDestinationV0V1Server is used to include destination v0 and v1 server to work // with older sources func WithDestinationV0V1Server() PluginOption { @@ -225,9 +216,8 @@ func (s *PluginServe) newCmdPluginServe() *cobra.Command { ) s.plugin.SetLogger(logger) pbv3.RegisterPluginServer(grpcServer, &serversv3.Server{ - Plugin: s.plugin, - Logger: logger, - NoSentry: noSentry, + Plugin: s.plugin, + Logger: logger, }) if s.destinationV0V1Server { pbDestinationV1.RegisterDestinationServer(grpcServer, &serverDestinationV1.Server{ @@ -246,33 +236,6 @@ func (s *PluginServe) newCmdPluginServe() *cobra.Command { Versions: []int32{0, 1, 2, 3}, }) - version := s.plugin.Version() - - if s.sentryDSN != "" && !strings.EqualFold(version, "development") && !noSentry { - err = sentry.Init(sentry.ClientOptions{ - Dsn: s.sentryDSN, - Debug: false, - AttachStacktrace: false, - Release: version, - Transport: sentry.NewHTTPSyncTransport(), - ServerName: "oss", // set to "oss" on purpose to avoid sending any identifying information - // https://docs.sentry.io/platforms/go/configuration/options/#removing-default-integrations - Integrations: func(integrations []sentry.Integration) []sentry.Integration { - var filteredIntegrations []sentry.Integration - for _, integration := range integrations { - if integration.Name() == "Modules" { - continue - } - filteredIntegrations = append(filteredIntegrations, integration) - } - return filteredIntegrations - }, - }) - if err != nil { - log.Error().Err(err).Msg("Error initializing sentry") - } - } - ctx := cmd.Context() c := make(chan os.Signal, 1) signal.Notify(c, os.Interrupt, syscall.SIGTERM) @@ -308,10 +271,8 @@ func (s *PluginServe) newCmdPluginServe() *cobra.Command { cmd.Flags().BoolVar(&otelEndpointInsecure, "otel-endpoint-insecure", false, "use Open Telemetry HTTP endpoint (for development only)") cmd.Flags().BoolVar(&noSentry, "no-sentry", false, "disable sentry") cmd.Flags().StringVar(&licenseFile, "license", "", "Path to offline license file or directory") - sendErrors := funk.ContainsString([]string{"all", "errors"}, telemetryLevel.String()) - if !sendErrors { - noSentry = true - } + + _ = cmd.Flags().MarkDeprecated("no-sentry", "no-sentry option is deprecated and unused") return cmd }