dd-trace
Advanced tools
Comparing version 0.2.0 to 0.2.1-beta.0
@@ -245,3 +245,3 @@ <h1 id="home">Datadog JavaScript Tracer API</h1> | ||
name: 'dd-trace', | ||
level: 'debug' | ||
level: 'trace' | ||
}) | ||
@@ -248,0 +248,0 @@ |
@@ -1,1 +0,1 @@ | ||
module.exports = '0.2.0' | ||
module.exports = '0.2.1' |
{ | ||
"name": "dd-trace", | ||
"version": "0.2.0", | ||
"version": "0.2.1-beta.0", | ||
"description": "Datadog APM tracing client for JavaScript (experimental)", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -45,2 +45,4 @@ 'use strict' | ||
req._datadog_trace_patched = true | ||
return next() | ||
@@ -88,2 +90,4 @@ }) | ||
function createWrapRouterMethod (tracer) { | ||
const context = tracer._context | ||
return function wrapRouterMethod (original) { | ||
@@ -99,2 +103,6 @@ return function methodWithTrace (fn) { | ||
layer.handle_request = (req, res, next) => { | ||
if (req._datadog_trace_patched) { | ||
next = context.bind(next) | ||
} | ||
return handle.call(layer, req, res, next) | ||
@@ -101,0 +109,0 @@ } |
@@ -243,2 +243,63 @@ 'use strict' | ||
it('should bind the next callback to the current context', done => { | ||
const app = express() | ||
app.use((req, res, next) => { | ||
context.run(() => { | ||
context.set('foo', 'bar') | ||
next() | ||
}) | ||
}) | ||
app.get('/user', (req, res) => { | ||
res.status(200).send(context.get('foo')) | ||
}) | ||
getPort().then(port => { | ||
appListener = app.listen(port, 'localhost', () => { | ||
axios.get(`http://localhost:${port}/user`) | ||
.then(res => { | ||
expect(res.status).to.equal(200) | ||
expect(res.data).to.be.empty | ||
done() | ||
}) | ||
.catch(done) | ||
}) | ||
}) | ||
}) | ||
it('should only include paths for routes that matched', done => { | ||
const app = express() | ||
const router = express.Router() | ||
router.use('/baz', (req, res, next) => next()) | ||
router.get('/user/:id', (req, res) => { | ||
res.status(200).send() | ||
}) | ||
router.use('/qux', (req, res, next) => next()) | ||
app.use('/foo', (req, res, next) => next()) | ||
app.use('/app', router) | ||
app.use('/bar', (req, res, next) => next()) | ||
getPort().then(port => { | ||
agent | ||
.use(traces => { | ||
expect(traces[0][0]).to.have.property('resource', '/app/user/:id') | ||
}) | ||
.then(done) | ||
.catch(done) | ||
appListener = app.listen(port, 'localhost', () => { | ||
axios.get(`http://localhost:${port}/app/user/123`) | ||
.then(res => { | ||
expect(res.status).to.equal(200) | ||
expect(res.data).to.be.empty | ||
done() | ||
}) | ||
.catch(done) | ||
}) | ||
}) | ||
}) | ||
it('should extract its parent span from the headers', done => { | ||
@@ -245,0 +306,0 @@ const app = express() |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
202442
5723
11