express-trace

Express route/middleware tracer & profiler

  • 所有者: rauchg/express-trace
  • 平台:
  • 許可證:
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

express-trace

Express tracer and middleware profiler.

Installation

 $ npm install express-trace

NOTE: supports express >= 2.3.5

Example

Suppose we have the following express app with a few routes that can satisfy a url with the form GET /user/NAME, and some middlware

app.use(express.favicon());
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(express.cookieParser());
app.use(express.session({ secret: 'foo' }));
app.use(express.static(__dirname));

app.get('/user/:name', ensureUsername('tj'), function(req, res, next){
  res.send('loaded tj');
});

app.get('/user/:name', function(req, res, next){
  setTimeout(next, 1000);
});

app.get('/user/:name', function(req, res, next){
  setTimeout(next, 200);
});

app.get('/user/tobi', function(req, res, next){
  res.send('loaded tobi');
});

all we need to do before we listen(), is require() express-trace and apply it to the app. This essentially wraps all of the middleware and routes with functions used for reporting.

require('express-trace')(app);

stderr for GET /user/tobi:

  GET /user/tobi
  middleware / anonymous 1ms
  middleware / favicon 0ms
  middleware / bodyParser 0ms
  middleware / methodOverride 0ms
  middleware / cookieParser 0ms
  middleware / session 1ms
  middleware / static 0ms
  middleware / router
    app.get(/user/:name) 0ms
      middleware ensureUsername 73ms
    app.get(/user/:name) 1000ms
    app.get(/user/:name) 200ms
    app.get(/user/tobi) 
  responded to GET /user/tobi in 1279ms with 200 "OK"

License

(The MIT License)

Copyright (c) 2011 TJ Holowaychuk <tj@vision-media.ca>

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

主要指標

概覽
名稱與所有者rauchg/express-trace
主編程語言JavaScript
編程語言JavaScript (語言數: 1)
平台
許可證
所有者活动
創建於2012-01-18 23:00:46
推送於2015-11-20 09:42:52
最后一次提交2012-01-18 15:04:49
發布數2
最新版本名稱0.0.2 (發布於 )
第一版名稱0.0.1 (發布於 2011-05-19 19:05:22)
用户参与
星數22
關注者數2
派生數9
提交數20
已啟用問題?
問題數0
打開的問題數0
拉請求數0
打開的拉請求數0
關閉的拉請求數1
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?