Skip to content
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

Add ExecutableDLQObserver #4881

Merged
merged 1 commit into from Oct 2, 2023
Merged

Add ExecutableDLQObserver #4881

merged 1 commit into from Oct 2, 2023

Conversation

MichaelSnowden
Copy link
Contributor

What changed?
I added queues.ExecutableDLQObserver which adds logging and metrics to the history task DLQ.

Why?
In order for us to alert on things like high DLQ latency, high DLQ rate, or high DLQ failure rate.

How did you test it?
There's 100% test coverage for the new code.

Potential risks

Is hotfix candidate?

@MichaelSnowden MichaelSnowden requested a review from a team as a code owner September 18, 2023 22:40
@MichaelSnowden MichaelSnowden force-pushed the snowden/dlq-5 branch 2 times, most recently from 73c1363 to 5804a83 Compare September 25, 2023 21:44
@MichaelSnowden MichaelSnowden changed the base branch from snowden/dlq-5 to snowden/dlq-telemetry-base September 25, 2023 21:54
service/history/queues/executable_dlq_observer.go Outdated Show resolved Hide resolved
logger.Error("Failed to send history task to the DLQ", tag.Error(err))
} else if err == nil && o.terminalFailureTime != nil {
latency := o.timeSource.Now().Sub(*o.terminalFailureTime)
o.metricsHandler.Timer(metrics.TaskDLQSendLatency.GetMetricName()).Record(latency)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this latency will also include the retry backoff? What does latency for send to DLQ exactly mean here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, probably not that useful. I think I was trying to track the E2E time from detection until it's actually DLQ'd, but that doesn't seem as important as the latency of the actual work. I changed it to just record the latency of the final execution, which successfully sends the task to the DLQ.

func (o *ExecutableDLQObserver) Execute() error {
err := o.ExecutableDLQ.Execute()
if errors.Is(err, ErrTerminalTaskFailure) {
o.metricsHandler.Counter(metrics.TaskTerminalFailures.GetMetricName()).Record(1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: shall we also tag namespace and task type?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added, and I added tests for them

Comment on lines 28 to 31
"go.temporal.io/server/common/clock"
"go.temporal.io/server/common/log"
"go.temporal.io/server/common/metrics"
"go.temporal.io/server/service/history/configs"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: plz group with other server imports and fix other files as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. I also tried making a config change for GoLand here, but it doesn't seem to work:
image

@MichaelSnowden MichaelSnowden changed the base branch from snowden/dlq-telemetry-base to snowden/dlq-feature September 28, 2023 13:05
Base automatically changed from snowden/dlq-feature to main September 28, 2023 17:07
return err
}

func (o *ExecutableDLQObserver) getMetricsHandler() metrics.Handler {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we just need to tag the metrics handler once and reuse the tagged handler I think. Same for the logger.

I remember I've implemented a lazyLogger and used in executableImpl, you might want to take a look.

}
}

func (o *ExecutableDLQObserver) Execute() error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not related to this PR but it just occurred to me.

If the State of the underlying task is not Pending (e.g. queue is shutting down or multi-cursor impl want to offload/delete some tasks from memory) anymore, the execution should be skipped.
https://github.com/temporalio/temporal/blob/main/service/history/queues/executable.go#L188

@MichaelSnowden MichaelSnowden merged commit ab2008d into main Oct 2, 2023
10 checks passed
@MichaelSnowden MichaelSnowden deleted the snowden/dlq-telemetry branch October 2, 2023 21:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants