<commit_before>require "socket"

module Metrix
  class OpenTSDB
    def initialize(host, port = 4242)
      @host = host
      @port = port
    end

    def <<(metric)
      metric.metrics.each do |m|
        Metrix.logger.debug "buffering #{m.to_opentsdb}"
        buffers << m.to_opentsdb
        flush if buffers.count >= 90
      end
    rescue => err
      Metrix.logger.error "#{err.message} #{err.inspect}"<commit_msg>expose host and port<commit_after>require "socket"

module Metrix
  class OpenTSDB
    attr_reader :host, :port

    def initialize(host, port = 4242)
      @host = host
      @port = port
    end

    def <<(metric)
      metric.metrics.each do |m|
        Metrix.logger.debug "buffering #{m.to_opentsdb}"
        buffers << m.to_opentsdb
        flush if buffers.count >= 90
      end
    rescue => err
      Metrix.logger.error "#{err.message} #{err.inspect}"
{'fraction_non_alphanumeric': 0.11386696730552424, 'fraction_numerical': 0.013528748590755355, 'mean_word_length': 2.3893129770992365, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 7, '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': '7622203', 'n_tokens_mistral': 300, 'n_tokens_neox': 292, 'n_words': 75}