Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(tracer): update warning to better format segment name #1750

Merged
merged 2 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -499,7 +500,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 @@ -953,7 +953,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 @@ -1414,7 +1415,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 @@ -405,7 +405,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