putting finishing touches on a Catalog service which uses Mongoid in place of an RDBMS & ActiveRecord. Operations Technology uses the Central Logger in production for all back end services and order processing. Mongoid is used on Operations Technology’s Supplier and Decorator Service for tracking supplier information/blanks inventory and printer/vendor data respectively. Thursday, January 20, 2011 Catalog manages products, styles clothing, and other items we sell. The primary functions of the supplier service are to: • store general supplier information • store blanks inventory data (e.g. availability and pricing) • support automated blanks ordering • support ordering logistics Decorator Service This service maintains all relevant data to describe decorator's (aka printer/vendor). • Vendor's details • Capacity • Supply inventory • Capabilities
Great Easy to Add New Fields Easy to Install and Deploy Lightweight Development Thursday, January 20, 2011 1. Good way to introduce developers and the company to Mongo 1. not-mission critical. Logs are teed to file as backup 2. model is tinker-friendly 2. Capped collections 1. emulate rolling logs 2. Never get larger than their configured size 3. natural ordering 4. fast, can handle large amount of audit data 3. Easy to add new fields 4. Easy to install and deploy
Railtie Captures Useful Metadata Thursday, January 20, 2011 1. Subclasses the Buffered Logger in Rails in order to tee logs to a mongo database 2. Its a gem 1. Works with Rails 2.3.8 to 3.0 2. Rail-Tie (replaces the buffered logger during rails boot) 3. Works with Heroku by using separate config 4. database.yml 5. central_logger.yml 3. default captures metadata you’re probably interested in 1. fields (log message, request_time, params, application, controller, elapsed execution time)
the Size of Your Capped Collection Thursday, January 20, 2011 1. gem install 2. Update ApplicationController 1. uses around_filter to audit all logging that occurs in an action 3. config file 1. database.yml - if using RDBMS 2. mongoid.yml - for ODM 3. central_logger.yml 4. Do some work to figure out how large your capped collection needs to be. 1. How many days of log data do you want? 2. count number of apps, current size of logs divided by days (assuming current load is normal) and multiply by number of machines for each app and the number of days you need 3. May want index for tail functionality 1. index uses gt to do this 2. link to tail article
console - look at type of Rails.logger 2. Go to an action you want to log, such as a listing page that extends ActionController 3. mongo console 1. use system_log (or whatever database you specified 2. show collections 3. db.development_log.count() 4. Falls back to Buffered Logger if logging isn’t working.
1. Replica set support - 1. in case your logs are extra important 2. Mongo Auth 1. Mongo recommends no auth, and its just basic 2. should use inside trusted network or over vpn (secure at other network layer)
in the call stack Thursday, January 20, 2011 1. Beware of buried BSON unserializable data types in your log statements 1. Will add this feature 2. Exceptions will usually have central_logger in the stack trace because of the around filter
Across Servers Grep Tail -f Functionality Thursday, January 20, 2011 1. Central Log Viewer 1. Want to see flattened log messages inside a document rooted at the action 2. Need to see log messages orchestrated across multiple services 3. Grep 4. Tail -f while making request
2011 rails controller uses eval (oh no)! no ODM or ORM installed, just jason returned to the client Handlebars - Templating DSL based on Mustache, but runs on client Coffeescript - concise language that eliminates complexity and ceremony of JS
Thursday, January 20, 2011 1. Currently just a rails app piggybacking off the central_logger 2. Change the config file to point to your central logger 3. Add indexes