Skip to content

Commit

Permalink
feat: add dropped spans data to end span
Browse files Browse the repository at this point in the history
  • Loading branch information
sagivoululumigo committed Jul 14, 2024
1 parent 4eb01b5 commit 343675e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ export class SpansContainer {
}
}

static getDroppedSpansReasons(): { [reason: string]: number } {
return this.droppedSpansReasons;
}

static getSpans(): BasicSpan[] {
return Object.values(this.spans);
}
Expand Down
4 changes: 2 additions & 2 deletions src/reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ export function getPrioritizedSpans(spans: any[], maxSendBytes: number): any[] {
false,
spansDropped
);

// TODO: update the end span with the new recorded drops
}

return Object.values(spansToSend);
Expand Down Expand Up @@ -223,8 +225,6 @@ export const forgeAndScrubRequestBody = (
logger.debug(`Trimmed spans due to size`);
}

// TODO: Add dropped spans details to the lambda end span (find it from the spans array)

logger.debug(`Filtered [${beforeLength - spans.length}] spans out`);
logger.debug(`Filtering and scrubbing, Took: [${new Date().getTime() - start}ms]`);
return spans.length > 0 ? JSON.stringify(spans) : undefined;
Expand Down
1 change: 1 addition & 0 deletions src/spans/awsSpan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ export const getEndFunctionSpan = (functionSpan, handlerReturnValue) => {
event,
envs,
totalSpans,
droppedSpansReasons: SpansContainer.getDroppedSpansReasons(),
});
logger.debug('End span created', newSpan);
return newSpan;
Expand Down

0 comments on commit 343675e

Please sign in to comment.