@@ -135,6 +135,7 @@ func (mcc *multiClusterClient) RemoveClusterClient(cluster string) {
135
135
func (mcc * multiClusterClient ) Create (ctx context.Context , obj client.Object , opts ... client.CreateOption ) (err error ) {
136
136
var cluster string
137
137
defer func () {
138
+ attachClusterToObjects (cluster , obj )
138
139
metrics .NewClientCountMetrics (cluster , "Create" , err )
139
140
}()
140
141
@@ -162,6 +163,7 @@ func (mcc *multiClusterClient) Create(ctx context.Context, obj client.Object, op
162
163
func (mcc * multiClusterClient ) Delete (ctx context.Context , obj client.Object , opts ... client.DeleteOption ) (err error ) {
163
164
var cluster string
164
165
defer func () {
166
+ attachClusterToObjects (cluster , obj )
165
167
metrics .NewClientCountMetrics (cluster , "Delete" , err ).Inc ()
166
168
}()
167
169
@@ -305,9 +307,7 @@ func (mcc *multiClusterClient) List(ctx context.Context, list client.ObjectList,
305
307
func (mcc * multiClusterClient ) Patch (ctx context.Context , obj client.Object , patch client.Patch , opts ... client.PatchOption ) (err error ) {
306
308
var cluster string
307
309
defer func () {
308
- if err == nil {
309
- attachClusterToObjects (cluster , obj )
310
- }
310
+ attachClusterToObjects (cluster , obj )
311
311
metrics .NewClientCountMetrics (cluster , "Patch" , err ).Inc ()
312
312
}()
313
313
@@ -335,9 +335,7 @@ func (mcc *multiClusterClient) Patch(ctx context.Context, obj client.Object, pat
335
335
func (mcc * multiClusterClient ) Update (ctx context.Context , obj client.Object , opts ... client.UpdateOption ) (err error ) {
336
336
var cluster string
337
337
defer func () {
338
- if err == nil {
339
- attachClusterToObjects (cluster , obj )
340
- }
338
+ attachClusterToObjects (cluster , obj )
341
339
metrics .NewClientCountMetrics (cluster , "Update" , err ).Inc ()
342
340
}()
343
341
@@ -388,9 +386,7 @@ type statusWriter struct {
388
386
func (sw * statusWriter ) Update (ctx context.Context , obj client.Object , opts ... client.UpdateOption ) (err error ) {
389
387
var cluster string
390
388
defer func () {
391
- if err == nil {
392
- attachClusterToObjects (cluster , obj )
393
- }
389
+ attachClusterToObjects (cluster , obj )
394
390
metrics .NewClientCountMetrics (cluster , "StatusUpdate" , err ).Inc ()
395
391
}()
396
392
@@ -415,9 +411,7 @@ func (sw *statusWriter) Update(ctx context.Context, obj client.Object, opts ...c
415
411
func (sw * statusWriter ) Patch (ctx context.Context , obj client.Object , patch client.Patch , opts ... client.PatchOption ) (err error ) {
416
412
var cluster string
417
413
defer func () {
418
- if err == nil {
419
- attachClusterToObjects (cluster , obj )
420
- }
414
+ attachClusterToObjects (cluster , obj )
421
415
metrics .NewClientCountMetrics (cluster , "StatusPatch" , err ).Inc ()
422
416
}()
423
417
0 commit comments