Closed serenitygrant closed 7 years ago
api.tasks.addMiddleware({ name: 'NewRelic Task Middleware', global: true, priority: 1, preProcessor: (next) => { let worker = this.worker newrelic.createBackgroundTransaction(worker.job.class) next() }, postProcessor: (next) => { newrelic.endTransaction() next() } })
Running this causes the following error:
newrelic.createBackgroundTransaction(worker.job.class) ^ TypeError: Cannot read property 'job' of undefined
However, changing preProcessor: (next) => to preProcessor: function(next) provides this with the correct context and actionhero starts without issue.
preProcessor: (next) =>
preProcessor: function(next)
this
Awesome. Please send in a pull request with this change!
@evantahler Done! https://github.com/actionhero/ah-newrelic-plugin/pull/7
Running this causes the following error:
However, changing
preProcessor: (next) =>
topreProcessor: function(next)
providesthis
with the correct context and actionhero starts without issue.