fix(instrumentation): open telemetry init#1426
Merged
icecrasher321 merged 1 commit intostagingfrom Sep 23, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Greptile Overview
Summary
This PR simplifies the OpenTelemetry initialization by removing the custom BatchSpanProcessor configuration and switching to the NodeSDK's built-in traceExporter approach. The change reduces complexity while maintaining the same telemetry functionality.
Key Changes:
- Removed manual
BatchSpanProcessorcreation and custom batch settings configuration - Simplified
NodeSDKinitialization to usetraceExporterdirectly instead ofspanProcessors - Eliminated dependency on
@opentelemetry/sdk-trace-nodeimport
Minor Issues Found:
- Batch settings in both config files are now unused and could be removed for cleaner configuration
Confidence Score: 4/5
- This PR is safe to merge with minimal risk - it simplifies code without introducing functional changes
- The changes are straightforward simplifications that maintain the same OpenTelemetry functionality while reducing complexity. The only minor issue is unused configuration options that don't affect runtime behavior.
- No files require special attention - the changes are simple refactoring
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| apps/sim/instrumentation-node.ts | 4/5 | Simplified OpenTelemetry initialization by removing custom BatchSpanProcessor and using NodeSDK's built-in trace exporter |
Sequence Diagram
sequenceDiagram
participant App as Application
participant Reg as register()
participant Sentry as Sentry Init
participant OTel as OpenTelemetry Init
participant SDK as NodeSDK
participant Exporter as OTLPTraceExporter
App->>Reg: Call register()
Reg->>Sentry: await initializeSentry()
Sentry-->>Reg: Sentry initialized (prod only)
Reg->>OTel: await initializeOpenTelemetry()
OTel->>OTel: Check NEXT_TELEMETRY_DISABLED
alt Telemetry disabled
OTel-->>Reg: Early return
else Telemetry enabled
OTel->>OTel: Dynamic import telemetry.config.ts
OTel->>OTel: Check serverSide.enabled
alt Server-side disabled
OTel-->>Reg: Early return
else Server-side enabled
OTel->>OTel: Import OpenTelemetry modules
OTel->>Exporter: Create OTLPTraceExporter
OTel->>SDK: Create NodeSDK with traceExporter
OTel->>SDK: sdk.start()
SDK-->>OTel: SDK started
OTel->>OTel: Setup shutdown handlers (SIGTERM, SIGINT)
OTel-->>Reg: Initialization complete
end
end
Reg-->>App: Registration complete
1 file reviewed, 2 comments
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.
Summary
Fix failing build on staging.
Type of Change