feat(otlp): add OTLP/JSON channel (@microsoft/applicationinsights-otlpchannel-js) - #2751
Draft
Jackson Weber (JacksonWeber) wants to merge 2 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>
| } | ||
|
|
||
| results.check(!seen[attr.key], path + " does not repeat the key '" + attr.key + "'"); | ||
| seen[attr.key] = true; |
| seen[attr.key] = true; | ||
|
|
||
| validateAnyValue(results, attr.value, attrPath + "(" + attr.key + ").value"); | ||
| map[attr.key] = attr.value; |
| const serviceName = resourceAttrs["service.name"] && resourceAttrs["service.name"].stringValue; | ||
| const marker = resourceAttrs["test.instance.marker"] && resourceAttrs["test.instance.marker"].stringValue; | ||
| if (serviceName) { | ||
| summary.services[serviceName] = (summary.services[serviceName] || 0) + 1; |
|
|
||
| if (isTrace) { | ||
| summary.spans++; | ||
| summary.spanNames[record.name] = (summary.spanNames[record.name] || 0) + 1; |
| const statusCode = record.status && typeof record.status.code !== "undefined" | ||
| ? record.status.code : 0; | ||
|
|
||
| summary.spanKinds[kind] = (summary.spanKinds[kind] || 0) + 1; |
| ? record.status.code : 0; | ||
|
|
||
| summary.spanKinds[kind] = (summary.spanKinds[kind] || 0) + 1; | ||
| summary.spanStatuses[statusCode] = (summary.spanStatuses[statusCode] || 0) + 1; |
| const telemetryType = attrs["microsoft.telemetry_type"] && | ||
| attrs["microsoft.telemetry_type"].stringValue; | ||
| if (telemetryType) { | ||
| summary.telemetryTypes[telemetryType] = (summary.telemetryTypes[telemetryType] || 0) + 1; |
|
|
||
| if (serviceName && recordMarker) { | ||
| const bucket = summary.markersByService[serviceName] || | ||
| (summary.markersByService[serviceName] = {}); |
| if (serviceName && recordMarker) { | ||
| const bucket = summary.markersByService[serviceName] || | ||
| (summary.markersByService[serviceName] = {}); | ||
| bucket[recordMarker] = (bucket[recordMarker] || 0) + 1; |
| "Content-Length": Buffer.byteLength(payload), | ||
| "Access-Control-Allow-Origin": "*" | ||
| }); | ||
| res.end(payload); |
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>
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 implementation is dependency-light: it uses the SDK's existing core transport infrastructure and does not depend on any
@opentelemetry/*package.Telemetry mapping
baseTypeRequestDataRemoteDependencyDataInProcPageviewDataOTelSpanMessageDataExceptionDataexception.*attributes and chained exceptionsEventDataeventNamePageviewPerformanceDataMetricDatametricsAsLogsis enabledContext tags are promoted onto the OTLP
Resource(service.name,service.instance.id,service.version, and related attributes). 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().1021, after the existing shipped channels, and continues the plugin chain unlessconsumeEventsis enabled.Transport and reliability
Uses the existing
SenderPostManagertransport stack and includes:httpXHROverridesupport.Retry-Aftersupport.CompressionStream, also honoring the SDKzipPayloadfeature flag.MetricDatais never sampled out.eventsSendRequest,eventsSent,eventsRetry, andeventsDiscardednotifications for SDK Stats and notification listeners.Privacy
OTLP does not have an equivalent of Common Schema PII/customer-content metadata.
piiModetherefore defaults 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.Configuration highlights
Configuration is supplied under the
OtlpChannelextension key. Major options include:pageViewAs,metricsAsLogs,piiMode, andsamplingPercentage.See
channels/otlp-channel-js/README.mdandIOtlpChannelConfigfor the complete configuration reference.Example and protocol validation
Adds
examples/otlp, a multi-page test site that runs two isolated SDK instances per page against a local mock OTLP collector. It supports manual and headless execution and 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 package includes unit coverage for:
The current OTLP channel suite contains 117 passing tests locally.
Known draft limitations
/v1/metrics) is not implemented;MetricDatacan currently be exported only as logs.baseData.properties.getOfflineSupport(), but the generic OfflineChannel persistence contract currently carries one payload URL and cannot correctly replay mixed/v1/tracesand/v1/logsbatches. Signal-aware persistent replay still needs follow-up work before offline durability parity is claimed.Repository wiring
Registers the new package in:
rush.jsongruntfile.jsversion.json.aiAutoMinify.jsontools/release-tools/package_groups.jsonRELEASES.mdThis PR remains draft while the limitations above and final package/release decisions are evaluated.