Messages

Warning

This site documents Glimpse 2.0.0. It is a work in progress, and still has a long way to go.

For Glimpse v1 documentation, please visit getglimpse.com/Docs.

This document outlines the standard message formats that Glimpse uses to transport and store data.

Tip

Messages are documented using JSON Schema. For the uninitiated, there’s a great open source JSON Schema book.

Tip

Messages can be loosely validated with online tooling. To author your own schema, be sure to check out the online generator.

Logging

Write

Type: log-write

Schema: (Link)

Note

The pattern property should be a JavaScript compatible Regular Expression representation of log messages that leverage string interpolation. The purpose of this property is allow Glimpse clients to treat interpolated values specially, as demonstrated on JSFiddle.

Regular Expressions were chosen since they are nearly universal and can represent any interpolation format. (%s, {0}, {1:d}, {foo}, $(bar), etc.)

MongoDB

Insert

Type: data-mongodb-insert

Schema: (Link)

Read

Reads tend to be more complex than writes because of cursors.

This annotated time line shows the approach we’ll take to measure duration, for now.

                   + <--+ Connection Opened
                   |
                   |
              +--> | <--+ Command Issued
              |    |
Duration NOT  |    |
Measured +--> |    |
by Glimpse    |    |
(for now)     |    |
              +--> | <--+ Cursor Returned (cursor not yet opened).
                   |
                   | <--+
                   |    |
                   |    |
                   |    | <--+ Interact w/ Cursor (e.g., set projection, limit, sort-order,...)
                   |    |
                   |    |
                   | <--+
                   |
              +--> | <--+ First "data read" operation on cursor (cursor will be opened).
              |    |
 Duration     |    |
Measured +--> |    |
by Glimpse    |    |
(for now)     |    |
              +--> | <--+ Result returned
                   |
                   |
              +--> | <--+ Subsequent "data read" operations on cursor
              |    |
Duration NOT  |    |
Measured +--> |    |
by Glimpse    |    |
(for now)     |    |
              +--> | <--+ Result Returned
                   |
                   | <--+ Cursor Closed
                   |
                   |
                   + <--+ Connection Closed
Instrumented Collection Operations
  • count()
  • findOne() - In Glimpse for Node.js, messages for findOne() will have an operation field with a value of “next”. This is because the findOne() implementation ultimately calls Cursor’s next() method.
Instrumented Cursor Operations
  • toArray() - time measured by Glimpse is the time to return all of the results to the client.
  • forEach() - time measured by Glimpse is the time to return the first result. Only the first call to forEach() will have a Glimpse message associated with it.
  • next() - Same behavior as forEach().
  • each() - Same behavior as forEach().
  • nextObject() - Same behavior as forEach().

Type: data-mongodb-read

Schema: (Link)

Note

The options may need to be cobbled together based on these possible calls on the cursor itself.

Update

Type: data-mongodb-update

Schema: (Link)

Delete

Type: data-mongodb-delete

Schema: (Link)

Undocumented Methods

The MongoDB Collection Driver API has lots of methods. The above schemas only cover a subset of them. The following methods are yet to be covered:

  • aggregate
  • bulkWrite
  • createIndex
  • createIndexes
  • distinct
  • drop
  • dropAllIndexes
  • dropIndex
  • dropIndexes
  • ensureIndex
  • findAndModify
  • findAndRemove
  • findOneAndReplace
  • geoHaystackSearch
  • geoNear
  • group
  • indexes
  • indexExists
  • indexInformation
  • initializeOrderedBulkOp
  • initializeUnorderedBulkOp
  • isCapped
  • listIndexes
  • mapReduce
  • options
  • parallelCollectionScan
  • reIndex
  • rename
  • save
  • stats
  • update

Web

Request

Type: web-request

Schema: (Link)

Response

Type: web-response

Schema: (Link)