Created
July 13, 2016 14:42
-
-
Save munshkr/94925d4a848e72788967ddef72e01cc9 to your computer and use it in GitHub Desktop.
NewRelic Sequel test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'sequel' | |
require 'newrelic_rpm' | |
# use NewRelic on DB | |
Sequel::Database.extension(:newrelic_instrumentation) | |
# connect to an in-memory database | |
DB = Sequel.sqlite | |
DB.logger = Logger.new(STDOUT) | |
# create an items table | |
DB.create_table :items do | |
primary_key :id | |
String :name | |
Float :price | |
end | |
# create a dataset from the items table | |
items = DB[:items] | |
# populate the table | |
items.insert(:name => 'abc', :price => rand * 100) | |
items.insert(:name => 'def', :price => rand * 100) | |
items.insert(:name => 'ghi', :price => rand * 100) | |
DB.log_yield("test sql") { "hi!" } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment