<commit_before>require "statsd-ruby"
require "thread"

module Alephant
  module Logger
    class Statsd
      def initialize(config = {})
        @server = connect defaults.merge(config)
      end

      def increment(key, interval = 1)
        send_data { server.increment(key, interval) }
      end

      private

      attr_reader :server

      def connect(config)
        ::Statsd.new(config[:host], config[:port]).tap do |s|
          s.namespace = config[:namespace]<commit_msg>Closes #2 - Add .metric method<commit_after>require "statsd-ruby"
require "thread"

module Alephant
  module Logger
    class Statsd
      def initialize(config = {})
        @server = connect defaults.merge(config)
      end

      def increment(key, interval = 1)
        send_data { server.increment(key, interval) }
      end

      alias metric increment

      private

      attr_reader :server

      def connect(config)
        ::Statsd.new(config[:host], config[:port]).tap do |s|
          s.namespace = config[:namespace]
{'fraction_non_alphanumeric': 0.10304219823356231, 'fraction_numerical': 0.002944062806673209, 'mean_word_length': 2.5664335664335662, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5369496', 'n_tokens_mistral': 300, 'n_tokens_neox': 284, 'n_words': 76}