[DRAFT] OTAP Dataflow extension support#1958
Closed
gouslu wants to merge 10 commits into
Closed
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1958 +/- ##
==========================================
- Coverage 85.47% 85.09% -0.38%
==========================================
Files 512 518 +6
Lines 158299 159362 +1063
==========================================
+ Hits 135307 135612 +305
- Misses 22458 23216 +758
Partials 534 534
🚀 New features to boost your workflow:
|
|
This pull request has been marked as stale due to lack of recent activity. It will be closed in 30 days if no further activity occurs. If this PR is still relevant, please comment or push new commits to keep it active. |
Contributor
|
In favor of #2141 |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Extensions Architecture
Draft PR to discuss a proposal of extensions architecture for OTAP Dataflow Engine. Please feel free to
participate in the discussion on issue #1966 .
Overview
Extensions are pipeline components that provide shared services to other components
(receivers, processors, exporters). Unlike data-processing components, extensions don't
participate in the data flow—instead, they expose capabilities that other components
can look up and use. Extensions support start method similar to other components and
can run recurring tasks. Additionally, they can implement first class traits and make them
available via "get_extension" interface in the effect handler.
Example use cases:
Benefits
Reusability: One extension can be used by multiple components. Configure an
authentication extension once, and any number of exporters can reference it.
Multiple instances: Create multiple instances of the same extension type with
different configurations (e.g., separate auth for different components or one single component with multitenant support).
Configurability: Extensions are configured by name in YAML. Components reference
them by name, and the engine handles the wiring.
API stability: Extension traits are first-class interfaces defined in the engine.
The sealed trait pattern locks down the API surface, ensuring stability for both
extension authors and consumers.
Example configuration:
Both exporters share the same extension instance.
Multiple instances: You can create multiple instances of the same extension type
with different configurations. Each instance has its own name:
Architecture
BearerTokenProviderComponents access extensions via their effect handler:
Key Components
Extension Traits
Extension traits define capabilities. They use a sealed trait pattern—only traits
defined in
otap-df-engine::extensionscan be used with the extension system.ExtensionBundle
A bundle holds all trait implementations for a single extension. One extension
can implement multiple traits:
The
extension_bundle!MacroSimplifies bundle creation:
The macro enforces compile-time type safety—only extension traits work.
ExtensionRegistry
Maps extension names to bundles. Built once during pipeline initialization,
then shared immutably with all components.
Why
Arc<dyn Trait>?Extensions are stored as
Arc<dyn Trait>because multiple components need sharedaccess to the same instance. When an extension implements multiple traits, the same
Arcis cast to each trait—all lookups return the same underlying instance.Extension Lifecycle
Registration: Extensions are registered via
ExtensionFactoryusing thedistributed_slicepattern for automatic discovery.Creation: During pipeline initialization, the engine creates each extension
and collects their
ExtensionBundles.Registry Build: All bundles are combined into an immutable
ExtensionRegistry.Distribution: The registry is cloned to each component's effect handler.
Start: Extensions run their main loop (e.g., token refresh) until shutdown.
Consumption: Components call
effect_handler.get_extension()to accessextension capabilities.
Implementing an Extension
Example: Azure Identity Auth Extension
The
AzureIdentityAuthExtensionprovides Azure authentication tokens to exporters.Here's how it's structured:
1. Configuration (
config.rs)2. Extension Implementation (
extension.rs)3. Factory Registration (
mod.rs)4. Pipeline Configuration (YAML)
Consuming Extensions
Components access extensions through their effect handler:
Adding New Extension Traits
To add a new extension trait:
otap-df-engine/src/extensions/:mod.rs:mod.rs:Thread Safety
Extensions support two modes:
Local (
!Send): Extension runs on a single thread. Use when the extensionuses thread-local state or
!Sendtypes.Shared (
Send): Extension can be shared across threads. Required forextensions that need to run on the shared runtime.
The
ExtensionWrapperenum abstracts over both modes, and the extension registrystores
Arc<dyn Trait>references that are alwaysSend + Sync.Error Handling
Extension lookup can fail with:
ExtensionError::NotFound: No extension with that name existsExtensionError::TraitNotImplemented: Extension exists but doesn'timplement the requested trait
Components should handle these errors appropriately: