-
Notifications
You must be signed in to change notification settings - Fork 256
Open
Description
When using trackDependencyData with W3C distributed tracing mode, the SDK blindly appends a trailing period to any id that doesn't already end with one. This breaks correlation when passing a plain W3C spanId.
Current behavior ajax.ts
// Hack since expected format in w3c mode is |abc.def.
// Non-w3c format is |abc.def
// @todo Remove if better solution is available, e.g. handle in portal
if (dependency.id[dependency.id.length - 1] !== ".") {
dependency.id += ".";
}The code only checks if the last character is a period, not whether the ID is actually in the expected |{traceId}.{spanId} format.
Problem
When manually tracking dependencies with trackDependencyData using a plain W3C spanId:
- Input:
id: "861bce51737e3ba6"(16-char hex spanId) - Result:
"861bce51737e3ba6."(spanId with trailing period)
This doesn't match the server-side parent_id (which is the plain spanId from the W3C traceparent header), breaking parent-child correlation in the waterfall view.
Expected behavior
The SDK should only append a period if the ID matches the legacy |{traceId}.{spanId} format:
const legacyIdPattern = /^\|[a-f0-9]+\.[a-f0-9]+$/i;
if (legacyIdPattern.test(dependency.id)) {
dependency.id += ".";
}This would:
|abc123.def456→|abc123.def456.(legacy format, add period)861bce51737e3ba6→861bce51737e3ba6(plain spanId, leave alone)
Reproduction
appInsights.trackDependencyData({
id: "861bce51737e3ba6", // plain W3C spanId
name: "GET /api/user",
duration: 100,
success: true,
responseCode: 200,
type: "HTTP",
target: "api.example.com"
});
// Results in id: "861bce51737e3ba6." which doesn't correlate with server parent_idEnvironment
- SDK version: latest
- distributedTracingMode: W3C
Related
- PR fix w3c correlation #1213 introduced this behavior
- Issue Id format changes in W3C mode #1136 discussed ID format changes
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels