<commit_before># dtrace-express

A library that implements dtrace for express. 

It also includes a D script to output info in chrome tracing format to view response times visually.

### install 
```
% npm install express -S
% npm install express-tracer -S 
% npm install dtrace-express -S
```

### usage

```
var express = require('express');
var expresstracer = require('express-tracer');
var dte = require('dtrace-express');

var app = express();
expresstracer(app);

// Add a middleware that fires at the start of a request.
app.use(dte.start);

// Add a route to show request traces.
app.get('/', function(req, res, next){
  res.trace('some.event', 'some event data');
  res.send('Hello world!');
  next();
});

// Add an after request processing middleware that runs trace.
app.use(dte.finish);


// Configure tracer.
app.instrument(dte.instrument);

app.listen(3000);
console.log('Express started on port 3000');ar dte = require('dtrace-express');
```

### example

```
% node examples/index.js
```

In a seperate console as root run 
```
# dtrace -s ./examples/chome-out.d > out.trc
```
Then open `out.trc` in the tracing tool embedded in chrome `chrome://tracing`
<commit_msg>Image of chrome tracing output<commit_after># dtrace-express

A library that implements dtrace for express. 

It also includes a D script to output info in chrome tracing format to view response times visually.

### install 
```
% npm install express -S
% npm install express-tracer -S 
% npm install dtrace-express -S
```

### usage

```
var express = require('express');
var expresstracer = require('express-tracer');
var dte = require('dtrace-express');

var app = express();
expresstracer(app);

// Add a middleware that fires at the start of a request.
app.use(dte.start);

// Add a route to show request traces.
app.get('/', function(req, res, next){
  res.trace('some.event', 'some event data');
  res.send('Hello world!');
  next();
});

// Add an after request processing middleware that runs trace.
app.use(dte.finish);


// Configure tracer.
app.instrument(dte.instrument);

app.listen(3000);
console.log('Express started on port 3000');ar dte = require('dtrace-express');
```

### example

```
% node examples/index.js
```

In a seperate console as root run 
```
# dtrace -s ./examples/chome-out.d > out.trc
```
Then open `out.trc` in the tracing tool embedded in chrome `chrome://tracing`

![](https://raw.githubusercontent.com/No9/dtrace-express/1764197e0309831fd99a1283108033ed1663b5b3/examples/tracing.png)

{'fraction_non_alphanumeric': 0.14473684210526316, 'fraction_numerical': 0.019537480063795853, 'mean_word_length': 4.2489539748953975, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4636287', 'n_tokens_mistral': 868, 'n_tokens_neox': 794, 'n_words': 265}