<commit_before>module NewRelicAWS
  module Collectors
    class Base
      def initialize(access_key, secret_key, region)
        @aws_access_key = access_key
        @aws_secret_key = secret_key
        @aws_region = region
        @cloudwatch = AWS::CloudWatch.new(
          :access_key_id     => @aws_access_key,
          :secret_access_key => @aws_secret_key,
          :region            => @aws_region
        )
      end

      def get_data_point(options)
        options[:period]     ||= 60
        options[:start_time] ||= (Time.now.utc-120).iso8601
        options[:end_time]   ||= (Time.now.utc-60).iso8601
        options[:dimensions] ||= [options[:dimension]]
        statistics = @cloudwatch.client.get_metric_statistics(
          :namespace   => options[:namespace],
          :metric_name => options[:metric_name],
          :unit        => options[:unit],
          :statistics  => ["Sum"],
          :period      => options[:period],
          :start_time  => options[:start_time],
          :end_time    => options[:end_time],
          :dimensions  => options[:dimensions]
        )
        point = statistics[:datapoints].last
        return if point.nil?
        component   = options[:component]
        component ||= options[:dimensions].map { |dimension| dimension[:value] }.join("/")
        [component, options[:metric_name], point[:unit].downcase, point[:sum], point[:timestamp].to_i]
      end

      def collect
        []
      end
    end
  end
end
<commit_msg>[statistic] support grabbing the correct statistic<commit_after>module NewRelicAWS
  module Collectors
    class Base
      def initialize(access_key, secret_key, region)
        @aws_access_key = access_key
        @aws_secret_key = secret_key
        @aws_region = region
        @cloudwatch = AWS::CloudWatch.new(
          :access_key_id     => @aws_access_key,
          :secret_access_key => @aws_secret_key,
          :region            => @aws_region
        )
      end

      def get_data_point(options)
        options[:period]     ||= 60
        options[:start_time] ||= (Time.now.utc-120).iso8601
        options[:end_time]   ||= (Time.now.utc-60).iso8601
        options[:dimensions] ||= [options[:dimension]]
        options[:statistic]  ||= "Sum"
        statistics = @cloudwatch.client.get_metric_statistics(
          :namespace   => options[:namespace],
          :metric_name => options[:metric_name],
          :unit        => options[:unit],
          :statistics  => [options[:statistic]],
          :period      => options[:period],
          :start_time  => options[:start_time],
          :end_time    => options[:end_time],
          :dimensions  => options[:dimensions]
        )
        point = statistics[:datapoints].last
        return if point.nil?
        component   = options[:component]
        component ||= options[:dimensions].map { |dimension| dimension[:value] }.join("/")
        statistic = options[:statistic].downcase.to_sym
        [component, options[:metric_name], point[:unit].downcase, point[statistic], point[:timestamp].to_i]
      end

      def collect
        []
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.12726694241170855, 'fraction_numerical': 0.009545020680878142, 'mean_word_length': 2.2990556138509968, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1866143', 'n_tokens_mistral': 934, 'n_tokens_neox': 906, 'n_words': 163}