<commit_before>module RaygunClient
  module HTTP
    class Post
      def self.logger
        @logger ||= ::Telemetry::Logger.get self
      end

      setting :api_key

      attr_reader :data

      dependency :telemetry, ::Telemetry
      dependency :logger, ::Telemetry::Logger
      dependency :http_post, ::HTTP::Commands::Post

      def self.build(connection: nil)
        new.tap do |instance|
          RaygunClient::Settings.set(instance)

          ::Telemetry.configure instance
          ::Telemetry::Logger.configure instance
          ::HTTP::Commands::Post.configure instance, :http_post, connection: connection
        end
      end

      def self.configure(receiver, attr_name=nil)
        attr_name ||= :raygun_post
        build.tap do |instance|
          receiver.send "#{attr_name}=", instance
        end
      end

      def self.call(data)
        instance = build
        instance.(data)
      end

      def call(data)
        logger.trace "Posting to Raygun"
        json_text = Serialize::Write.(data, :json)

        response = post(json_text)

        telemetry.record :posted, Telemetry::Data.new(data, response)

        logger.info "Posted to Raygun (#{LogText::Posted.(data, response)})"

        response
      end

      def self.host
        'api.raygun.io'
      end

      def path
        '/entries'
      end

      def uri
        URI::HTTPS.build :host => self.class.host, :path => path
      end

      def post(request_body)
        http_post.(request_body, uri, 'X-ApiKey' => api_key)
      end

      def self.register_telemetry_sink(post)
        sink = Telemetry.sink
        post.telemetry.register sink
        sink
      end

      module Telemetry
        class Sink
          include ::Telemetry::Sink

          record :posted

          module Assertions<commit_msg>Path is static<commit_after>module RaygunClient
  module HTTP
    class Post
      def self.logger
        @logger ||= ::Telemetry::Logger.get self
      end

      setting :api_key

      attr_reader :data

      dependency :telemetry, ::Telemetry
      dependency :logger, ::Telemetry::Logger
      dependency :http_post, ::HTTP::Commands::Post

      def self.build(connection: nil)
        new.tap do |instance|
          RaygunClient::Settings.set(instance)

          ::Telemetry.configure instance
          ::Telemetry::Logger.configure instance
          ::HTTP::Commands::Post.configure instance, :http_post, connection: connection
        end
      end

      def self.configure(receiver, attr_name=nil)
        attr_name ||= :raygun_post
        build.tap do |instance|
          receiver.send "#{attr_name}=", instance
        end
      end

      def self.call(data)
        instance = build
        instance.(data)
      end

      def call(data)
        logger.trace "Posting to Raygun"
        json_text = Serialize::Write.(data, :json)

        response = post(json_text)

        telemetry.record :posted, Telemetry::Data.new(data, response)

        logger.info "Posted to Raygun (#{LogText::Posted.(data, response)})"

        response
      end

      def self.host
        'api.raygun.io'
      end

      def self.path
        '/entries'
      end

      def uri
        URI::HTTPS.build :host => self.class.host, :path => self.class.path
      end

      def post(request_body)
        http_post.(request_body, uri, 'X-ApiKey' => api_key)
      end

      def self.register_telemetry_sink(post)
        sink = Telemetry.sink
        post.telemetry.register sink
        sink
      end

      module Telemetry
        class Sink
          include ::Telemetry::Sink

          record :posted

          module Assertions
{'fraction_non_alphanumeric': 0.09566639411283728, 'fraction_numerical': 0.0, 'mean_word_length': 2.0230642504118617, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '946273', 'n_tokens_mistral': 1065, 'n_tokens_neox': 1024, 'n_words': 253}