Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better error logging in postgres connector #1633

Merged
merged 1 commit into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion flow/alerting/alerting.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ func (a *Alerter) sendTelemetryMessage(ctx context.Context, flowName string, mor
_, err := a.telemetrySender.SendMessage(ctx, details, details, telemetry.Attributes{
Level: level,
DeploymentUID: peerdbenv.PeerDBDeploymentUID(),
Tags: []string{flowName},
Tags: []string{flowName, peerdbenv.PeerDBDeploymentUID()},
Type: flowName,
})
if err != nil {
Expand Down
6 changes: 5 additions & 1 deletion flow/connectors/postgres/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ type ReplState struct {
}

func NewPostgresConnector(ctx context.Context, pgConfig *protos.PostgresConfig) (*PostgresConnector, error) {
logger := logger.LoggerFromCtx(ctx)
connectionString := shared.GetPGConnectionString(pgConfig)

// create a separate connection pool for non-replication queries as replication connections cannot
Expand All @@ -68,11 +69,13 @@ func NewPostgresConnector(ctx context.Context, pgConfig *protos.PostgresConfig)

tunnel, err := NewSSHTunnel(ctx, pgConfig.SshConfig)
if err != nil {
logger.Error("failed to create ssh tunnel", slog.Any("error", err))
return nil, fmt.Errorf("failed to create ssh tunnel: %w", err)
}

conn, err := tunnel.NewPostgresConnFromConfig(ctx, connConfig)
if err != nil {
logger.Error("failed to create connection", slog.Any("error", err))
return nil, fmt.Errorf("failed to create connection: %w", err)
}

Expand All @@ -82,6 +85,7 @@ func NewPostgresConnector(ctx context.Context, pgConfig *protos.PostgresConfig)

customTypeMap, err := shared.GetCustomDataTypes(ctx, conn)
if err != nil {
logger.Error("failed to get custom type map", slog.Any("error", err))
return nil, fmt.Errorf("failed to get custom type map: %w", err)
}

Expand All @@ -101,7 +105,7 @@ func NewPostgresConnector(ctx context.Context, pgConfig *protos.PostgresConfig)
customTypesMapping: customTypeMap,
metadataSchema: metadataSchema,
hushWarnOID: make(map[uint32]struct{}),
logger: logger.LoggerFromCtx(ctx),
logger: logger,
relationMessageMapping: make(model.RelationMessageMapping),
}, nil
}
Expand Down
Loading