@osfactory/otel-hook 0.13.2 → 0.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +57 -0
- package/dist/{adapter-DyCb7y1N.d.ts → adapter-But5fFCk.d.ts} +9 -2
- package/dist/cli.js +628 -73
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +30 -4
- package/dist/config.js +161 -9
- package/dist/config.js.map +1 -1
- package/dist/{destinations-C4sSKjDO.d.ts → destinations-2KrcRslo.d.ts} +92 -2
- package/dist/{export-destinations-BjRXDots.d.ts → export-destinations-8tNkIC8a.d.ts} +110 -10
- package/dist/{filesystem-store-B3CpiIRl.d.ts → filesystem-store-Z8XgDtFj.d.ts} +1 -1
- package/dist/{hook-CKLpgrYP.d.ts → hook-D7XABd4f.d.ts} +19 -5
- package/dist/index.d.ts +14 -14
- package/dist/index.js +626 -72
- package/dist/index.js.map +1 -1
- package/dist/install.d.ts +4 -4
- package/dist/install.js.map +1 -1
- package/dist/integration.d.ts +9 -9
- package/dist/integration.js +555 -65
- package/dist/integration.js.map +1 -1
- package/dist/lifecycle.d.ts +1 -1
- package/dist/lifecycle.js +1 -1
- package/dist/lifecycle.js.map +1 -1
- package/dist/{memory-B3r6sZtC.d.ts → memory-gipZUiXP.d.ts} +1 -1
- package/dist/{payload-DLK7QaBB.d.ts → payload-DWdx9yk3.d.ts} +1 -1
- package/dist/{ports-DhpSDIkp.d.ts → ports-qZTwK-z2.d.ts} +22 -2
- package/dist/privacy.d.ts +2 -2
- package/dist/privacy.js +42 -1
- package/dist/privacy.js.map +1 -1
- package/dist/providers.d.ts +9 -9
- package/dist/providers.js +22 -5
- package/dist/providers.js.map +1 -1
- package/dist/{registry-DM-4YvIA.d.ts → registry-D9rmMYxw.d.ts} +2 -2
- package/dist/runtime.d.ts +24 -9
- package/dist/runtime.js +282 -30
- package/dist/runtime.js.map +1 -1
- package/dist/{schema-CD61uW99.d.ts → schema-oRsbo7WO.d.ts} +45 -0
- package/dist/{service-CbI9CObT.d.ts → service-DySC7KQM.d.ts} +6 -1
- package/dist/state.d.ts +3 -3
- package/dist/state.js.map +1 -1
- package/dist/telemetry.d.ts +6 -5
- package/dist/telemetry.js +304 -17
- package/dist/telemetry.js.map +1 -1
- package/dist/testing.d.ts +8 -8
- package/dist/testing.js +185 -10
- package/dist/testing.js.map +1 -1
- package/package.json +1 -1
package/dist/telemetry.d.ts
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
export { D as DEFAULT_INSTRUMENTATION_SCOPE, a as DeriveMetricObservationsInput, E as EventTraceIdentity, M as MAX_RECOVERED_START_ATTRIBUTES, b as METRIC_COST_USAGE, c as METRIC_INSTRUMENTS, d as METRIC_OPERATION_DURATION, e as METRIC_SESSIONS, f as METRIC_TOKEN_USAGE, g as METRIC_TOOL_CALLS, h as MetricInstrument, i as MetricInstrumentName, j as MetricObservation, k as MetricPoint, l as MetricsTemporality, O as OPERATION_DURATION_BUCKETS, S as SemanticMappingOptions, m as SpanCorrelation, n as SpanCorrelationResolver, o as SpanDisposition, p as SpanFamily, q as SpanOrphanClassification, r as SpanPairing, s as SpanScopeRef, T as TOKEN_USAGE_BUCKETS, t as TokenType, u as aggregateDeltaPoints, v as canonicalEventTraceIdentities, w as canonicalEventsToReadableSpans, x as deriveMetricObservations, y as parentScopeRefOf, z as spanScopeRefOf, A as startOnlySpanAttributes } from './metric-model-B4lIuk6i.js';
|
|
2
|
-
export { C as ContentWithholdingReason, D as DurableLogSpool,
|
|
2
|
+
export { C as ContentRestrictor, a as ContentWithholdingReason, D as DestinationFanoutOptions, b as DurableLogSpool, c as DurableLogSpoolOptions, d as DurableMetricSpool, e as DurableMetricSpoolOptions, f as DurableSpool, g as DurableSpoolOptions, E as ExportDestinationSinks, h as ExportDestinationsOptions, L as LOG_MAPPING_VERSION, i as LOG_SIGNALS, j as LogContentPolicy, k as LogMappingOptions, l as LogMappingResult, m as LogSignal, n as LogSpoolBatch, o as LogsDeliverability, M as MAX_LOG_BODY_CHARACTERS, p as MAX_LOG_RECORDS_PER_BATCH, q as MAX_LOG_RECORDS_PER_EVENT, r as MCP_TOOL_NAME_PATTERN, s as MetricExportResult, t as MetricSpoolBatch, u as MetricsDeliverability, N as NO_LOG_CONTENT, O as OtlpLogSinkOptions, v as OtlpLogTelemetrySink, w as OtlpMetricSinkOptions, x as OtlpMetricTelemetrySink, y as OtlpTelemetrySink, z as OtlpTraceSinkOptions, R as RouteEventsOptions, S as ScopedBatch, A as SerializedLogRecord, B as SerializedSpan, F as SharedCorrelationResolver, G as SignalFanoutOptions, H as SignalFanoutSink, I as SkippedExportDestination, J as SpoolBatch, K as SpoolDrainResult, P as SpoolDropCounts, Q as SpoolDropReason, T as SpoolEnqueueResult, U as SpoolOverflowPolicy, V as SpoolSendOutcome, W as SpoolStats, X as canonicalEventsToLogRecords, Y as createDestinationFanout, Z as createExportDestinationSinks, _ as createFileDurableLogSpool, $ as createFileDurableMetricSpool, a0 as createFileDurableSpool, a1 as createOtlpLogSink, a2 as createOtlpMetricSink, a3 as createOtlpTraceSink, a4 as createSignalFanout, a5 as describeLogsDeliverability, a6 as describeMetricsDeliverability, a7 as eventRepositoryKey, a8 as exporterPolicyForDestination, a9 as logSignalOf, aa as logSignalsForLifecycleEvents, ab as omitRestrictedContent, ac as pointRepositoryKey, ad as resolveLogsEndpoint, ae as resolveMetricsEndpoint, af as resourceRepositoryKey, ag as restrictEventContent, ah as routeEventsToScopes, ai as routePointsToScopes, aj as sessionIdVariantsFor, ak as shareCorrelationPerBatch, al as spoolQueueNamesFor, am as validateMetricSpoolBatch } from './export-destinations-8tNkIC8a.js';
|
|
3
3
|
import { ExportResult } from '@opentelemetry/core';
|
|
4
4
|
import '@opentelemetry/api';
|
|
5
5
|
import '@opentelemetry/resources';
|
|
6
6
|
import '@opentelemetry/sdk-trace';
|
|
7
7
|
import './events-fcomX6d5.js';
|
|
8
8
|
import 'zod';
|
|
9
|
-
import './destinations-
|
|
10
|
-
import './
|
|
11
|
-
import './
|
|
9
|
+
import './destinations-2KrcRslo.js';
|
|
10
|
+
import './policy-CimmCfRp.js';
|
|
11
|
+
import './content-M9xIKG7h.js';
|
|
12
|
+
import './schema-oRsbo7WO.js';
|
|
13
|
+
import './ports-qZTwK-z2.js';
|
|
12
14
|
import './errors.js';
|
|
13
15
|
import './primitives-CJ8-rn-f.js';
|
|
14
16
|
import './taxonomy-DwhTtuWd.js';
|
|
15
17
|
import './keys-Dej5bN3L.js';
|
|
16
18
|
import '@opentelemetry/sdk-logs';
|
|
17
|
-
import './content-M9xIKG7h.js';
|
|
18
19
|
import './diagnostics.js';
|
|
19
20
|
|
|
20
21
|
/**
|
package/dist/telemetry.js
CHANGED
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
} from "@opentelemetry/semantic-conventions/incubating";
|
|
19
19
|
|
|
20
20
|
// src/version.ts
|
|
21
|
-
var VERSION = "0.
|
|
21
|
+
var VERSION = "0.14.1";
|
|
22
22
|
|
|
23
23
|
// src/telemetry/export-identity.ts
|
|
24
24
|
import { ATTR_SESSION_ID } from "@opentelemetry/semantic-conventions/incubating";
|
|
@@ -1378,6 +1378,17 @@ var planGroup = (group, correlation, correlationAvailable) => {
|
|
|
1378
1378
|
};
|
|
1379
1379
|
var runDiscriminatorOf = (correlation) => correlation?.runSpanIdDiscriminator === void 0 ? void 0 : `run:${correlation.runSpanIdDiscriminator}`;
|
|
1380
1380
|
var resumedSessionParent = (ref, correlation) => ref.family === "session" && correlation?.runSpanIdDiscriminator !== void 0 ? ref : void 0;
|
|
1381
|
+
var spanEndEdgesOf = (events) => {
|
|
1382
|
+
const layout = layoutBatch(events);
|
|
1383
|
+
const ends = /* @__PURE__ */ new Map();
|
|
1384
|
+
for (const [eventId, groupKey] of layout.groupOf) {
|
|
1385
|
+
const end = layout.groups.get(groupKey)?.end;
|
|
1386
|
+
if (end !== void 0) {
|
|
1387
|
+
ends.set(eventId, end);
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1390
|
+
return ends;
|
|
1391
|
+
};
|
|
1381
1392
|
var canonicalEventTraceIdentities = (events, options = {}) => {
|
|
1382
1393
|
const layout = layoutBatch(events);
|
|
1383
1394
|
const correlations = indexCorrelations(options.correlations);
|
|
@@ -2184,6 +2195,60 @@ var OTLP_HEADER_VARIABLES = Object.freeze({
|
|
|
2184
2195
|
logs: "OTEL_EXPORTER_OTLP_LOGS_HEADERS"
|
|
2185
2196
|
});
|
|
2186
2197
|
|
|
2198
|
+
// src/config/repository-key.ts
|
|
2199
|
+
var ATTR_VCS_REPOSITORY_URL_FULL = "vcs.repository.url.full";
|
|
2200
|
+
var MAX_REPOSITORY_REFERENCE_LENGTH = 2048;
|
|
2201
|
+
var SCHEME_PATTERN = /^[a-z][a-z0-9+.-]*:\/\//i;
|
|
2202
|
+
var SCP_LIKE_PATTERN = /^(?:[^@/\s]+@)?([^:/\s]+):(?!\/\/)(.+)$/;
|
|
2203
|
+
var trimTrailingSlashes = (value) => {
|
|
2204
|
+
let end = value.length;
|
|
2205
|
+
while (end > 0 && value.charCodeAt(end - 1) === 47) end -= 1;
|
|
2206
|
+
return value.slice(0, end);
|
|
2207
|
+
};
|
|
2208
|
+
var keyOf = (host, pathname) => {
|
|
2209
|
+
const withoutSlashes = trimTrailingSlashes(pathname);
|
|
2210
|
+
const cleanedPath = trimTrailingSlashes(
|
|
2211
|
+
withoutSlashes.toLowerCase().endsWith(".git") ? withoutSlashes.slice(0, -4) : withoutSlashes
|
|
2212
|
+
);
|
|
2213
|
+
if (host.length === 0 || cleanedPath.length === 0 || cleanedPath === "/") {
|
|
2214
|
+
return void 0;
|
|
2215
|
+
}
|
|
2216
|
+
const withSlash = cleanedPath.startsWith("/") ? cleanedPath : `/${cleanedPath}`;
|
|
2217
|
+
return `${host}${withSlash}`.toLowerCase();
|
|
2218
|
+
};
|
|
2219
|
+
var normalizeRepositoryKey = (reference) => {
|
|
2220
|
+
const trimmed = reference.trim();
|
|
2221
|
+
if (trimmed.length === 0 || trimmed.length > MAX_REPOSITORY_REFERENCE_LENGTH) {
|
|
2222
|
+
return void 0;
|
|
2223
|
+
}
|
|
2224
|
+
if (SCHEME_PATTERN.test(trimmed)) {
|
|
2225
|
+
let url;
|
|
2226
|
+
try {
|
|
2227
|
+
url = new URL(trimmed);
|
|
2228
|
+
} catch {
|
|
2229
|
+
return void 0;
|
|
2230
|
+
}
|
|
2231
|
+
if (url.protocol === "file:") {
|
|
2232
|
+
return void 0;
|
|
2233
|
+
}
|
|
2234
|
+
return keyOf(url.hostname, url.pathname);
|
|
2235
|
+
}
|
|
2236
|
+
if (trimmed.startsWith("/") || trimmed.startsWith(".") || trimmed.includes("\\")) {
|
|
2237
|
+
return void 0;
|
|
2238
|
+
}
|
|
2239
|
+
const scp = SCP_LIKE_PATTERN.exec(trimmed);
|
|
2240
|
+
if (scp !== null && !trimmed.split(":")[0]?.includes("/")) {
|
|
2241
|
+
const [, host, pathPart] = scp;
|
|
2242
|
+
return host === void 0 || pathPart === void 0 ? void 0 : keyOf(host, pathPart);
|
|
2243
|
+
}
|
|
2244
|
+
try {
|
|
2245
|
+
const url = new URL(`https://${trimmed}`);
|
|
2246
|
+
return keyOf(url.hostname, url.pathname);
|
|
2247
|
+
} catch {
|
|
2248
|
+
return void 0;
|
|
2249
|
+
}
|
|
2250
|
+
};
|
|
2251
|
+
|
|
2187
2252
|
// src/config/destinations.ts
|
|
2188
2253
|
var DEFAULT_DESTINATION_NAME = "default";
|
|
2189
2254
|
var DESTINATION_NAME_PATTERN = /^[a-z0-9][a-z0-9_-]{0,62}$/;
|
|
@@ -2202,6 +2267,30 @@ var headerValueSchema = z12.string().min(1).max(MAX_HEADER_VALUE_LENGTH).refine(
|
|
|
2202
2267
|
"an env: header reference must name an environment variable, e.g. env:COLLECTOR_TOKEN"
|
|
2203
2268
|
);
|
|
2204
2269
|
var endpointSchema = z12.string().url().max(2048);
|
|
2270
|
+
var MAX_DESTINATION_SCOPES = 64;
|
|
2271
|
+
var MAX_SCOPE_REPOSITORIES = 256;
|
|
2272
|
+
var ALL_REPOSITORIES = "*";
|
|
2273
|
+
var repositoryReferenceSchema = z12.string().min(1).max(MAX_REPOSITORY_REFERENCE_LENGTH).refine(
|
|
2274
|
+
(value) => normalizeRepositoryKey(value) !== void 0,
|
|
2275
|
+
"not a repository URL: use https://host/owner/repo, git@host:owner/repo.git, or host/owner/repo"
|
|
2276
|
+
);
|
|
2277
|
+
var destinationScopeSchema = z12.strictObject({
|
|
2278
|
+
/**
|
|
2279
|
+
* Repository URLs (any spelling of the remote; compared by host and path,
|
|
2280
|
+
* case-insensitively, without `.git`), or `"*"` for every record that names
|
|
2281
|
+
* a repository. A record that names none never matches a scope.
|
|
2282
|
+
*/
|
|
2283
|
+
repositories: z12.union([
|
|
2284
|
+
z12.literal(ALL_REPOSITORIES),
|
|
2285
|
+
z12.array(repositoryReferenceSchema).min(1).max(MAX_SCOPE_REPOSITORIES).readonly()
|
|
2286
|
+
]),
|
|
2287
|
+
/** Signals sent for these repositories. Default: every signal the destination takes. */
|
|
2288
|
+
signals: z12.array(exportSignalSchema).min(1).max(3).readonly().optional(),
|
|
2289
|
+
/** Content disclosure for these repositories, never above `privacy.contentMode`. Default: unchanged. */
|
|
2290
|
+
contentMode: contentModeSchema.optional(),
|
|
2291
|
+
/** False leaves `session.id` off metric data points for these repositories. Default true. */
|
|
2292
|
+
includeSessionId: z12.boolean().optional()
|
|
2293
|
+
});
|
|
2205
2294
|
var exportDestinationSchema = z12.strictObject({
|
|
2206
2295
|
/** Unique, lowercase, filesystem-safe. `default` is reserved for the single-endpoint settings. */
|
|
2207
2296
|
name: z12.string().regex(DESTINATION_NAME_PATTERN, "destination names are lowercase letters, digits, _ and -"),
|
|
@@ -2235,7 +2324,15 @@ var exportDestinationSchema = z12.strictObject({
|
|
|
2235
2324
|
* opt-in for content-bearing records leaving the host. `metrics` is never on by
|
|
2236
2325
|
* default: a destination receives hook-derived metrics only when it lists them.
|
|
2237
2326
|
*/
|
|
2238
|
-
signals: z12.array(exportSignalSchema).min(1).max(3).readonly().optional()
|
|
2327
|
+
signals: z12.array(exportSignalSchema).min(1).max(3).readonly().optional(),
|
|
2328
|
+
/**
|
|
2329
|
+
* Per-repository filter. Absent: every record goes to this destination, as
|
|
2330
|
+
* before scopes existed. Present: a record goes only when its repository
|
|
2331
|
+
* (`vcs.repository.url.full`) matches a scope — the first matching scope
|
|
2332
|
+
* decides its signals, content mode, and session id — and a record that
|
|
2333
|
+
* names no repository is not sent here at all.
|
|
2334
|
+
*/
|
|
2335
|
+
scopes: z12.array(destinationScopeSchema).min(1).max(MAX_DESTINATION_SCOPES).readonly().optional()
|
|
2239
2336
|
}).refine(
|
|
2240
2337
|
(destination) => destination.endpoint !== void 0 || destination.tracesEndpoint !== void 0 || destination.logsEndpoint !== void 0 || destination.metricsEndpoint !== void 0,
|
|
2241
2338
|
"a destination needs an endpoint, or a tracesEndpoint / logsEndpoint / metricsEndpoint"
|
|
@@ -2279,6 +2376,32 @@ var effectiveSpoolPolicy = (exporter) => ({
|
|
|
2279
2376
|
maxAgeMillis: exporter.spool?.maxAgeMillis ?? DEFAULT_SPOOL_POLICY.maxAgeMillis,
|
|
2280
2377
|
maxBatches: exporter.spool?.maxBatches ?? DEFAULT_SPOOL_POLICY.maxBatches
|
|
2281
2378
|
});
|
|
2379
|
+
var resolveDestinationScopes = (scopes, destinationSignals) => scopes.map((scope) => {
|
|
2380
|
+
const listed = scope.signals ?? exportSignalSchema.options;
|
|
2381
|
+
return {
|
|
2382
|
+
repositories: scope.repositories === ALL_REPOSITORIES ? ALL_REPOSITORIES : new Set(
|
|
2383
|
+
scope.repositories.flatMap((reference) => {
|
|
2384
|
+
const key = normalizeRepositoryKey(reference);
|
|
2385
|
+
return key === void 0 ? [] : [key];
|
|
2386
|
+
})
|
|
2387
|
+
),
|
|
2388
|
+
signals: {
|
|
2389
|
+
traces: destinationSignals.traces && listed.includes("traces"),
|
|
2390
|
+
logs: destinationSignals.logs && listed.includes("logs"),
|
|
2391
|
+
metrics: destinationSignals.metrics && listed.includes("metrics")
|
|
2392
|
+
},
|
|
2393
|
+
...scope.contentMode === void 0 ? {} : { contentMode: scope.contentMode },
|
|
2394
|
+
includeSessionId: scope.includeSessionId ?? true
|
|
2395
|
+
};
|
|
2396
|
+
});
|
|
2397
|
+
var matchDestinationScope = (scopes, repositoryKey) => {
|
|
2398
|
+
if (repositoryKey === void 0) {
|
|
2399
|
+
return void 0;
|
|
2400
|
+
}
|
|
2401
|
+
return scopes.find(
|
|
2402
|
+
(scope) => scope.repositories === ALL_REPOSITORIES || scope.repositories.has(repositoryKey)
|
|
2403
|
+
);
|
|
2404
|
+
};
|
|
2282
2405
|
var legacyDestination = (exporter) => ({
|
|
2283
2406
|
name: DEFAULT_DESTINATION_NAME,
|
|
2284
2407
|
source: "exporter",
|
|
@@ -2303,6 +2426,11 @@ var resolveExportDestinations = (exporter) => {
|
|
|
2303
2426
|
continue;
|
|
2304
2427
|
}
|
|
2305
2428
|
const signals = destination.signals ?? DEFAULT_DESTINATION_SIGNALS;
|
|
2429
|
+
const flags = {
|
|
2430
|
+
traces: signals.includes("traces"),
|
|
2431
|
+
logs: exporter.logs.enabled && signals.includes("logs"),
|
|
2432
|
+
metrics: signals.includes("metrics")
|
|
2433
|
+
};
|
|
2306
2434
|
resolved.push({
|
|
2307
2435
|
name: destination.name,
|
|
2308
2436
|
source: "destinations",
|
|
@@ -2311,12 +2439,9 @@ var resolveExportDestinations = (exporter) => {
|
|
|
2311
2439
|
...destination.tracesEndpoint === void 0 ? {} : { tracesEndpoint: destination.tracesEndpoint },
|
|
2312
2440
|
...destination.logsEndpoint === void 0 ? {} : { logsEndpoint: destination.logsEndpoint },
|
|
2313
2441
|
...destination.metricsEndpoint === void 0 ? {} : { metricsEndpoint: destination.metricsEndpoint },
|
|
2314
|
-
signals:
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
metrics: signals.includes("metrics")
|
|
2318
|
-
},
|
|
2319
|
-
headers: { ...destination.headers ?? {} }
|
|
2442
|
+
signals: flags,
|
|
2443
|
+
headers: { ...destination.headers ?? {} },
|
|
2444
|
+
...destination.scopes === void 0 ? {} : { scopes: resolveDestinationScopes(destination.scopes, flags) }
|
|
2320
2445
|
});
|
|
2321
2446
|
}
|
|
2322
2447
|
return resolved;
|
|
@@ -3989,14 +4114,20 @@ var createSignalFanout = (options) => {
|
|
|
3989
4114
|
};
|
|
3990
4115
|
var shareCorrelationPerBatch = (correlate) => {
|
|
3991
4116
|
let pending;
|
|
3992
|
-
|
|
3993
|
-
if (pending
|
|
4117
|
+
const resolve = (events) => {
|
|
4118
|
+
if (pending !== void 0 && (pending.events === events || pending.aliases.has(events))) {
|
|
3994
4119
|
return pending.result;
|
|
3995
4120
|
}
|
|
3996
4121
|
const result = correlate(events);
|
|
3997
|
-
pending = { events, result };
|
|
4122
|
+
pending = { events, aliases: /* @__PURE__ */ new Set(), result };
|
|
3998
4123
|
return result;
|
|
3999
4124
|
};
|
|
4125
|
+
const alias = (subset, batch) => {
|
|
4126
|
+
if (pending?.events === batch && subset !== batch) {
|
|
4127
|
+
pending.aliases.add(subset);
|
|
4128
|
+
}
|
|
4129
|
+
};
|
|
4130
|
+
return Object.assign(resolve, { alias });
|
|
4000
4131
|
};
|
|
4001
4132
|
|
|
4002
4133
|
// src/telemetry/metric-model.ts
|
|
@@ -4625,6 +4756,117 @@ var createOtlpMetricSink = (options) => {
|
|
|
4625
4756
|
};
|
|
4626
4757
|
};
|
|
4627
4758
|
|
|
4759
|
+
// src/telemetry/destination-scope.ts
|
|
4760
|
+
var DISCLOSURE_RANK = Object.freeze({
|
|
4761
|
+
omitted: 0,
|
|
4762
|
+
masked: 1,
|
|
4763
|
+
redacted: 2,
|
|
4764
|
+
raw: 3
|
|
4765
|
+
});
|
|
4766
|
+
var omitRestrictedContent = (fact, mode) => {
|
|
4767
|
+
if (fact.text === void 0 || DISCLOSURE_RANK[fact.disclosure] <= DISCLOSURE_RANK[CONTENT_MODE_DISCLOSURE[mode]]) {
|
|
4768
|
+
return fact;
|
|
4769
|
+
}
|
|
4770
|
+
const { text, ...rest } = fact;
|
|
4771
|
+
void text;
|
|
4772
|
+
return { ...rest, disclosure: "omitted", truncated: false };
|
|
4773
|
+
};
|
|
4774
|
+
var keyOfValue = (value) => typeof value === "string" ? normalizeRepositoryKey(value) : void 0;
|
|
4775
|
+
var resourceRepositoryKey = (attributes) => keyOfValue(attributes[ATTR_VCS_REPOSITORY_URL_FULL]);
|
|
4776
|
+
var repositoryUrlForKey = (key) => `https://${key}`;
|
|
4777
|
+
var hasOwnStamp = (attributes) => attributes?.[ATTR_VCS_REPOSITORY_URL_FULL] !== void 0;
|
|
4778
|
+
var withRoutedRepository = (event2, key) => hasOwnStamp(event2.contextAttributes) ? event2 : {
|
|
4779
|
+
...event2,
|
|
4780
|
+
contextAttributes: { ...event2.contextAttributes, [ATTR_VCS_REPOSITORY_URL_FULL]: repositoryUrlForKey(key) }
|
|
4781
|
+
};
|
|
4782
|
+
var eventRepositoryKey = (event2, fallbackKey) => {
|
|
4783
|
+
const stamped = event2.contextAttributes?.[ATTR_VCS_REPOSITORY_URL_FULL];
|
|
4784
|
+
return stamped === void 0 ? fallbackKey : keyOfValue(stamped);
|
|
4785
|
+
};
|
|
4786
|
+
var pointRepositoryKey = (point, fallbackKey) => {
|
|
4787
|
+
const stamped = point.attributes[ATTR_VCS_REPOSITORY_URL_FULL];
|
|
4788
|
+
return stamped === void 0 ? fallbackKey : keyOfValue(stamped);
|
|
4789
|
+
};
|
|
4790
|
+
var restrictFacts = (facts, mode, restrict) => facts?.map((fact) => restrict(fact, mode));
|
|
4791
|
+
var restrictEventContent = (event2, mode, restrict) => {
|
|
4792
|
+
switch (event2.type) {
|
|
4793
|
+
case "prompt.submitted":
|
|
4794
|
+
return event2.content === void 0 ? event2 : { ...event2, content: restrict(event2.content, mode) };
|
|
4795
|
+
case "generation.start": {
|
|
4796
|
+
const inputContent = restrictFacts(event2.inputContent, mode, restrict);
|
|
4797
|
+
return inputContent === void 0 ? event2 : { ...event2, inputContent };
|
|
4798
|
+
}
|
|
4799
|
+
case "generation.end": {
|
|
4800
|
+
const outputContent = restrictFacts(event2.outputContent, mode, restrict);
|
|
4801
|
+
return outputContent === void 0 ? event2 : { ...event2, outputContent };
|
|
4802
|
+
}
|
|
4803
|
+
case "tool.start":
|
|
4804
|
+
return event2.input === void 0 ? event2 : { ...event2, input: restrict(event2.input, mode) };
|
|
4805
|
+
case "tool.end":
|
|
4806
|
+
return event2.output === void 0 ? event2 : { ...event2, output: restrict(event2.output, mode) };
|
|
4807
|
+
case "error.raised":
|
|
4808
|
+
return event2.message === void 0 ? event2 : { ...event2, message: restrict(event2.message, mode) };
|
|
4809
|
+
default:
|
|
4810
|
+
return event2;
|
|
4811
|
+
}
|
|
4812
|
+
};
|
|
4813
|
+
var routeEventsToScopes = (events, scopes, options) => {
|
|
4814
|
+
const ends = spanEndEdgesOf(events);
|
|
4815
|
+
const fallbackKey = options.workspaceRepositoryKey ?? options.resourceRepositoryKey;
|
|
4816
|
+
const traces = [];
|
|
4817
|
+
const logs = [];
|
|
4818
|
+
let unchanged = true;
|
|
4819
|
+
for (const event2 of events) {
|
|
4820
|
+
const anchor = ends.get(event2.eventId) ?? event2;
|
|
4821
|
+
const scope = matchDestinationScope(scopes, eventRepositoryKey(anchor, fallbackKey));
|
|
4822
|
+
if (scope === void 0 || !scope.signals.traces || !scope.signals.logs) {
|
|
4823
|
+
unchanged = false;
|
|
4824
|
+
}
|
|
4825
|
+
if (scope === void 0) {
|
|
4826
|
+
continue;
|
|
4827
|
+
}
|
|
4828
|
+
const lowered = scope.contentMode === void 0 ? event2 : restrictEventContent(event2, scope.contentMode, options.restrict);
|
|
4829
|
+
const restricted = hasOwnStamp(anchor.contextAttributes) || fallbackKey === void 0 ? lowered : withRoutedRepository(lowered, fallbackKey);
|
|
4830
|
+
if (restricted !== event2) {
|
|
4831
|
+
unchanged = false;
|
|
4832
|
+
}
|
|
4833
|
+
if (scope.signals.traces) {
|
|
4834
|
+
traces.push(restricted);
|
|
4835
|
+
}
|
|
4836
|
+
if (scope.signals.logs) {
|
|
4837
|
+
logs.push(restricted);
|
|
4838
|
+
}
|
|
4839
|
+
}
|
|
4840
|
+
return unchanged ? { traces: events, logs: events } : { traces, logs };
|
|
4841
|
+
};
|
|
4842
|
+
var routePointsToScopes = (scopes, pointsFor, options) => {
|
|
4843
|
+
const effective = (scope) => options.includeSessionId && scope.includeSessionId;
|
|
4844
|
+
const kept = [];
|
|
4845
|
+
for (const variant of [true, false]) {
|
|
4846
|
+
if (!scopes.some((scope) => scope.signals.metrics && effective(scope) === variant)) {
|
|
4847
|
+
continue;
|
|
4848
|
+
}
|
|
4849
|
+
for (const point of pointsFor(variant) ?? []) {
|
|
4850
|
+
const scope = matchDestinationScope(scopes, pointRepositoryKey(point, options.fallbackKey));
|
|
4851
|
+
if (scope?.signals.metrics === true && effective(scope) === variant) {
|
|
4852
|
+
kept.push(
|
|
4853
|
+
hasOwnStamp(point.attributes) || options.fallbackKey === void 0 ? point : {
|
|
4854
|
+
...point,
|
|
4855
|
+
attributes: {
|
|
4856
|
+
...point.attributes,
|
|
4857
|
+
[ATTR_VCS_REPOSITORY_URL_FULL]: repositoryUrlForKey(options.fallbackKey)
|
|
4858
|
+
}
|
|
4859
|
+
}
|
|
4860
|
+
);
|
|
4861
|
+
}
|
|
4862
|
+
}
|
|
4863
|
+
}
|
|
4864
|
+
return kept;
|
|
4865
|
+
};
|
|
4866
|
+
var sessionIdVariantsFor = (scopes, includeSessionId) => new Set(
|
|
4867
|
+
scopes.filter((scope) => scope.signals.metrics).map((scope) => includeSessionId && scope.includeSessionId)
|
|
4868
|
+
);
|
|
4869
|
+
|
|
4628
4870
|
// src/telemetry/export-destinations.ts
|
|
4629
4871
|
var spoolQueueNamesFor = (destination) => destination === DEFAULT_DESTINATION_NAME ? { traces: "spool", logs: "spool-logs", metrics: "spool-metrics" } : {
|
|
4630
4872
|
traces: `destinations/${destination}/spool`,
|
|
@@ -4691,6 +4933,8 @@ var createExportDestinationSinks = (options) => {
|
|
|
4691
4933
|
...options.exporter.endpointDownMillis === void 0 ? {} : { downMillis: options.exporter.endpointDownMillis },
|
|
4692
4934
|
probeMillis: effectiveExportTimeoutMillis(options.exporter) + 1e3
|
|
4693
4935
|
});
|
|
4936
|
+
const scopedResourceKey = resourceRepositoryKey(resourceFromExporterPolicy(options.exporter).attributes);
|
|
4937
|
+
const restrict = options.restrictContent ?? omitRestrictedContent;
|
|
4694
4938
|
for (const destination of resolveExportDestinations(options.exporter)) {
|
|
4695
4939
|
let headers;
|
|
4696
4940
|
let logHeaders;
|
|
@@ -4780,24 +5024,59 @@ var createExportDestinationSinks = (options) => {
|
|
|
4780
5024
|
metrics,
|
|
4781
5025
|
...spool === void 0 ? {} : { spool },
|
|
4782
5026
|
...logSpool === void 0 ? {} : { logSpool },
|
|
4783
|
-
...metricSpool === void 0 ? {} : { metricSpool }
|
|
5027
|
+
...metricSpool === void 0 ? {} : { metricSpool },
|
|
5028
|
+
...destination.scopes === void 0 ? {} : {
|
|
5029
|
+
scopes: destination.scopes,
|
|
5030
|
+
route: (events, workspaceRepositoryKey) => routeEventsToScopes(events, destination.scopes ?? [], {
|
|
5031
|
+
...scopedResourceKey === void 0 ? {} : { resourceRepositoryKey: scopedResourceKey },
|
|
5032
|
+
...workspaceRepositoryKey === void 0 ? {} : { workspaceRepositoryKey },
|
|
5033
|
+
restrict
|
|
5034
|
+
})
|
|
5035
|
+
}
|
|
4784
5036
|
});
|
|
4785
5037
|
}
|
|
4786
5038
|
return { destinations, skipped };
|
|
4787
5039
|
};
|
|
4788
|
-
var
|
|
5040
|
+
var createScopedFanout = (destination, correlate) => {
|
|
5041
|
+
const route = destination.route;
|
|
5042
|
+
const unscoped = createSignalFanout({ traces: destination.traces, logs: destination.logs });
|
|
5043
|
+
if (route === void 0) {
|
|
5044
|
+
return unscoped;
|
|
5045
|
+
}
|
|
5046
|
+
const none = { accepted: 0, rejected: 0, errors: [] };
|
|
5047
|
+
return {
|
|
5048
|
+
...unscoped,
|
|
5049
|
+
emit: async (events, emitOptions) => {
|
|
5050
|
+
const batch = route(events, emitOptions?.workspaceRepositoryKey);
|
|
5051
|
+
if (correlate !== void 0 && (batch.traces.length > 0 || batch.logs.length > 0)) {
|
|
5052
|
+
await correlate(events);
|
|
5053
|
+
correlate.alias(batch.traces, events);
|
|
5054
|
+
correlate.alias(batch.logs, events);
|
|
5055
|
+
}
|
|
5056
|
+
const traces = batch.traces.length === 0 ? none : await destination.traces.emit(batch.traces);
|
|
5057
|
+
const logs = batch.logs.length === 0 ? none : await destination.logs.emit(batch.logs);
|
|
5058
|
+
return {
|
|
5059
|
+
accepted: traces.accepted + logs.accepted,
|
|
5060
|
+
rejected: traces.rejected + logs.rejected,
|
|
5061
|
+
errors: [...traces.errors, ...logs.errors]
|
|
5062
|
+
};
|
|
5063
|
+
}
|
|
5064
|
+
};
|
|
5065
|
+
};
|
|
5066
|
+
var createDestinationFanout = (destinations, options = {}) => {
|
|
4789
5067
|
const fanouts = destinations.map((destination) => ({
|
|
4790
5068
|
name: destination.name,
|
|
4791
|
-
sink:
|
|
5069
|
+
sink: createScopedFanout(destination, options.correlate)
|
|
4792
5070
|
}));
|
|
4793
|
-
const
|
|
5071
|
+
const scoped = destinations.some((destination) => destination.route !== void 0);
|
|
5072
|
+
const only = fanouts.length === 1 && !scoped ? fanouts[0] : void 0;
|
|
4794
5073
|
if (only !== void 0) {
|
|
4795
5074
|
return only.sink;
|
|
4796
5075
|
}
|
|
4797
|
-
const emit = async (events) => {
|
|
5076
|
+
const emit = async (events, emitOptions) => {
|
|
4798
5077
|
const results = await Promise.all(
|
|
4799
5078
|
fanouts.map(
|
|
4800
|
-
(fanout) => fanout.sink.emit(events).catch(
|
|
5079
|
+
(fanout) => fanout.sink.emit(events, emitOptions).catch(
|
|
4801
5080
|
(thrown) => ({
|
|
4802
5081
|
accepted: 0,
|
|
4803
5082
|
rejected: events.length,
|
|
@@ -4859,13 +5138,21 @@ export {
|
|
|
4859
5138
|
deriveMetricObservations,
|
|
4860
5139
|
describeLogsDeliverability,
|
|
4861
5140
|
describeMetricsDeliverability,
|
|
5141
|
+
eventRepositoryKey,
|
|
4862
5142
|
exporterPolicyForDestination,
|
|
4863
5143
|
isPermanentExportFailure,
|
|
4864
5144
|
logSignalOf,
|
|
4865
5145
|
logSignalsForLifecycleEvents,
|
|
5146
|
+
omitRestrictedContent,
|
|
4866
5147
|
parentScopeRefOf,
|
|
5148
|
+
pointRepositoryKey,
|
|
4867
5149
|
resolveLogsEndpoint,
|
|
4868
5150
|
resolveMetricsEndpoint,
|
|
5151
|
+
resourceRepositoryKey,
|
|
5152
|
+
restrictEventContent,
|
|
5153
|
+
routeEventsToScopes,
|
|
5154
|
+
routePointsToScopes,
|
|
5155
|
+
sessionIdVariantsFor,
|
|
4869
5156
|
shareCorrelationPerBatch,
|
|
4870
5157
|
spanScopeRefOf,
|
|
4871
5158
|
spoolQueueNamesFor,
|