[Beta] Add startSpan, withSpan, Route Strategy#2647
Merged
Conversation
shared/AppInsightsCore/src/OpenTelemetry/attribute/attributeContainer.ts
Fixed
Show fixed
Hide fixed
shared/AppInsightsCore/src/OpenTelemetry/interfaces/config/IOTelTraceCfg.ts
Fixed
Show fixed
Hide fixed
f8bce57 to
4bd44b0
Compare
bc8e145 to
e7b0b79
Compare
MSNev
commented
Sep 22, 2025
e7b0b79 to
0d494ec
Compare
1bf69c4 to
207affd
Compare
c2f2008 to
5014727
Compare
9f4ec24 to
549f782
Compare
549f782 to
02e150e
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This draft PR adds OpenTelemetry-compatible tracing API support to the Application Insights JavaScript SDK, including span creation, route strategy, and attribute containers with inheritance.
Changes:
- Adds comprehensive OpenTelemetry tracing API documentation
- Implements span creation helpers (
startSpan,withSpan,useSpan) - Adds route strategy and attribute container functionality
- Refactors sampling logic to use factory functions
- Introduces Request telemetry type support
Reviewed changes
Copilot reviewed 53 out of 182 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| docs/OTel/otelApi.md | Complete API reference for OpenTelemetry functionality |
| docs/OTel/examples.md | Comprehensive examples and usage patterns |
| docs/OTel/README.md | Overview and quick start guide |
| common/Tests/Framework/src/Assert.ts | Adds doesNotThrow helper method |
| common/Tests/Framework/src/AITestClass.ts | Adds storage clearing methods for tests |
| channels/.../SamplingScoreGenerator.ts | Refactors to factory pattern |
| channels/.../HashCodeScoreGenerator.ts | Converts class to standalone function |
| channels/.../Sample.ts | Refactors to factory function pattern |
| channels/.../RequestData.ts | New file for Request telemetry data |
| channels/.../RemoteDependencyData.ts | New file for dependency telemetry |
| channels/.../Data.ts | Helper for creating data structures |
| channels/.../Serializer.ts | Refactors serialization logic |
| channels/.../Sender.ts | Updates for new telemetry types |
| channels/.../IRequestData.ts | Interface for Request telemetry |
| channels/.../EnvelopeCreator.ts | Adds Request envelope creator |
| channels/.../Sender.tests.ts | Updates test data type references |
| channels/.../Sample.tests.ts | Updates for refactored sampling |
| README.md | Adds OpenTelemetry section |
| AISKULight/src/index.ts | Adds IRequestTelemetry export |
| AISKULight/Tests/.../otelNegative.tests.ts | Negative tests for OTel without provider |
| AISKULight/Tests/.../aiskuliteunittests.ts | Registers new test suite |
| AISKULight/Tests/.../AISKULightSize.Tests.ts | Updates size thresholds |
| AISKU/src/internal/trace/spanUtils.ts | Core span utilities and telemetry conversion |
| AISKU/src/applicationinsights-web.ts | Exports OTel interfaces |
| AISKU/src/InternalConstants.ts | Adds UNDEFINED_VALUE constant |
| AISKU/src/Init.ts | Exports IRequestTelemetry |
| AISKU/src/IApplicationInsights.ts | Extends interface with OTel APIs |
| AISKU/src/AISku.ts | Implements OTel API initialization |
| AISKU/examples/span-usage-example.ts | Example of span usage |
| AISKU/Tests/.../applicationinsights.e2e.tests.ts | E2E tests for CDN and data types |
| AISKU/Tests/.../aiskuunittests.ts | Registers new OTel test suites |
| AISKU/Tests/.../WithSpan.Tests.ts | Comprehensive withSpan tests |
| AISKU/Tests/.../UseSpan.Tests.ts | Comprehensive useSpan tests |
| AISKU/Tests/.../TraceSuppression.Tests.ts | Tests for trace suppression |
| AISKU/Tests/.../OTelInit.Tests.ts | OTel initialization tests |
| AISKU/Tests/.../AISKUSize.Tests.ts | Updates size thresholds |
Files not reviewed (1)
- common/config/rush/npm-shrinkwrap.json: Language not supported
Comments suppressed due to low confidence (1)
docs/OTel/examples.md:1
- Corrected spelling of 'Semabtic' to 'Semantic'
# OpenTelemetry Examples and Patterns
02e150e to
eb870e6
Compare
eb870e6 to
07edc6a
Compare
hectorhdzg
reviewed
Jan 16, 2026
hectorhdzg
reviewed
Jan 16, 2026
hectorhdzg
reviewed
Jan 16, 2026
hectorhdzg
reviewed
Jan 16, 2026
- Attribute Container with inheritance - Initial OTelAPI with span creation - Prior to Removing IOTelContext, IOTelContextManager and IOTelSpanContext
Change API Surface - Use IReadableSpan instead of IOTelSpan Removed - IOTelSpanContext (use IDistributedTraceContext instead) - IOTelLink - IOTelContext - IOTelContextManager Renamed - IOTelTraceCfg -> ITraceCfg - IOTelTraceApi -> ITraceApi Changed - IReadableSpan - removed droppedEventCount - removed droppedLinksCount - changed spanContext, parentSpanContext return IDistributedTraceContext instead - ITraceApi - add getActiveSpan, setActiveSpan - IOTelApi - removed context (IOTelContextManager) - ITraceCfg - added suppressTracing config
…nclude in the build
- add additional tests - Changed to only create OTel SDK after initialization - Negative tests - Refactor to use ITraceHost instead of core - Add URL redaction - Additional tests - Remove truncation - Change how OTel is lazily initialized and used - Add 1ds MsWebSpan creation
07edc6a to
b70946c
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 53 out of 186 changed files in this pull request and generated 20 comments.
Files not reviewed (1)
- common/config/rush/npm-shrinkwrap.json: Language not supported
Comments suppressed due to low confidence (2)
AISKU/src/internal/trace/spanUtils.ts:1
- Optional chaining (
?.) is used here. This repo targets ES5 and the project guidelines call out avoiding optional chaining to reduce output size / maintain compatibility expectations. Consider rewriting these checks using&&(e.g.if (span.parentSpanContext && span.parentSpanContext.spanId) { ... }).
// Copyright (c) Microsoft Corporation.
AISKU/src/internal/trace/spanUtils.ts:1
- Optional chaining (
?.) is used here. This repo targets ES5 and the project guidelines call out avoiding optional chaining to reduce output size / maintain compatibility expectations. Consider rewriting these checks using&&(e.g.if (span.parentSpanContext && span.parentSpanContext.spanId) { ... }).
// Copyright (c) Microsoft Corporation.
channels/applicationinsights-channel-js/src/TelemetryProcessors/Sample.ts
Show resolved
Hide resolved
b70946c to
4beb8d8
Compare
- Merge in qunit browser test task from otel-sdk work - Fix tests failing to run
4beb8d8 to
4777e29
Compare
JacksonWeber
approved these changes
Jan 23, 2026
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.
Change API Surface
Removed
Renamed
Changed
IReadableSpan
ITraceApi
IOTelApi
ITraceCfg
add additional tests
Changed to only create OTel SDK after initialization
Negative tests
Refactor to use ITraceHost instead of core
Add URL redaction
Additional tests
Remove truncation
Change how OTel is lazily initialized and used
Add 1ds MsWebSpan creation