How to debug edge functions on Data Stream
The debugging process in edge functions’ code on Data Stream helps you identify if errors are still occurring or if the process was successful.
Before analyzing the process, you need to apply the debugging code. Find out more on Debugging edge functions.
Setting up Data Stream to debug edge functions
After applying the debugging code for edge functions:
- Access Azion Console.
- On the upper-left corner, select Data Stream on the Observe section.
- Click + Stream.
- Choose a name for your stream.
- On the Source dropdown menu, select Edge Functions.
- On the Template dropdown menu, select Edge Functions Event Collector.
- On the Data Set code box, add the following variables:
{ "time": "$time", "global_id": "$global_id", "edge_function_id": "$edge_function_id", "request_id": "$request_id", "log_level": "$log_level", "log_message": "$log_message"
}
- On Domains > Options, select between All Current and Future Domains or Filter Domains. See more about each option on How to associate domains on Data Stream.
- On the Destination section, select a Connector on the dropdown menu. See more about setting an endpoint.
- You’ll see different fields depending on the connector type you choose.
- Access Real-Time Manager.
- On the upper-left corner, select Data Stream on the OBSERVE section.
- Click Add Streaming.
- Choose a name for your stream.
- On the Data Source dropdown menu, select Edge Functions.
- On the Template dropdown menu, select Custom Template.
- On the Data Set code box, add the following variables:
{ "time": "$time", "global_id": "$global_id", "edge_function_id": "$edge_function_id", "request_id": "$request_id", "log_level": "$log_level", "log_message": "$log_message"
}
- On Options, select between Filter Domains or All Domains. See more about each option on How to associate domains on Data Stream.
- On the Destination section, select an Endpoint Type on the dropdown menu. See more about setting an endpoint.
- You’ll see different fields depending on the endpoint type you choose.
Finally, to finish your stream setup:
- Make sure the Active switch is turned on.
- Click the Save button.
Now, you’ll be able to analyze the behavior of the edge functions debugging process through the logs sent to your configured stream.
Variables definition
Variable | Definition |
---|---|
$time | Request date and time. Example: Oct. 31st, 2022 - 19:30:41 |
$global_id | Settings identifier. |
$edge_function_id | Edge Function identifier. |
$request_id | Unique request identifier. Example: 5f222ae5938482c32a822dbf15e19f0f |
$log_level | Level of the log generator: ERROR, WARN, INFO, DEBUG, or TRACE. |
$log_message | Editable message used in the log function. Available for users to identify and report a given behavior. |