Glimpse architecture

Overview

We’ll give you a high-level overview of Glimpse concepts, what your app looks like when running glimspe with the default configuration, and we’ll describe how to configure your applications so that multiple Node.js processes can all produce messages viewable in a single Glimpse Client UI.

Default Glimpse configuration

The default configuration for Glimpse will embed a “Glimpse Server” and a “Glimpse Message Store” inside your application’s process space. That is, when you include the following in your app(*).

if (process.env.NODE_ENV !== 'production') {
    require('@glimpse/glimpse').init();
}

You end up with a process that looks something like this:

Glimpse default configuration runs with the Glimpse server inside your Node.js process

Glimpse default configuration runs with the Glimpse server inside your Node.js process

Glimpse concepts

The picture above shows a few key concepts. We’ll define these in more detail below:

The Glimpse Client is the Glimpse UI that displays diagnostic data about your application.

Proxies are instrumentation code that Glimpse injects into common modules used by your application. The proxies produce Glimpse Messages that are sent to the Glimpse Server and subsequently persisted in the Message Store. Sets of Proxies are packaged in an Agent. Glimpse has two agents:

  • a Node Agent for node.js
  • a Browser Agent which contains proxies for common browser modules.

Glimpse Messages contain the critical diagnostic information about your application’s behavior. These are sent from the Proxies to the Glimpse Server, stored in the Glimpse Message Store, and transmitted from the Glimpse Server to the Glimpse Client.

The Glimpse Server is an http server that can receive Glimpse messages for storage and return Glimpse messages to the Glimpse Client for display.

The Message Store is where the Glimpse Server stores Glimpse Messages.

Multiple processes sharing a single Glimpse server

For some users, larger applications are decomposed into a set of smaller independent services. In such cases, it is useful to view all of the http requests in a single client UI. You can configure multiple, independent node processes to use a single Glimpse Server.

To do so, you need to add the following code snippet(*) to one of your node applications:

if (process.env.NODE_ENV !== 'production') {
    require('@glimpse/glimpse').init();
}

Note the server & port that the above process is running on. The process above is hosting the Glimpse Server. For any other processes, you’ll need to tell it how to access the Glimpse Server above, via the following code snippet(*):

var glimpseAgent = require('@glimpse/glimpse-agent-node');
glimpseAgent.agent.init({
    metadataUri: 'http://<server-host-name>:<server-port>/glimpse/metadata'
});

You’ll need to replace <server-host-name> and <server-port> in the snippet above with actual server name and port where your Glimpse Server is running. For example, if you ran the first command on a machine named app-1-host and it is listening on port 3000, then your metadataUri would be 'http://app-1-host:3000/glimpse/metadata'.

When you do this, you’ll have a set of processes that look something like this:

Glimpse can be configured with the Glimpse server running b a different process

Glimpse can be configured with the Glimpse server running in a different process

The Glimpse calculator-micro-services sample shows such a configuration working in a simple example.

(*) Note: all Glimpse initialization code must happen before any require statements. Otherwise, the Glimpse agents may not be able to correctly instrument key APIs.

An experiment by Microsoft