Skip to content

Commit

Permalink
ensure nest js attached error to the correct span
Browse files Browse the repository at this point in the history
  • Loading branch information
Vadman97 committed Apr 17, 2024
1 parent bcb17ae commit 72775a6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
8 changes: 7 additions & 1 deletion sdk/highlight-nest/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,13 @@ export class HighlightInterceptor
const fn = api.context.bind(spanCtx, () =>
next.handle().pipe(
catchError((err) => {
NodeH.consumeError(err)
NodeH.consumeError(
err,
undefined,
undefined,
{},
{ span: requestSpan },
)
return throwError(() => err)
}),
finalize(() => {
Expand Down
3 changes: 2 additions & 1 deletion sdk/highlight-node/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,9 @@ export class Highlight {
secureSessionId: string | undefined,
requestId: string | undefined,
metadata?: Attributes,
options?: { span: OtelSpan },
) {
let span = api.trace.getActiveSpan()
let span = options?.span ?? api.trace.getActiveSpan()
if (!span) {
span = this.tracer.startSpan('highlight.error')
}
Expand Down
3 changes: 3 additions & 0 deletions sdk/highlight-node/src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export interface HighlightInterface {
secureSessionId?: string,
requestId?: string,
metadata?: Attributes,
options?: { span: OtelSpan },
) => void
recordMetric: (
secureSessionId: string,
Expand Down Expand Up @@ -95,13 +96,15 @@ export const H: HighlightInterface = {
secureSessionId?: string,
requestId?: string,
metadata?: Attributes,
options?: { span: OtelSpan },
) => {
try {
highlight_obj.consumeCustomError(
error,
secureSessionId,
requestId,
metadata,
options,
)
} catch (e) {
console.warn('highlight-node consumeError error: ', e)
Expand Down

0 comments on commit 72775a6

Please sign in to comment.