diff --git a/specification/configuration/api.md b/specification/configuration/api.md index ceb5cacfddd..806e278cd55 100644 --- a/specification/configuration/api.md +++ b/specification/configuration/api.md @@ -13,6 +13,7 @@ weight: 1 * [ConfigProvider](#configprovider) + [ConfigProvider operations](#configprovider-operations) - [Get instrumentation config](#get-instrumentation-config) + - [Add config change listener](#add-config-change-listener) * [ConfigProperties](#configproperties) @@ -49,6 +50,7 @@ default `ConfigProvider`, and set/register it. The `ConfigProvider` MUST provide the following functions: * [Get instrumentation config](#get-instrumentation-config) +* [Add config change listener](#add-config-change-listener) TODO: decide if additional operations are needed to improve API ergonomics @@ -63,6 +65,64 @@ configuration mapping node. If the `.instrumentation` node is not set, get instrumentation config SHOULD return an empty `ConfigProperties` (as if `.instrumentation: {}` was set). +##### Add config change listener + +Register a listener to be notified when configuration at a specific watched path +changes. + +This API MUST accept the following parameters: + +* `path`: declarative configuration path to watch. +* `listener`: callback invoked on changes. + +**Returns:** A registration handle with a close operation. + +Path requirements: + +* `path` MUST be an absolute declarative configuration path. +* `path` matching is exact. Wildcards and prefix matching are not supported. +* In this version, paths are defined only for named properties. Sequence/array indexing is not supported +* API implementations SHOULD document accepted path syntax in language-specific + docs and include examples such as `.instrumentation/development.general.http` + and `.instrumentation/development.java.methods`. + +Callback requirements: + +* If a watched path changes, the callback MUST receive: + * `path`: the changed watched path. + * `newConfig`: the updated [`ConfigProperties`](#configproperties) for that + path. +* `newConfig` MUST be a valid [`ConfigProperties`](#configproperties) instance + (never null/nil/None). +* If the watched node is unset or cleared, `newConfig` MUST represent an empty + mapping node (equivalent to `{}`). +* Implementations MAY coalesce rapid successive updates for the same watched + path. If coalescing is performed, callback delivery MUST use the latest + configuration state. +* Ordering of callback delivery is not specified, including for updates touching + multiple watched paths in one configuration transaction. + +Concurrency and lifecycle requirements: + +* Callback implementations SHOULD be reentrant and SHOULD avoid blocking + operations. +* Implementations MUST document callback concurrency guarantees. If they do not, + users MUST assume callbacks may be invoked concurrently. +* Closing a registration handle MUST unregister the listener. +* Close MUST be idempotent (subsequent calls have no effect). +* After close returns, implementations SHOULD stop new callback delivery for that + registration. A callback already in progress MAY complete. +* Registrations SHOULD be dropped automatically when the corresponding + `ConfigProvider` is shut down or otherwise disposed. + +Error handling and unsupported providers: + +* If callback execution throws an error, implementations SHOULD isolate the + failure to that callback and SHOULD continue notifying other callbacks. +* If a provider does not support change notifications, registration MUST still + succeed by returning a no-op registration handle, and callbacks MUST NOT be + invoked. + ### ConfigProperties `ConfigProperties` is a programmatic representation of a configuration mapping