Skip to content

Commit 666ee1d

Browse files
committed
fix: refresh admin email on registration retry and improve logging
1 parent 264e720 commit 666ee1d

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

threadwinds-ingestion/internal/client/cm_client.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,17 @@ func (c *CustomersManagerClient) RegisterUserReporter(email string) (*Registrati
5757
case http.StatusBadRequest:
5858
return nil, catcher.Error("invalid registration data", err, map[string]any{
5959
"status": statusCode,
60+
"email": email,
6061
})
6162
case http.StatusInternalServerError:
6263
return nil, catcher.Error("registration service error", err, map[string]any{
6364
"status": statusCode,
65+
"email": email,
6466
})
6567
default:
6668
return nil, catcher.Error("registration failed", err, map[string]any{
6769
"status": statusCode,
70+
"email": email,
6871
})
6972
}
7073
}

threadwinds-ingestion/internal/client/postgres_client.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ func (c *PostgresClient) GetAdminEmail(ctx context.Context) (*AdminEmailResult,
9292
result.LastModified = lastModifiedDate.Time
9393
}
9494

95+
catcher.Info("retrieved current admin email", map[string]any{
96+
"email": email,
97+
"last_modified_by": lastModifiedBy,
98+
})
99+
95100
return result, nil
96101
}
97102

threadwinds-ingestion/main.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,16 @@ func main() {
6363
var regResp *client.RegistrationResponse
6464

6565
registerFunc := func() error {
66-
resp, err := cmClient.RegisterUserReporter(adminEmail)
66+
currentEmail, emailErr := postgresClient.GetAdminEmail(ctx)
67+
if emailErr != nil {
68+
return catcher.Error("failed to get current admin email", emailErr, nil)
69+
}
70+
71+
catcher.Info("attempting ThreadWinds registration", map[string]any{
72+
"email": currentEmail.Email,
73+
})
74+
75+
resp, err := cmClient.RegisterUserReporter(currentEmail.Email)
6776
if err != nil {
6877
return err
6978
}

0 commit comments

Comments
 (0)