https://dagster.io/ logo
b

Brian Abelson

03/18/2021, 10:45 PM
Can anyone share a pattern they use for including stack traces in failure hooks? I currently use a
failure_hook
on all my pipelines that looks like this:
Copy code
@failure_hook(required_resource_keys={"slack"})
def slack_message_on_failure(context: HookContext):
    message = f"*ALERT*: Dagster failed while running pipeline `{context.pipeline.pipeline_name}` at solid `{context.solid.name}`.\nCheck out the logs at <https://dagster.ioby.network/instance/runs/{context.run_id}>"
    context.resources.slack.chat_postMessage(channel="product-alerts", text=message, icon_emoji=':scream_cat:', username='Uh-oh Cat')
y

yuhan

03/19/2021, 2:33 AM
Hi @Brian Abelson we internally are using the similar pattern as you do here, i.e. linking to the logs in Dagit. As mentioned in #3576, the system-provided
slack_on_failure
and
slack_on_success
takes
dagit_base_url
, the underlying logic of which is exactly the pattern you are using. see details in source code
meanwhile, we’ve been thinking of improving the hook api, esp providing access to the step events, so you would be able to get the full failure event info including the the stack traces tracking issue: https://github.com/dagster-io/dagster/issues/2975
b

Brian Abelson

03/19/2021, 2:15 PM
thank you so much! this is great context @yuhan. i'll follow along on the issue