From b263c1fedf28fd18cb25300175d6893cb6f0ed6f Mon Sep 17 00:00:00 2001 From: Steven Soroka Date: Thu, 11 Mar 2021 16:35:26 -0500 Subject: [PATCH] accurate state documentation for Starlark --- plugins/processors/starlark/README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/processors/starlark/README.md b/plugins/processors/starlark/README.md index c14c3e8bc..2922fc42e 100644 --- a/plugins/processors/starlark/README.md +++ b/plugins/processors/starlark/README.md @@ -165,9 +165,12 @@ def apply(metric): **How can I save values across multiple calls to the script?** -A shared global dictionary named `state` exists, this can be used by the `apply` function. +Telegraf freezes the global scope, which prevents it from being modified, except for a special shared global dictionary +named `state`, this can be used by the `apply` function. See an example of this in [compare with previous metric](/plugins/processors/starlark/testdata/compare_metrics.star) +Other than the `state` variable, attempting to modify the global scope will fail with an error. + **How to manage errors that occur in the apply function?** In case you need to call some code that may return an error, you can delegate the call