• Stars
    star
    471
  • Rank 93,216 (Top 2 %)
  • Language
    JavaScript
  • License
    Other
  • Created over 9 years ago
  • Updated almost 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Trace is a visualised distributed tracing platform designed for microservices.

Trace logo

Build status npm version Website Slack Status Twitter URL


App | Documentation | Status page | Case study


⚠️ Trace-Nodejs is discontinued ⚠️ The client is not longer being developed and the backend has been shut down.

⚠️ Breaking change

With version 3.x.x we have dropped support for Node v0.10. This means that future releases under this major version might contain code changes that are incompatible with Node.js v0.10 to an extent of crashing your application. Please consider updating to a newer runtime, especially that the maintenance of v0.10 has already ended. See our compatibility table below.

Also, since 3.1.0 we switched to a different API backend for collecting traces which is incompatible with the old one. The old endpoint is still supported, but we would like it to be phased out eventually. Please update your agents to 3.1.0 or newer.

Installation and usage

As Trace uses scoped packages, be sure to use npm version greater than 2.7.0.

npm install --save @risingstack/trace

⚠️

Trace depends on a couple of native addons. We host precompiled binaries of these for Linux and Darwin 64-bit platforms at https://oss.risingstack.com. The installer will attempt to download these dependencies, so it should be allowed through your firewall, or else the download will fail and the installer will fall back to building from source. This also happens if there isn't a precompiled binary for your platform. Note that compiling native addons requires native toolchain.

After you installed Trace as a dependency, you just require it at the beginning of your main file.

var trace = require('@risingstack/trace');

Configuration

You can specify the configuration two ways. Configuration options can be set via environment variables or using a config module. We look for a config module named trace.config.js at your current working directory by default, which can be overridden with the TRACE_CONFIG_PATH environment variable. Having a config module is optional, but some options may be set only with it. In order to use our service, you need to specify an api key and and a service name at minimum. The corresponding environment variables are: TRACE_API_KEY and TRACE_SERVICE_NAME.

An example for how to start your app with environment variables:

node TRACE_SERVICE_NAME=MyApp TRACE_API_KEY=1 index.js

An example with a custom config file using the Trace servers:

node TRACE_CONFIG_PATH=/path/to/my/config.js index.js

or simply

node index.js

if it's in the current working directory.

/**
* Your Trace configuration file at /path/to/my/config.js
*/

module.exports = {
  serviceName: 'your-awesome-app',
  apiKey: 'KEEP_ME_SECRET',
  ignoreHeaders: {
    'user-agent': ['007']
  },
  ignorePaths: [
    '/healthcheck'
  ],
  ignoreStatusCodes: [
    401,
    404
  ],
  ignoreOutgoingHosts: [
    'google.com'
  ],
  disableInstrumentations: [
    'mongodb'
  ],
  proxy: 'http://168.63.76.32:3128',
  keepQueryParams: true
}

For the complete set of configuration options, visit the docs.

⚠️

If you are running your app with NODE_ENV=test, Trace won't start

API

trace.report(name, object)

This method can be use to report additional data to the Trace servers which later on helps with debugging.

trace.report('name', {
  userId: 10
});

Throws an error if first parameter is not a String. Throws an error if second parameter is not an Object.

trace.reportError(name, error)

This method can be used to send errors to the Trace servers.

trace.reportError('mysql_error', new Error('connection refused'));

Throws an error if first parameter is not a String.

trace.getTransactionId()

This method can be use to get the current transactionId. It can be useful if you want to integrate trace with your current logging systems.

var transactionId = trace.getTransactionId();

trace.recordMetric(name, value)

This method can be used to record custom metrics values.

trace.recordMetric('user/imageUpload', 6)

The name must have the following format: <Category>/<Name> The value must be a number.

trace.incrementMetric(name, [amount])

This method can be used to record increment-only type of metrics.

trace.incrementMetric('user/signup')

The name must have the following format: <Category>/<Name>

trace.stop([cb])

This method gracefully stops trace.

trace.stop(cb)

Accepts a node-style callback to be called when trace stopped.

Note: There is no way to restart trace after calling this method. You should end your process after calling this method.

Troubleshooting

Debug logs

If you have problems using Trace, e.g it doesn't seem to report anything you can turn on logging. We use the lightweight debug. If you are not familiar with it yet, please read its documentation to learn how it works.

Quickstart

To turn it only for Trace start your app with the DEBUG environment variable set to risingstack/trace*.

DEBUG=risingstack/trace* node my_app.js

Configure logging

To make it possible to filter severities and components in Trace we use subnamespaces. The namespace will start with trace/risingstack then a : then a mandatory severity specifier,

  • error,
  • warn or
  • info.

Then come zero or more namespaces led by colons. The namespaces are hierarchically organized according to components inside of Trace.

Currently these namespaces (and their subnamespaces) are used:

  • config
  • instrumentation
  • agent
  • agent:tracer
  • agent:metrics
  • agent:profiler
  • agent:security
  • api

As they can have subnamespaces, always append an * to them to get all messages.

Examples:

  • get all error messages: DEBUG=risingstack/trace:error*

  • get all messages from agents: DEBUG=risingstack/trace:*:agent*

  • get all error messages and all messages from agents: DEBUG=risingstack/trace:error*,risingstack/trace:*:agent*

Compatibility with Node versions

  • node v0.12
  • node v4
  • node v5
  • node v6
  • node v7

Migrating from previous versions

Versions below 2.x

The trace.config.js file changed, and has the following format:

module.exports = {
  serviceName: 'your-awesome-app',
  apiKey: 'KEEP_ME_SECRET'
}

Also, from 2.x you can specify these values using only environment variables: TRACE_SERVICE_NAME and TRACE_API_KEY.

Custom reporters are no longer supported in trace 2.x*

Versions below 3.x

We dropped support for Node v0.10. Update your runtime to a more recent version to continue using Trace.

More Repositories

1

react-easy-state

Simple React state management. Made with ❤️ and ES6 Proxies.
JavaScript
2,559
star
2

graffiti

⚠️ DEVELOPMENT DISCONTINUED - Node.js GraphQL ORM
JavaScript
1,009
star
3

node-style-guide

A mostly reasonable approach to JavaScript - how we write Node.js at RisingStack
992
star
4

graphql-server

Example GraphQL server with Mongoose (MongoDB) and Node.js
JavaScript
846
star
5

risingstack-bootcamp

This is the Node.js Bootcamp we ask new recruits at RisingStack to finish in their first weeks. It helps to get the basics right, and prepare you to work on enterprise projects.
JavaScript
703
star
6

multi-process-nodejs-example

JavaScript
516
star
7

protect

Proactively protect your Node.js web services
JavaScript
401
star
8

graffiti-mongoose

⚠️ DEVELOPMENT DISCONTINUED - Mongoose (MongoDB) adapter for graffiti (Node.js GraphQL ORM)
JavaScript
382
star
9

node-typescript-starter

TypeScript
351
star
10

react-way-getting-started

The React Way: Getting Started
JavaScript
343
star
11

example-prometheus-nodejs

Prometheus monitoring example with Node.js
JavaScript
332
star
12

nodehero-authentication

JavaScript
231
star
13

react-way-immutable-flux

React.js way with ES6, Immutable.js and Flux
JavaScript
224
star
14

kubernetes-graceful-shutdown-example

Example app for graceful start and stop with Kubernetes and Node.js
JavaScript
167
star
15

kubernetes-nodejs-example

Node.js example application with Kubernetes and CircleCI config
JavaScript
149
star
16

opentracing-auto

Out of the box distributed tracing for Node.js applications with OpenTracing.
JavaScript
133
star
17

http2-push-example

HTTP/2 Push example
JavaScript
129
star
18

event-sourcing-example

Event Sourcing Example repo for the Node.js at Scale blog series
JavaScript
87
star
19

node-with-rust

JavaScript
87
star
20

cqrs-example

CQRS: Command Query Responsibility Segregation - Node.js at Scale
JavaScript
83
star
21

koa-prerender

KOA middleware for prerendering javascript-rendered pages on the fly for SEO
JavaScript
77
star
22

react-baby-steps

Zero to Redux through Flux (with Rx) in baby steps
JavaScript
67
star
23

jaeger-node

Out of the box distributed tracing for Node.js applications.
JavaScript
67
star
24

mysql-large-data-handling

Code for the blogpost about handling large amount of data in Node
JavaScript
60
star
25

graffiti-todo

Example Relay TodoMVC application using graffiti-mongoose
JavaScript
58
star
26

example-http-timings

Example HTTP Timings in Node.js
JavaScript
50
star
27

example-kubernetes-nodejs

Introduction to Kubernetes with Node.js
JavaScript
50
star
28

training-microservices

Node.js Microservices training
49
star
29

docker-node

Dockerfiles for running Node.js
JavaScript
45
star
30

writing-testable-apis-the-basics

Writing testable HTTP APIs - the basics
JavaScript
43
star
31

anchor

Turns Kubernetes resources into a Helm chart
JavaScript
38
star
32

nodehero-testing

JavaScript
37
star
33

pact-example

This is an example of using pact-js with node.
JavaScript
34
star
34

Swiftify-iOS

Run Node.js code with Browserify on iOS
Swift
28
star
35

colorblinder

An example React-Native game for the series "Learning React-Native as a React developer: a definitive guide".
JavaScript
28
star
36

webinar-kubernetes-api-gateway

Microservices​ ​with​ ​Node.js​ ​and​ ​Kubernetes​
JavaScript
26
star
37

training-microservices-v3

Microservices training
JavaScript
19
star
38

opentracing-infrastructure-graph

Infrastructure visualisation via OpenTracing instrumentation
JavaScript
16
star
39

debug-node-docker

Code of the "How to debug a Node app in a Docker container" post on https://blog.risingstack.com
JavaScript
14
star
40

docker-codeship-project

JavaScript
13
star
41

opentracing-metrics-tracer

Exports cross-process metrics via OpenTracing to Prometheus.
JavaScript
13
star
42

nodejs-at-scale-handling-async

Article examples to handle async for the Node.js at Scale series.
JavaScript
12
star
43

thorken

Redis based JWT session for Node.js with the power of Thor
JavaScript
11
star
44

trace-go

Trace is a visualised stack trace platform designed for microservices.
Go
11
star
45

react-training

JavaScript
8
star
46

golang-tutorial-for-nodejs-developers-getting-started

This is the reference implematition for the "Golang Tutorial for Node.js Developers, Part I.: Getting started" blogpost at https://blog.risingstack.com/golang-tutorial-for-nodejs-developers-getting-started/
Go
8
star
47

post-stripe

Blog post about Stripe and Webshops: https://blog.risingstack.com/stripe-payments-integration-tutorial-javascript/
JavaScript
8
star
48

nrs

nsr - npm registry switcher
JavaScript
7
star
49

training-microservices-v2

Microservices training
JavaScript
7
star
50

post-stripe-api

API for Blog post about Stripe and Webshops: https://blog.risingstack.com/stripe-payments-integration-tutorial-javascript/
JavaScript
7
star
51

kubernetes-training

Shell
6
star
52

rising-url

Extends require('url').format() with parameters and easier inputs
JavaScript
6
star
53

auth0-ts-vue-example

Example repository for setting up Auth0 for Vue apps with TypeScript
TypeScript
6
star
54

cache

Stale / Expire Cache Implementation
JavaScript
6
star
55

rate-limiter

Rolling rate limiter
JavaScript
6
star
56

your-first-browserify-module

JavaScript
5
star
57

nuxt3-rendering-modes

Rendering modes showcase for nuxt 3
Vue
5
star
58

easy-state-hook-examples

Notes for a blogpost, nothing to see here (yet).
HTML
5
star
59

learnyougo

Go
5
star
60

surviving-web-security

Showcase for some of the Node.js / Web Security Best Practices
JavaScript
4
star
61

kubernetes-prometheus-nodejs

Monitoring with prometheus example
JavaScript
4
star
62

node-community-convention-training

JavaScript
3
star
63

endava_node

JavaScript
3
star
64

last-release-git-tag

GitHub Plugin for semantic-release
JavaScript
3
star
65

node-basics-skeleton

JavaScript
3
star
66

aha-news

TypeScript
3
star
67

oneshot-contest

JavaScript
3
star
68

shapeblinder

Fun demo project for the 2020 Dart and Flutter crash course series
Dart
3
star
69

profiler

JavaScript
3
star
70

expense_tracker

Expense tracker app
JavaScript
2
star
71

react-hooks-meetup

JavaScript
2
star
72

ncc-training

node community convention training
JavaScript
2
star
73

docker-node-base

JavaScript
1
star
74

find-port

Open port finder with Promise interface.
JavaScript
1
star
75

distributed-loadtests-jmeter

HCL
1
star
76

bc-node-example

JavaScript
1
star
77

node-hero-webinar-demo-app-authentication

1
star
78

almandite-user-service

Reference implementation of a user authentication service in GOlang!
Go
1
star
79

jsconfbp-2019-graphql

JavaScript
1
star
80

hwsw-adatbazis_muveletek

JavaScript
1
star
81

trace-cli

CLI for Trace by RisingStack: deployhook
JavaScript
1
star
82

silver-giggle

JavaScript
1
star
83

hwsw-react

JavaScript
1
star
84

demo-api

Demo Node API for testing your frontend's HTTP capabilities.
JavaScript
1
star
85

nuxt3-caching-with-auth

Demonstrate SWR and ISR rendering modes usage with auth
Vue
1
star