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
Server.prototype.checkThreshold = function(metric, template, data) { | |
var t = metric.threshold; | |
if (t) { | |
var last = this.lastValues[metric._id] | |
, v = parseFloat(data[template.primary]); | |
if (!isNaN(v)) | |
this.lastValues[metric._id] = v; | |
if (last >= t && t > v) |
-
Hi, I'm Visnu. I'm a co-founder of Fortnight Labs, a data consultancy. This is a product we've been working on mostly for ourselves and as a future platform.
-
- monitaur is monitoring itself
- this is real time
- start focused with the server metrics vertical, but
- we just added custom metrics (# people using the site)
-
sign up as a new user
- show threshold alert
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
# throw this bad boy at the end of your application.rb. | |
# rails will then treat these exceptions like it does | |
# ActiveRecord::RecordNotFound and others by showing you a nice backtrace | |
# on localhost and the static error pages in production. | |
ActionDispatch::ShowExceptions.rescue_responses.update({ | |
'Mongoid::Errors::DocumentNotFound' => :not_found, | |
'BSON::InvalidObjectId' => :not_found, | |
'SecurityError' => :unauthorized |
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 "spec/spec_helper" | |
class Coffee | |
include Mongoid::Document | |
field :beany | |
references_many :beans #, :validate => false works | |
end |
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
class Mongoid::Relations::Metadata | |
# @return [ true, false ] False unless explictly set to true. | |
def validate? | |
self[:validate] | |
end | |
end |
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 'spec/spec_helper' | |
class Coffee | |
include Mongoid::Document | |
references_and_referenced_in_many :beans #, :inverse_of => nil | |
end | |
class Bean | |
include Mongoid::Document |

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 'benchmark' | |
require './spec/spec_helper' | |
p = Person.create | |
Benchmark.bm do |x| | |
x.report("new") { 10_000.times do Person.new end } | |
x.report("reload") { 10_000.times do p.reload end } | |
x.report("find") { 10_000.times do Person.find(p.id) end } |
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 "spec_helper" | |
class ValInheritanceParent | |
include Mongoid::Document | |
field :parent_value | |
embeds_many :val_inheritance_embed | |
references_many :val_inheritance_ref |