Skip to content

feat(tracing): upgrade to Otel 2.0+#3863

Open
MichaelDoyle wants to merge 1 commit intomainfrom
otel-two
Open

feat(tracing): upgrade to Otel 2.0+#3863
MichaelDoyle wants to merge 1 commit intomainfrom
otel-two

Conversation

@MichaelDoyle
Copy link
Copy Markdown
Contributor

@MichaelDoyle MichaelDoyle commented Nov 27, 2025

BREAKING CHANGE: upgrade to Otel 2.0+

Key Changes:

  1. Core Telemetry Fixes (js/core)

    • Initialization Race Condition: Updated enableTelemetry in tracing.ts to correctly store and await the actual initialization promise. This prevents spans from being created before the SDK is fully ready.
    • Improved Test Reliability: Added await flushTracing() to beforeEach and relevant test cases in action_test.ts and flow_test.ts. This ensures all asynchronously emitted spans are captured before assertions are made.
    • Version-Agnostic Span Processing: Implemented a MultiSpanProcessor in node-telemetry-provider.ts to reliably handle multiple span processors across different OpenTelemetry versions.
    • SDK Re-initialization: Refined the enableTelemetry logic to properly shut down existing SDK instances before re-initializing, avoiding duplicate instrumentation and resource leaks.
  2. OpenTelemetry 2.0 Compatibility (js/plugins/google-cloud)

    • Traces Test: Updated traces_test.ts to use parentSpanContext?.spanId instead of the deprecated parentSpanId property, which was removed in OTel 2.0.
    • Metrics Test:
      • Updated metrics_test.ts to use the InstrumentType enum for metric type comparisons.
      • Addressed the removal of the type property from the MetricDescriptor interface.

Checklist (if applicable):

AIM

image

Dev UI

image

@MichaelDoyle
Copy link
Copy Markdown
Contributor Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request upgrades OpenTelemetry dependencies to version 2.0 across the core and Google Cloud plugin packages. Key changes include the introduction of a MultiSpanProcessor to multiplex span processors, updates to exporters and resource detection to align with OTel 2.0 API changes (e.g., using instrumentationScope and parentSpanContext), and refined data point time handling for GCP metrics. Feedback focuses on improving the robustness of the MultiSpanProcessor through error handling and better typing, ensuring isolation when modifying shared HrTime objects in metric exporters, and avoiding side effects by cloning configuration objects.

@github-actions github-actions bot added the config label Apr 1, 2026
@MichaelDoyle MichaelDoyle force-pushed the otel-two branch 11 times, most recently from 98a2e4f to e2ee1b7 Compare April 1, 2026 20:50
@MichaelDoyle
Copy link
Copy Markdown
Contributor Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request upgrades OpenTelemetry dependencies to version 2.x and refactors the telemetry provider to support multiple span processors and metric readers. It also improves the reliability of the shutdown sequence and updates the Google Cloud plugin to accommodate OTel API changes. Review feedback suggests consistently using the default logger during shutdown to ensure logs are captured and to prevent potential recursion issues.

@MichaelDoyle MichaelDoyle changed the title fix(tracing): upgrade to Otel 2.0+ feat(tracing): upgrade to Otel 2.0+ Apr 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant