['find', 'findOne', 'update', 'remove', 'upsert', 'insert'].forEach(function(func) {
  var originalFunc = Meteor.Collection.prototype[func];
  Meteor.Collection.prototype[func] = function(selector) {
    var payload = {
      coll: this._name,
      func: func,
    };

    if(func == 'insert') {
      NotificationManager.methodTrackEvent('db', payload);  
    } else {
      payload.selector = selector;
      NotificationManager.methodTrackEvent('db', payload);
    }

    var ret = originalFunc.apply(this, arguments);
    NotificationManager.methodTrackEvent('dbend');

    if(func == 'find' && !ret.constructor.prototype._ampOk) {
      hijackCursor(ret.constructor.prototype);
    }

    return ret;
  };
});

function hijackCursor(cursorProto) {
  ['forEach', 'map', 'rewind', 'fetch', 'count'].forEach(function(type) {
    var originalFunc = cursorProto[type];
    cursorProto[type] = function() {
      var cursorDescription = this._cursorDescription;
      var payload = {
        coll: cursorDescription.collectionName,
        selector: cursorDescription.selector,
        func: type
      };

      NotificationManager.methodTrackEvent('db', payload);
      var ret = originalFunc.apply(this, arguments);
      NotificationManager.methodTrackEvent('dbend');

      return ret;
    };
  });

  cursorProto._ampOk = true;
}
@@ -1,8 +1,63 @@
+var mongoConnectionProto = getMongoConnectionProto();%0A%0A
 %5B'find',
@@ -106,16 +106,46 @@
 'insert'
+, '_ensureIndex', '_dropIndex'
 %5D.forEac
@@ -188,35 +188,28 @@
 c = 
-Meteor.Coll
+mongoConn
 ection
-.p
+P
 roto
-type
 %5Bfun
@@ -218,35 +218,28 @@
 ;%0A  
-Meteor.Coll
+mongoConn
 ection
-.p
+P
 roto
-type
 %5Bfun
@@ -252,16 +252,26 @@
 unction(
+collName, 
 selector
@@ -310,15 +310,13 @@
 ll: 
-this._n
+collN
 ame,
@@ -379,75 +379,217 @@
     
-NotificationManager.methodTrackEvent('db', payload);  %0A    %7D else %7B
+//add nothing more to the payload  %0A    %7D else if(func == '_ensureIndex' %7C%7C func == '_dropIndex') %7B%0A      //add index%0A      payload.index = selector;%0A    %7D else %7B%0A      //all the other functions have selectors
 %0A   
@@ -618,24 +618,33 @@
 selector;%0A  
+  %7D%0A    %0A
     Notifica
@@ -687,22 +687,16 @@
 ayload);
-%0A    %7D
 %0A%0A    va
@@ -1552,8 +1552,289 @@
  true;%0A%7D
+%0A%0Afunction getMongoConnectionProto() %7B%0A  var coll = new Meteor.Collection('__apm_dummy_collection__');%0A  //we need wait until db get connected with meteor, .findOne() does that%0A  coll.findOne();%0A  return MongoInternals.defaultRemoteCollectionDriver().mongo.constructor.prototype;%0A%7D

add better db support with directly hijacking MongoConnection