Sha256: 9c22be1df3b3b80f5a61efb1aaa448a277b755de168c94a727e01a73a751e3b5

Contents?: true

Size: 1.02 KB

Versions: 9

Compression:

Stored size: 1.02 KB

Contents

module JFlow
  class Stats

    attr_reader :domain_name, :tasklist

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

    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

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

  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
jflow-0.5.1 lib/jflow/stats.rb
jflow-0.5.0 lib/jflow/stats.rb
jflow-0.4.5 lib/jflow/stats.rb
jflow-0.4.4 lib/jflow/stats.rb
jflow-0.4.3 lib/jflow/stats.rb
jflow-0.4.2 lib/jflow/stats.rb
jflow-0.4.1 lib/jflow/stats.rb
jflow-0.4.0 lib/jflow/stats.rb
jflow-0.3.6 lib/jflow/stats.rb