This topic describes the common request headers, HTTP status codes, response headers, and log formats of a custom runtime.
Common request headers in Function ComputeThe following table describes the common request headers that Function Compute forwards to a custom runtime. If you want to access other Alibaba Cloud services, you may need to use the request headers that specify a temporary AccessKey pair. If you migrate existing applications to Function Compute, ignore the following information.
NoteFor a custom runtime or a custom container, you can check whether you sent a request to invoke an HTTP function or an event function based on the value of this parameter. Valid values:
A custom runtime can work as an HTTP server. Each function invocation that you make is an HTTP request. This way, each response includes a response code and a response header.
StatusCode
)
200
: succeeded404
: failedx-fc-status
)
200
: succeeded404
: failedYou can include the
x-fc-status
field in response headers to report to
Function Computewhether the local function is successfully invoked.
Note We recommend that you specify the StatusCode
and x-fc-status
fields in the HTTP response.
We recommend that you enable logging when you create a service in Function Compute. This way, all stdout logs that the system generates are stored in the specified Log Service project. For more information, see Configure the logging feature.
If Function Compute invokes a function in a runtime that is not a custom runtime or a custom container and the request contains the x-fc-log-type" = "Tail"
header, the response that contains the x-fc-log-result
header is the log that the system generates when the system invokes the function. The maximum size of a log is 4 KB. You can view the log in the results of the function invocation in the Function Compute console. If you want to view the logs of a custom runtime in the results of the function invocation in the console, you must record the start and end logs of the requests in the code.
Note The cold start flag of the function is recorded.
FunctionCompute ${runtime} runtime inited.
Note You can specify a custom value for the ${runtime}
parameter. We recommend that you do not specify an official language name in Function Compute, such as Node.js, Python, or PHP.
FC Invoke Start RequestId: ${RequestId}
End log of function invocation Yes FC Invoke End RequestId: ${RequestId}
Start log of function initialization No
Note If you use an initializer function, record this log.
FC Initialize Start RequestId: ${RequestId}
End log of function initialization No
Note If you use an initializer function, record this log.
FC Initialize End RequestId: ${RequestId}
We recommend that you also include the request ID in your logs for diagnostics in the future and the request ID in your logs is in the $utcdatetime(yyyy-MM-ddTHH:mm:ss.fff) $requestId [$Level] $message
format.
The API operation that you can perform to specify the log level varies based on the programming language. For more information, see
Log records.
ReferencesThank you! We've received your feedback.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4