Skip to content

[Beta] Add startSpan, withSpan, Route Strategy#2647

Merged
MSNev merged 7 commits intobetafrom
MSNev/TraceStateBeta
Jan 23, 2026
Merged

[Beta] Add startSpan, withSpan, Route Strategy#2647
MSNev merged 7 commits intobetafrom
MSNev/TraceStateBeta

Conversation

@MSNev
Copy link
Collaborator

@MSNev MSNev commented Sep 18, 2025

  • Attribute Container with inheritance
  • Initial OTelAPI with span creation

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
  • 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

@MSNev MSNev added the keep Do not Mark as Stale and close label Sep 18, 2025
@MSNev MSNev force-pushed the MSNev/TraceStateBeta branch from f8bce57 to 4bd44b0 Compare September 22, 2025 19:26
@MSNev MSNev changed the title (Broken) [Draft][Beta] Add Route Strategy [Draft][Beta] Add startSpan, withSpan, Route Strategy Sep 22, 2025
@MSNev MSNev force-pushed the MSNev/TraceStateBeta branch from bc8e145 to e7b0b79 Compare September 22, 2025 22:55
@MSNev MSNev force-pushed the MSNev/TraceStateBeta branch 2 times, most recently from 1bf69c4 to 207affd Compare December 16, 2025 00:40
@MSNev MSNev force-pushed the MSNev/TraceStateBeta branch 4 times, most recently from c2f2008 to 5014727 Compare December 24, 2025 01:17
@MSNev MSNev force-pushed the MSNev/TraceStateBeta branch 7 times, most recently from 9f4ec24 to 549f782 Compare January 1, 2026 00:45
@MSNev MSNev force-pushed the MSNev/TraceStateBeta branch from 549f782 to 02e150e Compare January 10, 2026 01:02
@MSNev MSNev marked this pull request as ready for review January 10, 2026 01:29
@MSNev MSNev requested a review from a team as a code owner January 10, 2026 01:29
Copilot AI review requested due to automatic review settings January 10, 2026 01:29
@MSNev MSNev changed the title [Draft][Beta] Add startSpan, withSpan, Route Strategy [Beta] Add startSpan, withSpan, Route Strategy Jan 10, 2026
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

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

@MSNev MSNev force-pushed the MSNev/TraceStateBeta branch from 02e150e to eb870e6 Compare January 10, 2026 01:54
@MSNev MSNev force-pushed the MSNev/TraceStateBeta branch from eb870e6 to 07edc6a Compare January 10, 2026 02:00
MSNev added 5 commits January 20, 2026 14:43
- 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
- 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
Copy link

@JacksonWeber JacksonWeber left a comment

Choose a reason for hiding this comment

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

LGTM

@MSNev MSNev force-pushed the MSNev/TraceStateBeta branch from 07edc6a to b70946c Compare January 23, 2026 01:29
@MSNev MSNev requested review from JacksonWeber and Copilot January 23, 2026 01:29
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

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.

@MSNev MSNev force-pushed the MSNev/TraceStateBeta branch from b70946c to 4beb8d8 Compare January 23, 2026 01:53
- Merge in qunit browser test task from otel-sdk work
- Fix tests failing to run
@MSNev MSNev force-pushed the MSNev/TraceStateBeta branch from 4beb8d8 to 4777e29 Compare January 23, 2026 02:06
@MSNev MSNev added otel compat OpenTelemetry Compatibility support and removed keep Do not Mark as Stale and close labels Jan 23, 2026
@MSNev MSNev merged commit 5ec4d24 into beta Jan 23, 2026
9 checks passed
@MSNev MSNev deleted the MSNev/TraceStateBeta branch January 23, 2026 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

otel compat OpenTelemetry Compatibility support

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants