feat(otlp): add OTLP/JSON channel (@microsoft/applicationinsights-otlpchannel-js) - #2751
Draft
JacksonWeber wants to merge 1 commit into
Draft
feat(otlp): add OTLP/JSON channel (@microsoft/applicationinsights-otlpchannel-js)#2751JacksonWeber wants to merge 1 commit into
JacksonWeber wants to merge 1 commit into
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); |
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 new preview channel that converts Application Insights telemetry to OTLP/JSON in memory and exports it to an OpenTelemetry Protocol (OTLP) HTTP endpoint (/v1/tracesand/v1/logs). It requires no@opentelemetry/*dependency and can be used on its own or alongside the existing sender, which forwards every item along the chain (the tee channel is only needed when the channels must be in separate queues).Details
processTelemetryas they are received, and records are buffered pre-grouped by resource and signal with incremental byte accounting, so sending a batch performs no conversion work. This keeps the page unload path as fast as possible.RequestData/RemoteDependencyData/PageviewDataare exported as spans, andMessageData/ExceptionData/EventData/PageviewPerformanceDataas log records. Native Common Schema spans (OTelSpan) are exported as spans directly, preserving their kind, parent, trace state and status.Resource; everything else becomes record attributes, with Application Insights specific values namespaced undermicrosoft..piiMode), since OTLP has no equivalent marker.getOfflineSupport()so it can be combined with@microsoft/applicationinsights-offlinechannel-js.Example / validation
Adds
examples/otlp, a multi page test site that runs two independent SDK instances per page against a local mock OTLP collector. It can be driven manually or run headlessly (npm test), and validates the OTLP envelope, resource attributes, span/log field validity, nanosecond timestamp precision, attribute well-formedness, and that the two instances stay fully isolated from each other. The collector config can optionally round-trip payloads through a real OpenTelemetry Collector so malformed data is rejected by the real protocol implementation rather than quietly accepted.Repo wiring
Registers the package in
rush.json,gruntfile.js,version.json,.aiAutoMinify.jsonandtools/release-tools/package_groups.json, and adds anRELEASES.mdentry under Unreleased Changes.Unit tests
New unit tests under
channels/otlp-channel-js/Tests/Unitcover the channel lifecycle and config, channel chaining, item conversion, OTLP fidelity (including PII drop/hash modes) and nanosecond time utilities.