Skip to content

Commit

Permalink
PR comment fixes
Browse files Browse the repository at this point in the history
- Simplify tests
- Fix typos

Signed-off-by: nkomonen-amazon <[email protected]>
  • Loading branch information
nkomonen-amazon committed Nov 15, 2024
1 parent 7e89891 commit 123e897
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 22 deletions.
2 changes: 1 addition & 1 deletion docs/telemetry.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ function failsDependingOnInput(num: number) {

### Solution

On class methods use the `@withTelemetryContext()` decorator add context to the execution. Depending on the args set, it provides features like emitting the result, or adding it's context to errors.
On class methods, use the `@withTelemetryContext()` decorator to add context to the execution. Depending on the args set, it provides features like emitting the result, or adding it's context to errors.

> NOTE: Decorators are currently only supported for methods and not functions
Expand Down
39 changes: 18 additions & 21 deletions packages/core/src/test/shared/telemetry/spans.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -642,37 +642,34 @@ describe('TelemetryTracer', function () {
assert.throws(
() => inst.throwsError(),
(e) => {
if (!(e instanceof ToolkitError)) {
return false
}
const id = getErrorId(e)
const message = e.message
const cause = e.cause
return id === 'TestThrows' && message === 'ctx: throwsError' && cause === arbitraryError
return (
e instanceof ToolkitError &&
getErrorId(e) === 'TestThrows' &&
e.message === 'ctx: throwsError' &&
e.cause === arbitraryError
)
}
)
assert.throws(
() => inst.throwsErrorButNoClass(),
(e) => {
if (!(e instanceof ToolkitError)) {
return false
}
const id = getErrorId(e)
const message = e.message
const cause = e.cause
return id === 'Error' && message === 'ctx: throwsError' && cause === arbitraryError
return (
e instanceof ToolkitError &&
getErrorId(e) === 'Error' &&
e.message === 'ctx: throwsError' &&
e.cause === arbitraryError
)
}
)
await assert.rejects(
() => inst.throwsAsyncError(),
(e) => {
if (!(e instanceof ToolkitError)) {
return false
}
const id = getErrorId(e)
const message = e.message
const cause = e.cause
return id === 'Error' && message === 'ctx: throwsError' && cause === arbitraryError
return (
e instanceof ToolkitError &&
getErrorId(e) === 'Error' &&
e.message === 'ctx: throwsError' &&
e.cause === arbitraryError
)
}
)
})
Expand Down

0 comments on commit 123e897

Please sign in to comment.