outboundForwarder.ts ×19

Frontier kind: Code frontier

unlabeled · c_517c3361ce07

9 tests · 9290 LOC · 41 files · introduces 0 tests · 155 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
19 ranges155 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1470 ranges9290 lines · 41 files · Browse complete extent
All tests (intent)
9 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 specializationoutboundForwarder.ts ×3 · 6 introduced LOCoutboundForwarder.ts ×3outboundForwarder.ts ×1 · 2 introduced LOCoutboundForwarder.ts ×1outboundForwarder.ts ×4 · 12 introduced LOCoutboundForwarder.ts ×4outboundForwarder.ts ×2 · 4 introduced LOCoutboundForwarder.ts ×2otel - outboundForwarder OtlpHttpForwarder re-POSTs raw body with custom headers|occurrence=1 · 0 introduced LOCotel - outboundForwarder…traces to a bare base endpoint|occurrence=1 · 0 introduced LOCtraces to a bare base en…outboundForwarder.ts ×1 · 1 introduced LOCoutboundForwarder.ts ×1outboundForwarder.ts ×5 · 34 introduced LOCoutboundForwarder.ts ×5outboundForwarder.ts ×2 · 14 introduced LOCoutboundForwarder.ts ×2outboundForwarder.ts ×7 · 27 introduced LOCoutboundForwarder.ts ×7outboundForwarder.ts ×4 · 15 introduced LOCoutboundForwarder.ts ×4outboundForwarder.ts ×4 · 16 introduced LOCoutboundForwarder.ts ×4outboundForwarder.ts ×1 · 2 introduced LOCoutboundForwarder.ts ×1outboundForwarder.ts ×1 · 2 introduced LOCoutboundForwarder.ts ×1outboundForwarder.ts ×1 · 3 introduced LOCoutboundForwarder.ts ×1outboundForwarder.ts ×2 · 4 introduced LOCoutboundForwarder.ts ×2log.ts ×72 · 446 introduced LOClog.ts ×72contextkey.ts ×1 · 2 introduced LOCcontextkey.ts ×1contextkey.ts ×3 · 7 introduced LOCcontextkey.ts ×3async.ts ×202 · 1247 introduced LOCasync.ts ×202contextkey.ts ×1 · 3 introduced LOCcontextkey.ts ×1contextkey.ts ×1 · 2 introduced LOCcontextkey.ts ×1contextkey.ts ×1 · 3 introduced LOCcontextkey.ts ×1contextkey.ts ×1 · 2 introduced LOCcontextkey.ts ×1contextkey.ts ×2 · 3 introduced LOCcontextkey.ts ×2contextkey.ts ×1 · 2 introduced LOCcontextkey.ts ×1contextkey.ts ×2 · 3 introduced LOCcontextkey.ts ×2contextkey.ts ×2 · 3 introduced LOCcontextkey.ts ×2contextkey.ts ×1 · 2 introduced LOCcontextkey.ts ×1contextkey.ts ×1 · 4 introduced LOCcontextkey.ts ×1contextkey.ts ×201 · 796 introduced LOCcontextkey.ts ×201hash.ts ×17 · 74 introduced LOChash.ts ×17resources.ts ×23 · 253 introduced LOCresources.ts ×23network.ts ×20 · 292 introduced LOCnetwork.ts ×20extpath.ts ×17 · 91 introduced LOCextpath.ts ×17strings.ts ×101 · 542 introduced LOCstrings.ts ×101cancellation.ts ×18 · 90 introduced LOCcancellation.ts ×18event.ts ×1 · 1 introduced LOCevent.ts ×1event.ts ×4 · 9 introduced LOCevent.ts ×4event.ts ×2 · 6 introduced LOCevent.ts ×2event.ts ×93 · 864 introduced LOCevent.ts ×93buffer.ts ×42 · 483 introduced LOCbuffer.ts ×42scanner.ts ×13 · 13 introduced LOCscanner.ts ×13scanner.ts ×3 · 3 introduced LOCscanner.ts ×3scanner.ts ×1 · 1 introduced LOCscanner.ts ×1scanner.ts ×1 · 1 introduced LOCscanner.ts ×1scanner.ts ×1 · 1 introduced LOCscanner.ts ×1scanner.ts ×1 · 1 introduced LOCscanner.ts ×1scanner.ts ×1 · 1 introduced LOCscanner.ts ×1scanner.ts ×1 · 1 introduced LOCscanner.ts ×1scanner.ts ×36 · 181 introduced LOCscanner.ts ×36spanData.ts ×1 · 44 introduced LOCspanData.ts ×1utils.ts ×3 · 9 introduced LOCutils.ts ×3nls.ts ×1 · 1 introduced LOCnls.ts ×1errorMessage.ts ×6 · 29 introduced LOCerrorMessage.ts ×6linkedList.ts ×13 · 44 introduced LOClinkedList.ts ×13nls.ts ×6 · 13 introduced LOCnls.ts ×6instantiation.ts ×5 · 111 introduced LOCinstantiation.ts ×5lifecycle.ts ×2 · 4 introduced LOClifecycle.ts ×2lifecycle.ts ×4 · 8 introduced LOClifecycle.ts ×4lifecycle.ts ×6 · 16 introduced LOClifecycle.ts ×6lazy.ts ×1 · 2 introduced LOClazy.ts ×1lazy.ts ×3 · 37 introduced LOClazy.ts ×3lifecycle.ts ×1 · 2 introduced LOClifecycle.ts ×1lifecycle.ts ×1 · 2 introduced LOClifecycle.ts ×1uint.ts ×2 · 43 introduced LOCuint.ts ×2lifecycle.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/async.ts · 2749 LOCcommon/async.tssrc/vs/base/common/buffer.ts · 499 LOCcommon/buffer.tssrc/vs/base/common/cache.ts · 153 LOCcommon/cache.tssrc/vs/base/common/cancellation.ts · 206 LOCcommon/cancellation.tssrc/vs/base/common/charCode.ts · 450 LOCcommon/charCode.tssrc/vs/base/common/collections.ts · 176 LOCcommon/collections.tssrc/vs/base/common/errorMessage.ts · 113 LOCcommon/errorMessage.tssrc/vs/base/common/errors.ts · 357 LOCcommon/errors.tssrc/vs/base/common/event.ts · 1964 LOCcommon/event.tssrc/vs/base/common/extpath.ts · 433 LOCcommon/extpath.tssrc/vs/base/common/functional.ts · 32 LOCcommon/functional.tssrc/vs/base/common/hash.ts · 324 LOCcommon/hash.tssrc/vs/base/common/iterator.ts · 194 LOCcommon/iterator.tssrc/vs/base/common/lazy.ts · 57 LOCcommon/lazy.tssrc/vs/base/common/lifecycle.ts · 974 LOCcommon/lifecycle.tssrc/vs/base/common/linkedList.ts · 151 LOCcommon/linkedList.tssrc/vs/base/common/map.ts · 1016 LOCcommon/map.tssrc/vs/base/common/marshallingIds.ts · 33 LOCcommon/marshallingIds.tssrc/vs/base/common/network.ts · 440 LOCcommon/network.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/resources.ts · 444 LOCcommon/resources.tssrc/vs/base/common/stopwatch.ts · 41 LOCcommon/stopwatch.tssrc/vs/base/common/stream.ts · 790 LOCcommon/stream.tssrc/vs/base/common/strings.ts · 1413 LOCcommon/strings.tssrc/vs/base/common/symbols.ts · 9 LOCcommon/symbols.tssrc/vs/base/common/types.ts · 410 LOCcommon/types.tssrc/vs/base/common/uint.ts · 59 LOCcommon/uint.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/contextkey/common/contextkey.ts · 2183 LOCcommon/contextkey.tssrc/vs/platform/contextkey/common/scanner.ts · 384 LOCcommon/scanner.tssrc/vs/platform/instantiation/common/instantiation.ts · 130 LOCcommon/instantiation.tssrc/vs/platform/log/common/log.ts · 926 LOCcommon/log.tssrc/vs/platform/otel/common/spanData.ts · 44 LOCcommon/spanData.tssrc/vs/platform/otel/node/otlp/outboundForwarder.ts · 307 LOCotlp/outboundForwarder.t…otel - outboundForwarder CompositeForwarder fans out forwardRaw and forwardSpans|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/otel/test/node/otlp/outboundForwarder.test|title=platform/otel - outboundForwarder CompositeForwarder fans out forwardRaw and forwardSpans|occurrence=1otel - outboundForwarder…otel - outboundForwarder ConsoleForwarder logs one info per span|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/otel/test/node/otlp/outboundForwarder.test|title=platform/otel - outboundForwarder ConsoleForwarder logs one info per span|occurrence=1otel - outboundForwarder…otel - outboundForwarder FileForwarder appends one JSON line per span|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/otel/test/node/otlp/outboundForwarder.test|title=platform/otel - outboundForwarder FileForwarder appends one JSON line per span|occurrence=1otel - outboundForwarder…otel - outboundForwarder FileForwarder ignores empty result|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/otel/test/node/otlp/outboundForwarder.test|title=platform/otel - outboundForwarder FileForwarder ignores empty result|occurrence=1otel - outboundForwarder…traces to a bare base endpoint|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/otel/test/node/otlp/outboundForwarder.test|title=platform/otel - outboundForwarder OtlpHttpForwarder auto-appends /v1/traces to a bare base endpoint|occurrence=1traces to a bare base en…otel - outboundForwarder OtlpHttpForwarder logs warning on upstream 500 and does not throw|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/otel/test/node/otlp/outboundForwarder.test|title=platform/otel - outboundForwarder OtlpHttpForwarder logs warning on upstream 500 and does not throw|occurrence=1otel - outboundForwarder…otel - outboundForwarder OtlpHttpForwarder re-POSTs raw body with custom headers|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/otel/test/node/otlp/outboundForwarder.test|title=platform/otel - outboundForwarder OtlpHttpForwarder re-POSTs raw body with custom headers|occurrence=1otel - outboundForwarder…otel - outboundForwarder OtlpHttpForwarder uses supplied fetch with raw body and custom headers|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/otel/test/node/otlp/outboundForwarder.test|title=platform/otel - outboundForwarder OtlpHttpForwarder uses supplied fetch with raw body and custom headers|occurrence=1otel - outboundForwarder…otel - outboundForwarder resolveOtlpTracesEndpoint appends path on base URL, leaves explicit path alone|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/otel/test/node/otlp/outboundForwarder.test|title=platform/otel - outboundForwarder resolveOtlpTracesEndpoint appends path on base URL, leaves explicit path alone|occurrence=1otel - outboundForwarder…Focused concept · outboundForwarder.ts ×19 · 155 introduced LOCoutboundForwarder.ts ×19

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.

1 file ranked by introduced lines: 155 introduced LOC across 19 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/otel/node/otlp/outboundForwarder.ts 155 introduced LOC · 19 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- outboundForwarder.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 type * as http from 'http';
7 > import type * as https from 'https';
8 > import { Queue } from '../../../../base/common/async.js';
9 > import { Disposable, toDisposable } from '../../../../base/common/lifecycle.js';
10 > import { URL } from 'url';
11 > import { promises as fs } from 'fs';
12 > import { ILogService } from '../../../log/common/log.js';
13 > import { ICompletedSpanData } from '../../common/spanData.js';
14 > import { IDecodeResult } from './otlpJsonDecode.js';
15 >
16 > /**
17 > * Fan-out target for span data the loopback receiver collects. Each
18 > * implementation isolates failures so that the receiver's response to the SDK
19 > * is never blocked by an upstream problem.
20 > */
21 > export interface IOutboundForwarder {
22 > /** Forward raw OTLP/HTTP request bytes unchanged (for OTLP exporters). */
23 > forwardRaw?(body: Buffer, contentType: string): void;
24 > /** Forward decoded spans (for console / file / structured sinks). */
25 > forwardSpans?(result: IDecodeResult): void;
26 > /**
27 > * Drain any in-flight work. Best-effort; never throws. Callers should
28 > * await this on shutdown so file/network writes have a chance to complete.
29 > */
30 > flush(): Promise<void>;
31 > dispose(): void;
32 > }
33 >
34 > // ---------------------------------------------------------------------------
35 > // OTLP/HTTP forwarder: re-POST the raw body to a remote OTLP collector.
36 > // ---------------------------------------------------------------------------
37 >
38 > export interface IOtlpHttpForwarderOptions {
39 > /**
40 > * Target URL. May be either:
41 > *
42 > * - A full signal-specific URL (`http://host:4318/v1/traces`) — used verbatim.
43 > * - A bare base URL (`http://host:4318` or `http://host:4318/`) — `/v1/traces`
44 > * is auto-appended, matching the `OTEL_EXPORTER_OTLP_ENDPOINT` convention
45 > * used by OTLP exporters in the official OpenTelemetry SDKs.
46 > */
47 > readonly endpoint: string;
48 > /** Extra headers (e.g. authorization). */
49 > readonly headers?: Readonly<Record<string, string>>;
50 > /** Per-request timeout in ms. Defaults to 10s. */
51 > readonly timeoutMs?: number;
52 > }
53 >
54 > /**
55 > * Resolve an OTLP/HTTP traces endpoint, matching the path-handling rules used
56 > * by the OpenTelemetry SDKs: a bare base URL (no path or just `/`) gets
57 > * `/v1/traces` appended; any other path is used verbatim.
58 > *
59 > * Returns the input string when it cannot be parsed as a URL so the caller's
60 > * error path remains in charge.
61 > */
62 > export function resolveOtlpTracesEndpoint(endpoint: string): string {
63 try {
64 const url = new URL(endpoint);
72 }
73 }
75 > /**
76 > * Forwards raw OTLP/HTTP request bytes to a user-configured remote endpoint.
77 > *
78 > * Re-POSTs the exact body and content-type the SDK sent, preserving wire-format
79 > * fidelity. This is the same passthrough pattern the OpenTelemetry Collector's
80 > * `otlphttpexporter` uses internally.
81 > */
82 > export class OtlpHttpForwarder extends Disposable implements IOutboundForwarder {
83 > private readonly _queue = new Queue<void>();
84 > private _disposed = false;
85 > private readonly _resolvedEndpoint: string;
86 >
87 > constructor(
88 private readonly _options: IOtlpHttpForwarderOptions,
89 private readonly _logService: ILogService,
94 this._register(toDisposable(() => { this._disposed = true; }));
95 }
97 > forwardRaw(body: Buffer, contentType: string): void {
98 if (this._disposed) {
99 return;
101 void this._queue.queue(() => this._sendOnce(body, contentType));
102 }
104 > async flush(): Promise<void> {
105 try {
106 await this._queue.queue(() => Promise.resolve());
107 } catch { /* never throws */ }
108 }
110 > private async _sendOnce(body: Buffer, contentType: string): Promise<void> {
111 try {
112 if (this._fetchFn) {
147 }
148 }
150 >
151 > interface IPostOptions {
152 > readonly host: string;
153 > readonly port: number;
154 > readonly path: string;
155 > readonly method: 'POST';
156 > readonly headers: Record<string, string>;
157 > readonly timeoutMs: number;
158 > }
159 >
160 function postOnce(mod: typeof http | typeof https, options: IPostOptions, body: Buffer): Promise<void> {
161 return new Promise<void>((resolve, reject) => {
187 });
188 }
190 > // ---------------------------------------------------------------------------
191 > // File forwarder: append decoded spans as JSON-lines to a user-configured path.
192 > // ---------------------------------------------------------------------------
193 >
194 > export interface IFileForwarderOptions {
195 > readonly filePath: string;
196 > }
197 >
198 > /**
199 > * Appends decoded spans (one JSON object per line) to a user-configured file.
200 > * Mirrors the `github.copilot.chat.otel.outfile` behavior so users can collect
201 > * Agent Host traces with the same offline-friendly format.
202 > */
203 > export class FileForwarder extends Disposable implements IOutboundForwarder {
204 > private readonly _queue = new Queue<void>();
205 > private _disposed = false;
206 >
207 > constructor(
208 private readonly _options: IFileForwarderOptions,
209 private readonly _logService: ILogService,
212 this._register(toDisposable(() => { this._disposed = true; }));
213 }
215 > forwardSpans(result: IDecodeResult): void {
216 if (this._disposed || result.spans.length === 0) {
217 return;
220 void this._queue.queue(() => this._append(lines));
221 }
223 > async flush(): Promise<void> {
224 try {
225 await this._queue.queue(() => Promise.resolve());
226 } catch { /* never throws */ }
227 }
229 > private async _append(lines: string): Promise<void> {
230 try {
231 await fs.appendFile(this._options.filePath, lines, { encoding: 'utf8' });
234 }
235 }
237 >
238 > // ---------------------------------------------------------------------------
239 > // Console forwarder: log a one-line summary per span to the log service.
240 > // ---------------------------------------------------------------------------
241 >
242 > /**
243 > * Pretty-prints one line per span to the log service. Intended for quick
244 > * debugging — not a structured sink.
245 > */
246 > export class ConsoleForwarder extends Disposable implements IOutboundForwarder {
247 > private _disposed = false;
248 >
249 > constructor(private readonly _logService: ILogService) {
250 super();
251 this._register(toDisposable(() => { this._disposed = true; }));
252 }
254 > forwardSpans(result: IDecodeResult): void {
255 if (this._disposed) {
256 return;
260 }
261 }
263 > async flush(): Promise<void> {
264 // Console writes are synchronous-enough; nothing to drain.
265 }
267 >
268 function formatSpan(s: ICompletedSpanData): string {
269 const duration = Math.max(0, s.endTime - s.startTime);
273 return `${s.name} (${duration}ms) trace=${s.traceId} span=${s.spanId}${tail ? ' ' + tail : ''}`;
274 }
276 > // ---------------------------------------------------------------------------
277 > // Composite: fan out to N forwarders.
278 > // ---------------------------------------------------------------------------
279 >
280 > /** Aggregates several forwarders behind a single `IOutboundForwarder` surface. */
281 > export class CompositeForwarder extends Disposable implements IOutboundForwarder {
282 > private readonly _children: readonly IOutboundForwarder[];
283 >
284 > constructor(children: readonly IOutboundForwarder[]) {
285 super();
286 this._children = children;
289 }
290 }
292 > forwardRaw(body: Buffer, contentType: string): void {
293 for (const c of this._children) {
294 c.forwardRaw?.(body, contentType);
295 }
296 }
298 > forwardSpans(result: IDecodeResult): void {
299 for (const c of this._children) {
300 c.forwardSpans?.(result);
301 }
302 }
304 > async flush(): Promise<void> {
305 await Promise.all(this._children.map(c => c.flush()));
306 }