Cognitive in-memory API logging

Managing application programming interface (API) execution logging is provided. It is determined whether a log trigger definition corresponding to a log include definition is satisfied. In response to determining that the log trigger definition corresponding to the log include definition is satisfied, an execution log of the API is transferred from memory to a file in a storage device. The execution log of the API and a set of API definitions in the file is analyzed using natural language processing to identify a usability context pattern corresponding to the API. A specific set of API log definitions for the API is recommended based on the identified usability context pattern corresponding to the API.

BACKGROUND

The disclosure relates generally to application programming interface (API) logging and more specifically to managing cognitive API execution in-memory logging based on user-defined API log definitions that reduce an amount of information contained within a log file corresponding to a specified API.

2. Description of the Related Art

Logs are commonly used to analyze API issues. Typically, only an information or error level logging is turned on by default to avoid increased overhead on system performance. Also, by having detailed logging turned on, a system may generate too much information in log files, which may quickly grow to gigabits in verbose mode. A verbose logging mode is an available option in many systems that provides additional details as to what an API is doing while executing. This level of detail can be very helpful for troubleshooting API problems. In other words, verbose logging records more information than the typical logging modes, but may slow down system performance. This makes it difficult to analyze specific problems without external tooling or intervention to help scrape API logs to pull out relevant information on a particular problem. Even in these cases, the external tooling is limited and fixed.

One common problem is that a user will turn on logging to a finer granular level on some set of components or code packages after some issue is reported. In many cases, this requires a restart of the system to enable the finer-grained logging to be turned on, which causes downtime for clients. Also, the problem may not always be easily replicated. For example, when a particular API has a reported problem, the system administrator enables logging for that particular API. However, after logging is enabled and after another five hundred invocations of that particular API, the problem happens again. The key issues in this example are: 1) performance overhead involved with the logging all five hundred API invocations and writing that information to hard disk or a log server; and 2) large log files containing a multitude of unnecessary information, such as tens of gigabits of data with only five lines of relevant log data relating to the problem.

Another common problem is that many times the troubleshooting engineer knows what to trace at a finer granular level (e.g., a specific API call in an e-commerce system for a specific shopper identification (ID) or for a specific product ID in an e-commerce API). Unfortunately, without a complex logging mechanism and development effort, the troubleshooting engineer is limited to a much larger trace log, which records unnecessary data that takes up disk space, consumes memory during tracing, increases CPU utilization, and the like.

SUMMARY

According to one illustrative embodiment, a computer system for managing application programming interface (API) execution logging is provided. The computer system determines whether a log trigger definition corresponding to the API listed in the log include definition is satisfied. In response to the computer system determining that the log trigger definition corresponding to the API listed in the log include definition is satisfied, the computer system transfers the execution log of the API from a memory to a file in a storage device of the computer system. The computer system analyzes the execution log of the API and a set of API definitions in the file using natural language processing to identify a usability context pattern corresponding to the API. The computer system recommends a specific set of API log definitions for the API based on the identified usability context pattern corresponding to the API. According to another illustrative embodiment, a computer program product for managing API execution logging is provided.

DETAILED DESCRIPTION

With reference now to the figures, and in particular, with reference toFIG. 1andFIG. 2, diagrams of data processing environments are provided in which illustrative embodiments may be implemented. It should be appreciated thatFIG. 1andFIG. 2are only meant as examples and are not intended to assert or imply any limitation with regard to the environments in which different embodiments may be implemented. Many modifications to the depicted environments may be made.

FIG. 1depicts a pictorial representation of a network of data processing systems in which illustrative embodiments may be implemented. Network data processing system100is a network of computers, data processing systems, and other devices in which the illustrative embodiments may be implemented. Network data processing system100contains network102, which is the medium used to provide communications links between the computers, data processing systems, and other devices connected together within network data processing system100. Network102may include connections, such as, for example, wire communication links, wireless communication links, and fiber optic cables.

In the depicted example, server104and server106connect to network102, along with storage108. Server104and server106may be, for example, server computers with high-speed connections to network102. Also, it should be noted that server104and server106may each represent a plurality of different servers. In this example, server104and server106provide configurable API execution logging management services.

For example, server104provides a configurable API logging component so that a system user, such as a support engineer or a system administrator, is able to define under what conditions to collect log/trace data into a memory device of server104. The configurable API logging component also allows the system user to define a “log trigger” so that when the log trigger is satisfied, server104writes or transfers the log/trace data from memory to a file stored on a hard disk of server104for consumption by the system user and/or a cognitive component of server104. The log/trace data transfer may be a one-time data dump from memory to disk. Alternatively, for more heavily logged scenarios, a data size limit may force the data dump from memory to disk. Thus, illustrative embodiments not only decrease the performance overhead (e.g., storage and processor utilization) of server104for verbose logging, but also the log file is more consumable by only containing relevant information corresponding to the defined log trigger that the system user wants to analyze. Further, illustrative embodiments do not require restart of server104to implement and perform the user-defined API execution logging. It should be noted that API as used herein may mean a representational state transfer (REST) API corresponding to a web service, a call stack corresponding to an object-oriented program, and the like.

As an example, the system user may define API execution logging at a verbose level for an “createOrder API” (i.e., an API log include definition) for client user “Tom” (i.e., a log condition definition) when a response time of the createOrder API is greater than four seconds or a specified exception, such as “ABCException”, occurs during execution of the createOrder API (i.e., a log trigger definition). As a result, when client user Tom invokes the createOrder API, server104starts recording the log data for the createOrder API in memory. If the response time of the createOrder API is greater than the four second performance threshold or the specified exception occurs during execution of the createOrder API, then server104transfers the log data from memory to disk for analysis by the system user and/or the cognitive component of server104to resolve the problems or issues associated with the createOrder API and/or make recommendations for future API execution logging definitions for the createOrder API or similar application programming interfaces (APIs).

Thus, server104provides API execution logging capabilities that are able to limit the amount of information contained in an API execution log based only on a specific API listed in an API log include definition, a log condition definition, and a log trigger definition that the system user defined. In other words, server104only includes in-depth logging on specified APIs that the system user wants to include in the logging process. Further, server104has an ability to exclude the log recording of other APIs listed in an API exclude definition decreasing the I/O footprint of the logging components and utilization of data processing components of server104. Consequently, server104provides an in-depth API execution log that is tailored to only the specified API, the log condition definition, and log trigger definition defined by the system user.

Client110, client112, and client114also connect to network102. Clients110,112, and114are clients of server104and server106. In this example, clients110,112, and114are illustrated as desktop or personal computers with wire communication links to network102. However, it should be noted that clients110,112, and114are meant as examples only. In other words, clients110,112, and114may include other types of data processing systems, such as, for example, network computers, laptop computers, handheld computers, smart phones, smart televisions, smart watches, gaming devices, kiosks, and the like, with wire or wireless communication links to network102. Users of clients110,112, and114may utilize clients110,112, and114to access one or more web service APIs corresponding to server104and server106to perform a task or function, such as transferring monetary funds between bank accounts online.

Storage108is a network storage device capable of storing any type of data in a structured format or an unstructured format. In addition, storage108may represent a plurality of network storage devices. Storage108may store, for example, a plurality of different APIs and their corresponding names and identifiers; a plurality of different API execution log files; a plurality of different user-defined API log definitions; a plurality of different system-recommended API log definitions; names and identifiers for a plurality of different client device users; and the like. Further, storage108may store other data, such as authentication or credential data that may include user names, passwords, and biometric data associated with support engineers and system administrators, for example.

In addition, it should be noted that network data processing system100may include any number of additional server computers, client devices, and other devices not shown. Program code located in network data processing system100may be stored on a computer readable storage medium and downloaded to a computer or data processing system for use. For example, program code may be stored on a computer readable storage medium on server104and downloaded to client110over network102for use on client110.

In the depicted example, network data processing system100may be implemented as a number of different types of communication networks, such as, for example, an internet, an intranet, a local area network (LAN), a wide area network (WAN), or any combination thereof.FIG. 1is intended as an example, and not as an architectural limitation for the different illustrative embodiments.

With reference now toFIG. 2, a diagram of a data processing system is depicted in accordance with an illustrative embodiment. Data processing system200is an example of a computer, such as server104inFIG. 1, in which computer readable program code or program instructions implementing processes of illustrative embodiments may be located. In this illustrative example, data processing system200includes communications fabric202, which provides communications between processor unit204, memory206, persistent storage208, communications unit210, input/output (I/O) unit212, and display214.

Processor unit204serves to execute instructions for software applications and programs that may be loaded into memory206. Processor unit204may be a set of one or more hardware processor devices or may be a multi-processor core, depending on the particular implementation. Further, processor unit204may be implemented using one or more heterogeneous processor systems, in which a main processor is present with secondary processors on a single chip. As another illustrative example, processor unit204may be a symmetric multi-processor system containing multiple processors of the same type.

In this example, persistent storage208stores API execution log manager218. API execution log manager218controls API execution logging based on user-defined API log definitions that reduce an amount of information contained within a log file corresponding to a specified API. It should be noted that even though API execution log manager218is illustrated as residing in persistent storage208, in an alternative illustrative embodiment API execution log manager218may be a separate component of data processing system200. For example, API execution log manager218may be a hardware component coupled to communication fabric202or a combination of hardware and software components. In another alternative illustrative embodiment, a first set of components of API execution log manager218may be located in data processing system200and a second set of one or more components of API execution log manager218may be located in a log server, such as server106inFIG. 1.

In this example, persistent storage208also stores APIs220and API file222. APIs220represent a plurality of different APIs that when invoked perform a plurality of different web services or functions. It should be noted that a user of a client device, such as client110inFIG. 1, another server, or data processing system200, itself, may invoke an API in APIs220. APIs220also include names and identifiers for each of the plurality of different APIs.

In this example, API file222includes API log definitions224. A user of data processing system200, such as, for example, a support engineer, defines API log definitions224. API execution log manager218utilizes API log definitions224to control the process of recording the execution logs of one or more specified APIs in APIs220. API log definitions224include log include definition226, log exclude definition228, log condition definition230, and log trigger definition232. Log include definition226specifies one or more names or identifiers of particular APIs in APIs220that the support engineer wants API execution log manager218to perform detailed (e.g., verbose level) logging on. It should be noted that log exclude definition228, log condition definition230, and log trigger definition232correspond to the specified API or APIs listed in log include definition226.

Log exclude definition228specifies the names or identifiers of the APIs to be excluded in the detailed logging. Log condition definition230describes the condition under which the detailed logging of the specified API is to be recorded in memory206. Log trigger definition232identifies the condition under which the data corresponding to the detailed logging of the specified API, which is recorded in memory206, is to be transferred or written to persistent storage208.

In response to API execution log manager218determining that log condition definition230corresponding to the API specified in log include definition226is not met, then API execution log manager218does not record any API logging data in memory206. In response to API execution log manager218determining that log condition definition230corresponding to the specified API is met, then API execution log manager218records the detailed logging of the specified API (i.e., API execution log234) in memory206. In response to API execution log manager218determining that execution of the specified API has stopped due to, for example, successful execution of the specified API or occurrence of an exception, then API execution log manager218determines whether log trigger definition232corresponding to the specified API has been satisfied. In response to API execution log manager218determining that log trigger definition232corresponding to the specified API has been satisfied, API execution log manager218transfers API execution log234from memory206to persistent storage208, shown as API execution log236. In other words, API execution236is the same as API execution log234in this example. In response to API execution log manager218determining that log trigger definition232corresponding to the specified API has not been satisfied, API execution log manager218deletes API execution log234from memory206and does not transfer API execution log234to persistent storage208.

In this example, API execution log manager218utilizes natural language processor238of cognitive component240to analyze API execution log236. However, it should be noted that API execution log manager218may include more or fewer components than shown. For example, different illustrative embodiments may combine the two components into one component, divide one component into two or more components, or add other components not shown. In addition, it should be noted that API execution log236may represent a plurality of different API execution logs stored in persistent storage208.

After analyzing API execution log236using natural language processing, natural language processor238generates API usability context pattern242. API usability context pattern242represents the support engineer's desired usability of the specified API. Cognitive component240generates recommendation244, which contains a recommendation of one or more specific API log definitions corresponding to the specified API based on API usability context pattern242generated by natural language processor238. API execution log manager218outputs recommendation244to the support engineer on display214, for example.

Thus, illustrative embodiments improve the functioning of data processing system200by decreasing utilization of memory space for log data based on an API include definition, decreasing the number of APIs being logged based on an API log exclude definition, decreasing the number and size of API execution logs based on an API log condition definition, and decreasing the number of API execution logs stored and analyzed in persistent storage208based on an API log trigger definition, which results in increased free disk space, decreased memory consumption, and decreased processor utilization during API execution data logging and analysis.

Program code246is located in a functional form on computer readable media248that is selectively removable and may be loaded onto or transferred to data processing system200for running by processor unit204. Program code246and computer readable media248form computer program product250. In one example, computer readable media248may be computer readable storage media252or computer readable signal media254. Computer readable storage media252may include, for example, an optical or magnetic disc that is inserted or placed into a drive or other device that is part of persistent storage208for transfer onto a storage device, such as a hard drive, that is part of persistent storage208. Computer readable storage media252also may take the form of a persistent storage, such as a hard drive, a thumb drive, or a flash memory that is connected to data processing system200. In some instances, computer readable storage media252may not be removable from data processing system200.

Alternatively, program code246may be transferred to data processing system200using computer readable signal media254. Computer readable signal media254may be, for example, a propagated data signal containing program code246. For example, computer readable signal media254may be an electro-magnetic signal, an optical signal, and/or any other suitable type of signal. These signals may be transmitted over communication links, such as wireless communication links, an optical fiber cable, a coaxial cable, a wire, and/or any other suitable type of communications link. In other words, the communications link and/or the connection may be physical or wireless in the illustrative examples. The computer readable media also may take the form of non-tangible media, such as communication links or wireless transmissions containing the program code.

In some illustrative embodiments, program code246may be downloaded over a network to persistent storage208from another device or data processing system through computer readable signal media254for use within data processing system200. For instance, program code stored in a computer readable storage media in a data processing system may be downloaded over a network from the data processing system to data processing system200. The data processing system providing program code246may be a server computer, a client computer, or some other device capable of storing and transmitting program code246.

As another example, a computer readable storage device in data processing system200is any hardware apparatus that may store data. Memory206, persistent storage208, and computer readable storage media252are examples of physical storage devices in a tangible form.

Illustrative embodiments provide API-level logging. API-level logging causes generation of a log/trace when an API is invoked. An API may be, for example, a REST API corresponding to a web service, a call stack corresponding to an object-oriented program, or the like. A user, such as, a support engineer or system administrator, creates a set of API log definitions. The set of API definitions define what APIs are to be logged and under what conditions. The set of API definitions include an API log include definition, an API log exclude definition, an API log condition definition, and an API log trigger definition.

The API log include definition specifies the name and/or identifier of each API that is to be included in detailed (e.g., verbose or highly granular) execution logging. The API log exclude definition specifies the name and/or identifier of each API not to be included in (i.e., excluded from) the detailed logging process. The API log condition definition describes the condition or conditions under which the API-level logging is to be recorded in memory. The API log trigger definition describes the condition or conditions under which the API execution log data in memory to is to be transferred or written to a hard disk file or a log server.

As an example, a support engineer wants to use illustrative embodiments to define a log/trace in verbose level for a specified API, such as a “createOrder API”, for an online shopper “Tom”, when the response time for the specified API is longer than 4 seconds or a specified exception, such as “ABCException”, occurs during execution of the specified API. The support engineer would write this example API log definition as:

When the specified API (e.g., the createOrderAPI) is invoked, API execution logging begins. Specifically, when the log condition definition (e.g., request.shopperId='Tom') is satisfied for the specified API, then illustrative embodiments start recording the log/trace in memory. Alternatively, if the log condition definition for the specified API is not satisfied, then illustrative embodiments do not record the log/trace in memory (i.e., illustrative embodiments do not perform a log/trace).

Upon successful execution of the specified API or exiting execution of the specified API with an exception, then illustrative embodiments check whether the log trigger definition (e.g., responseTime>4 s or ABCException) is satisfied. If the log trigger definition is satisfied, then illustrative embodiments write the log/trace data from memory to a disk file or a log server. If the log trigger definition is not satisfied, then illustrative embodiments delete or discard the log/trace data in memory.

When a support engineer creates a set of API log definitions, illustrative embodiments cognitively learn from historical API log definitions for same or similar API issues previously recorded on hard disk and recommend specific API log definitions to the support engineer. Using the example above, illustrative embodiments may recommend one or more specific API log trigger definitions, such as, for example, a specific response time and/or a specific exception type, the next time the support engineer defines an API log trigger definition corresponding to a particular shopper or shopper ID. Over time, illustrative embodiments collect useful data based on the previously used API log definitions. Thus, illustrative embodiments are able to recommend to the support engineer specific API log trigger definitions used most often for a particular shopper ID so that the support engineer does not have to create trigger definitions from scratch.

Moreover, illustrative embodiments also may provide additional API log include definitions and API log trigger definitions based on analyzing the stored historical data. For example, if a trigger corresponding to a particular exception type (e.g., ABCException) appears to have a significant impact on the system, then illustrative embodiments may recommend this information to other support engineers also needing to know in-depth details regarding a createShipmentAPI to get to the root cause of an issue with that particular API. Ultimately, the recommendations provided by illustrative embodiments may get to a level where the support engineer only needs to have minimal knowledge of an API issue to provide an include, trigger, or condition definition to get an optimal log with minimum impact on system performance.

As a result, illustrative embodiments may trigger API execution logging only when a particular API performance threshold is met or exceeded. Illustrative embodiments may utilize natural language processing to analyze the stored historical log definition data and a cognitive component to make recommendations to support engineers to determine which API log definitions to use for a particular API.

With reference now toFIG. 3A-3B, a flowchart illustrating a process for managing API execution logging is shown in accordance with an illustrative embodiment. The process shown inFIG. 3A-3Bmay be implemented in a computer, such as, for example, server104inFIG. 1or data processing system200inFIG. 2.

The process begins when the computer receives a set of API log definitions from a support engineer (step302). The computer stores the set of API log definitions in a file stored on a storage device of the computer (step304). Subsequently, the computer receives a name of an API that has been invoked (step306). The computer then retrieves the set of API log definitions (step308).

Afterward, the computer makes a determination as to whether the name of the API is included in a log include definition of the set of API log definitions (step310). If the computer determines that the name of the API is not included in the log include definition of the set of API log definitions, no output of step310, then the computer excludes the API from execution log recording (step312). Thereafter, the process terminates.

If the computer determines that the name of the API is included in the log include definition of the set of API log definitions, yes output of step310, then the computer identifies a set of APIs in a log exclude definition corresponding to the log include definition (step314). In addition, the computer excludes the set of APIs from execution log recording (step316). However, it should be noted that the set of APIs may be a null set of APIs.

Further, the computer makes a determination as to whether a log condition definition corresponding to the log include definition is satisfied (step318). If the computer determines that the log condition definition corresponding to the log include definition is not satisfied, no output of step318, then the process returns to step312where the computer excludes the API from execution log recording. If the computer determines that the log condition definition corresponding to the log include definition is satisfied, yes output of step318, then the computer records an execution log of the API in memory of the computer (step320).

Subsequently, the computer receives an indication that execution of the API has stopped (step322). Execution of the API may stop due to successful execution or occurrence of an exception, for example. Afterward, the computer makes a determination as to whether a log trigger definition corresponding to the log include definition is satisfied (step324).

If the computer determines that the log trigger definition corresponding to the log include definition is not satisfied, no output of step324, then the computer deletes the execution log of the API from the memory of the computer (step326) and the process terminates thereafter. If the computer determines that the log trigger definition corresponding to the log include definition is satisfied, yes output of step324, then the computer transfers the execution log of the API from the memory to the file in the storage device of the computer (step328). In addition, the computer analyzes the execution log of the API and the set of API definitions in the file using a natural language processor of a cognitive component of the computer to identify a usability context pattern corresponding to the API (step330). The usability context pattern identifies the support engineer's intent for usability of the specified API in the log include definition. Further, the computer recommends a specific set of API log definitions for the API to the support engineer based on the identified usability context pattern corresponding to the API (step332). Thereafter, the process terminates.

Thus, illustrative embodiments of the present invention provide a computer-implemented method, computer system, and computer program product for managing API execution logging based on user-defined API log definitions that reduce an amount of information contained within a log file corresponding to a specified API listed in an API log include definition. The descriptions of the various embodiments of the present invention have been presented for purposes of illustration, but are not intended to be exhaustive or limited to the embodiments disclosed. Many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The terminology used herein was chosen to best explain the principles of the embodiments, the practical application or technical improvement over technologies found in the marketplace, or to enable others of ordinary skill in the art to understand the embodiments disclosed herein.