This article describes how to import the data from your Ruby applications, using Treasure Data’s Ruby SDK.
Basic knowledge of Ruby, Gems, and Bundler.
Basic knowledge of Treasure Data.
Ruby 1.9 or higher (for local testing).
Install ‘td’ Gem
td (‘T’reasure ‘D’ata) gem to your
Install the gem locally via bundler.
Modify Your App
The ‘td’ gem comes with a built-in library for recording in-app events. Insert code, as shown in the following example, to record events from your app. Further details regarding the event logger API can be found on GitHub.
YOUR_API_KEY should be your actual apikey string. Retrieve your API key.
Your event-logging code should be placed near its corresponding event-generating code.
When using the
td gem, the posted records are buffered in the memory locally at first, and the data is uploaded every 5 minutes. Because a dedicated thread uploads the data into the cloud, it doesn’t affect your application’s response time.
The local buffer also has a size limit. If the local data exceeds this limit, the records are uploaded immediately.
Confirming Data Import
The data gets uploaded every 5 minutes. You can confirm the data import from TD Console or CLI.
From TD Console
To confirm that your data has been uploaded successfully, check your dataset from the web browser.
td tables command if you have a CLI client.