Aspecto uses OpenTelemetry to collect data.
Install our Node.js library using npm
:
$ npm install @aspecto/opentelemetry
In the root folder create an aspecto.json
file with content {"token" : "-- token goes here --"}
.
Alternatively, you can provide it through ASPECTO_AUTH env param OR aspectoAuth
init option.
Obtain your token here.
Add this call at the top of your app entry point, before any other import:
require('@aspecto/opentelemetry')();// ... other imports ...
You can pass a configuration object when initializing Aspecto, like this for example:
require('@aspecto/opentelemetry')({packageName: 'my-package',env: 'production',samplingRatio: 0.1});
Available configurations are (all optional):
Option | Type | Description | Default |
| string | Set environment name manually |
|
| UUID | Set Aspecto token from code instead of using | |
| string | Service name | "name" in |
| string | Service version | "version" is |
| boolean | When set to true, enable live flows | false |
| boolean | When set to true, enable isolated mode for live flows | false |
| number | Specify port for live flows | random |
| logger interface | Logger to be used in this tracing library. common use for debugging | |
| URL | Send all traces to additional Zipkin server for debug | |
| number | Rate of traces to be sampled. Between 0 to 1. Uses parent-based sampling. | 1 |
Live Flows captures all payloads and traces in your local environment and automatically extracts the topology & dependencies between endpoints.
Activate it using {local:true}
, like this:
require('@aspecto/opentelemetry')({ local: true });
Live flows works in two modes:
connected
isolated
This is the default mode. It allows you to capture flows from all the microservices that you're running locally (both on the host env and docker) withlocal
mode enabled. Once the process starts it will output the following link:
=====================================================================================================================================| || 🕵️♀️See the live tracing stream at https://app.aspecto.io/app/live-flows/sessions?instanceId=14243e72-14dc-4255-87af-ef846b247578 || |=====================================================================================================================================
Click on the link to open the Live Flow, to see traces from all the microservices that are running on your environment that have local mode enabled. The link is valid for a limited period of time (a couple of days, but it may change in the future). If you don't see a trace from some microservice (or none of them), click the newly-generated link.
In this mode, you can only see flows from one microservice. Also, in this case, all the data is being sent directly to the browser. To activate isolated mode use isolate
option like so:
require('@aspecto/opentelemetry')({ local: true, isolate: true });
In isolated mode, the message in the console will look like this (with port
parameter):
===============================================================================================| || 🕵️♀️ See the live tracing stream at https://app.aspecto.io/app/live-flows/sessions?port=59778 || |===============================================================================================
Note: To make sure the port used is consistent between restarts, use the liveExporterPort
configuration option.