ddtrace/contrib/pymongo/parse.py
def parse_spec(spec, db=None):
    """ Return a Command that has parsed the relevant detail for the given
        pymongo SON spec.
    """

    # the first element is the command and collection
    items = list(spec.items())
    if not items:
        return None
    name, coll = items[0]
    cmd = Command(name, db, coll)

    if 'ordered' in spec: # in insert and update
        cmd.tags['mongodb.ordered'] = spec['ordered']

    if cmd.name == 'insert':
        if 'documents' in spec:
            cmd.metrics['mongodb.documents'] = len(spec['documents'])

    elif cmd.name == 'update':
        updates = spec.get('updates')
        if updates:
            # FIXME[matt] is there ever more than one here?
            cmd.query = updates[0].get("q")

    elif cmd.name == 'delete':
        dels = spec.get('deletes')
        if dels:
            # FIXME[matt] is there ever more than one here?
            cmd.query = dels[0].get("q")

    return cmd
 Return a Command that has parsed the relevant detail for the given
        pymongo SON spec.
    
Return a Command that has parsed the relevant detail for the given
pymongo SON spec.
Return a Command that has parsed the relevant detail for the given pymongo SON spec .
def parse_spec(spec, db=None):
    items = list(spec.items())
    if not items:
        return None
    name, coll = items[0]
    cmd = Command(name, db, coll)
    if 'ordered' in spec: 
        cmd.tags['mongodb.ordered'] = spec['ordered']
    if cmd.name == 'insert':
        if 'documents' in spec:
            cmd.metrics['mongodb.documents'] = len(spec['documents'])
    elif cmd.name == 'update':
        updates = spec.get('updates')
        if updates:
            cmd.query = updates[0].get("q")
    elif cmd.name == 'delete':
        dels = spec.get('deletes')
        if dels:
            cmd.query = dels[0].get("q")
    return cmd
def parse_spec ( spec , db = None ) : items = list ( spec . items ( ) ) if not items : return None name , coll = items [ 0 ] cmd = Command ( name , db , coll ) if 'ordered' in spec : cmd . tags [ 'mongodb.ordered' ] = spec [ 'ordered' ] if cmd . name == 'insert' : if 'documents' in spec : cmd . metrics [ 'mongodb.documents' ] = len ( spec [ 'documents' ] ) elif cmd . name == 'update' : updates = spec . get ( 'updates' ) if updates : cmd . query = updates [ 0 ] . get ( "q" ) elif cmd . name == 'delete' : dels = spec . get ( 'deletes' ) if dels : cmd . query = dels [ 0 ] . get ( "q" ) return cmd
Return a Command that has parsed the relevant detail for the given
pymongo SON spec.
Return a Command that has parsed the relevant detail for the given pymongo SON spec .
""" Return a Command that has parsed the relevant detail for the given
        pymongo SON spec.
    """ # the first element is the command and collection # in insert and update # FIXME[matt] is there ever more than one here? # FIXME[matt] is there ever more than one here?
spec
db