<commit_before>module HostedGraphite
  class TCP < Protocol
    private
      def build_message(name, value)
        message = [name, value].join(' ') + "\n"
        [@api_key, message].join('.')
      end

      def send_message(message)
        socket.puts(message)
        true
      end

      def socket
        Thread.current[:hostedgraphite_tcpsocket] ||= TCPSocket.new addr_info.ip_address,
                                                                    addr_info.ip_port
      end

      def addr_info
        Addrinfo.tcp(HOST, PORT)
      end
  end
end<commit_msg>Configure TCP protocol to accept an optional timestamp<commit_after>module HostedGraphite
  class TCP < Protocol
    private
      def build_message(name, value, timestamp = nil)
        if timestamp
          message = [name, value, timestamp].join(' ') + "\n"
        else
          message = [name, value].join(' ') + "\n"
        end

        [@api_key, message].join('.')
      end

      def send_message(message)
        socket.puts(message)
        true
      end

      def socket
        Thread.current[:hostedgraphite_tcpsocket] ||= TCPSocket.new addr_info.ip_address,
                                                                    addr_info.ip_port
      end

      def addr_info
        Addrinfo.tcp(HOST, PORT)
      end
  end
end
{'fraction_non_alphanumeric': 0.0872836719337848, 'fraction_numerical': 0.0, 'mean_word_length': 1.607843137254902, 'pattern_counts': {'":': 0, '<': 5, '<?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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4595174', 'n_tokens_mistral': 366, 'n_tokens_neox': 358, 'n_words': 87}