-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[service/extensions] extension lifecycle order (#8768)
**Description**: Enforce order of start and shutdown of extensions according to their internally declared dependencies **Link to tracking Issue**: Resolves #8732 **Motivation**: This is an alternative approach to #8733 which uses declaration order in the config to start extensions. That approach (a) enforces order when it's not always necessary to enforce, and (b) exposes unnecessary complexity to the user by making them responsible for the order. This PR instead derives the desired order of extensions based on the dependencies they declare by implementing a `DependentExtension` interface. That means that extensions that must depend on others can expose this interface and be guaranteed to start after their dependencies, while other extensions can be started in arbitrary order (same as happens today because of iterating over a map). The extensions that have dependencies have two options to expose them: 1. if the dependency is always static (e.g. `jaeger_query` extension depending on `jaeger_storage` as in the OP), the extension can express this statically as well, by returning a predefined ID of the dependent extension 2. in cases where dependencies are dynamic, the extension can read the names of the dependencies from its configuration. The 2nd scenario is illustrated by the following configuration. Here each complex extension knows that it needs dependencies that implement `storage` and `encoding` interfaces (both existing APIs in collector & contrib), but does not know statically which instances of those, the actual names are supplied by the user in the configuration. ```yaml extensions: complex_extension_1: storage: filestorage encoding: otlpencoding complex_extension_2: storage: dbstorage encoding: jsonencoding filestorage: ... dbstorage: ... otlpencoding: jsonencoding: ``` **Changes**: * Introduce `DependentExtension` optional interface * Change `Extensions` constructor to derive the required order using a directed graph (similar to pipelines) * Inherited from #8733 - use new ordered list of IDs to start/stop/notify extensions in the desired order (previously a map was used to iterate over, which resulted in random order). * Tests **Testing**: Unit tests --------- Signed-off-by: Yuri Shkuro <[email protected]> Co-authored-by: Antoine Toulme <[email protected]>
- Loading branch information
1 parent
29c16a2
commit 2e44da3
Showing
7 changed files
with
351 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Use this changelog template to create an entry for release notes. | ||
|
||
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' | ||
change_type: enhancement | ||
|
||
# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver) | ||
component: service/extensions | ||
|
||
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). | ||
note: Allow extensions to declare dependencies on other extensions and guarantee start/stop/notification order accordingly. | ||
|
||
# One or more tracking issues or pull requests related to the change | ||
issues: [8732] | ||
|
||
# (Optional) One or more lines of additional information to render under the primary note. | ||
# These lines will be padded with 2 spaces and then inserted directly into the document. | ||
# Use pipe (|) for multiline entries. | ||
subtext: | ||
|
||
# Optional: The change log or logs in which this entry should be included. | ||
# e.g. '[user]' or '[user, api]' | ||
# Include 'user' if the change is relevant to end users. | ||
# Include 'api' if there is a change to a library API. | ||
# Default: '[user]' | ||
change_logs: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.