Skip to content

Commit

Permalink
* Error hook now expects options for handling early unexpected errors
Browse files Browse the repository at this point in the history
* Updated dependencies and bumped version to 2.1.3
  • Loading branch information
dekelev committed Oct 13, 2018
1 parent c308332 commit ba64158
Show file tree
Hide file tree
Showing 4 changed files with 217 additions and 344 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ module.exports = {
error: {
all: [
...
opentracingError(),
opentracingError(config.opentracing.options),
]
},
};
Expand Down
11 changes: 8 additions & 3 deletions hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,19 @@ const opentracingEnd = (options = {}) => {
};
};

const opentracingError = () => {
const opentracingError = (options = {}) => {
return async context => {
if (context.service.remote)
return context;

const { params } = context;
const { span } = params;
const { code, message, stack } = context.error;
const { params } = context;
let { span } = params;

if (!span) {
opentracingBegin(options)(context);
span = params.span;
}

span.setTag(opentracing.Tags.SAMPLING_PRIORITY, 1);
span.setTag(opentracing.Tags.ERROR, true);
Expand Down
Loading

0 comments on commit ba64158

Please sign in to comment.