Skip to content

Instantly share code, notes, and snippets.

@jchamb
Created February 18, 2021 12:39
Show Gist options
  • Save jchamb/7192569e6257e0dca041de35996f6591 to your computer and use it in GitHub Desktop.
Save jchamb/7192569e6257e0dca041de35996f6591 to your computer and use it in GitHub Desktop.
Wrap feathers service methods with DD traces
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