Skip to content

Commit e3d89fd

Browse files
committed
log telemetry init
1 parent 8f8a243 commit e3d89fd

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

cyclops-ctrl/cmd/main/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func main() {
5757

5858
setupLog.Info("starting handler")
5959

60-
telemetryClient, _ := telemetry.NewClient(getEnvBool("DISABLE_TELEMETRY"))
60+
telemetryClient, _ := telemetry.NewClient(getEnvBool("DISABLE_TELEMETRY"), setupLog)
6161
telemetryClient.InstanceStart()
6262

6363
k8sClient, err := k8sclient.New()

cyclops-ctrl/internal/telemetry/client.go

+14-2
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,21 @@ type Client interface {
1111
InstanceStart()
1212
}
1313

14+
type logger interface {
15+
Info(string, ...any)
16+
Error(error, string, ...any)
17+
}
18+
1419
type EnqueueClient struct {
1520
client posthog.Client
1621
distinctID string
1722
}
1823

1924
type MockClient struct{}
2025

21-
func NewClient(disable bool) (Client, error) {
26+
func NewClient(disable bool, logger logger) (Client, error) {
2227
if disable {
28+
logger.Info("telemetry disabled")
2329
return MockClient{}, nil
2430
}
2531

@@ -30,17 +36,23 @@ func NewClient(disable bool) (Client, error) {
3036
},
3137
)
3238
if err != nil {
39+
logger.Error(err, "error starting telemetry")
3340
return nil, err
3441
}
3542

3643
id, err := uuid.NewUUID()
3744
if err != nil {
45+
logger.Error(err, "error creating UUID")
3846
return nil, err
3947
}
4048

49+
idStr := id.String()
50+
51+
logger.Info("starting instance with UUID", "UUID", idStr)
52+
4153
return EnqueueClient{
4254
client: client,
43-
distinctID: id.String(),
55+
distinctID: idStr,
4456
}, nil
4557
}
4658

0 commit comments

Comments
 (0)