otlpJsonDecode.ts ×9

Frontier kind: Code frontier

unlabeled · c_f935f41fa1a7

20 tests · 3623 LOC · 21 files · introduces 0 tests · 199 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
10 ranges199 lines · 2 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
492 ranges3623 lines · 21 files · Browse complete extent
All tests (intent)
20 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Introduced files, introduced tests, and structurally relevant concept specializationlocalOtlpReceiver.ts ×1 · 2 introduced LOClocalOtlpReceiver.ts ×1localOtlpReceiver.ts ×2 · 4 introduced LOClocalOtlpReceiver.ts ×2localOtlpReceiver.ts ×1 · 1 introduced LOClocalOtlpReceiver.ts ×1localOtlpReceiver.ts ×1 · 1 introduced LOClocalOtlpReceiver.ts ×1localOtlpReceiver.ts ×2 · 7 introduced LOClocalOtlpReceiver.ts ×2localOtlpReceiver.ts ×1 · 3 introduced LOClocalOtlpReceiver.ts ×1localOtlpReceiver.ts ×3 · 9 introduced LOClocalOtlpReceiver.ts ×3localOtlpReceiver.ts ×4 · 14 introduced LOClocalOtlpReceiver.ts ×4localOtlpReceiver.ts ×5 · 25 introduced LOClocalOtlpReceiver.ts ×5localOtlpReceiver.ts ×1 · 4 introduced LOClocalOtlpReceiver.ts ×1localOtlpReceiver.ts ×1 · 3 introduced LOClocalOtlpReceiver.ts ×1localOtlpReceiver.ts ×1 · 1 introduced LOClocalOtlpReceiver.ts ×1localOtlpReceiver.ts ×1 · 4 introduced LOClocalOtlpReceiver.ts ×1localOtlpReceiver.ts ×1 · 1 introduced LOClocalOtlpReceiver.ts ×1localOtlpReceiver.ts ×1 · 3 introduced LOClocalOtlpReceiver.ts ×1localOtlpReceiver.ts ×1 · 5 introduced LOClocalOtlpReceiver.ts ×1localOtlpReceiver.ts ×1 · 1 introduced LOClocalOtlpReceiver.ts ×1localOtlpReceiver.ts ×6 · 21 introduced LOClocalOtlpReceiver.ts ×6localOtlpReceiver.ts ×6 · 100 introduced LOClocalOtlpReceiver.ts ×6otlpJsonDecode.ts ×8 · 26 introduced LOCotlpJsonDecode.ts ×8otlpJsonDecode.ts ×2 · 11 introduced LOCotlpJsonDecode.ts ×2otlpJsonDecode.ts ×3 · 11 introduced LOCotlpJsonDecode.ts ×3otel - otlpJsonDecode span-level attribute overrides resource attribute on collision|occurrence=1 · 0 introduced LOCotel - otlpJsonDecode sp…otlpJsonDecode.ts ×1 · 5 introduced LOCotlpJsonDecode.ts ×1otlpJsonDecode.ts ×3 · 6 introduced LOCotlpJsonDecode.ts ×3otlpJsonDecode.ts ×7 · 16 introduced LOCotlpJsonDecode.ts ×7 all-zero parent|occurrence=1 · 0 introduced LOC all-zero parent|occurre…otlpJsonDecode.ts ×1 · 1 introduced LOCotlpJsonDecode.ts ×1otel - otlpJsonDecode treats time stringified as decimal nanos and floors to ms|occurrence=1 · 0 introduced LOCotel - otlpJsonDecode tr…otlpJsonDecode.ts ×1 · 1 introduced LOCotlpJsonDecode.ts ×1otlpJsonDecode.ts ×1 · 5 introduced LOCotlpJsonDecode.ts ×1otlpJsonDecode.ts ×12 · 29 introduced LOCotlpJsonDecode.ts ×12otlpJsonDecode.ts ×2 · 5 introduced LOCotlpJsonDecode.ts ×2otlpJsonDecode.ts ×1 · 2 introduced LOCotlpJsonDecode.ts ×1otlpJsonDecode.ts ×14 · 43 introduced LOCotlpJsonDecode.ts ×14otlpJsonDecode.ts ×1 · 2 introduced LOCotlpJsonDecode.ts ×1otlpJsonDecode.ts ×3 · 10 introduced LOCotlpJsonDecode.ts ×3spanData.ts ×1 · 44 introduced LOCspanData.ts ×1uri.test|title=URI URI#file, win-speciale|occurrence=1, charCode.test|title=CharCode has good values|occurrence=1, +2 · 0 introduced LOCuri.test|title=URI URI#f…utils.ts ×3 · 9 introduced LOCutils.ts ×3lifecycle.ts ×2 · 4 introduced LOClifecycle.ts ×2lifecycle.ts ×1 · 2 introduced LOClifecycle.ts ×1lifecycle.ts ×4 · 8 introduced LOClifecycle.ts ×4lifecycle.ts ×6 · 16 introduced LOClifecycle.ts ×6lifecycle.ts ×1 · 2 introduced LOClifecycle.ts ×1lifecycle.ts ×1 · 2 introduced LOClifecycle.ts ×1lifecycle.ts ×1 · 3 introduced LOClifecycle.ts ×1map.ts ×97 · 3334 introduced LOCmap.ts ×97src/vs/base/common/arrays.ts · 949 LOCcommon/arrays.tssrc/vs/base/common/arraysFind.ts · 226 LOCcommon/arraysFind.tssrc/vs/base/common/assert.ts · 91 LOCcommon/assert.tssrc/vs/base/common/charCode.ts · 450 LOCcommon/charCode.tssrc/vs/base/common/collections.ts · 176 LOCcommon/collections.tssrc/vs/base/common/errors.ts · 357 LOCcommon/errors.tssrc/vs/base/common/functional.ts · 32 LOCcommon/functional.tssrc/vs/base/common/iterator.ts · 194 LOCcommon/iterator.tssrc/vs/base/common/lifecycle.ts · 974 LOCcommon/lifecycle.tssrc/vs/base/common/map.ts · 1016 LOCcommon/map.tssrc/vs/base/common/marshallingIds.ts · 33 LOCcommon/marshallingIds.tssrc/vs/base/common/path.ts · 1589 LOCcommon/path.tssrc/vs/base/common/platform.ts · 281 LOCcommon/platform.tssrc/vs/base/common/process.ts · 76 LOCcommon/process.tssrc/vs/base/common/types.ts · 410 LOCcommon/types.tssrc/vs/base/common/uri.ts · 754 LOCcommon/uri.tssrc/vs/base/test/common/utils.ts · 107 LOCcommon/utils.tssrc/vs/nls.ts · 244 LOCvs/nls.tssrc/vs/platform/otel/common/spanData.ts · 44 LOCcommon/spanData.tssrc/vs/platform/otel/node/otlp/localOtlpReceiver.ts · 227 LOCotlp/localOtlpReceiver.t…src/vs/platform/otel/node/otlp/otlpJsonDecode.ts · 245 LOCotlp/otlpJsonDecode.tssrc/vs/platform/otel/node/otlp/otlpJsonTypes.ts · 148 LOCotlp/otlpJsonTypes.tscharCode.test|title=CharCode has good values|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/charCode.test|title=CharCode has good values|occurrence=1charCode.test|title=Char…path.test|title=Paths (Node Implementation) path|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/path.test|title=Paths (Node Implementation) path|occurrence=1path.test|title=Paths (N…uri.test|title=URI File paths containing apostrophes break URI parsing and cannot be opened #276075|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/uri.test|title=URI File paths containing apostrophes break URI parsing and cannot be opened #276075|occurrence=1uri.test|title=URI File …uri.test|title=URI URI#file, win-speciale|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/uri.test|title=URI URI#file, win-speciale|occurrence=1uri.test|title=URI URI#f…otel - localOtlpHttpReceiver accepts a valid OTLP-JSON payload and delivers decoded spans|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/otel/test/node/otlp/localOtlpReceiver.test|title=platform/otel - localOtlpHttpReceiver accepts a valid OTLP-JSON payload and delivers decoded spans|occurrence=1otel - localOtlpHttpRece…otel - localOtlpHttpReceiver binds to 127.0.0.1 on an ephemeral port|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/otel/test/node/otlp/localOtlpReceiver.test|title=platform/otel - localOtlpHttpReceiver binds to 127.0.0.1 on an ephemeral port|occurrence=1otel - localOtlpHttpRece…otel - localOtlpHttpReceiver forwards raw body to onForward callback unchanged|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/otel/test/node/otlp/localOtlpReceiver.test|title=platform/otel - localOtlpHttpReceiver forwards raw body to onForward callback unchanged|occurrence=1otel - localOtlpHttpRece…otel - localOtlpHttpReceiver rejects non-JSON content-type with 415|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/otel/test/node/otlp/localOtlpReceiver.test|title=platform/otel - localOtlpHttpReceiver rejects non-JSON content-type with 415|occurrence=1otel - localOtlpHttpRece…otel - localOtlpHttpReceiver rejects non-identity content-encoding with 415|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/otel/test/node/otlp/localOtlpReceiver.test|title=platform/otel - localOtlpHttpReceiver rejects non-identity content-encoding with 415|occurrence=1otel - localOtlpHttpRece…otel - localOtlpHttpReceiver returns 400 for invalid JSON|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/otel/test/node/otlp/localOtlpReceiver.test|title=platform/otel - localOtlpHttpReceiver returns 400 for invalid JSON|occurrence=1otel - localOtlpHttpRece…otel - localOtlpHttpReceiver returns 404 for unknown paths|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/otel/test/node/otlp/localOtlpReceiver.test|title=platform/otel - localOtlpHttpReceiver returns 404 for unknown paths|occurrence=1otel - localOtlpHttpRece…otel - localOtlpHttpReceiver returns 405 for non-POST|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/otel/test/node/otlp/localOtlpReceiver.test|title=platform/otel - localOtlpHttpReceiver returns 405 for non-POST|occurrence=1otel - localOtlpHttpRece…otel - localOtlpHttpReceiver returns 413 when body exceeds maxBodyBytes|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/otel/test/node/otlp/localOtlpReceiver.test|title=platform/otel - localOtlpHttpReceiver returns 413 when body exceeds maxBodyBytes|occurrence=1otel - localOtlpHttpRece…otel - localOtlpHttpReceiver returns partial_success when some spans are rejected|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/otel/test/node/otlp/localOtlpReceiver.test|title=platform/otel - localOtlpHttpReceiver returns partial_success when some spans are rejected|occurrence=1otel - localOtlpHttpRece…otel - localOtlpHttpReceiver still responds 200 even if onForward throws|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/otel/test/node/otlp/localOtlpReceiver.test|title=platform/otel - localOtlpHttpReceiver still responds 200 even if onForward throws|occurrence=1otel - localOtlpHttpRece…otel - otlpJsonDecode decodes a complete chat span with all attribute types and resource merge|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/otel/test/node/otlp/otlpJsonDecode.test|title=platform/otel - otlpJsonDecode decodes a complete chat span with all attribute types and resource merge|occurrence=1otel - otlpJsonDecode de… nested attribute arrays and kvlistValue|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/otel/test/node/otlp/otlpJsonDecode.test|title=platform/otel - otlpJsonDecode falls back to JSON for mixed-type / nested attribute arrays and kvlistValue|occurrence=1 nested attribute arrays…otel - otlpJsonDecode handles an empty request|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/otel/test/node/otlp/otlpJsonDecode.test|title=platform/otel - otlpJsonDecode handles an empty request|occurrence=1otel - otlpJsonDecode ha…otel - otlpJsonDecode maps status codes: ERROR → ERROR, missing → UNSET|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/otel/test/node/otlp/otlpJsonDecode.test|title=platform/otel - otlpJsonDecode maps status codes: ERROR → ERROR, missing → UNSET|occurrence=1otel - otlpJsonDecode ma… all-zero parent|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/otel/test/node/otlp/otlpJsonDecode.test|title=platform/otel - otlpJsonDecode preserves parent span id; drops empty / all-zero parent|occurrence=1 all-zero parent|occurre… missing times|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/otel/test/node/otlp/otlpJsonDecode.test|title=platform/otel - otlpJsonDecode rejects spans with invalid trace_id / span_id / missing times|occurrence=1 missing times|occurrenc…otel - otlpJsonDecode returns errors[] when an exception is thrown for a span|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/otel/test/node/otlp/otlpJsonDecode.test|title=platform/otel - otlpJsonDecode returns errors[] when an exception is thrown for a span|occurrence=1otel - otlpJsonDecode re…otel - otlpJsonDecode span-level attribute overrides resource attribute on collision|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/otel/test/node/otlp/otlpJsonDecode.test|title=platform/otel - otlpJsonDecode span-level attribute overrides resource attribute on collision|occurrence=1otel - otlpJsonDecode sp…otel - otlpJsonDecode treats time stringified as decimal nanos and floors to ms|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/otel/test/node/otlp/otlpJsonDecode.test|title=platform/otel - otlpJsonDecode treats time stringified as decimal nanos and floors to ms|occurrence=1otel - otlpJsonDecode tr…Focused concept · otlpJsonDecode.ts ×9 · 199 introduced LOCotlpJsonDecode.ts ×9

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

2 files ranked by introduced lines: 199 introduced LOC across 10 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/otel/node/otlp/otlpJsonTypes.ts 148 introduced LOC · 1 range

Open complete file

1 > /*--------------------------------------------------------------------------------------------- otlpJsonTypes.ts
2 > * Copyright (c) Microsoft Corporation. All rights reserved.
3 > * Licensed under the MIT License. See License.txt in the project root for license information.
4 > *--------------------------------------------------------------------------------------------*/
5 >
6 > /**
7 > * Minimal OTLP/HTTP JSON wire types for the trace export request body.
8 > *
9 > * Reference:
10 > * - opentelemetry-proto/opentelemetry/proto/trace/v1/trace.proto
11 > * - opentelemetry-proto/opentelemetry/proto/common/v1/common.proto
12 > * - opentelemetry-proto/opentelemetry/proto/resource/v1/resource.proto
13 > * - opentelemetry-proto/docs/specification.md#json-protobuf-encoding
14 > *
15 > * JSON encoding rules used here:
16 > * - field names are camelCase (NOT snake_case)
17 > * - `traceId`/`spanId`/`parentSpanId` are lower-hex strings
18 > * (32 hex chars / 16 hex chars; parentSpanId may be empty)
19 > * - `startTimeUnixNano`/`endTimeUnixNano`/`timeUnixNano` are stringified
20 > * unsigned 64-bit decimal integers (string fits int64 without precision loss)
21 > * - `intValue` on AnyValue is a stringified int64; other numeric fields are JSON numbers
22 > * - bytesValue is base64-encoded
23 > * - all fields are technically optional in proto3; producers MAY omit defaults
24 > *
25 > * Only the subset of fields we currently consume is modeled here. Unknown
26 > * fields are ignored by the decoder (forwards-compatible).
27 > */
28 >
29 >
30 > /** Status code as defined by the OTLP trace status enum. */
31 > export const enum OtlpStatusCode {
32 > UNSET = 0,
33 > OK = 1,
34 > ERROR = 2,
35 > }
36 >
37 > /** Span kind as defined by the OTLP trace span_kind enum. */
38 > export const enum OtlpSpanKind {
39 > UNSPECIFIED = 0,
40 > INTERNAL = 1,
41 > SERVER = 2,
42 > CLIENT = 3,
43 > PRODUCER = 4,
44 > CONSUMER = 5,
45 > }
46 >
47 > /**
48 > * A single attribute value. Exactly one of the optional fields is set, except
49 > * for empty values which may be entirely absent (proto3 defaults).
50 > */
51 > export interface IOtlpAnyValue {
52 > readonly stringValue?: string;
53 > readonly boolValue?: boolean;
54 > /** Stringified int64. */
55 > readonly intValue?: string | number;
56 > readonly doubleValue?: number;
57 > readonly arrayValue?: { readonly values?: readonly IOtlpAnyValue[] };
58 > readonly kvlistValue?: { readonly values?: readonly IOtlpKeyValue[] };
59 > /** Base64-encoded bytes. */
60 > readonly bytesValue?: string;
61 > }
62 >
63 > export interface IOtlpKeyValue {
64 > readonly key: string;
65 > readonly value?: IOtlpAnyValue;
66 > }
67 >
68 > export interface IOtlpStatus {
69 > readonly code?: OtlpStatusCode;
70 > readonly message?: string;
71 > }
72 >
73 > export interface IOtlpEvent {
74 > readonly timeUnixNano?: string;
75 > readonly name?: string;
76 > readonly attributes?: readonly IOtlpKeyValue[];
77 > readonly droppedAttributesCount?: number;
78 > }
79 >
80 > export interface IOtlpLink {
81 > readonly traceId?: string;
82 > readonly spanId?: string;
83 > readonly traceState?: string;
84 > readonly attributes?: readonly IOtlpKeyValue[];
85 > readonly droppedAttributesCount?: number;
86 > readonly flags?: number;
87 > }
88 >
89 > export interface IOtlpSpan {
90 > readonly traceId: string;
91 > readonly spanId: string;
92 > readonly traceState?: string;
93 > readonly parentSpanId?: string;
94 > readonly flags?: number;
95 > readonly name?: string;
96 > readonly kind?: OtlpSpanKind;
97 > readonly startTimeUnixNano?: string;
98 > readonly endTimeUnixNano?: string;
99 > readonly attributes?: readonly IOtlpKeyValue[];
100 > readonly droppedAttributesCount?: number;
101 > readonly events?: readonly IOtlpEvent[];
102 > readonly droppedEventsCount?: number;
103 > readonly links?: readonly IOtlpLink[];
104 > readonly droppedLinksCount?: number;
105 > readonly status?: IOtlpStatus;
106 > }
107 >
108 > export interface IOtlpInstrumentationScope {
109 > readonly name?: string;
110 > readonly version?: string;
111 > readonly attributes?: readonly IOtlpKeyValue[];
112 > readonly droppedAttributesCount?: number;
113 > }
114 >
115 > export interface IOtlpScopeSpans {
116 > readonly scope?: IOtlpInstrumentationScope;
117 > readonly spans?: readonly IOtlpSpan[];
118 > readonly schemaUrl?: string;
119 > }
120 >
121 > export interface IOtlpResource {
122 > readonly attributes?: readonly IOtlpKeyValue[];
123 > readonly droppedAttributesCount?: number;
124 > }
125 >
126 > export interface IOtlpResourceSpans {
127 > readonly resource?: IOtlpResource;
128 > readonly scopeSpans?: readonly IOtlpScopeSpans[];
129 > readonly schemaUrl?: string;
130 > }
131 >
132 > /** The body shape of `POST /v1/traces`. */
133 > export interface IOtlpExportTraceServiceRequest {
134 > readonly resourceSpans?: readonly IOtlpResourceSpans[];
135 > }
136 >
137 > /**
138 > * The response shape from `POST /v1/traces`.
139 > *
140 > * On full success: `{}` is acceptable (per spec).
141 > * On partial success: `partialSuccess` is set; the request is NOT retried.
142 > */
143 > export interface IOtlpExportTraceServiceResponse {
144 > readonly partialSuccess?: {
145 > readonly rejectedSpans?: number;
146 > readonly errorMessage?: string;
147 > };
148 > }
src/vs/platform/otel/node/otlp/otlpJsonDecode.ts 51 introduced LOC · 9 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- otlpJsonDecode.ts
2 > * Copyright (c) Microsoft Corporation. All rights reserved.
3 > * Licensed under the MIT License. See License.txt in the project root for license information.
4 > *--------------------------------------------------------------------------------------------*/
5 >
6 > import { ICompletedSpanData, ISpanEventRecord, SpanStatusCode } from '../../common/spanData.js';
7 > import {
8 > IOtlpAnyValue,
9 > IOtlpEvent,
10 > IOtlpExportTraceServiceRequest,
11 > IOtlpKeyValue,
12 > IOtlpSpan,
13 > OtlpStatusCode,
14 > } from './otlpJsonTypes.js';
15 >
16 > type AttrValue = string | number | boolean | string[];
17 >
18 > const HEX_RE = /^[0-9a-fA-F]+$/;
19 > const ALL_ZERO_TRACE_ID = '00000000000000000000000000000000';
20 > const ALL_ZERO_SPAN_ID = '0000000000000000';
21 >
22 > /**
23 > * Decode an OTLP/HTTP JSON `ExportTraceServiceRequest` into flat
24 > * {@link ICompletedSpanData} records.
25 > *
26 > * The decoder is intentionally lenient: malformed individual spans are skipped
27 > * and reported via `partialFailures`, so the receiver can return a 200 with
28 > * `partial_success` populated (per OTLP/HTTP spec) rather than failing the
29 > * whole batch.
30 > *
31 > * Resource attributes (e.g. `service.name`) are merged into each span's
32 > * attribute map. Span-level attributes win on key collision. This keeps the
33 > * SQLite schema flat and avoids a separate resource table.
34 > *
35 > * Unknown OTLP fields (e.g. `links`, `traceState`) are dropped silently.
36 > */
37 > export interface IDecodeResult {
38 > readonly spans: readonly ICompletedSpanData[];
39 > readonly rejected: number;
40 > readonly errors: readonly string[];
41 > }
42 >
43 > export function decodeExportTraceRequest(request: IOtlpExportTraceServiceRequest | undefined): IDecodeResult {
44 if (!request || !Array.isArray(request.resourceSpans)) {
45 return { spans: [], rejected: 0, errors: [] };
78 return { spans, rejected, errors };
79 }
81 function decodeSpan(span: IOtlpSpan | undefined, resourceAttrs: Record<string, AttrValue>): ICompletedSpanData | undefined {
82 if (!span) {
134 };
135 }
137 function decodeEvent(ev: IOtlpEvent | undefined): ISpanEventRecord | undefined {
138 if (!ev) {
153 };
154 }
156 function decodeStatus(code: OtlpStatusCode | undefined, message: string | undefined): ICompletedSpanData['status'] {
157 switch (code) {
165 }
166 }
168 function decodeAttributes(kvs: readonly IOtlpKeyValue[] | undefined): Record<string, AttrValue> {
169 const out: Record<string, AttrValue> = {};
176 return out;
177 }
179 function setAttribute(target: Record<string, AttrValue>, kv: IOtlpKeyValue | undefined): void {
180 if (!kv || typeof kv.key !== 'string' || kv.key.length === 0) {
186 }
187 }
189 function decodeAnyValue(v: IOtlpAnyValue | undefined): AttrValue | undefined {
190 if (!v) {
229 return undefined;
230 }
232 function nanosToMillis(s: string | undefined): number | undefined {
233 if (s === undefined || s === '' || s === '0') {
240 return Number.isFinite(n) ? n : undefined;
241 }
243 function isValidHex(s: string, len: number): boolean {
244 return s.length === len && HEX_RE.test(s);