Skip to content

Commit

Permalink
removed ENABLE_STATS option, checking for catalog connectivity and co…
Browse files Browse the repository at this point in the history
…de cleanup
  • Loading branch information
heavycrystal committed Oct 16, 2023
1 parent 0957cfb commit 21f02c6
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 22 deletions.
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

0 comments on commit 21f02c6

Please sign in to comment.