https://github.com/component/trace
Client-side tracing for performance analysis
https://github.com/component/trace
Last synced: 7 months ago
JSON representation
Client-side tracing for performance analysis
- Host: GitHub
- URL: https://github.com/component/trace
- Owner: component
- Created: 2013-04-19T21:13:08.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2013-06-11T21:19:27.000Z (almost 13 years ago)
- Last Synced: 2025-08-15T04:41:11.561Z (8 months ago)
- Language: JavaScript
- Homepage:
- Size: 96.7 KB
- Stars: 46
- Watchers: 6
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: Readme.md
- Changelog: History.md
Awesome Lists containing this project
README
# trace
Client-side tracing for performance analysis in production.
## Installation
$ component install component/trace
## API
### Cycle(name, id)
Initialize a new Tracer with the given `id`
and `name`. A "cycle" represents N related traces,
these traces may be sequential or concurrent, later
graphed to show you how long the cycle and its components
spent processing.
### Cycle#start(type:String, [date]:Number|Date)
Trace start of `type` with optional `date`.
### Cycle#end(type:String, [date]:Number|Date)
Trace end of `type` with optional `date`.
### .flush()
Return all cycles collected thus far, flushing them for subsequent calls.
This method allows you to report the cycles to the server periodicially,
you'll likely want to also transmit user-agent data along with this.
```js
var cycle = require('trace');
cycle.flush();
```
Yields an array similar to the following with your trace data:
```json
[
{
"id": 1,
"cycle": "upload",
"type": "upload",
"start": 1366405821464
},
{
"id": 1,
"cycle": "upload",
"type": "thumb",
"start": 1366405822465
},
{
"id": 1,
"cycle": "upload",
"type": "thumb",
"end": 1366405822766
},
{
"id": 1,
"cycle": "upload",
"type": "upload",
"end": 1366405823268
}
]
```
## License
MIT