Class: JFlow::Stats

Inherits:
Object
  • Object
show all
Defined in:
lib/jflow/stats.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(domain_name, tasklist) ⇒ Stats

Returns a new instance of Stats.



6
7
8
9
# File 'lib/jflow/stats.rb', line 6

def initialize(domain_name, tasklist)
  @domain_name = domain_name
  @tasklist    = tasklist
end

Instance Attribute Details

#domain_nameObject (readonly)

Returns the value of attribute domain_name.



4
5
6
# File 'lib/jflow/stats.rb', line 4

def domain_name
  @domain_name
end

#tasklistObject (readonly)

Returns the value of attribute tasklist.



4
5
6
# File 'lib/jflow/stats.rb', line 4

def tasklist
  @tasklist
end

Instance Method Details

#backlog_countObject



36
37
38
39
40
41
42
43
# File 'lib/jflow/stats.rb', line 36

def backlog_count
  JFlow.configuration.swf_client.count_pending_activity_tasks({
    domain: domain_name,
    task_list: {
      name: tasklist,
    },
  }).count
end

#tickObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/jflow/stats.rb', line 11

def tick
  value = backlog_count
  JFlow.configuration.cloudwatch_client.put_metric_data({
    namespace: "SWF/Custom",
    metric_data: [
      {
        metric_name: "TasklistBacklog",
        dimensions: [
          {
            name: "Domain",
            value: domain_name,
          },{
            name: "Tasklist",
            value: tasklist,
          }
        ],
        timestamp: Time.now,
        value: value,
        unit: "Count"
      },
    ],
  })
  JFlow.configuration.logger.debug "Sending tick stats with value: #{value}"
end