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

Use message variable in slack_notifier for attachment text via options #292

Open
daino3 opened this issue Nov 2, 2015 · 1 comment
Open

Comments

@daino3
Copy link

daino3 commented Nov 2, 2015

I might be missing something in the code, or it might simply be a documentation thing, but I don't see an easy way to take the message variable in the slack_notifier#call and reuse it from within the options hash for setting up an attachment.

Something like:

# slack_notifier.rb

def call(exception, options={})
  message = "An exception occurred: '#{exception.message}'"
  message += " on '#{exception.backtrace.first}'" if exception.backtrace

  message = enrich_message_with_data(message, options)
  message = enrich_message_with_backtrace(message, exception) if exception.backtrace

  if  @message_opts[:attachments].any? && send_to_slack_as_attachment # config variable
    @message_opts[:attachments].each do | attachment |
      attachment[:text] = message
    end
  end
  @notifier.ping(message, @message_opts) if valid?
end
@daino3 daino3 changed the title Use Message / text is slack notifier for attachment option Use message variable in slack_notifier for attachment text via options Nov 2, 2015
@nunosilva800
Copy link

Yeah, #299 didn't really fix this once and for all...

We can't add additional attachments because of @message_opts.merge(attachments: attchs)
https://github.com/smartinez87/exception_notification/blob/v4.1.2/lib/exception_notifier/slack_notifier.rb#L41

It would be nice to have at least this ability:

    additional_parameters: {
      attachments: [
        fields: [{ title: 'Project', value: "P-A" }]
      ]
    }

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

No branches or pull requests

2 participants