feat(otlp): add OTLP/JSON channel (@microsoft/applicationinsights-otlpchannel-js) - #2751
Draft
Jackson Weber (JacksonWeber) wants to merge 4 commits into
Draft
Conversation
…pchannel-js) Adds a new preview channel that converts Application Insights telemetry to OTLP/JSON in memory and exports it to an OTLP HTTP endpoint (/v1/traces and /v1/logs) with no @opentelemetry/* dependency. - Conversion and serialization happen on the processTelemetry path, with records buffered pre-grouped by resource and signal and incremental byte accounting, so flushing a batch performs no conversion work - RequestData / RemoteDependencyData / PageviewData export as spans; MessageData / ExceptionData / EventData / PageviewPerformanceData export as log records; native Common Schema OTelSpan items export as spans directly - Context tags are promoted onto the OTLP Resource, other values become record attributes namespaced under microsoft. - Values marked as PII or customer content are dropped by default (piiMode) - Implements getOfflineSupport() for use with the offline channel - Adds examples/otlp, a multi page test site running two isolated SDK instances per page against a local mock OTLP collector, runnable headlessly - Registers the package in rush.json, gruntfile.js, version.json, .aiAutoMinify.json and package_groups.json Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add Sender-equivalent sampling, compression, lifecycle notifications, retry controls, unload retry accounting, and idle-state reporting. Preserve retry attempts and original telemetry summaries across OTLP batching. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Add crash-safe session-storage recovery, offline-aware replay, UTF-8 batch limits, unload at-least-once semantics, redirect affinity, and Fetch retry header propagation. Remove the incompatible generic OfflineChannel example. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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
Adds
@microsoft/applicationinsights-otlpchannel-js(0.1.0), a preview browser channel that converts Application Insights telemetry to OTLP/JSON and exports it over OTLP/HTTP to/v1/tracesand/v1/logs.The channel is implemented as a production-capable replacement for the classic Sender's transferable behavior. It uses the SDK's existing core transport infrastructure and has no
@opentelemetry/*dependency.Telemetry mapping
baseTypeRequestDataRemoteDependencyDataInProcPageviewDataOTelSpanMessageDataExceptionDataexception.*attributes and chained exceptionsEventDataeventNamePageviewPerformanceDataMetricDataContext tags are promoted onto the OTLP
Resource. Remaining tags, Part A extensions, Part C data, custom properties, and measurements become record attributes; Application Insights-specific values use themicrosoft.namespace.Conversion and batching
processTelemetry, before the send path.isCompletelyIdle().1021and continues the plugin chain unlessconsumeEventsis enabled.Production durability
Includes Sender-equivalent integrated persistence rather than relying on the generic OfflineChannel contract:
namePrefix, storage enablement, and custombufferOverridechanges use destination-first migration and dual-write while requests are in flight.namePrefixand the classicIStorageBufferoverride contract are supported.getOfflineSupport()intentionally returnsnull: the generic OfflineChannel contract carries one endpoint per payload and cannot safely represent OTLP's separate trace and log envelopes. The invalid OfflineChannel custom-SKU example has been removed.Transport and reliability
Uses
SenderPostManagerand includes:httpXHROverridesupport.application/jsoncontent type or authentication headers.Retry-Aftersupport.499internal status) normalized as retryable failures.CompressionStream, also honoring the SDKzipPayloadfeature flag.eventsSendRequest,eventsSent,eventsRetry, andeventsDiscardedlifecycle notifications for SDK Stats/listeners.The shared
SenderPostManagerFetch path now forwards non-2xx response bodies and headers through its completion callback so channels can honor collectorRetry-Afterheaders.Privacy
OTLP has no equivalent of Common Schema PII/customer-content metadata.
piiModedefaults todrop; it can alternatively hash values or retain them with marker attributes for downstream scrubbing.The instrumentation key is excluded from the resource by default and can be included explicitly with
includeIKeyInResource.Example and protocol validation
Adds
examples/otlp, a multi-page test site with two isolated SDK instances per page and a local mock collector. It validates:AnyValuecorrectness and duplicate-key prevention.The example can also send through a real OpenTelemetry Collector so malformed payloads are rejected by the protocol implementation.
Tests
The OTLP suite contains 130 passing tests, including:
The shared AppInsightsCore suite contains 909 passing tests after the Fetch completion change.
Known protocol limitations
/v1/metrics) is not implemented;MetricDatais retained as logs.baseData.properties.Repository wiring
Registers the package in
rush.json,gruntfile.js,version.json,.aiAutoMinify.json,tools/release-tools/package_groups.json, andRELEASES.md.This remains a draft while protocol limitations and final package/release decisions are evaluated.