Giter VIP home page Giter VIP logo

node-connect-datadog's Introduction

DEPRECATED

This library is deprecated and has been replaced with Datadog APM which generates the same metrics but also has many other features and integrations. We highly recommend upgrading to APM as this library will receive no further updates.

node-connect-datadog

Datadog middleware for Connect JS / Express

Usage

Add middleware immediately before your router.

app.use(require("connect-datadog")({}));
app.use(app.router);

Options

All options are optional.

  • dogstatsd node-dogstatsd client. default = new require("node-dogstatsd").StatsD()
  • stat string name for the stat. default = "node.express.router"
  • tags array of tags to be added to the histogram. default = []
  • path boolean include path tag. default = false
  • base_url boolean include baseUrl. default = false
  • method boolean include http method tag. default = false
  • protocol boolean include protocol tag. default = false
  • response_code boolean include http response codes. default = false
  • delim string char to replace pipe char with in the route default = '-'

License

View the LICENSE file.

node-connect-datadog's People

Contributors

jedi4ever avatar kcroaker avatar lewisvail3 avatar respectthecode avatar rochdev avatar rue-mchang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-connect-datadog's Issues

Doesn't support arrays of paths since Express 4.16.4, "Pipe character bug fix"

Since Express 4.x it has been valid syntax to use an array for a path, ie app.get(['/','/login'], ...). Since the pipe character bug fix was added in 0.0.7 this results in the following bug when the connect-datadog middleware gets called:

TypeError: str.replace is not a function
    at replacePipeChar (/usr/src/app/node_modules/connect-datadog/lib/index.js:27:21)
    at ServerResponse.res.end (/usr/src/app/node_modules/connect-datadog/lib/index.js:46:39)
    at ServerResponse.send (/usr/src/app/node_modules/express/lib/response.js:221:10)

It fails in the replacePipeChar function because it assumes that req.route.path will be a string, but it is actually an an array.

Metrics are not captured for requests routed using app.use(path, handlers)

When routing requests using app.use(path, handlers), the req.route object is not set and so metrics are not reported for those requests. Below is an example route that you may want metrics for which currently doesn't work:

var proxy = require('express-http-proxy');
var app = require('express')();
 
app.use('/proxy', proxy('www.google.com'));

TypeError: str.replace is not a function

According to https://expressjs.com/en/4x/api.html#app.get the path parameter can be a string, regexp or array containing any of the above. It would appear that if the path is an array it will cause the following unhandled exception:

TypeError: str.replace is not a function
    at replacePipeChar (/home/stieg/Devel/airfordable/af-beta/node_modules/connect-datadog/lib/index.js:27:21)
    at getRoute (/home/stieg/Devel/airfordable/af-beta/node_modules/connect-datadog/lib/index.js:33:20)
    at ServerResponse.res.end (/home/stieg/Devel/airfordable/af-beta/node_modules/connect-datadog/lib/index.js:48:18)
    at ServerResponse.res.end (/home/stieg/Devel/airfordable/af-beta/node_modules/express-winston/index.js:316:17)
    at Gzip.onStreamEnd (/home/stieg/Devel/airfordable/af-beta/node_modules/compression/index.js:212:14)
    at Gzip.emit (events.js:214:15)
    at Gzip.EventEmitter.emit (domain.js:476:20)
    at endReadableNT (_stream_readable.js:1178:12)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)

What is the alternative to this?

In the Readme you state that:

[DEPRECATED] Datadog middleware for Connect JS / Express

Yet you do not talk about the newer alternatives. What is the current alternative to datadog-connect?

Misleading documentation about statsd client

Docs says the statsd lib is node-dogstatsd but I couldn't find the options I was looking for so I had a look in the code https://github.com/DataDog/node-connect-datadog/blob/master/lib/index.js#L4 and realized the doc was misleading: the statsd client is hot-shots.

Moreover typing definitions seems wrong:

image

I get the typescript error: Type 'StatsD' is missing the following properties from type 'StatsDClient': incrementBy, decrementBy

because the expected type comes from node-dogstatsd: import { StatsDClient } from 'node-dogstatsd'

localhost is hardocded

Hi !
I've notived that localhost is hardcoded
let datadog = options.dogstatsd || new hotShots.StatsD("localhost", 8125);

I can use the options.dogstatsd to create myself a new object with correct value but it may be easier for developpers to config host and port directly.

I've just pushed a PR which does it.
This is backward-compatible.

Ability to create route specific tags

With connect-datadog 0.0.9 it is not possible to add route specific tags. I would like to do so to associate routes to a SLO domain with a tag: domain:my-domain.

I don't see an elegant way to do so. One way would be to adjust this line to read tags that could have been added in middlewares defined after datadog middleware:

let statTags = [...tags, ...req.ddTags]

Would you merge such a PR?

Add support for request-received middleware

The request-received middleware at https://github.com/cabinjs/request-received exposes a Symbol.for property, which this package could conditionally consume if interested (as opposed to just generating a new Date().

e.g.

req._startTime = new Date();
would change from req._startTime = new Date(); to req._startTime = req[Symbol.for('request-received.startTime')] ? req[Symbol.for('request-received.startTime')] : new Date()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.