Class: Ring::SQA::Alarm::Slack

Inherits:
Object
  • Object
show all
Defined in:
lib/ring/sqa/alarm/slack.rb

Constant Summary collapse

TIMEOUT =
10

Instance Method Summary collapse

Instance Method Details

#send(opts) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/ring/sqa/alarm/slack.rb', line 10

def send opts
  short, long = opts[:short], opts[:long]
  cfg  = CFG.slack
  json = JSON.pretty_generate(
    {
      "attachments" => [
        {
          "fallback"    => short,
          "pretext"     => short,
          "author_name" => "NLNog Ring SQA",
          "author_link" => "https://ring.nlnog.net/news/2014/07/new-monitoring-tool-ring-sqa/",
          "text"        => long,
        },
      ],
    },
  )
  post json, cfg.url
rescue => error
  Log.error "Slack send raised '#{error.class}' with message '#{error.message}'"
end