stackify-ruby-apm 1.9.8 → 1.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/stackify_apm/agent.rb +0 -2
- data/lib/stackify_apm/config.rb +2 -0
- data/lib/stackify_apm/context.rb +1 -1
- data/lib/stackify_apm/helper/database_helper.rb +1 -1
- data/lib/stackify_apm/instrumenter_helper.rb +3 -4
- data/lib/stackify_apm/logger/log_device.rb +7 -5
- data/lib/stackify_apm/logger/logger_high_version.rb +5 -1
- data/lib/stackify_apm/logger/logger_lower_version.rb +5 -1
- data/lib/stackify_apm/root_info.rb +1 -1
- data/lib/stackify_apm/spies/custom_instrumenter.rb +13 -1
- data/lib/stackify_apm/spies/delayed_job.rb +49 -0
- data/lib/stackify_apm/spies/sidekiq.rb +44 -0
- data/lib/stackify_apm/transport/agent_base.rb +23 -0
- data/lib/stackify_apm/transport/agent_http_client.rb +17 -11
- data/lib/stackify_apm/transport/unix_socket_client.rb +12 -5
- data/lib/stackify_apm/util.rb +0 -9
- data/lib/stackify_apm/version.rb +1 -1
- data/lib/stackify_ruby_apm.rb +0 -3
- data/stackify-ruby-apm.gemspec +1 -16
- metadata +18 -64
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 5617c10d650b0e32554d8e6ae3deb13c24275b7d2df82f0f1c6b223654397e4d
         | 
| 4 | 
            +
              data.tar.gz: 55a0d2aa8b75165c5f4d7c4cdc0fad19411ae6b3a6e3c57e3d47e13b4f9b37a7
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: d9cd97e0abb2265239113f5afcfa73bb7d9522de34e37137e3da8ab5b49705d96864d8f03c3e55908623e695bfe5a5b981319463e8a0ebf4e085d71c2b020e0d
         | 
| 7 | 
            +
              data.tar.gz: 842839b3d394985cbf583b3b200515272e3c510b377406f0ff0054d2ca85d8145a7f1ae81c3edfec4362f35cf30d5d4f5b2ab17da739a8fba6e8a8b720953866
         | 
    
        data/lib/stackify_apm/agent.rb
    CHANGED
    
    | @@ -101,8 +101,6 @@ module StackifyRubyAPM | |
| 101 101 | 
             
                  info '[Agent] start()'
         | 
| 102 102 | 
             
                  info '[Agent] transport type: ' + @config.transport
         | 
| 103 103 | 
             
                  spies_name = ''
         | 
| 104 | 
            -
                  # If the rake task is detected as being ran then we don't load the spies
         | 
| 105 | 
            -
                  StackifyRubyAPM::Util.apm_disabled_in_rake
         | 
| 106 104 | 
             
                  return false unless @config.instrument
         | 
| 107 105 | 
             
                  config.enabled_spies.each do |lib|
         | 
| 108 106 | 
             
                    spies_name = spies_name + ', ' + lib.inspect.to_s
         | 
    
        data/lib/stackify_apm/config.rb
    CHANGED
    
    
    
        data/lib/stackify_apm/context.rb
    CHANGED
    
    
| @@ -90,9 +90,8 @@ module StackifyRubyAPM | |
| 90 90 | 
             
                                      )
         | 
| 91 91 | 
             
                                    end
         | 
| 92 92 |  | 
| 93 | 
            -
                              req = #{current_method_without}(*args, &block)
         | 
| 94 93 | 
             
                              StackifyRubyAPM.span name, type, context: ctx do
         | 
| 95 | 
            -
                                 | 
| 94 | 
            +
                                #{current_method_without}(*args, &block)
         | 
| 96 95 | 
             
                              end
         | 
| 97 96 | 
             
                            else
         | 
| 98 97 | 
             
                              return #{current_method_without}(*args, &block)
         | 
| @@ -169,9 +168,9 @@ module StackifyRubyAPM | |
| 169 168 | 
             
                                        CATEGORY: 'Ruby'
         | 
| 170 169 | 
             
                                      )
         | 
| 171 170 | 
             
                                    end
         | 
| 172 | 
            -
             | 
| 171 | 
            +
             | 
| 173 172 | 
             
                              StackifyRubyAPM.span name, type, context: ctx do
         | 
| 174 | 
            -
                                 | 
| 173 | 
            +
                                _self_without_apm_#{current_method}(*args, &block)
         | 
| 175 174 | 
             
                              end
         | 
| 176 175 | 
             
                            else
         | 
| 177 176 | 
             
                              return _self_without_apm_#{current_method}(*args, &block)
         | 
| @@ -14,9 +14,6 @@ module StackifyRubyAPM | |
| 14 14 | 
             
                    if FileTest.exist?(@filename)
         | 
| 15 15 | 
             
                    else
         | 
| 16 16 | 
             
                      @dev = create_logfile(@filename)
         | 
| 17 | 
            -
                      File.chmod(0o777, @filename)
         | 
| 18 | 
            -
             | 
| 19 | 
            -
                      return @dev
         | 
| 20 17 | 
             
                    end
         | 
| 21 18 | 
             
                  end
         | 
| 22 19 | 
             
                  write_without_apm(message)
         | 
| @@ -58,7 +55,6 @@ module StackifyRubyAPM | |
| 58 55 | 
             
                  temp_newfilename = "#{temp_filename}-#{filename_counter}.log"
         | 
| 59 56 | 
             
                  @filename = temp_newfilename
         | 
| 60 57 | 
             
                  @dev = create_logfile(@filename)
         | 
| 61 | 
            -
                  File.chmod(0o777, @filename)
         | 
| 62 58 |  | 
| 63 59 | 
             
                  true
         | 
| 64 60 | 
             
                end
         | 
| @@ -80,10 +76,16 @@ module StackifyRubyAPM | |
| 80 76 | 
             
                  @dev.close rescue nil
         | 
| 81 77 | 
             
                  File.rename(@filename.to_s, age_file)
         | 
| 82 78 | 
             
                  @dev = create_logfile(@filename)
         | 
| 83 | 
            -
                  File.chmod(0o777, @filename)
         | 
| 84 79 |  | 
| 85 80 | 
             
                  true
         | 
| 86 81 | 
             
                end
         | 
| 82 | 
            +
             | 
| 83 | 
            +
                # Override create_logfile of core LogDevice class where we set File.chmod to 0o777
         | 
| 84 | 
            +
                def create_logfile(filename)
         | 
| 85 | 
            +
                  logdev = super
         | 
| 86 | 
            +
                  File.chmod(0o777, filename)
         | 
| 87 | 
            +
                  logdev
         | 
| 88 | 
            +
                end
         | 
| 87 89 | 
             
                # rubocop:enable Style/RescueModifier
         | 
| 88 90 | 
             
                # rubocop:enable Lint/RescueWithoutErrorClass
         | 
| 89 91 | 
             
              end
         | 
| @@ -29,7 +29,11 @@ module StackifyRubyAPM | |
| 29 29 | 
             
                      temp_filename = logdev.gsub('-1.log', '')
         | 
| 30 30 | 
             
                      new_logdev = temp_filename + '-1.log'
         | 
| 31 31 | 
             
                    end
         | 
| 32 | 
            -
                     | 
| 32 | 
            +
                    begin
         | 
| 33 | 
            +
                      @logdev = LogDevice.new(new_logdev, shift_size: shift_size)
         | 
| 34 | 
            +
                    rescue StandardError => e
         | 
| 35 | 
            +
                      puts "Stackify Profiler unable to access [" + logdev + "]"
         | 
| 36 | 
            +
                    end
         | 
| 33 37 | 
             
                  end
         | 
| 34 38 | 
             
                end
         | 
| 35 39 | 
             
                require 'stackify_apm/logger/log_device'
         | 
| @@ -20,7 +20,11 @@ module StackifyRubyAPM | |
| 20 20 | 
             
                      temp_filename = logdev.gsub('-1.log', '')
         | 
| 21 21 | 
             
                      new_logdev = temp_filename + '-1.log'
         | 
| 22 22 | 
             
                    end
         | 
| 23 | 
            -
                     | 
| 23 | 
            +
                    begin
         | 
| 24 | 
            +
                      @logdev = LogDevice.new(new_logdev, shift_size: shift_size)
         | 
| 25 | 
            +
                    rescue StandardError => e
         | 
| 26 | 
            +
                      puts "Stackify Profiler unable to access [" + logdev + "]"
         | 
| 27 | 
            +
                    end
         | 
| 24 28 | 
             
                  end
         | 
| 25 29 | 
             
                end
         | 
| 26 30 |  | 
| @@ -26,7 +26,7 @@ module StackifyRubyAPM | |
| 26 26 |  | 
| 27 27 | 
             
                  hash = {
         | 
| 28 28 | 
             
                    PROFILER_VERSION: StackifyRubyAPM::VERSION,
         | 
| 29 | 
            -
                    CATEGORY: 'Ruby',
         | 
| 29 | 
            +
                    CATEGORY: @transaction.context.category || 'Ruby',
         | 
| 30 30 | 
             
                    APPLICATION_PATH: '/',
         | 
| 31 31 | 
             
                    APPLICATION_FILESYSTEM_PATH: @config.root_path,
         | 
| 32 32 | 
             
                    APPLICATION_NAME: @config.application_name.strip,
         | 
| @@ -3,6 +3,7 @@ | |
| 3 3 | 
             
            # Monkey patch for the custom instrumentation any values from config/stackify.json will be loop and will
         | 
| 4 4 | 
             
            # register as a spy.
         | 
| 5 5 | 
             
            #
         | 
| 6 | 
            +
            require 'logger'
         | 
| 6 7 | 
             
            require 'stackify_apm/instrumenter_helper.rb'
         | 
| 7 8 | 
             
            require 'stackify_apm/config'
         | 
| 8 9 | 
             
            require 'json'
         | 
| @@ -10,7 +11,8 @@ require 'json' | |
| 10 11 | 
             
            # rubocop:disable Metrics/PerceivedComplexity
         | 
| 11 12 | 
             
            module StackifyRubyAPM
         | 
| 12 13 | 
             
              # @api private
         | 
| 13 | 
            -
              module Spies
         | 
| 14 | 
            +
              module Spies extend Log
         | 
| 15 | 
            +
             | 
| 14 16 | 
             
                def self.run_custom_instrumentation
         | 
| 15 17 | 
             
                  config = Config.new
         | 
| 16 18 | 
             
                  to_instrument = parse_json_config(config.json_config_file)
         | 
| @@ -27,11 +29,21 @@ module StackifyRubyAPM | |
| 27 29 | 
             
                    tracked_func = custom_spy['trackedFunction']
         | 
| 28 30 | 
             
                    tracked_func_name = defined?(custom_spy['trackedFunctionName']) ? custom_spy['trackedFunctionName'] : ''
         | 
| 29 31 | 
             
                    transaction = defined?(custom_spy['transaction']) ? custom_spy['transaction'] : nil
         | 
| 32 | 
            +
                    file_path = defined?(custom_spy['file_path']) ? custom_spy['file_path'] : nil
         | 
| 30 33 |  | 
| 31 34 | 
             
                    tracked_function_tpl = tracked_func_name.nil? ? '{{ClassName}}.{{MethodName}}' : tracked_func_name
         | 
| 32 35 | 
             
                    tracked_function_name = tracked_function_tpl.sub '{{ClassName}}', current_class
         | 
| 33 36 | 
             
                    tracked_function_name = tracked_function_name.sub '{{MethodName}}', current_method
         | 
| 34 37 |  | 
| 38 | 
            +
                    if !class_exists?(current_class) && !file_path.nil?
         | 
| 39 | 
            +
                      begin
         | 
| 40 | 
            +
                        require file_path
         | 
| 41 | 
            +
                      rescue LoadError => e
         | 
| 42 | 
            +
                        debug "[StackifyRubyAPM] File path doesn't exist."
         | 
| 43 | 
            +
                        debug e.inspect
         | 
| 44 | 
            +
                      end
         | 
| 45 | 
            +
                    end
         | 
| 46 | 
            +
             | 
| 35 47 | 
             
                    # rubocop:disable Style/Next
         | 
| 36 48 | 
             
                    if class_exists?(current_class)
         | 
| 37 49 | 
             
                      mod_constant = Module.const_get(current_class.to_s)
         | 
| @@ -0,0 +1,49 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            # Monkey patch for the delayed_job class for running async tasks.
         | 
| 4 | 
            +
            #
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            module StackifyRubyAPM
         | 
| 7 | 
            +
              # @api private
         | 
| 8 | 
            +
              module Spies
         | 
| 9 | 
            +
                # @api private
         | 
| 10 | 
            +
                class DelayedJobSpy
         | 
| 11 | 
            +
                  def install
         | 
| 12 | 
            +
                    Delayed::Backend::Base.class_eval do
         | 
| 13 | 
            +
                      alias_method 'invoke_job_without_apm', 'invoke_job'
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                      def invoke_job(*args, &block)
         | 
| 16 | 
            +
                        ret = nil
         | 
| 17 | 
            +
                        begin
         | 
| 18 | 
            +
                          name = nil
         | 
| 19 | 
            +
                          if payload_object.is_a?(::Delayed::PerformableMethod)
         | 
| 20 | 
            +
                            object = payload_object.object
         | 
| 21 | 
            +
                            klass = object.is_a?(Class) ? object : object.class
         | 
| 22 | 
            +
                            class_name = klass.name
         | 
| 23 | 
            +
                            separator = payload_object.object.is_a?(Class) ? '.' : '#'
         | 
| 24 | 
            +
                            method_name = payload_object.method_name
         | 
| 25 | 
            +
                            name = "#{class_name}#{separator}#{method_name}"
         | 
| 26 | 
            +
                          else
         | 
| 27 | 
            +
                            name = payload_object.class.name
         | 
| 28 | 
            +
                          end
         | 
| 29 | 
            +
                          ctx = StackifyRubyAPM::Context.new
         | 
| 30 | 
            +
                          ctx.category = 'Delayed::Job'
         | 
| 31 | 
            +
                          transaction = StackifyRubyAPM.transaction name, 'TASK', context: ctx
         | 
| 32 | 
            +
                          ret = invoke_job_without_apm(*args, &block)
         | 
| 33 | 
            +
                        rescue StackifyRubyAPM::InternalError
         | 
| 34 | 
            +
                          raise # Don't report StackifyRubyAPM errors
         | 
| 35 | 
            +
                        rescue StandardError => e
         | 
| 36 | 
            +
                          StackifyRubyAPM.report e
         | 
| 37 | 
            +
                          raise e
         | 
| 38 | 
            +
                        ensure
         | 
| 39 | 
            +
                          transaction.submit()
         | 
| 40 | 
            +
                        end
         | 
| 41 | 
            +
                        ret
         | 
| 42 | 
            +
                      end
         | 
| 43 | 
            +
                    end
         | 
| 44 | 
            +
                  end
         | 
| 45 | 
            +
                end
         | 
| 46 | 
            +
             | 
| 47 | 
            +
                register 'Delayed::Backend::Base', 'delayed/backend/base', DelayedJobSpy.new
         | 
| 48 | 
            +
              end
         | 
| 49 | 
            +
            end
         | 
| @@ -0,0 +1,44 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            # Monkey patch for the sidekiq class for running async tasks.
         | 
| 4 | 
            +
            #
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            module StackifyRubyAPM
         | 
| 7 | 
            +
              # @api private
         | 
| 8 | 
            +
              module Spies
         | 
| 9 | 
            +
                # @api private
         | 
| 10 | 
            +
                class SidekiqClientSpy
         | 
| 11 | 
            +
                  def install
         | 
| 12 | 
            +
                    Sidekiq::Processor.class_eval do
         | 
| 13 | 
            +
                      alias_method 'process_without_apm', 'process'
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                      def process(work, *args, &block)
         | 
| 16 | 
            +
                        ret = nil
         | 
| 17 | 
            +
                        begin
         | 
| 18 | 
            +
                          job = nil
         | 
| 19 | 
            +
                          if defined? work.message
         | 
| 20 | 
            +
                            job = work.message
         | 
| 21 | 
            +
                          else
         | 
| 22 | 
            +
                            job = work.job
         | 
| 23 | 
            +
                          end
         | 
| 24 | 
            +
                          job_hash = JSON.parse job
         | 
| 25 | 
            +
                          name = job_hash["class"]
         | 
| 26 | 
            +
                          transaction = StackifyRubyAPM.transaction name, 'TASK'
         | 
| 27 | 
            +
                          ret = process_without_apm(work, *args, &block)
         | 
| 28 | 
            +
                        rescue StackifyRubyAPM::InternalError
         | 
| 29 | 
            +
                          raise # Don't report StackifyRubyAPM errors
         | 
| 30 | 
            +
                        rescue StandardError => e
         | 
| 31 | 
            +
                          StackifyRubyAPM.report e
         | 
| 32 | 
            +
                          raise e
         | 
| 33 | 
            +
                        ensure
         | 
| 34 | 
            +
                          transaction.submit()
         | 
| 35 | 
            +
                        end
         | 
| 36 | 
            +
                        ret
         | 
| 37 | 
            +
                      end
         | 
| 38 | 
            +
                    end
         | 
| 39 | 
            +
                  end
         | 
| 40 | 
            +
                end
         | 
| 41 | 
            +
             | 
| 42 | 
            +
                register 'Sidekiq::Processor', 'sidekiq/processor', SidekiqClientSpy.new
         | 
| 43 | 
            +
              end
         | 
| 44 | 
            +
            end
         | 
| @@ -1,3 +1,4 @@ | |
| 1 | 
            +
            require 'json'
         | 
| 1 2 | 
             
            require 'stackify_apm/root_info'
         | 
| 2 3 | 
             
            require 'stackify_apm/serializers'
         | 
| 3 4 |  | 
| @@ -12,6 +13,15 @@ module StackifyRubyAPM | |
| 12 13 | 
             
                  @transaction_serializers = Serializers::Transactions.new(config)
         | 
| 13 14 | 
             
                end
         | 
| 14 15 |  | 
| 16 | 
            +
                def get_protobuf_message(transactions)
         | 
| 17 | 
            +
                  protobuf_obj = build_message(transactions)
         | 
| 18 | 
            +
                  StackifyProtoBuf::Traces.encode(protobuf_obj)
         | 
| 19 | 
            +
                end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                def get_json_message(transactions)
         | 
| 22 | 
            +
                  JSON.generate(build_json_message(transactions))
         | 
| 23 | 
            +
                end
         | 
| 24 | 
            +
             | 
| 15 25 | 
             
                # This method will build a group of Stackify::Traces from the protobuf objects.
         | 
| 16 26 | 
             
                # It accept Array of transactions.
         | 
| 17 27 | 
             
                def build_message(transactions = [])
         | 
| @@ -28,6 +38,19 @@ module StackifyRubyAPM | |
| 28 38 | 
             
                  debug "[AgentBaseTransport] build_message() exception: #{e.inspect}"
         | 
| 29 39 | 
             
                end
         | 
| 30 40 |  | 
| 41 | 
            +
                def build_json_message(transactions = [])
         | 
| 42 | 
            +
                  traces = []
         | 
| 43 | 
            +
                  transactions.each do |transaction|
         | 
| 44 | 
            +
                    # convert transaction to json
         | 
| 45 | 
            +
                    json_transaction = @transaction_serializers.build_json(@config, transaction)
         | 
| 46 | 
            +
                    # add to traces array
         | 
| 47 | 
            +
                    traces << json_transaction
         | 
| 48 | 
            +
                  end
         | 
| 49 | 
            +
                  return traces
         | 
| 50 | 
            +
                rescue StandardError => e
         | 
| 51 | 
            +
                  debug "[AgentBaseTransport] build_json_message() exception: #{e.inspect}"
         | 
| 52 | 
            +
                end
         | 
| 53 | 
            +
             | 
| 31 54 | 
             
                def post(_transactions = [])
         | 
| 32 55 | 
             
                  raise NotImplementedError
         | 
| 33 56 | 
             
                end
         | 
| @@ -5,24 +5,32 @@ require 'faraday' | |
| 5 5 | 
             
            require 'ostruct'
         | 
| 6 6 |  | 
| 7 7 | 
             
            module StackifyRubyAPM
         | 
| 8 | 
            -
              # This class will handle the sending of  | 
| 8 | 
            +
              # This class will handle the sending of transaction messages through HTTP.
         | 
| 9 9 | 
             
              # @api private
         | 
| 10 10 | 
             
              class AgentHTTPClient < AgentBaseTransport
         | 
| 11 11 | 
             
                include Log
         | 
| 12 12 |  | 
| 13 | 
            -
                HEADERS = {
         | 
| 14 | 
            -
                  'Content-Type' => 'application/x-protobuf'
         | 
| 15 | 
            -
                }.freeze
         | 
| 16 | 
            -
             | 
| 17 13 | 
             
                def initialize(config)
         | 
| 18 14 | 
             
                  @config = config
         | 
| 19 15 | 
             
                  super(config)
         | 
| 20 16 | 
             
                end
         | 
| 21 17 |  | 
| 18 | 
            +
                def get_protobuf_headers
         | 
| 19 | 
            +
                  {
         | 
| 20 | 
            +
                    'Content-Type' => 'application/x-protobuf'
         | 
| 21 | 
            +
                  }.freeze
         | 
| 22 | 
            +
                end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                def get_json_headers
         | 
| 25 | 
            +
                  {
         | 
| 26 | 
            +
                    'Content-Type' => 'application/json'
         | 
| 27 | 
            +
                  }.freeze
         | 
| 28 | 
            +
                end
         | 
| 29 | 
            +
             | 
| 22 30 | 
             
                # rubocop:disable Metrics/CyclomaticComplexity
         | 
| 23 31 | 
             
                # rubocop:disable Metrics/PerceivedComplexity
         | 
| 24 32 | 
             
                #
         | 
| 25 | 
            -
                # This method will send a  | 
| 33 | 
            +
                # This method will send a transction message to HTTP request.
         | 
| 26 34 | 
             
                # It will accept Array of transactions.
         | 
| 27 35 | 
             
                def post(transactions = [])
         | 
| 28 36 | 
             
                  debug '[AgentHTTPClient] post()' if ENV['STACKIFY_TRANSPORT_LOG_LEVEL'] == '0'
         | 
| @@ -31,16 +39,14 @@ module StackifyRubyAPM | |
| 31 39 | 
             
                  retry_count = 0
         | 
| 32 40 | 
             
                  delay = @config.delay_seconds
         | 
| 33 41 | 
             
                  begin
         | 
| 34 | 
            -
                     | 
| 35 | 
            -
                    message = StackifyProtoBuf::Traces.encode(protobuf_obj)
         | 
| 36 | 
            -
                    # Convert message into binary and send it to http request
         | 
| 42 | 
            +
                    message = get_json_message(transactions)
         | 
| 37 43 | 
             
                    conn = Faraday.new(ssl: { verify: false })
         | 
| 38 44 | 
             
                    response = conn.post do |req|
         | 
| 39 45 | 
             
                      req.url URI(@config.transport_http_endpoint + @config.agent_traces_url)
         | 
| 40 | 
            -
                      req.headers =  | 
| 46 | 
            +
                      req.headers = get_json_headers
         | 
| 41 47 | 
             
                      req.body = message
         | 
| 42 48 | 
             
                    end
         | 
| 43 | 
            -
                    if response. | 
| 49 | 
            +
                    if defined?(response.status) && response.status == 200
         | 
| 44 50 | 
             
                      debug '[AgentHTTPClient] Successfully send message via http request.' if ENV['STACKIFY_TRANSPORT_LOG_LEVEL'] == '0'
         | 
| 45 51 | 
             
                    elsif ENV['STACKIFY_TRANSPORT_LOG_LEVEL'] == '0'
         | 
| 46 52 | 
             
                      debug "[AgentHTTPClient] Failure sending via http request: #{response.inspect}"
         | 
| @@ -4,7 +4,7 @@ require 'net_http_unix' | |
| 4 4 | 
             
            require 'ostruct'
         | 
| 5 5 |  | 
| 6 6 | 
             
            module StackifyRubyAPM
         | 
| 7 | 
            -
              # This class will handle the sending of  | 
| 7 | 
            +
              # This class will handle the sending of transaction messages through unix domain socket.
         | 
| 8 8 | 
             
              # @api private
         | 
| 9 9 | 
             
              class UnixSocketClient < AgentBaseTransport
         | 
| 10 10 | 
             
                include Log
         | 
| @@ -14,10 +14,18 @@ module StackifyRubyAPM | |
| 14 14 | 
             
                  super(config)
         | 
| 15 15 | 
             
                end
         | 
| 16 16 |  | 
| 17 | 
            +
                def get_protobuf_headers
         | 
| 18 | 
            +
                  'application/x-protobuf'
         | 
| 19 | 
            +
                end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                def get_json_headers
         | 
| 22 | 
            +
                  'application/json'
         | 
| 23 | 
            +
                end
         | 
| 24 | 
            +
             | 
| 17 25 | 
             
                # rubocop:disable Metrics/CyclomaticComplexity
         | 
| 18 26 | 
             
                # rubocop:disable Metrics/PerceivedComplexity
         | 
| 19 27 | 
             
                #
         | 
| 20 | 
            -
                # This method will send a  | 
| 28 | 
            +
                # This method will send a transaction message to the unix domain socket.
         | 
| 21 29 | 
             
                # It will accept Array of transactions.
         | 
| 22 30 | 
             
                def post(transactions = [])
         | 
| 23 31 | 
             
                  debug '[UnixSocketClient] post()' if ENV['STACKIFY_TRANSPORT_LOG_LEVEL'] == '0'
         | 
| @@ -27,11 +35,10 @@ module StackifyRubyAPM | |
| 27 35 | 
             
                  delay = @config.delay_seconds
         | 
| 28 36 | 
             
                  begin
         | 
| 29 37 | 
             
                    # Convert message into binary and send it to unix domain socket
         | 
| 30 | 
            -
                     | 
| 31 | 
            -
                    message = StackifyProtoBuf::Traces.encode(protobuf_obj)
         | 
| 38 | 
            +
                    message = get_json_message(transactions)
         | 
| 32 39 | 
             
                    client = NetX::HTTPUnix.new('unix://' + @config.unix_socket_path)
         | 
| 33 40 | 
             
                    req = Net::HTTP::Post.new(@config.agent_traces_url)
         | 
| 34 | 
            -
                    req.set_content_type( | 
| 41 | 
            +
                    req.set_content_type(get_json_headers)
         | 
| 35 42 | 
             
                    req.body = message
         | 
| 36 43 | 
             
                    response = client.request(req)
         | 
| 37 44 | 
             
                    debug "[UnixSocketClient] status_code = #{response.code}" if ENV['STACKIFY_TRANSPORT_LOG_LEVEL'] == '0'
         | 
    
        data/lib/stackify_apm/util.rb
    CHANGED
    
    | @@ -8,15 +8,6 @@ module StackifyRubyAPM | |
| 8 8 | 
             
                  target.to_i * 1_000_000 + target.usec
         | 
| 9 9 | 
             
                end
         | 
| 10 10 |  | 
| 11 | 
            -
                #
         | 
| 12 | 
            -
                # This method will check if there is any rake task is running.
         | 
| 13 | 
            -
                # If rake task is detected we set instrument=false and don't load the spies.
         | 
| 14 | 
            -
                #
         | 
| 15 | 
            -
                def self.apm_disabled_in_rake
         | 
| 16 | 
            -
                  cmd_rake = ($PROGRAM_NAME =~ /rake$/)
         | 
| 17 | 
            -
                  StackifyRubyAPM.agent.config.instrument = false if cmd_rake
         | 
| 18 | 
            -
                end
         | 
| 19 | 
            -
             | 
| 20 11 | 
             
                def self.host_os
         | 
| 21 12 | 
             
                  host_os = RbConfig::CONFIG['host_os']
         | 
| 22 13 | 
             
                  case host_os
         | 
    
        data/lib/stackify_apm/version.rb
    CHANGED
    
    
    
        data/lib/stackify_ruby_apm.rb
    CHANGED
    
    | @@ -35,9 +35,6 @@ require 'stackify_apm/transport/unix_socket_client' | |
| 35 35 | 
             
            require 'stackify_apm/transport/agent_http_client'
         | 
| 36 36 | 
             
            require 'stackify_apm/transport/aws_lambda_logging'
         | 
| 37 37 |  | 
| 38 | 
            -
            require 'google/protobuf'
         | 
| 39 | 
            -
            require 'proto/stackify_trace'
         | 
| 40 | 
            -
             | 
| 41 38 | 
             
            # Checks if the framework using is Rails
         | 
| 42 39 | 
             
            require 'stackify_apm/railtie' if defined?(::Rails::Railtie)
         | 
| 43 40 |  | 
    
        data/stackify-ruby-apm.gemspec
    CHANGED
    
    | @@ -33,20 +33,6 @@ Gem::Specification.new do |spec| | |
| 33 33 | 
             
                spec.add_development_dependency  'bigdecimal'
         | 
| 34 34 | 
             
              end
         | 
| 35 35 |  | 
| 36 | 
            -
              # rubocop
         | 
| 37 | 
            -
              if RUBY_VERSION >= '2.2.0'
         | 
| 38 | 
            -
                spec.add_development_dependency 'rubocop-performance'
         | 
| 39 | 
            -
              end
         | 
| 40 | 
            -
             | 
| 41 | 
            -
              # protobuf
         | 
| 42 | 
            -
              if RUBY_VERSION >= '2.7'
         | 
| 43 | 
            -
                spec.add_development_dependency 'google-protobuf', '= 3.5.0'
         | 
| 44 | 
            -
              elsif RUBY_VERSION > '2.3'
         | 
| 45 | 
            -
                spec.add_development_dependency 'google-protobuf', '>= 3.5.0'
         | 
| 46 | 
            -
              else
         | 
| 47 | 
            -
                spec.add_development_dependency 'google-protobuf', '= 3.5.0'
         | 
| 48 | 
            -
              end
         | 
| 49 | 
            -
             | 
| 50 36 | 
             
              spec.add_development_dependency 'bundler', '~> 1.16'
         | 
| 51 37 | 
             
              spec.add_development_dependency 'rake', '~> 10.0'
         | 
| 52 38 | 
             
              spec.add_development_dependency 'rspec', '~> 3.0'
         | 
| @@ -57,7 +43,6 @@ Gem::Specification.new do |spec| | |
| 57 43 | 
             
              spec.add_development_dependency 'httpclient'
         | 
| 58 44 | 
             
              spec.add_development_dependency 'mongo'
         | 
| 59 45 | 
             
              spec.add_development_dependency 'mysql2'
         | 
| 60 | 
            -
              spec.add_development_dependency 'net_http_unix', '~> 0.2'
         | 
| 61 46 | 
             
              spec.add_development_dependency 'pg', '~> 0.20'
         | 
| 62 47 | 
             
              spec.add_development_dependency 'rack-test'
         | 
| 63 48 | 
             
              spec.add_development_dependency 'rubocop'
         | 
| @@ -69,11 +54,11 @@ Gem::Specification.new do |spec| | |
| 69 54 | 
             
              spec.add_development_dependency 'timecop'
         | 
| 70 55 | 
             
              spec.add_development_dependency 'to_bool'
         | 
| 71 56 | 
             
              spec.add_development_dependency 'webmock'
         | 
| 57 | 
            +
              spec.add_development_dependency 'delayed_job'
         | 
| 72 58 |  | 
| 73 59 | 
             
              spec.add_dependency('concurrent-ruby', '~> 1.0')
         | 
| 74 60 | 
             
              spec.add_dependency('delegate_matcher', '~> 0.4')
         | 
| 75 61 | 
             
              spec.add_dependency('faraday', '~> 0.8')
         | 
| 76 | 
            -
              spec.add_dependency('google-protobuf', '>= 3.5.0', '< 4.0')
         | 
| 77 62 | 
             
              spec.add_dependency('net_http_unix', '~> 0.2')
         | 
| 78 63 | 
             
              spec.add_dependency('rufus-scheduler', '~> 3.0')
         | 
| 79 64 | 
             
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: stackify-ruby-apm
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1. | 
| 4 | 
            +
              version: 1.11.1
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Stackify
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: exe
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2020- | 
| 11 | 
            +
            date: 2020-06-22 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: rails
         | 
| @@ -38,34 +38,6 @@ dependencies: | |
| 38 38 | 
             
                - - ">="
         | 
| 39 39 | 
             
                  - !ruby/object:Gem::Version
         | 
| 40 40 | 
             
                    version: '0'
         | 
| 41 | 
            -
            - !ruby/object:Gem::Dependency
         | 
| 42 | 
            -
              name: rubocop-performance
         | 
| 43 | 
            -
              requirement: !ruby/object:Gem::Requirement
         | 
| 44 | 
            -
                requirements:
         | 
| 45 | 
            -
                - - ">="
         | 
| 46 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 47 | 
            -
                    version: '0'
         | 
| 48 | 
            -
              type: :development
         | 
| 49 | 
            -
              prerelease: false
         | 
| 50 | 
            -
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 51 | 
            -
                requirements:
         | 
| 52 | 
            -
                - - ">="
         | 
| 53 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 54 | 
            -
                    version: '0'
         | 
| 55 | 
            -
            - !ruby/object:Gem::Dependency
         | 
| 56 | 
            -
              name: google-protobuf
         | 
| 57 | 
            -
              requirement: !ruby/object:Gem::Requirement
         | 
| 58 | 
            -
                requirements:
         | 
| 59 | 
            -
                - - ">="
         | 
| 60 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 61 | 
            -
                    version: 3.5.0
         | 
| 62 | 
            -
              type: :development
         | 
| 63 | 
            -
              prerelease: false
         | 
| 64 | 
            -
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 65 | 
            -
                requirements:
         | 
| 66 | 
            -
                - - ">="
         | 
| 67 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 68 | 
            -
                    version: 3.5.0
         | 
| 69 41 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 70 42 | 
             
              name: bundler
         | 
| 71 43 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -206,20 +178,6 @@ dependencies: | |
| 206 178 | 
             
                - - ">="
         | 
| 207 179 | 
             
                  - !ruby/object:Gem::Version
         | 
| 208 180 | 
             
                    version: '0'
         | 
| 209 | 
            -
            - !ruby/object:Gem::Dependency
         | 
| 210 | 
            -
              name: net_http_unix
         | 
| 211 | 
            -
              requirement: !ruby/object:Gem::Requirement
         | 
| 212 | 
            -
                requirements:
         | 
| 213 | 
            -
                - - "~>"
         | 
| 214 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 215 | 
            -
                    version: '0.2'
         | 
| 216 | 
            -
              type: :development
         | 
| 217 | 
            -
              prerelease: false
         | 
| 218 | 
            -
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 219 | 
            -
                requirements:
         | 
| 220 | 
            -
                - - "~>"
         | 
| 221 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 222 | 
            -
                    version: '0.2'
         | 
| 223 181 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 224 182 | 
             
              name: pg
         | 
| 225 183 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -374,6 +332,20 @@ dependencies: | |
| 374 332 | 
             
                - - ">="
         | 
| 375 333 | 
             
                  - !ruby/object:Gem::Version
         | 
| 376 334 | 
             
                    version: '0'
         | 
| 335 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 336 | 
            +
              name: delayed_job
         | 
| 337 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 338 | 
            +
                requirements:
         | 
| 339 | 
            +
                - - ">="
         | 
| 340 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 341 | 
            +
                    version: '0'
         | 
| 342 | 
            +
              type: :development
         | 
| 343 | 
            +
              prerelease: false
         | 
| 344 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 345 | 
            +
                requirements:
         | 
| 346 | 
            +
                - - ">="
         | 
| 347 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 348 | 
            +
                    version: '0'
         | 
| 377 349 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 378 350 | 
             
              name: concurrent-ruby
         | 
| 379 351 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -416,26 +388,6 @@ dependencies: | |
| 416 388 | 
             
                - - "~>"
         | 
| 417 389 | 
             
                  - !ruby/object:Gem::Version
         | 
| 418 390 | 
             
                    version: '0.8'
         | 
| 419 | 
            -
            - !ruby/object:Gem::Dependency
         | 
| 420 | 
            -
              name: google-protobuf
         | 
| 421 | 
            -
              requirement: !ruby/object:Gem::Requirement
         | 
| 422 | 
            -
                requirements:
         | 
| 423 | 
            -
                - - ">="
         | 
| 424 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 425 | 
            -
                    version: 3.5.0
         | 
| 426 | 
            -
                - - "<"
         | 
| 427 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 428 | 
            -
                    version: '4.0'
         | 
| 429 | 
            -
              type: :runtime
         | 
| 430 | 
            -
              prerelease: false
         | 
| 431 | 
            -
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 432 | 
            -
                requirements:
         | 
| 433 | 
            -
                - - ">="
         | 
| 434 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 435 | 
            -
                    version: 3.5.0
         | 
| 436 | 
            -
                - - "<"
         | 
| 437 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 438 | 
            -
                    version: '4.0'
         | 
| 439 391 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 440 392 | 
             
              name: net_http_unix
         | 
| 441 393 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -519,6 +471,7 @@ files: | |
| 519 471 | 
             
            - lib/stackify_apm/spies/curb/easy.rb
         | 
| 520 472 | 
             
            - lib/stackify_apm/spies/curb/multi.rb
         | 
| 521 473 | 
             
            - lib/stackify_apm/spies/custom_instrumenter.rb
         | 
| 474 | 
            +
            - lib/stackify_apm/spies/delayed_job.rb
         | 
| 522 475 | 
             
            - lib/stackify_apm/spies/httparty.rb
         | 
| 523 476 | 
             
            - lib/stackify_apm/spies/httpclient.rb
         | 
| 524 477 | 
             
            - lib/stackify_apm/spies/httprb.rb
         | 
| @@ -526,6 +479,7 @@ files: | |
| 526 479 | 
             
            - lib/stackify_apm/spies/net_http.rb
         | 
| 527 480 | 
             
            - lib/stackify_apm/spies/redis.rb
         | 
| 528 481 | 
             
            - lib/stackify_apm/spies/sequel.rb
         | 
| 482 | 
            +
            - lib/stackify_apm/spies/sidekiq.rb
         | 
| 529 483 | 
             
            - lib/stackify_apm/spies/sinatra.rb
         | 
| 530 484 | 
             
            - lib/stackify_apm/spies/sinatra_activerecord/mysql_adapter.rb
         | 
| 531 485 | 
             
            - lib/stackify_apm/spies/sinatra_activerecord/postgresql_adapter.rb
         |