Functions are blocks of code that run on demand without the need to manage any infrastructure. Develop on your local machine, test your code from the command line (using doctl
), then deploy to a production namespace or App Platform — no servers required.
Each asynchronous (or non-blocking) activation of a function creates an activation record, which you can retrieve to learn more about the process. Asynchronous activations are the default behavior when using the function’s authenticated REST API.
All web-based invocations are blocking and do not retain an activation record.
You can retrieve activation records from the command line using doctl
or from the Logs tab of the Functions namespace in the control panel. See the Inspect Logs section of How to Develop Functions for more information.
Activation records are a JSON object in the following structure:
{
"activationId": "c15d4bacedfa4bab9d4bacedfa2bcbec",
"annotations": [
{
"key": "path",
"value": "fn-feb132ee-706a-4f13-9c81-f24a3330260b/sample/hello"
},
{
"key": "waitTime",
"value": 80
},
{
"key": "uuid",
"value": "da25db4890885df62c1bfb6afdb4c91cb3b4bca5"
},
{
"key": "entry",
"value": "main"
},
{
"key": "user_id",
"value": "2559851"
},
{
"key": "gbs",
"value": 0.025
},
{
"key": "kind",
"value": "nodejs:14"
},
{
"key": "timeout",
"value": false
},
{
"key": "limits",
"value": {
"concurrency": 1,
"logs": 16,
"memory": 256,
"timeout": 3000
}
}
],
"date": "2022-05-13 11:13:11",
"duration": 5,
"end": 1652454791582,
"logs": [
"2022-05-13T15:13:11.580825656Z stdout: Hello sammy"
],
"name": "hello",
"namespace": "fn-feb132ee-706a-4f13-9c81-f24a3330260b",
"publish": false,
"response": {
"result": {
"body": "Hello sammy"
},
"size": 27,
"status": "success",
"success": true
},
"start": 1652454791577,
"subject": "da25db4890885df62c1bfb6afdb4c91cb3b4bca5",
"version": "0.0.5"
}
The output includes the following fields:
activationId
: The activation IDannotations
: An array of key-value pairs that record metadata about the action activationnamespace
and name
: The namespace and function namestart
and end
: Timestamps recording the start and end of the activation. The values are in UNIX time formatlogs
: An array of strings with the logs that are produced by the action during its activation. Each array element corresponds to a line output to stdout
or stderr
by the action, and includes the time and stream of the log output. The structure is as follows: TIMESTAMP
STREAM:
LOG LINE
response
: A dictionary that defines the following keys:
result
: A dictionary as a JSON object which contains the activation result. If the activation was successful, this contains the value that is returned by the action. If the activation was unsuccessful, result
contains the error
key, generally with an explanation of the failure.success
: Is true if and only if the status is “success”.status
: The activation result, which might be one of the following values:
success
: the function invocation completed successfullyapplication error
: the function was invoked, but returned an error value on purpose, for instance because a precondition on the arguments was not metaction developer error
: the action was invoked, but it completed abnormally, for instance the action did not detect an exception, or a syntax error existed. This status code is also returned under specific conditions such as: