Created
February 18, 2021 12:39
-
-
Save jchamb/7192569e6257e0dca041de35996f6591 to your computer and use it in GitHub Desktop.
Wrap feathers service methods with DD traces
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const ddTrace = require('dd-trace'); | |
module.exports = function (app) { | |
if (process.env.LOCAL) return; | |
const tracer = ddTrace.init({ | |
tags: ['app:fx-' + process.env.NODE_ENV], | |
env: process.env.NODE_ENV, | |
logInjection: true | |
}); | |
app.mixins.push((service, path) => { | |
Object.keys(service.methods).forEach(method => { | |
if (service[method]) service[method] = tracer.wrap(`feathers`, tracer.wrap(`service.${ path }`, service[method])); | |
}); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment