Enhanced debug headers

In addition to the standard debug information, enhanced debug headers include a status message and the amount of wall time, CPU time, and memory consumed by the event handler. You can also configure enhanced debug headers to provide information about HTTP sub-requests.

To receive enhanced debugging information about the EdgeWorkers execution in the debug response headers the request must pass:

  • An Akamai-EW-Trace request header that contains a secure authentication token.

  • One of the standard Pragma headers. See the Enable standard debug headers for more information.

  • For responseProvider you need to add the Pragma: akamai-x-ew-debug-rp header that enables the multi-part response header. See Enable enhanced debug headers for responseProvider for more information.

  • To debug HTTP sub-requests you need to add the Pragma: akamai-x-ew-debug-subs header to the request.

Add a secret key to your property

To enable enhanced debug headers you need to add a secret key to your property. This secret key is used to generate the authentication token used in the enhanced debug header request.

You only need to add this secret key to your property once. These instructions describe how to use the EdgeWorkers CLI to generate a secret key.

👍

Review the enhanced debug header details documentation to learn more about the response debug fields and to view examples.

Before you begin, go to Akamai CLI for EdgeWorkers for instructions on how to install the EdgeWorkers package. You'll also find an overview of commands you can use to manage your EdgeWorkers.

Make sure to follow the instructions in the Get Started with APIs documentation. These instructions apply to both Akamai APIs and Akamai CLIs. You need to authenticate your CLI requests using EdgeGrid, a proprietary authentication system for APIs deployed through Akamai Control Center.

  1. Use this EdgeWorkers CLI command to generate a secret key:
$ akamai edgeworkers secret

Here’s an example of a secret key (this key is an example and cannot be used in your user-defined variable):

fef77a483a6dd85b45a6c5092f1c178a6eaf21e56a3b69195e33f53070eec669
  1. Add a user-defined variable named, EW_DEBUG_KEY to your property. See User-defined variables for more information.

  2. Enter the secret key you created in step 1 into the Initial Value column of the user-defined variable.

  3. Select the Sensitive Security Setting to prevent exposing the key.

    Secret keySecret key

  4. Save and activate your property.

Request enhanced debug headers

Follow these steps to generate an authentication token and add enhanced debug headers to your requests. You can also use these steps to re-generate an expired token.

👍

You can also use the EdgeWorkers API to generate a secret key.

  1. Use this EdgeWorkers CLI command to generate an authentication token. In this example we set the token expiry to 60 minutes for the www.example.com hostname.
akamai edgeworkers auth --expiry 60 www.example.com

Here’s an example of a response.

Creating auth token ... /
------------------------------------------------------------------------------------------------------------------------------------------------
Add the following request header to your requests to get additional trace information.
Akamai-EW-Trace: st=1601393394~exp=1601395194~acl=/*~hmac=89ec982c9098536d82ad7c24232578a4fdee88739e7c75c9c371be66b6fe614b
------------------------------------------------------------------------------------------------------------------------------------------------

📘

You need to provide the EdgeWorkers CLI with API access to the hostname in the request. Without this access the command will fail to provide a valid debug header. For more information refer to the Get Started with APIs documentation.

  1. Active your EdgeWorkers code bundle.

  2. To receive enhanced debugging information add the following request header to your requests.

curl "http://www.example.com" -H 'Pragma: akamai-x-ew-debug' -H 'Akamai-EW-Trace: st=1601393394~exp=1601395194~acl=/*~hmac=89ec982c9098536d82ad7c24232578a4fdee88739e7c75c9c371be66b6fe614b'

Here's an example of enhanced debug information.

HTTP/2 200
content-type: application/json
date: Fri, 16 Oct 2020 21:05:28 GMT
content-length: 65
server-timing: cdn-cache; desc=HIT
server-timing: edge; dur=2153
x-akamai-edgeWorker-onclientresponse-log: D:main.js:16 iron\r\nx-akamai-edgeworker-onclientresponse-info: ew=<your EdgeWorker ID> v1.0:example; status=Success; status_msg=-; res_tier=200; wall_time=0.500; cpu_time=0.400; memory_usage=2464
x-akamai-edgeworker-onclientrequest-info: ew=<your EdgeWorker ID> v1.0:example; status=UnimplementedEventHandler; status_msg=-; wall_time=0; cpu_time=0; memory_usage=229836