1 of 20
2 of 20
3 of 20
4 of 20
5 of 20
6 of 20
7 of 20
8 of 20
9 of 20
10 of 20
11 of 20
12 of 20
13 of 20
14 of 20
15 of 20
16 of 20
17 of 20
18 of 20
19 of 20
20 of 20

site

doc

blog

success stories

Debugging

Edit on GitHub

Debugging is a process that allows developers to fix log messages or variables, for example. The debugging method allows an Edge Functions user to generate logs as if they were using a browser’s JavaScript.

  1. What it is
  2. How it works
  3. Setting up

1. What it is

The debugging process in Edge Functions has the purpose of promoting better control over the application to identify errors. It can also be used to assist in the development and debugging of a function, resulting in greater observability.


2. How it works

To debug codes, you must create a new function that will use the log method. This function prints to a local file a message that was previously sent by a parameter to the function.

Check the use of the console_from_event.log function below:

   async function handleRequest(request, console_from_event) {
       console_from_event.log("Hello World");

       return new Response("Checking console output.", {
           status: 200,
       });
   }
   addEventListener("fetch", (event) => {
       event.respondWith(handleRequest(event.request, event.console));
   });
}

The message is then collected and made available to be accessed on the Data Streaming product.


3. Setting up

  1. Access Real-Time Manager with your login credentials.
  2. On the Edge Analytics menu, select Data Streaming.
  3. Select an existing template or create a new one by clicking the Add Streaming button.
  4. Fill out the following fields with the necessary information

Name for Data Streaming: define a name for your template.

Data

Data Source: this is the Azion platform that will generate the events from which you are collecting data.

Template: the definition of the variables. Select Custom Template to create a new data set and include the variables below into the Data Set box:

Variable Definition
$time Date and time of the request.
$global_id Settings identifier.
$edge_function_id Edge Function identifier.
$request_id Request identifier.
$log_level Level of the log created (ERROR, WARN, INFO, DEBUG, TRACE).
$log_message Message used on the log when the function is requested.

Options: where data will be collected. It is possible to filter the domains (Filter Domains) or select all (All Domains) by choosing one option. *

*This option will appear only if you have more than one domain set up.

Domains: in case you wish to specify which domains, select them on the displayed boxes.

Sampling: the definition of % of data that will be transmitted. You can only change this value when selecting All Domains in the Options field. *

*This option will appear only if you have more than one domain set up.

Destination

Endpoint type: the method by which your endpoint will receive the data collected by Data Streaming. Select an option.

Endpoint URL: the URL that will receive information transmitted by Data Streaming. Define the URL.

Custom Headers: include here the need to add headers at requests.

  1. Click the Save button to finish the process.

Didn’t find what you were looking for? Open a ticket.