yr.InvokeOptions.custom_extensions

yr.InvokeOptions.custom_extensions#

InvokeOptions.custom_extensions: Dict[str, str]#

Specify user-defined configurations, such as function concurrency. It can also be used as a user-defined tag for metrics to collect user information.

Common custom_extensions configuration#

“Concurrency”

Concurrency. Range: [1,1000].

“lifecycle”

detached, supports detached mode.

“DELEGATE_DIRECTORY_INFO”

Custom directories support the ability to create and delete subdirectories. When an instance is created, if the user-defined directory exists and has read and write permissions, a subdirectory is created under it as the working directory; otherwise, a subdirectory is created under the /tmp directory as the working directory. When the instance is destroyed, the working directory is destroyed. The user function can obtain the working directory through the INSTANCE_WORK_DIR environment variable.

“DELEGATE_DIRECTORY_QUOTA”

Subdirectory quota size, value range is greater than 0 M and less than 1 TB. If this configuration is not set, the default is 512 M. If the configuration is -1, monitoring is not performed. Unit: MB.

“GRACEFUL_SHUTDOWN_TIME”

Customize the graceful exit time, in seconds. Limit: >=0, 0 means immediate exit, and does not guarantee that the user’s graceful exit function can be completed; if configured <0, the system configuration at deployment time is used as the timeout time.

“RECOVER_RETRY_TIMEOUT”

Customize the recover timeout time. The instance recover timeout time is in milliseconds. Limit: >0, Default to 10 * 60 * 1000

When used as a user-defined tag for metrics:

>>> import yr
>>> yr.init()
>>> opt = yr.InvokeOptions()
>>> opt.custom_extensions["YR_Metrics"] = "{'endpoint':'127.0.0.1', 'project_id':'my_project_id'}"

In Prometheus, select metrics name as yr_app_instance_billing_invoke_latency, and you can find the custom tag information in the collected invoke information:

yr_app_instance_billing_invoke_latency{
...
endpoint="127.0.0.1",
...}