From 1e2e11ee3b00b85395b6d259825d1bf3fbecf7f0 Mon Sep 17 00:00:00 2001 From: Diego Sampaio Date: Fri, 18 Oct 2024 18:40:37 -0300 Subject: [PATCH] add statusCode for APIs --- apps/meteor/app/api/server/api.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/apps/meteor/app/api/server/api.ts b/apps/meteor/app/api/server/api.ts index 25de5a6eb2a6..7bb7f5af28ba 100644 --- a/apps/meteor/app/api/server/api.ts +++ b/apps/meteor/app/api/server/api.ts @@ -660,9 +660,13 @@ export class APIClass extends Restivus { if (span) { this.response.setHeader('X-Trace-Id', span.spanContext().traceId); } - return ( - (await DDP._CurrentInvocation.withValue(invocation as any, async () => originalAction.apply(this))) || API.v1.success() - ); + + const result = + (await DDP._CurrentInvocation.withValue(invocation as any, async () => originalAction.apply(this))) || API.v1.success(); + + span?.setAttribute('status', result.statusCode); + + return result; }, );