From e0041a62c360ca856f2916458e5d2d44b91338e8 Mon Sep 17 00:00:00 2001 From: Ben Johnson Date: Wed, 10 Apr 2024 15:30:32 -0600 Subject: [PATCH] Fix temporal namespace --- cmd/fly-autoscaler/main.go | 1 + temporal/temporal.go | 24 +++++++++++------------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/cmd/fly-autoscaler/main.go b/cmd/fly-autoscaler/main.go index 356f0b9..7ad145c 100644 --- a/cmd/fly-autoscaler/main.go +++ b/cmd/fly-autoscaler/main.go @@ -174,6 +174,7 @@ func NewConfigFromEnv() (*Config, error) { c.MetricCollectors = append(c.MetricCollectors, &MetricCollectorConfig{ Type: "temporal", Address: addr, + Namespace: os.Getenv("FAS_TEMPORAL_NAMESPACE"), MetricName: os.Getenv("FAS_TEMPORAL_METRIC_NAME"), CertData: certData, KeyData: keyData, diff --git a/temporal/temporal.go b/temporal/temporal.go index 069b3e6..ebd49cc 100644 --- a/temporal/temporal.go +++ b/temporal/temporal.go @@ -3,6 +3,7 @@ package temporal import ( "context" "crypto/tls" + "fmt" "log/slog" "github.com/superfly/fly-autoscaler" @@ -16,16 +17,13 @@ type MetricCollector struct { name string client client.Client - // Host & port of the Temporal server. Defaults to localhost:7233. - // Must be set before calling Open(). + // Host & port of the Temporal server. Must be set before calling Open(). Address string - // Namespace to connect to. Defaults to "default". - // Must be set before calling Open(). + // Namespace to connect to. Must be set before calling Open(). Namespace string - // Certificate & key data. Optional. - // Must be set before calling Open(). + // Certificate & key data. Optional. Must be set before calling Open(). Cert []byte Key []byte @@ -38,18 +36,18 @@ func NewMetricCollector(name string) *MetricCollector { } func (c *MetricCollector) Open() (err error) { + if c.Address == "" { + return fmt.Errorf("temporal address required") + } + if c.Namespace == "" { + return fmt.Errorf("temporal namespace required") + } + opt := client.Options{ HostPort: c.Address, Namespace: c.Namespace, } - slog.Info("connecting to temporal", - slog.String("address", c.Address), - slog.String("namespace", c.Namespace), - slog.String("cert", string(c.Cert)), - slog.String("key", string(c.Key)), - slog.String("query", c.Query)) - if len(c.Cert) != 0 || len(c.Key) != 0 { cert, err := tls.X509KeyPair(c.Cert, c.Key) if err != nil {