express-generate-statsdkey

1.0.0 • Public • Published

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"));

Readme

Keywords

none

Package Sidebar

Install

npm i express-generate-statsdkey

Weekly Downloads

2

Version

1.0.0

License

MIT

Unpacked Size

3.8 kB

Total Files

5

Last publish

Collaborators

  • goeman