Skip to content

Commit

Permalink
chore(tracer): update warning to better format segment name (#1750)
Browse files Browse the repository at this point in the history
* chore(tracer): update warning in Tracer to better format segment name

* chore: linting
  • Loading branch information
dreamorosi committed Oct 18, 2023
1 parent d20269d commit 9e7458d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
6 changes: 4 additions & 2 deletions packages/tracer/src/Tracer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,8 @@ class Tracer extends Utility implements TracerInterface {
subsegment?.close();
} catch (error) {
console.warn(
`Failed to close or serialize segment, ${subsegment?.name}. We are catching the error but data might be lost.`,
`Failed to close or serialize segment %s. We are catching the error but data might be lost.`,
subsegment?.name,
error
);
}
Expand Down Expand Up @@ -501,7 +502,8 @@ class Tracer extends Utility implements TracerInterface {
subsegment?.close();
} catch (error) {
console.warn(
`Failed to close or serialize segment, ${subsegment?.name}. We are catching the error but data might be lost.`,
`Failed to close or serialize segment %s. We are catching the error but data might be lost.`,
subsegment?.name,
error
);
}
Expand Down
3 changes: 2 additions & 1 deletion packages/tracer/src/middleware/middy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ const captureLambdaHandler = (
handlerSegment.close();
} catch (error) {
console.warn(
`Failed to close or serialize segment, ${handlerSegment.name}. We are catching the error but data might be lost.`,
`Failed to close or serialize segment %s. We are catching the error but data might be lost.`,
handlerSegment.name,
error
);
}
Expand Down
6 changes: 4 additions & 2 deletions packages/tracer/tests/unit/Tracer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1253,7 +1253,8 @@ describe('Class: Tracer', () => {
expect(closeSpy).toHaveBeenCalledTimes(1);
expect(logWarningSpy).toHaveBeenNthCalledWith(
1,
`Failed to close or serialize segment, ${handlerSubsegment.name}. We are catching the error but data might be lost.`,
`Failed to close or serialize segment %s. We are catching the error but data might be lost.`,
handlerSubsegment.name,
new Error('dummy error')
);
});
Expand Down Expand Up @@ -1714,7 +1715,8 @@ describe('Class: Tracer', () => {
expect(closeSpy).toHaveBeenCalledTimes(1);
expect(logWarningSpy).toHaveBeenNthCalledWith(
1,
`Failed to close or serialize segment, ${handlerSubsegment.name}. We are catching the error but data might be lost.`,
`Failed to close or serialize segment %s. We are catching the error but data might be lost.`,
handlerSubsegment.name,
new Error('dummy error')
);
});
Expand Down
3 changes: 2 additions & 1 deletion packages/tracer/tests/unit/middy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,8 @@ describe('Middy middleware', () => {
expect(closeSpy).toHaveBeenCalledTimes(1);
expect(logWarningSpy).toHaveBeenNthCalledWith(
1,
`Failed to close or serialize segment, ${handlerSubsegment.name}. We are catching the error but data might be lost.`,
`Failed to close or serialize segment %s. We are catching the error but data might be lost.`,
handlerSubsegment.name,
new Error('dummy error')
);
// Check that the segments are restored
Expand Down

0 comments on commit 9e7458d

Please sign in to comment.