-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add caller-side Nexus operation metrics #10071
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
base: main
Are you sure you want to change the base?
Changes from all commits
1896db3
2fd2bd6
219d5e0
359c1d3
0086243
78653e1
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 |
|---|---|---|
|
|
@@ -135,6 +135,10 @@ var TransitionStarted = chasm.NewTransition( | |
| // Store the operation token for async completion. | ||
| o.OperationToken = event.OperationToken | ||
|
|
||
| // Emit schedule-to-start latency | ||
| metricsHandler := o.metricsHandler(ctx) | ||
| NexusOperationScheduleToStartLatency.With(metricsHandler).Record(startTime.Sub(o.GetScheduledTime().AsTime())) | ||
|
Contributor
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. I'm trying to wrap my head around the fact that
Contributor
Author
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.
|
||
|
|
||
| // Emit a start-to-close timeout task if configured. | ||
| if o.StartToCloseTimeout != nil && o.StartToCloseTimeout.AsDuration() != 0 { | ||
| deadline := startTime.Add(o.StartToCloseTimeout.AsDuration()) | ||
|
|
@@ -185,6 +189,7 @@ var TransitionSucceeded = chasm.NewTransition( | |
| Successful: &nexusoperationpb.OperationOutcome_Successful{Result: event.Result}, | ||
| } | ||
|
|
||
| o.emitOnSucceededMetrics(ctx, closeTime) | ||
| // Terminal state - no tasks to emit. | ||
| return nil | ||
| }, | ||
|
|
@@ -212,6 +217,7 @@ var TransitionFailed = chasm.NewTransition( | |
| } | ||
| // Attempts only execute in SCHEDULED, so that status identifies attempt-originated failures. | ||
| fromAttempt := o.GetStatus() == nexusoperationpb.OPERATION_STATUS_SCHEDULED | ||
| o.emitOnFailedMetrics(ctx, closeTime) | ||
| return o.resolveUnsuccessfully(ctx, event.Failure, closeTime, fromAttempt) | ||
| }, | ||
| ) | ||
|
|
@@ -236,6 +242,7 @@ var TransitionCanceled = chasm.NewTransition( | |
| if event.CompleteTime != nil { | ||
| closeTime = *event.CompleteTime | ||
| } | ||
| o.emitOnCanceledMetrics(ctx, closeTime) | ||
| // Attempts only execute in SCHEDULED, so that status identifies attempt-originated cancels. | ||
|
S15 marked this conversation as resolved.
|
||
| fromAttempt := o.GetStatus() == nexusoperationpb.OPERATION_STATUS_SCHEDULED | ||
| return o.resolveUnsuccessfully(ctx, event.Failure, closeTime, fromAttempt) | ||
|
|
@@ -268,11 +275,12 @@ var TransitionTerminated = chasm.NewTransition( | |
| }, | ||
| }, | ||
| } | ||
| o.emitOnTerminatedMetrics(ctx, closeTime) | ||
| return o.resolveUnsuccessfully(ctx, failure, closeTime, false) | ||
| }, | ||
| ) | ||
|
|
||
| // EventTimedOut is triggered when the schedule-to-close timeout is triggered for an operation. | ||
| // EventTimedOut is triggered when a timeout is triggered for an operation. | ||
| type EventTimedOut struct { | ||
| Failure *failurepb.Failure | ||
| // FromAttempt is true when the failure came from an invocation attempt. | ||
|
|
@@ -287,6 +295,9 @@ var TransitionTimedOut = chasm.NewTransition( | |
| }, | ||
| nexusoperationpb.OPERATION_STATUS_TIMED_OUT, | ||
| func(o *Operation, ctx chasm.MutableContext, event EventTimedOut) error { | ||
| return o.resolveUnsuccessfully(ctx, event.Failure, ctx.Now(o), event.FromAttempt) | ||
| closeTime := ctx.Now(o) | ||
| timeoutType := event.Failure.GetTimeoutFailureInfo().GetTimeoutType().String() | ||
| o.emitOnTimedOutMetrics(ctx, closeTime, timeoutType) | ||
| return o.resolveUnsuccessfully(ctx, event.Failure, closeTime, event.FromAttempt) | ||
| }, | ||
| ) | ||
Uh oh!
There was an error while loading. Please reload this page.
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.
@bergundy I think I've addressed everything mentioned in the previous version of this PR, except I haven't done anything with the names here.
I agree, I don't really care for the names here, but I think it is good to be consistent with activities.I double checked, and and activity uses:
and I have matched those.