Refactor ServerComponents into separate classes for OTEL instrumentations#67
Merged
Refactor ServerComponents into separate classes for OTEL instrumentations#67
Conversation
… can startup before other OTEL instrumentations are loaded
Zee2413
reviewed
Oct 13, 2025
Zee2413
reviewed
Oct 13, 2025
Zee2413
reviewed
Oct 13, 2025
Zee2413
reviewed
Oct 13, 2025
Zee2413
reviewed
Oct 13, 2025
Zee2413
reviewed
Oct 13, 2025
Zee2413
reviewed
Oct 13, 2025
Zee2413
reviewed
Oct 13, 2025
Zee2413
reviewed
Oct 13, 2025
Zee2413
approved these changes
Oct 13, 2025
Contributor
Zee2413
left a comment
There was a problem hiding this comment.
Approving large change. Comments should be addressed as necessary in quick followup.
kddejong
approved these changes
Oct 13, 2025
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.
High-Level Summary of PR #67
This PR refactors the monolithic ServerComponents class into a layered architecture with separate component classes to enable proper initialization order for the Telemetry SDK before other OpenTelemetry instrumentations load.
The Problem
OpenTelemetry (OTEL) instrumentations must be initialized before any application code loads. This is critical because:
The Root Cause
The old ServerComponents class created a circular dependency problem:
TelemetryService → ServerComponents → (all components) → LoggerFactory → TelemetryService
This meant:
• Telemetry couldn't start first because it needed ServerComponents
• ServerComponents imported everything, triggering all module loads
• By the time telemetry initialized, instrumentation targets were already loaded
Key Architectural Changes:
Component Separation (4 new classes)
• LspComponents - LSP protocol-level components (diagnostics, workspace, documents, communication, handlers)
• CfnInfraCore - Core infrastructure with no external dependencies (settings, document management, syntax trees, telemetry)
• CfnExternal - AWS services and external APIs (CloudFormation, CCAPI, schemas, linting)
• CfnLspProviders - Business logic and LSP feature providers (completion, hover, code actions, etc.)
Interface Refactoring
• Renamed Configurable → SettingsConfigurable for clarity
• Moved Closeable and Configurable interfaces to separate utility files (src/utils/Closeable.ts, src/utils/Configurable.ts)
• Added Configurables interface for components that contain multiple configurable sub-components
• Made Subscription generic: Subscription
Dependency Injection Improvements
• Components now explicitly declare dependencies through constructor parameters
• Removed static factory methods (.create()) in favor of direct instantiation
• Better separation of concerns with clear dependency flow: LSP → Core → External → Providers
Telemetry Initialization
• LoggerFactory and TelemetryService converted to proper singletons with lazy initialization
• Simplified ClientMessage (removed settings configuration, now just a thin wrapper)
• Enables telemetry SDK to start before other OTEL instrumentations
Widespread Updates (88 modified files)
• All components updated to use SettingsConfigurable instead of Configurable
• Removed unnecessary logger/clientMessage dependencies from many classes
• Updated test mocks to match new architecture
• Cleaned up imports and removed circular dependencies
Impact:
• Net deletion: -1221 lines removed, +929 added = 292 lines of code eliminated
• Better testability through explicit dependencies
• Clearer component lifecycle management
• Proper telemetry initialization order for OpenTelemetry instrumentation