-
Notifications
You must be signed in to change notification settings - Fork 107
Open
Description
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
Metadata
Metadata
Assignees
Labels
No labels