Cat client for Node.js.
Last updated a year ago by stdrickforce .
Original npm · Tarball · package.json
$ cnpm install @dianping-cat/client 
SYNC missed versions from official npm registry.

Cat Client for Node.js

nodecat supports node v8+.




  • Update example codes


As everybody knows that node.js is an event-driven programming language. It's hard for us to trace messages.

Transactions can be intersected, makes it impossible to know which transaction is the parent of another one.

It caused problems, so we fallback the default mode to atomic, which means all messages will be sent immediately after it has been completed.

As the message tree is useful in some cases, we have introduced a brand new Thread Mode in this version.

In this mode, the first transaction will be the root transaction, all the following transactions and events will become its child nodes. Instead of being sent after themselves have been completed, the entire message tree will be sent after the root transaction (their parent) has been completed.

Here is the example usage.

var cat = require('@dp-cat/client')

    appkey: 'nodecat'

cat = new cat.Cat(true)

let a = cat.newTransaction("Context", "A")
let b = cat.newTransaction("Context", "B")
let c = cat.newTransaction("Context", "C")

setTimeout(function() {
}, 1000)

setTimeout(function() {
}, 1500)

setTimeout(function() {
    console.log("a complete")
}, 2000)


The nodecat required libcatclient.so to be installed in LD_LIBRARY_PATH.

Please refer to ccat installation for further information.


via npm

npm i @dp-cat/client


Some preparations needs to be done before initializing ccat.

Then you can initialize nodecat with the following codes:

var cat = require('@dp-cat/client')

    appkey: 'appkey'

Only English characters (a-z, A-Z), numbers (0-9), underscore (_) and dash (-) are allowed in appkey.



let t = cat.newTransaction('foo', 'bar')
setTimeout(() => t.complete(), 3000)

Transaction apis

We offered a series of APIs to modify the transaction.

  • addData
  • setStatus
  • complete

Here is an exapmle:

let t = cat.newTransaction('foo', 'bar')
t.addData("key", "val")
setTimeout(() => t.complete(), 3000)

You can call addData several times, the added data will be connected by &.



Log an event.

// Log a event with success status and empty data.
cat.logEvent("Event", "E1")

// The 3rd parameter (status) is optional, default is "0".
// It can be any of string value.
// The event will be treated as "problem" unless the given status == cat.STATUS.SUCCESS ("0")
// which will be recorded in our problem report.
cat.logEvent("Event", "E2", cat.STATUS.FAIL)
cat.logEvent("Event", "E3", "failed")

// The 4th parameter (data) is optional, default is "".
// It can be any of string value.
cat.logEvent("Event", "E4", "failed", "some debug info")

// The 4th parameter (data) can also be an object
// In this case, the object will be dumped into json.
cat.logEvent("Event", "E5", "failed", {a: 1, b: 2})


Log an error with error stack traces.

Error is a special event, with type = Exception and name is given by the 1st parameter.

And the error stack traces will be added to data, which is always useful in debugging.

cat.logError('ErrorInTransaction', new Error())

Current Tags

  • 0.0.1                                ...           latest (a year ago)

1 Versions

  • 0.0.1                                ...           a year ago
Maintainers (1)
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 1
Last Month 0
Dependencies (7)
Dependents (0)

Copyright 2014 - 2016 © taobao.org |