Skip to content

Commit

Permalink
Fix TS example for recording exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
Grunet authored Jan 10, 2025
1 parent bd801c6 commit e5e89f2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions content/en/docs/languages/js/instrumentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -1085,7 +1085,9 @@ import opentelemetry, { SpanStatusCode } from '@opentelemetry/api';
try {
doWork();
} catch (ex) {
span.recordException(ex);
if (ex instanceof Error) {
span.recordException(ex);
}
span.setStatus({ code: SpanStatusCode.ERROR });
}
```
Expand All @@ -1100,7 +1102,9 @@ const opentelemetry = require('@opentelemetry/api');
try {
doWork();
} catch (ex) {
span.recordException(ex);
if (ex instanceof Error) {
span.recordException(ex);
}
span.setStatus({ code: opentelemetry.SpanStatusCode.ERROR });
}
```
Expand Down

0 comments on commit e5e89f2

Please sign in to comment.