express-generate-statsdkey
v1.0.0
Published
An express middleware to generate statsdkey for web request paths
Downloads
4
Readme
express-generate-statsdkey (Derived from Seneca-Web-StatsD)
Adds a custom key (statsdKey) to Express request object with the current HTTP path. This key is used by express-statsd as key for the logged stats. For a HTTP POST request to /api/hello/world the key would look like hostname.env.http.post.api.hello.world.
The module takes as parameter an optional function that can modify the HTTP path.
Usage
In your express app:
var generateStatsdKey = require("express-generate-statsdkey").generateStatsdKey;
then use as middleware:
var express = require("express");
var app = express();
app.use(generateStatsdKey());
// Optionally if you apply to a specific routeset you can set the prefix manually:
app.use("/api/hello/world", generateStatsdKey("api.hello.world"));