Skip to content

Commit 1af397f

Browse files
authored
📝 log telemetry initialization
log telemetry initialization
2 parents 826a369 + c12051f commit 1af397f

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
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

install/cyclops-install.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ spec:
333333
spec:
334334
containers:
335335
- name: cyclops-ui
336-
image: cyclopsui/cyclops-ui:v0.2.0
336+
image: cyclopsui/cyclops-ui:v0.2.1-logging
337337
ports:
338338
- containerPort: 80
339339
env:
@@ -379,7 +379,7 @@ spec:
379379
serviceAccountName: cyclops-ctrl
380380
containers:
381381
- name: cyclops-ctrl
382-
image: cyclopsui/cyclops-ctrl:v0.2.0
382+
image: cyclopsui/cyclops-ctrl:v0.2.1-logging
383383
ports:
384384
- containerPort: 8080
385385
env:

0 commit comments

Comments
 (0)