Skip to content

OTel Web SDK Phase 1#2715

Merged
hectorhdzg merged 6 commits intomicrosoft:otel-sdkfrom
hectorhdzg:hectorhdzg/phase1
Mar 19, 2026
Merged

OTel Web SDK Phase 1#2715
hectorhdzg merged 6 commits intomicrosoft:otel-sdkfrom
hectorhdzg:hectorhdzg/phase1

Conversation

@hectorhdzg
Copy link
Member

Phase 1: SDK Foundation (Critical)
Component Location Description
createOTelWebSdk() src/otel/sdk/ Main SDK entry point factory
IOTelWebSdkConfig src/interfaces/otel/config/ SDK configuration interface
Deprecate OTelSdk class src/otel/sdk/OTelSdk.ts Remove DynamicProto usage
Deliverable: Functional SDK that can be instantiated with trace+log providers.

@hectorhdzg hectorhdzg requested a review from a team as a code owner March 7, 2026 00:09
Copilot AI review requested due to automatic review settings March 7, 2026 00:09
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Implements the Phase 1 “SDK Foundation” for the OTel Web SDK by introducing a new factory-based createOTelWebSdk() entry point and associated interfaces, while removing the legacy OTelSdk dynamicProto-based class and wiring in unit tests.

Changes:

  • Added createOTelWebSdk() factory and new IOTelWebSdk / IOTelWebSdkConfig public interfaces.
  • Removed legacy OTelSdk + related interfaces/exports and updated shared/otel-core public exports accordingly.
  • Fixed createContext().setValue() to return a new context instance and added extensive unit coverage for the new SDK.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
shared/otel-core/src/utils/DataCacheHelper.ts Changes cache namespace versioning behavior (currently hardcodes a version string).
shared/otel-core/src/otel/sdk/OTelWebSdk.ts Adds the new SDK factory implementation (tracer + logger access, lifecycle APIs).
shared/otel-core/src/otel/sdk/OTelSdk.ts Removes the legacy dynamicProto-based SDK class.
shared/otel-core/src/otel/api/context/context.ts Fixes context immutability behavior for setValue().
shared/otel-core/src/interfaces/otel/trace/IOTelTracerCtx.ts Updates interface documentation wording.
shared/otel-core/src/interfaces/otel/config/IOTelWebSdkConfig.ts Introduces SDK configuration interface for dependency injection.
shared/otel-core/src/interfaces/otel/IOTelWebSdk.ts Introduces the main SDK interface (tracer/logger/lifecycle/config).
shared/otel-core/src/interfaces/otel/IOTelSdkCtx.ts Removes legacy SDK context interface.
shared/otel-core/src/interfaces/otel/IOTelSdk.ts Removes legacy SDK interface.
shared/otel-core/src/index.ts Updates public exports to expose the new SDK API and remove the old one.
shared/otel-core/Tests/Unit/src/sdk/OTelWebSdk.Tests.ts Adds unit tests covering construction, tracing, logging, flush/shutdown, and config.
shared/otel-core/Tests/Unit/src/index.tests.ts Registers the new OTelWebSdk test suite.

Comment on lines +109 to +111
if (!config.performanceNow) {
handleError(_handlers, "createOTelWebSdk: performanceNow must be provided");
}
Copy link

Copilot AI Mar 7, 2026

Choose a reason for hiding this comment

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

The code validates performanceNow as a required config dependency, but the value is never used anywhere in OTelWebSdk.ts. Either wire performanceNow into span/log timing (or wherever it’s intended to be used) or make it optional so consumers aren’t forced to pass a dead field.

Suggested change
if (!config.performanceNow) {
handleError(_handlers, "createOTelWebSdk: performanceNow must be provided");
}

Copilot uses AI. Check for mistakes.
hectorhdzg and others added 3 commits March 6, 2026 16:37
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
_self.forceFlush = function (): IPromise<void> {
if (_isShutdown) {
handleWarn(_handlers, "Cannot force flush a shutdown OTelWebSdk");
return createSyncPromise(function (resolve) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Small code improvement (minification) there is a createSyncResolvedPromise which does this already

let spanAttributes = attributes;
if (isRecording && samplingResult.attributes) {
// Merge: user attributes take precedence, sampler attributes fill gaps
spanAttributes = {};
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should use the AttributeContainer for this to avoid copying / enumerating all of the attributes unless needed.

let activeCtx = ctx || _getActiveContext();
let contextWithSpan = setContextSpan(activeCtx, span);

return _contextManager.with(contextWithSpan, function () {
Copy link
Collaborator

Choose a reason for hiding this comment

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

likewise this this we have "useSpan" and "withSpan" helpers for the same reason.

Copy link
Collaborator

@MSNev MSNev left a comment

Choose a reason for hiding this comment

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

There are some possible minor issues, but this is a good start for us to build upon and find the stuff we don't know yet :-)

@hectorhdzg hectorhdzg merged commit 95d6fec into microsoft:otel-sdk Mar 19, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants