-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Emiting reconcile_elapsed_ms metrics #6534
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -238,7 +238,6 @@ func (c *Controller) Run(ctx context.Context) error { | |||||||||||||||||||||||||
if len(hanging) != 0 { | ||||||||||||||||||||||||||
loopErr = fmt.Errorf("reconciles for resources %v have hung for more than %s after cancelation", hanging, reconcileCancelationTimeout.String()) | ||||||||||||||||||||||||||
stop = true | ||||||||||||||||||||||||||
break | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
case <-c.catalog.hasEventsCh: // The catalog has events to process | ||||||||||||||||||||||||||
// Need a write lock to call resetEvents. | ||||||||||||||||||||||||||
|
@@ -257,7 +256,6 @@ func (c *Controller) Run(ctx context.Context) error { | |||||||||||||||||||||||||
c.mu.RUnlock() | ||||||||||||||||||||||||||
case <-ctx.Done(): // We've been asked to stop | ||||||||||||||||||||||||||
stop = true | ||||||||||||||||||||||||||
break | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
|
@@ -275,7 +273,7 @@ func (c *Controller) Run(ctx context.Context) error { | |||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
c.mu.RUnlock() | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
// Allow 10 seconds for closing invocations and reconcilers | ||||||||||||||||||||||||||
// Allow 30 seconds for closing invocations and reconcilers | ||||||||||||||||||||||||||
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) | ||||||||||||||||||||||||||
defer cancel() | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
|
@@ -1360,24 +1358,35 @@ func (c *Controller) processCompletedInvocation(inv *invocation) error { | |||||||||||||||||||||||||
c.Logger.Info("Reconciled resource", logArgs...) | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
// Emit event unless it was a cancellation. | ||||||||||||||||||||||||||
if inv.cancelledOn.IsZero() { | ||||||||||||||||||||||||||
eventArgs := []attribute.KeyValue{ | ||||||||||||||||||||||||||
attribute.String("name", inv.name.Name), | ||||||||||||||||||||||||||
attribute.String("type", PrettifyResourceKind(inv.name.Kind)), | ||||||||||||||||||||||||||
attribute.Int64("elapsed_ms", elapsed.Milliseconds()), | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
if inv.isDelete { | ||||||||||||||||||||||||||
eventArgs = append(eventArgs, attribute.Bool("deleted", true)) | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
if inv.isRename { | ||||||||||||||||||||||||||
eventArgs = append(eventArgs, attribute.Bool("renamed", true)) | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
if inv.result.Err != nil { | ||||||||||||||||||||||||||
eventArgs = append(eventArgs, attribute.String("error", inv.result.Err.Error())) | ||||||||||||||||||||||||||
commonDims := []attribute.KeyValue{ | ||||||||||||||||||||||||||
attribute.String("resource_id", inv.name.Name), | ||||||||||||||||||||||||||
attribute.String("resource_type", PrettifyResourceKind(inv.name.Kind)), | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
if inv.isDelete { | ||||||||||||||||||||||||||
commonDims = append(commonDims, attribute.Bool("is_deleted", true)) | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
if inv.isRename { | ||||||||||||||||||||||||||
commonDims = append(commonDims, attribute.Bool("is_renamed", true)) | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Grammar:
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added reconcile_operation instead of two different dimensions |
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
if !inv.cancelledOn.IsZero() { | ||||||||||||||||||||||||||
commonDims = append(commonDims, attribute.String("reconcile_status", "Cancelled")) | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
rill/proto/rill/runtime/v1/resources.proto Lines 12 to 17 in d4fa2a1
Maybe consider There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||||||||||||||||||||||||||
} else if inv.result.Err != nil { | ||||||||||||||||||||||||||
if errors.Is(inv.result.Err, context.Canceled) { | ||||||||||||||||||||||||||
commonDims = append(commonDims, attribute.String("reconcile_status", "Cancelled")) | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit : There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given the key is snake case, consider also using snake case for the values (this seems like pascal case or title case). E.g. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||||||||||||||||||||||||||
} else if errors.Is(inv.result.Err, context.DeadlineExceeded) { | ||||||||||||||||||||||||||
commonDims = append(commonDims, attribute.String("reconcile_status", "Timeout")) | ||||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||||
commonDims = append(commonDims, attribute.String("reconcile_status", "Error"), attribute.String("reconcile_error", inv.result.Err.Error())) | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
c.Activity.Record(context.Background(), activity.EventTypeLog, "reconciled_resource", eventArgs...) | ||||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||||
commonDims = append(commonDims, attribute.String("reconcile_status", "Succeeded")) | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: call it "success" instead of "Succeeded" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
if !inv.result.Retrigger.IsZero() { | ||||||||||||||||||||||||||
commonDims = append(commonDims, attribute.String("retrigger_time", inv.result.Retrigger.Format(time.RFC3339))) | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
c.Activity.RecordMetric(context.Background(), "reconcile_elapsed_ms", float64(elapsed.Milliseconds()), commonDims...) | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
r, err := c.catalog.get(inv.name, true, false) | ||||||||||||||||||||||||||
if err != nil { | ||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done