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

removed ENABLE_STATS option, checking for catalog connectivity #517

Merged
merged 2 commits into from
Oct 16, 2023
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: 0 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ x-flow-worker-env: &flow-worker-env
ENABLE_PROFILING: "true"
# enables exporting of mirror metrics to Prometheus for visualization using Grafana
ENABLE_METRICS: "true"
# enables exporting of mirror metrics to Catalog in the PEERDB_STATS schema.
ENABLE_STATS: "true"
PYROSCOPE_SERVER_ADDRESS: http://pyroscope:4040

services:
Expand Down
9 changes: 0 additions & 9 deletions flow/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,6 @@ func main() {
EnvVars: []string{"ENABLE_METRICS"},
}

monitoringFlag := &cli.BoolFlag{
Name: "enable-monitoring",
Value: false, // Default is off
Usage: "Enable mirror monitoring for the application",
EnvVars: []string{"ENABLE_STATS"},
}

pyroscopeServerFlag := &cli.StringFlag{
Name: "pyroscope-server-address",
Value: "http://pyroscope:4040",
Expand All @@ -76,7 +69,6 @@ func main() {
TemporalHostPort: temporalHostPort,
EnableProfiling: ctx.Bool("enable-profiling"),
EnableMetrics: ctx.Bool("enable-metrics"),
EnableMonitoring: ctx.Bool("enable-monitoring"),
PyroscopeServer: ctx.String("pyroscope-server-address"),
MetricsServer: ctx.String("metrics-server"),
})
Expand All @@ -85,7 +77,6 @@ func main() {
temporalHostPortFlag,
profilingFlag,
metricsFlag,
monitoringFlag,
pyroscopeServerFlag,
metricsServerFlag,
},
Expand Down
15 changes: 4 additions & 11 deletions flow/cmd/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ import (
"syscall"
"time"

//nolint:gosec
_ "net/http/pprof"

"github.com/PeerDB-io/peer-flow/activities"
utils "github.com/PeerDB-io/peer-flow/connectors/utils/catalog"
"github.com/PeerDB-io/peer-flow/connectors/utils/monitoring"
Expand All @@ -31,7 +28,6 @@ type WorkerOptions struct {
TemporalHostPort string
EnableProfiling bool
EnableMetrics bool
EnableMonitoring bool
PyroscopeServer string
MetricsServer string
}
Expand Down Expand Up @@ -111,14 +107,11 @@ func WorkerMain(opts *WorkerOptions) error {
}
}

catalogMirrorMonitor := monitoring.NewCatalogMirrorMonitor(nil)
if opts.EnableMonitoring {
conn, err := utils.GetCatalogConnectionPoolFromEnv()
if err != nil {
return fmt.Errorf("unable to create catalog connection pool: %w", err)
}
catalogMirrorMonitor = monitoring.NewCatalogMirrorMonitor(conn)
conn, err := utils.GetCatalogConnectionPoolFromEnv()
if err != nil {
return fmt.Errorf("unable to create catalog connection pool: %w", err)
}
catalogMirrorMonitor := monitoring.NewCatalogMirrorMonitor(conn)
defer catalogMirrorMonitor.Close()

c, err := client.Dial(clientOptions)
Expand Down
5 changes: 5 additions & 0 deletions flow/connectors/utils/catalog/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ func GetCatalogConnectionPoolFromEnv() (*pgxpool.Pool, error) {
return nil, fmt.Errorf("unable to establish connection with catalog: %w", err)
}

err = catalogConn.Ping(context.Background())
if err != nil {
return nil, fmt.Errorf("unable to establish connection with catalog: %w", err)
}

return catalogConn, nil
}

Expand Down