# US 11,119,891 B2 · Providing additional stack trace information for time-based sampling in asynchronous execution environments

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 11,119,891 B2
- Document ID: US11119891B2
- Status: Granted
- Kind: B2
- Application number: 16/740,169
- Filed: 2020-01-10
- Published: 2020-05-14
- Granted: 2021-09-14
- Earliest claimed: 2017-07-17
- Assignees: Sap SE
- Applicants: Sap SE
- Inventors: Ralf Schmelter; Rene Schuenemann; Axel Siebenborn
- Web page: https://patentgrep.com/patent/US11119891B2

## CPC

- G06F 11/3636: {by tracing the execution of the program}
- G06F 9/547: {Remote procedure calls [RPC]; Web services}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

The present disclosure describes methods, systems, and computer program products for providing additional stack trace information for time-based sampling (TBS) in asynchronous execution environments. One computer-implemented method includes determining whether time-based sampling is activated to capture a time-based sampling data during execution of a JavaScript function; in response to determining that the time-based sampling is activated to capture the time-based sampling data, determining whether a callback stack trace is active; in response to determining that the callback stack trace is active, loading the callback stack trace; retrieving a current stack trace of the JavaScript function; and saving the loaded callback stack trace and the current stack trace of the JavaScript function as the time-based sampling data.

## Claims

### Claim 1

A computer-implemented method, comprising:
determining whether time-based sampling is activated to capture a time-based sampling data during execution of a JavaScript function; and
in response to determining that the time-based sampling is activated:
determining whether a callback stack trace is active;
in response to determining that the callback stack trace is active:
loading an active callback stack trace; and
providing the active callback stack trace and a current stack trace of the JavaScript function as the time-based sampling data; and
in response to determining that the callback stack trace is not active:
skipping loading the active callback stack trace; and
providing the current stack trace of the JavaScript function as the time-based sampling data.

### Claim 2 (depends on 1)

The computer-implemented method of claim 1, wherein the JavaScript function comprises an asynchronous function execute in a Node.js system.

### Claim 3 (depends on 1)

The computer-implemented method of claim 1, comprising:
in response to determining that the time-based sampling is not activated:
determining whether a new callback is registered during the execution of the JavaScript function; and
in response to determining that the new callback is registered during the execution of the JavaScript function, saving the current stack trace as the callback stack trace.

### Claim 4 (depends on 3)

The computer-implemented method of claim 3, wherein saving the current stack trace as the callback stack trace comprises attaching the current stack trace to previously saved callback stack trace.

### Claim 5 (depends on 1)

The computer-implemented method of claim 1, comprising:
in response to determining that the time-based sampling is not activated:
determining whether a new callback is registered during the execution of the JavaScript function; and
in response to determining that the new callback is not registered during the execution of the JavaScript function:
determining whether a registered callback is called;
in response to determining that the registered callback is called by an asynchronous JavaScript function, determining whether the callback stack trace of the registered callback is available; and
in response to determining that the callback stack trace of the registered callback is available, setting the callback stack trace as active by associating the callback stack trace with the asynchronous JavaScript function.

### Claim 6 (depends on 1)

The computer-implemented method of claim 1, comprising:
in response to determining that the time-based sampling is not activated:
determining whether a new callback is registered during the execution of the JavaScript function; and
in response to determining that the new callback is not registered during the execution of the JavaScript function:
determining whether a registered callback is called;
in response to determining that the registered callback is not called by an asynchronous JavaScript function:
determining whether a registered callback is ended;
in response to determining that the registered callback is ended, determining whether the callback stack trace is active; and
in response to determining that the callback stack trace is active, discarding saved stack trace of the registered callback that is ended.

### Claim 7

A non-transitory, computer-readable medium storing one or more instructions executable by a computer system to perform operations comprising:
determining whether time-based sampling is activated to capture a time-based sampling data during execution of a JavaScript function; and
in response to determining that the time-based sampling is activated:
determining whether a callback stack trace is active;
in response to determining that the callback stack trace is active:
loading an active the callback stack trace; and
providing the active callback stack trace and a current stack trace of the JavaScript function as the time-based sampling data; and
in response to determining that the callback stack trace is not active:
skipping loading the active callback stack trace; and
providing the current stack trace of the JavaScript function as the time-based sampling data.

### Claim 8 (depends on 7)

The computer-readable medium of claim 7, wherein the JavaScript function comprises an asynchronous function execute in a Node.js system.

### Claim 9 (depends on 7)

The computer-readable medium of claim 7, wherein the operations comprise:
in response to determining that the time-based sampling is not activated:
determining whether a new callback is registered during the execution of the JavaScript function; and
in response to determining that the new callback is registered during the execution of the JavaScript function, saving the current stack trace as the callback stack trace.

### Claim 10 (depends on 9)

The computer-readable medium of claim 9, wherein saving the current stack trace as the callback stack trace comprises attaching the current stack trace to previously saved callback stack trace.

### Claim 11 (depends on 7)

The computer-readable medium of claim 7, wherein the operations comprise:
in response to determining that the time-based sampling is not activated:
determining whether a new callback is registered during the execution of the JavaScript function; and
in response to determining that the new callback is not registered during the execution of the JavaScript function:
determining whether a registered callback is called;
in response to determining that the registered callback is called by an asynchronous JavaScript function, determining whether the callback stack trace of the registered callback is available; and
in response to determining that the callback stack trace of the registered callback is available, setting the callback stack trace as active by associating the callback stack trace with the asynchronous JavaScript function.

### Claim 12 (depends on 7)

The computer-readable medium of claim 7, wherein the operations comprise:
in response to determining that the time-based sampling is not activated:
determining whether a new callback is registered during the execution of the JavaScript function; and
in response to determining that the new callback is not registered during the execution of the JavaScript function:
determining whether a registered callback is called;
in response to determining that the registered callback is not called by an asynchronous JavaScript function:
determining whether a registered callback is ended;
in response to determining that the registered callback is ended, determining whether the callback stack trace is active; and
in response to determining that the callback stack trace is active, discarding saved stack trace of the registered callback that is ended.

### Claim 13

A computer-implemented system, comprising:
a computer memory; and
a hardware processor interoperably coupled with the computer memory and configured to perform operations comprising:
determining whether time-based sampling is activated to capture a time-based sampling data during execution of a JavaScript function; and
in response to determining that the time-based sampling is activated:
determining whether a callback stack trace is active;
in response to determining that the callback stack trace is active:
loading an active callback stack trace; and
providing the active callback stack trace and a current stack trace of the JavaScript function as the time-based sampling data; and
in response to determining that the callback stack trace is not active:
skipping loading the active callback stack trace; and
providing the current stack trace of the JavaScript function as the time-based sampling data.

### Claim 14 (depends on 13)

The computer-implemented system of claim 13, wherein the JavaScript function comprises an asynchronous function execute in a Node.js system.

### Claim 15 (depends on 13)

The computer-implemented system of claim 13, wherein the operations comprise:
in response to determining that the time-based sampling is not activated:
determining whether a new callback is registered during the execution of the JavaScript function; and
in response to determining that the new callback is registered during the execution of the JavaScript function, saving the current stack trace as the callback stack trace.

### Claim 16 (depends on 13)

The computer-implemented system of claim 13, wherein the operations comprise:
in response to determining that the time-based sampling is not activated:
determining whether a new callback is registered during the execution of the JavaScript function; and
in response to determining that the new callback is not registered during the execution of the JavaScript function:
determining whether a registered callback is called;
in response to determining that the registered callback is called by an asynchronous JavaScript function, determining whether the callback stack trace of the registered callback is available; and
in response to determining that the callback stack trace of the registered callback is available, setting the callback stack trace as active by associating the callback stack trace with the asynchronous JavaScript function.

### Claim 17 (depends on 13)

The computer-implemented system of claim 13, wherein the operations comprise:
in response to determining that the time-based sampling is not activated:
determining whether a new callback is registered during the execution of the JavaScript function; and
in response to determining that the new callback is not registered during the execution of the JavaScript function:
determining whether a registered callback is called;
in response to determining that the registered callback is not called by an asynchronous JavaScript function:
determining whether a registered callback is ended;
in response to determining that the registered callback is ended, determining whether the callback stack trace is active; and
in response to determining that the callback stack trace is active, discarding saved stack trace of the registered callback that is ended.
