Error Messages to Slack¶
bibtutils.slack.error¶
Enables sending alerts (crashes and other errors) to Slack.
- bibtutils.slack.error.send_cf_error(message, webhook, proj_envar='_GOOGLE_PROJECT')[source]¶
Sends an error message to Slack. Not necessarily indicative of a crash.
from bibtutils.slack.error import send_cf_error try: raise IOError('Invalid input!') except IOError as e: send_cf_error( f'Exception raised! {type(e).__name__} : {e}', 'https://hooks.slack.com/services/1234/1234/1234' ) pass
- Parameters:
message (
str
) – a description of the error, included as an attachment in the Slack message.webhook (
str
) – a slack webhook in the standard format:'https://hooks.slack.com/services/{app_id}/{channel_id}/{hash}'
proj_envar (
str
) – (Optional) the environment variable to reference for current GCP project. Defaults to'_GOOGLE_PROJECT'
.
- bibtutils.slack.error.send_cf_fail_alert(currenttime, eventtime, webhook, proj_envar='_GOOGLE_PROJECT')[source]¶
Sends a cloud function runtime failure alert to Slack. Automatically called by the
process_trigger()
method if function retry threshold is exceeded. Will include an appropriately-timestamped link to the cloud function’s logs in the Slack message.- Parameters:
currenttime (
datetime.datetime
) – a datetime object representing the current time.eventtime (
datetime.datetime
) – a datetime object representing the original triggering time.webhook (
str
) – a slack webhook in the standard format:'https://hooks.slack.com/services/{app_id}/{channel_id}/{hash}'
proj_envar (
str
) – (Optional) the environment variable to reference for current GCP project. Defaults to'_GOOGLE_PROJECT'
.