You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to emit the metric workflow_failed when the workflow execution fails (replicating metrics emitted by other SDKs). To achieve that, I registered a workflow middleware in my worker. In my middleware, I rescue errors and emit this metric.
The problem is that the workflow middleware doesn't raise an error when the workflow execution fails. AFAIK, there is no way of knowing if the workflow execution failed in the context of a workflow middleware. Conversely, in the activity middleware, errors are raised so it's possible to emit the metric activity_exectuion_failed. How can I emit the workflow_failed metrics when the workflow execution fails?
Setup:
worker.rb:
class Worker < Temporal::Worker
def self.start
worker = Temporal::Worker.new
# configure...
worker.add_workflow_middleware(MetricsWorkflowMiddleware)
worker.start
end
end
metrics_workflow_middleware.rb:
class MetricsWorkflowMiddleware
def call(metadata)
yield
Statsd.increment('workflow_completed')
rescue StandardError
Statsd.increment('workflow_failed')
raise
end
end
The text was updated successfully, but these errors were encountered:
etiennelalumiere
changed the title
Workflow Middleware doesn't raise error on workflow execution failure
Workflow middlewares don't raise error on workflow execution failure
Jul 26, 2024
I'd like to emit the metric
workflow_failed
when the workflow execution fails (replicating metrics emitted by other SDKs). To achieve that, I registered a workflow middleware in my worker. In my middleware, I rescue errors and emit this metric.The problem is that the workflow middleware doesn't raise an error when the workflow execution fails. AFAIK, there is no way of knowing if the workflow execution failed in the context of a workflow middleware. Conversely, in the activity middleware, errors are raised so it's possible to emit the metric
activity_exectuion_failed
. How can I emit theworkflow_failed
metrics when the workflow execution fails?Setup:
worker.rb
:metrics_workflow_middleware.rb
:The text was updated successfully, but these errors were encountered: