class ElasticAPM::CentralConfig

def handle_success(resp)

rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
def handle_success(resp)
  if (etag = resp.headers['Etag'])
    @etag = etag
  end
  if resp.status == 304
    debug 'Received 304 Not Modified'
  else
    if resp.body && !resp.body.empty?
      update = JSON.parse(resp.body.to_s)
      assign(update)
    end
    if update&.any?
      info 'Updated config from Kibana'
      debug 'Modified: %s', update.inspect
      debug 'Modified original options: %s', @modified_options.inspect
    end
  end
  schedule_next_fetch(resp)
  true
rescue Exception => e
  error 'Failed to apply remote config, %s', e.inspect
  debug { e.backtrace.join('\n') }
end