risicare 0.9.2 → 0.10.0
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/CHANGELOG.md +183 -0
- package/README.md +37 -19
- package/dist/frameworks/instructor.cjs +46 -1
- package/dist/frameworks/instructor.cjs.map +1 -1
- package/dist/frameworks/instructor.js +46 -1
- package/dist/frameworks/instructor.js.map +1 -1
- package/dist/frameworks/langchain.cjs +46 -1
- package/dist/frameworks/langchain.cjs.map +1 -1
- package/dist/frameworks/langchain.js +46 -1
- package/dist/frameworks/langchain.js.map +1 -1
- package/dist/frameworks/langgraph.cjs +46 -1
- package/dist/frameworks/langgraph.cjs.map +1 -1
- package/dist/frameworks/langgraph.js +46 -1
- package/dist/frameworks/langgraph.js.map +1 -1
- package/dist/frameworks/llamaindex.cjs +46 -1
- package/dist/frameworks/llamaindex.cjs.map +1 -1
- package/dist/frameworks/llamaindex.js +46 -1
- package/dist/frameworks/llamaindex.js.map +1 -1
- package/dist/index.cjs +329 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -5
- package/dist/index.d.ts +14 -5
- package/dist/index.js +329 -15
- package/dist/index.js.map +1 -1
- package/dist/providers/anthropic/index.cjs +117 -8
- package/dist/providers/anthropic/index.cjs.map +1 -1
- package/dist/providers/anthropic/index.js +117 -8
- package/dist/providers/anthropic/index.js.map +1 -1
- package/dist/providers/bedrock/index.cjs +64 -4
- package/dist/providers/bedrock/index.cjs.map +1 -1
- package/dist/providers/bedrock/index.js +64 -4
- package/dist/providers/bedrock/index.js.map +1 -1
- package/dist/providers/cerebras/index.cjs +64 -4
- package/dist/providers/cerebras/index.cjs.map +1 -1
- package/dist/providers/cerebras/index.js +64 -4
- package/dist/providers/cerebras/index.js.map +1 -1
- package/dist/providers/cohere/index.cjs +64 -4
- package/dist/providers/cohere/index.cjs.map +1 -1
- package/dist/providers/cohere/index.js +64 -4
- package/dist/providers/cohere/index.js.map +1 -1
- package/dist/providers/google/index.cjs +64 -4
- package/dist/providers/google/index.cjs.map +1 -1
- package/dist/providers/google/index.js +64 -4
- package/dist/providers/google/index.js.map +1 -1
- package/dist/providers/groq/index.cjs +64 -4
- package/dist/providers/groq/index.cjs.map +1 -1
- package/dist/providers/groq/index.js +64 -4
- package/dist/providers/groq/index.js.map +1 -1
- package/dist/providers/huggingface/index.cjs +64 -4
- package/dist/providers/huggingface/index.cjs.map +1 -1
- package/dist/providers/huggingface/index.js +64 -4
- package/dist/providers/huggingface/index.js.map +1 -1
- package/dist/providers/mistral/index.cjs +64 -4
- package/dist/providers/mistral/index.cjs.map +1 -1
- package/dist/providers/mistral/index.js +64 -4
- package/dist/providers/mistral/index.js.map +1 -1
- package/dist/providers/ollama/index.cjs +64 -4
- package/dist/providers/ollama/index.cjs.map +1 -1
- package/dist/providers/ollama/index.js +64 -4
- package/dist/providers/ollama/index.js.map +1 -1
- package/dist/providers/openai/index.cjs +102 -6
- package/dist/providers/openai/index.cjs.map +1 -1
- package/dist/providers/openai/index.js +102 -6
- package/dist/providers/openai/index.js.map +1 -1
- package/dist/providers/together/index.cjs +64 -4
- package/dist/providers/together/index.cjs.map +1 -1
- package/dist/providers/together/index.js +64 -4
- package/dist/providers/together/index.js.map +1 -1
- package/dist/providers/vercel-ai/index.cjs +48 -3
- package/dist/providers/vercel-ai/index.cjs.map +1 -1
- package/dist/providers/vercel-ai/index.js +48 -3
- package/dist/providers/vercel-ai/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -310,10 +310,17 @@ interface RisicareConfig {
|
|
|
310
310
|
/**
|
|
311
311
|
* Whether prompt/completion content may leave the process.
|
|
312
312
|
*
|
|
313
|
-
* **Default `
|
|
314
|
-
*
|
|
315
|
-
*
|
|
316
|
-
*
|
|
313
|
+
* **Default `true`** (capture is on). Set `false`, or set
|
|
314
|
+
* `RISICARE_TRACE_CONTENT=false`, to stop capture. Capture was on through
|
|
315
|
+
* 0.5.0, off by default from 0.5.2 to 0.9.2, and is on by default again after
|
|
316
|
+
* 0.9.2. When false, every content-keyed attribute is replaced with
|
|
317
|
+
* `<risicare:content-omitted>` on the export path — including content you
|
|
318
|
+
* set by hand, which 0.5.0 and earlier did NOT gate. The project setting in
|
|
319
|
+
* the Risicare dashboard can also turn content off for a project; the
|
|
320
|
+
* gateway then drops it. With `traceContent: false`, the SDK still sends the
|
|
321
|
+
* status message, the exception message, the stack trace (which repeats the
|
|
322
|
+
* message), `error.message` and `exception.message`. Only the project switch
|
|
323
|
+
* masks them, at the gateway.
|
|
317
324
|
*/
|
|
318
325
|
traceContent?: boolean;
|
|
319
326
|
/** Sample rate 0.0–1.0 (default: 1.0 = trace all) */
|
|
@@ -400,7 +407,9 @@ interface TracerConfig {
|
|
|
400
407
|
/** Whether tracing is enabled */
|
|
401
408
|
enabled?: boolean;
|
|
402
409
|
/**
|
|
403
|
-
* Whether prompt/completion content may leave the process
|
|
410
|
+
* Whether prompt/completion content may leave the process. A Tracer built
|
|
411
|
+
* without this value uses `false` (fail-closed); that is NOT the user default,
|
|
412
|
+
* which is `true` in `resolveConfig`.
|
|
404
413
|
*
|
|
405
414
|
* ⚠ The Tracer only CARRIES this for the provider patches to read via
|
|
406
415
|
* `getTraceContent()`. It is NOT the enforcement point — the gate runs in the
|
package/dist/index.d.ts
CHANGED
|
@@ -310,10 +310,17 @@ interface RisicareConfig {
|
|
|
310
310
|
/**
|
|
311
311
|
* Whether prompt/completion content may leave the process.
|
|
312
312
|
*
|
|
313
|
-
* **Default `
|
|
314
|
-
*
|
|
315
|
-
*
|
|
316
|
-
*
|
|
313
|
+
* **Default `true`** (capture is on). Set `false`, or set
|
|
314
|
+
* `RISICARE_TRACE_CONTENT=false`, to stop capture. Capture was on through
|
|
315
|
+
* 0.5.0, off by default from 0.5.2 to 0.9.2, and is on by default again after
|
|
316
|
+
* 0.9.2. When false, every content-keyed attribute is replaced with
|
|
317
|
+
* `<risicare:content-omitted>` on the export path — including content you
|
|
318
|
+
* set by hand, which 0.5.0 and earlier did NOT gate. The project setting in
|
|
319
|
+
* the Risicare dashboard can also turn content off for a project; the
|
|
320
|
+
* gateway then drops it. With `traceContent: false`, the SDK still sends the
|
|
321
|
+
* status message, the exception message, the stack trace (which repeats the
|
|
322
|
+
* message), `error.message` and `exception.message`. Only the project switch
|
|
323
|
+
* masks them, at the gateway.
|
|
317
324
|
*/
|
|
318
325
|
traceContent?: boolean;
|
|
319
326
|
/** Sample rate 0.0–1.0 (default: 1.0 = trace all) */
|
|
@@ -400,7 +407,9 @@ interface TracerConfig {
|
|
|
400
407
|
/** Whether tracing is enabled */
|
|
401
408
|
enabled?: boolean;
|
|
402
409
|
/**
|
|
403
|
-
* Whether prompt/completion content may leave the process
|
|
410
|
+
* Whether prompt/completion content may leave the process. A Tracer built
|
|
411
|
+
* without this value uses `false` (fail-closed); that is NOT the user default,
|
|
412
|
+
* which is `true` in `resolveConfig`.
|
|
404
413
|
*
|
|
405
414
|
* ⚠ The Tracer only CARRIES this for the provider patches to read via
|
|
406
415
|
* `getTraceContent()`. It is NOT the enforcement point — the gate runs in the
|
package/dist/index.js
CHANGED
|
@@ -281,7 +281,49 @@ var CONTENT_KEYS_EXACT = /* @__PURE__ */ new Set([
|
|
|
281
281
|
"audio.transcript",
|
|
282
282
|
"traceloop.entity.input",
|
|
283
283
|
// OpenLLMetry
|
|
284
|
-
"traceloop.entity.output"
|
|
284
|
+
"traceloop.entity.output",
|
|
285
|
+
// Gateway corpus v2 (R41): the content keys of more frameworks. The same 75
|
|
286
|
+
// keys as `CONTENT_KEYS_EXACT` in the gateway's `content_control.rs`.
|
|
287
|
+
"agent.backstory",
|
|
288
|
+
// OpenInference
|
|
289
|
+
"agent.goal",
|
|
290
|
+
"llm.available_functions",
|
|
291
|
+
"llm.tools",
|
|
292
|
+
"ai.prompt",
|
|
293
|
+
// Vercel AI SDK
|
|
294
|
+
"ai.prompt.messages",
|
|
295
|
+
"ai.prompt.tools",
|
|
296
|
+
"ai.response.files",
|
|
297
|
+
"ai.response.object",
|
|
298
|
+
"ai.response.reasoning",
|
|
299
|
+
"ai.response.text",
|
|
300
|
+
"ai.response.toolCalls",
|
|
301
|
+
"ai.result.object",
|
|
302
|
+
// the older Vercel names
|
|
303
|
+
"ai.result.text",
|
|
304
|
+
"ai.result.toolCalls",
|
|
305
|
+
"ai.toolCall.args",
|
|
306
|
+
"ai.toolCall.result",
|
|
307
|
+
"ai.value",
|
|
308
|
+
// the text of an embedding call
|
|
309
|
+
"ai.values",
|
|
310
|
+
"final_result",
|
|
311
|
+
// Pydantic AI
|
|
312
|
+
"model_request_parameters",
|
|
313
|
+
"pydantic_ai.all_messages",
|
|
314
|
+
"tool_arguments",
|
|
315
|
+
"tool_response",
|
|
316
|
+
"gcp.vertex.agent.data",
|
|
317
|
+
// Google ADK
|
|
318
|
+
"gcp.vertex.agent.llm_request",
|
|
319
|
+
"gcp.vertex.agent.llm_response",
|
|
320
|
+
"gcp.vertex.agent.tool_call_args",
|
|
321
|
+
"gcp.vertex.agent.tool_response",
|
|
322
|
+
"gen_ai.task.input",
|
|
323
|
+
// OpenLLMetry
|
|
324
|
+
"gen_ai.task.output",
|
|
325
|
+
"sk.available_functions"
|
|
326
|
+
// Semantic Kernel
|
|
285
327
|
]);
|
|
286
328
|
var CONTENT_LAST_SEGMENT_IN_CONTEXT = /* @__PURE__ */ new Map([
|
|
287
329
|
["function_call_arguments_json", /* @__PURE__ */ new Set()],
|
|
@@ -289,7 +331,15 @@ var CONTENT_LAST_SEGMENT_IN_CONTEXT = /* @__PURE__ */ new Map([
|
|
|
289
331
|
["data", /* @__PURE__ */ new Set(["message_content"])],
|
|
290
332
|
["url", /* @__PURE__ */ new Set(["image"])],
|
|
291
333
|
// `image.url` can hold base64 data
|
|
292
|
-
["metadata", /* @__PURE__ */ new Set(["document", "documents"])]
|
|
334
|
+
["metadata", /* @__PURE__ */ new Set(["document", "documents"])],
|
|
335
|
+
// Gateway corpus v2: a list of tool definitions. The `description` of one tool
|
|
336
|
+
// on a tool span (`tool.description`) is not content; the descriptions in a list are.
|
|
337
|
+
["description", /* @__PURE__ */ new Set(["definitions", "functions", "tools"])],
|
|
338
|
+
["json_schema", /* @__PURE__ */ new Set(["tool", "tools"])],
|
|
339
|
+
["parameters", /* @__PURE__ */ new Set(["definitions", "functions", "tool", "tools"])],
|
|
340
|
+
// Gateway corpus v2: the Mastra span I/O, `mastra.<span type>.input|output`.
|
|
341
|
+
["input", /* @__PURE__ */ new Set(["mastra"])],
|
|
342
|
+
["output", /* @__PURE__ */ new Set(["mastra"])]
|
|
293
343
|
]);
|
|
294
344
|
var CONTENT_CONTAINER_SEGMENTS = /* @__PURE__ */ new Set([
|
|
295
345
|
"message",
|
|
@@ -302,8 +352,23 @@ var CONTENT_CONTAINER_SEGMENTS = /* @__PURE__ */ new Set([
|
|
|
302
352
|
"documents",
|
|
303
353
|
"tool_call",
|
|
304
354
|
"tool_calls",
|
|
305
|
-
"function"
|
|
355
|
+
"function",
|
|
356
|
+
// Gateway corpus v2: LiteLLM `gen_ai.completion.{i}.function_call.arguments` and
|
|
357
|
+
// OpenInference `llm.prompts.{i}.prompt.text`.
|
|
358
|
+
"function_call",
|
|
359
|
+
"prompt",
|
|
360
|
+
"prompts"
|
|
361
|
+
]);
|
|
362
|
+
var CONTENT_FIRST_SEGMENTS = /* @__PURE__ */ new Set(["crewai"]);
|
|
363
|
+
var CONTENT_EVENT_NAMES = /* @__PURE__ */ new Set([
|
|
364
|
+
"gen_ai.assistant.message",
|
|
365
|
+
"gen_ai.choice",
|
|
366
|
+
"gen_ai.system.message",
|
|
367
|
+
"gen_ai.tool.message",
|
|
368
|
+
"gen_ai.user.message"
|
|
306
369
|
]);
|
|
370
|
+
var CONTENT_EVENT_PREFIX = "gen_ai.content.";
|
|
371
|
+
var CONTENT_EVENT_KEEP_KEYS = /* @__PURE__ */ new Set(["gen_ai.provider.name", "gen_ai.system"]);
|
|
307
372
|
var CONTENT_KEYS_KEEP_EXACT = /* @__PURE__ */ new Set([
|
|
308
373
|
"gen_ai.response.content_type",
|
|
309
374
|
"gen_ai.response.content_blocks",
|
|
@@ -321,10 +386,60 @@ var KEEP_LAST_SEGMENTS = /* @__PURE__ */ new Set([
|
|
|
321
386
|
"index",
|
|
322
387
|
"model",
|
|
323
388
|
"finish_reason",
|
|
324
|
-
"mime_type"
|
|
389
|
+
"mime_type",
|
|
390
|
+
// Gateway v2 at risicare-ingestion main (PR 94): a model name
|
|
391
|
+
// (`crewai.agent.llm`) and the crew process type are not content.
|
|
392
|
+
"llm",
|
|
393
|
+
"process"
|
|
325
394
|
]);
|
|
326
395
|
var KEEP_LAST_SUFFIXES = ["_length", "_tokens", "_count"];
|
|
396
|
+
var CONTENT_IN_JSON_OBJECT = /* @__PURE__ */ new Map([
|
|
397
|
+
[
|
|
398
|
+
"llm.invocation_parameters",
|
|
399
|
+
/* @__PURE__ */ new Set([
|
|
400
|
+
"additionalinstructions",
|
|
401
|
+
// OpenAI assistants run
|
|
402
|
+
"chathistory",
|
|
403
|
+
// Cohere
|
|
404
|
+
"contents",
|
|
405
|
+
// Gemini
|
|
406
|
+
"documents",
|
|
407
|
+
// Cohere RAG
|
|
408
|
+
"functions",
|
|
409
|
+
"input",
|
|
410
|
+
"inputtext",
|
|
411
|
+
// Bedrock Titan
|
|
412
|
+
"instructions",
|
|
413
|
+
"message",
|
|
414
|
+
// Cohere
|
|
415
|
+
"messages",
|
|
416
|
+
"preamble",
|
|
417
|
+
// Cohere
|
|
418
|
+
"prediction",
|
|
419
|
+
// OpenAI predicted output
|
|
420
|
+
"prompt",
|
|
421
|
+
"system",
|
|
422
|
+
// Anthropic
|
|
423
|
+
"systeminstruction",
|
|
424
|
+
// Gemini
|
|
425
|
+
"texts",
|
|
426
|
+
// Cohere embed
|
|
427
|
+
"toolconfig",
|
|
428
|
+
// Gemini
|
|
429
|
+
"tools"
|
|
430
|
+
])
|
|
431
|
+
]
|
|
432
|
+
]);
|
|
433
|
+
var VALUE_RULE_PREFIXES = new Set(
|
|
434
|
+
[...CONTENT_IN_JSON_OBJECT.keys()].flatMap((key) => {
|
|
435
|
+
const segments = key.split(".");
|
|
436
|
+
return segments.slice(1).map((_, i) => segments.slice(0, i + 1).join("."));
|
|
437
|
+
})
|
|
438
|
+
);
|
|
327
439
|
var CONTENT_OMITTED_MARKER = "<risicare:content-omitted>";
|
|
440
|
+
function hasKeepLastSegment(last) {
|
|
441
|
+
return KEEP_LAST_SEGMENTS.has(last) || KEEP_LAST_SUFFIXES.some((x) => last.endsWith(x));
|
|
442
|
+
}
|
|
328
443
|
function isContentKey(key) {
|
|
329
444
|
if (CONTENT_KEYS_KEEP_EXACT.has(key)) return false;
|
|
330
445
|
if (CONTENT_KEYS_EXACT.has(key) || key.endsWith("_content")) return true;
|
|
@@ -334,25 +449,220 @@ function isContentKey(key) {
|
|
|
334
449
|
if (context && (context.size === 0 || segments.slice(0, -1).some((s) => context.has(s)))) {
|
|
335
450
|
return true;
|
|
336
451
|
}
|
|
337
|
-
if (
|
|
452
|
+
if (hasKeepLastSegment(last)) {
|
|
338
453
|
return false;
|
|
339
454
|
}
|
|
455
|
+
if (segments.length > 1 && CONTENT_FIRST_SEGMENTS.has(segments[0])) return true;
|
|
340
456
|
if (last === "content") return true;
|
|
341
457
|
if (last === "text" || last === "arguments") {
|
|
342
458
|
return segments.slice(0, -1).some((s) => CONTENT_CONTAINER_SEGMENTS.has(s));
|
|
343
459
|
}
|
|
344
460
|
return false;
|
|
345
461
|
}
|
|
346
|
-
function
|
|
462
|
+
function isContentEvent(name) {
|
|
463
|
+
return CONTENT_EVENT_NAMES.has(name) || name.startsWith(CONTENT_EVENT_PREFIX);
|
|
464
|
+
}
|
|
465
|
+
function isContentEventAttribute(key) {
|
|
466
|
+
if (isContentKey(key)) return true;
|
|
467
|
+
const last = key.slice(key.lastIndexOf(".") + 1);
|
|
468
|
+
return !(CONTENT_KEYS_KEEP_EXACT.has(key) || CONTENT_EVENT_KEEP_KEYS.has(key) || hasKeepLastSegment(last));
|
|
469
|
+
}
|
|
470
|
+
function jsonObjectContentKeys(keyPath, key) {
|
|
471
|
+
for (const [ruleKey, keys] of CONTENT_IN_JSON_OBJECT) {
|
|
472
|
+
if (ruleKey === keyPath || ruleKey === key) return keys;
|
|
473
|
+
}
|
|
474
|
+
return void 0;
|
|
475
|
+
}
|
|
476
|
+
function isJsonObject(value) {
|
|
477
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
478
|
+
}
|
|
479
|
+
function flatValueRule(keyPath, key) {
|
|
480
|
+
for (const [ruleKey, keys] of CONTENT_IN_JSON_OBJECT) {
|
|
481
|
+
for (const k of [keyPath, key]) {
|
|
482
|
+
if (k.startsWith(`${ruleKey}.`)) return [k.slice(ruleKey.length + 1), keys];
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
return void 0;
|
|
486
|
+
}
|
|
487
|
+
function normalisedKey(key) {
|
|
488
|
+
return key.replace(/_/g, "").replace(/[A-Z]/g, (c) => c.toLowerCase());
|
|
489
|
+
}
|
|
490
|
+
function namesListedKey(key, keys) {
|
|
491
|
+
return key.split(".").some((part) => keys.has(normalisedKey(part)));
|
|
492
|
+
}
|
|
493
|
+
function isKeyRuleText(keyPath, key) {
|
|
494
|
+
return isContentKey(keyPath) || isContentKey(key);
|
|
495
|
+
}
|
|
496
|
+
function startsAsJson(text) {
|
|
497
|
+
return /^[ \t\n\r]*[{[]/.test(text);
|
|
498
|
+
}
|
|
499
|
+
function parseJson(text) {
|
|
500
|
+
return JSON.parse(text, (_key, value) => {
|
|
501
|
+
if (typeof value === "number" && !Number.isFinite(value)) {
|
|
502
|
+
throw new RangeError("not JSON: a number out of range");
|
|
503
|
+
}
|
|
504
|
+
return value;
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
function jsonCopy(value) {
|
|
508
|
+
return parseJson(
|
|
509
|
+
JSON.stringify(value, (_key, v) => {
|
|
510
|
+
if (typeof v === "number" && !Number.isFinite(v)) throw new RangeError("not JSON: a non-finite number");
|
|
511
|
+
return v;
|
|
512
|
+
})
|
|
513
|
+
);
|
|
514
|
+
}
|
|
515
|
+
function omitInJsonObject(value, keyPath, keys) {
|
|
516
|
+
try {
|
|
517
|
+
let parsed;
|
|
518
|
+
if (typeof value === "string") parsed = parseJson(value);
|
|
519
|
+
else if (typeof value === "object" && value !== null) parsed = jsonCopy(value);
|
|
520
|
+
if (!isJsonObject(parsed)) return [CONTENT_OMITTED_MARKER, 1];
|
|
521
|
+
let n = 0;
|
|
522
|
+
for (const k of Object.keys(parsed)) {
|
|
523
|
+
const [entry, count] = omitInParameterEntry(parsed[k], `${keyPath}.${k}`, k, keys);
|
|
524
|
+
parsed[k] = entry;
|
|
525
|
+
n += count;
|
|
526
|
+
}
|
|
527
|
+
return [typeof value === "string" ? JSON.stringify(parsed) : parsed, n];
|
|
528
|
+
} catch {
|
|
529
|
+
return [CONTENT_OMITTED_MARKER, 1];
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
function omitInParameterEntry(value, keyPath, key, keys) {
|
|
533
|
+
if (namesListedKey(key, keys) || isKeyRuleText(keyPath, key)) return [CONTENT_OMITTED_MARKER, 1];
|
|
534
|
+
return omitInParameter(value, keyPath, keys);
|
|
535
|
+
}
|
|
536
|
+
function omitInParameter(value, path, keys) {
|
|
347
537
|
let n = 0;
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
538
|
+
if (Array.isArray(value)) {
|
|
539
|
+
value.forEach((item, i) => {
|
|
540
|
+
const [entry, count] = omitInParameter(item, `${path}.${i}`, keys);
|
|
541
|
+
value[i] = entry;
|
|
542
|
+
n += count;
|
|
543
|
+
});
|
|
544
|
+
} else if (isJsonObject(value)) {
|
|
545
|
+
for (const k of Object.keys(value)) {
|
|
546
|
+
const [entry, count] = omitInParameterEntry(value[k], `${path}.${k}`, k, keys);
|
|
547
|
+
value[k] = entry;
|
|
548
|
+
n += count;
|
|
549
|
+
}
|
|
550
|
+
} else if (typeof value === "string" && startsAsJson(value)) {
|
|
551
|
+
try {
|
|
552
|
+
const [tree, count] = omitInParameter(parseJson(value), path, keys);
|
|
553
|
+
return [count ? JSON.stringify(tree) : value, count];
|
|
554
|
+
} catch {
|
|
555
|
+
return [CONTENT_OMITTED_MARKER, 1];
|
|
352
556
|
}
|
|
353
557
|
}
|
|
558
|
+
return [value, n];
|
|
559
|
+
}
|
|
560
|
+
function omitFlat(value, keyPath, key, rest, keys) {
|
|
561
|
+
if (namesListedKey(rest, keys) || isKeyRuleText(keyPath, key)) return [CONTENT_OMITTED_MARKER, 1];
|
|
562
|
+
try {
|
|
563
|
+
if (typeof value === "object" && value !== null) {
|
|
564
|
+
const [tree, n] = omitInParameter(jsonCopy(value), keyPath, keys);
|
|
565
|
+
return n ? [tree, n] : [value, 0];
|
|
566
|
+
}
|
|
567
|
+
return omitInParameter(value, keyPath, keys);
|
|
568
|
+
} catch {
|
|
569
|
+
return [CONTENT_OMITTED_MARKER, 1];
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
function omitBelow(value, path) {
|
|
573
|
+
const text = typeof value === "string" ? value : value instanceof String ? value.valueOf() : void 0;
|
|
574
|
+
if (text !== void 0) {
|
|
575
|
+
let tree;
|
|
576
|
+
try {
|
|
577
|
+
tree = parseJson(text);
|
|
578
|
+
} catch {
|
|
579
|
+
return startsAsJson(text) ? [CONTENT_OMITTED_MARKER, 1] : [value, 0];
|
|
580
|
+
}
|
|
581
|
+
if (typeof tree !== "object" || tree === null) return [value, 0];
|
|
582
|
+
try {
|
|
583
|
+
const [n, found] = omitBelowParsed(tree, path);
|
|
584
|
+
return found ? [JSON.stringify(tree), n] : [value, 0];
|
|
585
|
+
} catch {
|
|
586
|
+
return [CONTENT_OMITTED_MARKER, 1];
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
if (typeof value !== "object" || value === null) return [value, 0];
|
|
590
|
+
try {
|
|
591
|
+
const tree = jsonCopy(value);
|
|
592
|
+
const [n, found] = omitBelowParsed(tree, path);
|
|
593
|
+
return found ? [tree, n] : [value, 0];
|
|
594
|
+
} catch {
|
|
595
|
+
return [CONTENT_OMITTED_MARKER, 1];
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
function omitBelowParsed(tree, path) {
|
|
599
|
+
let n = 0;
|
|
600
|
+
let found = false;
|
|
601
|
+
if (Array.isArray(tree)) {
|
|
602
|
+
tree.forEach((item, i) => {
|
|
603
|
+
const child = `${path}.${i}`;
|
|
604
|
+
if (!VALUE_RULE_PREFIXES.has(child)) return;
|
|
605
|
+
const [count, below] = omitBelowParsed(item, child);
|
|
606
|
+
n += count;
|
|
607
|
+
found ||= below;
|
|
608
|
+
});
|
|
609
|
+
} else if (isJsonObject(tree)) {
|
|
610
|
+
for (const k of Object.keys(tree)) {
|
|
611
|
+
const child = `${path}.${k}`;
|
|
612
|
+
const keys = jsonObjectContentKeys(child, k);
|
|
613
|
+
const flat = keys ? void 0 : flatValueRule(child, k);
|
|
614
|
+
if (keys) {
|
|
615
|
+
const [entry, count] = omitInJsonObject(tree[k], child, keys);
|
|
616
|
+
tree[k] = entry;
|
|
617
|
+
n += count;
|
|
618
|
+
found = true;
|
|
619
|
+
} else if (flat) {
|
|
620
|
+
const [entry, count] = omitFlat(tree[k], child, k, flat[0], flat[1]);
|
|
621
|
+
tree[k] = entry;
|
|
622
|
+
n += count;
|
|
623
|
+
found = true;
|
|
624
|
+
} else if (VALUE_RULE_PREFIXES.has(child)) {
|
|
625
|
+
const [count, below] = omitBelowParsed(tree[k], child);
|
|
626
|
+
n += count;
|
|
627
|
+
found ||= below;
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
return [n, found];
|
|
632
|
+
}
|
|
633
|
+
function reachesValueRule(key) {
|
|
634
|
+
return CONTENT_IN_JSON_OBJECT.has(key) || VALUE_RULE_PREFIXES.has(key) || flatValueRule(key, key) !== void 0;
|
|
635
|
+
}
|
|
636
|
+
function stripAttributes(attrs, rule = isContentKey) {
|
|
637
|
+
let n = 0;
|
|
638
|
+
for (const k of Object.keys(attrs)) {
|
|
639
|
+
const keys = rule === isContentKey ? jsonObjectContentKeys(k, k) : void 0;
|
|
640
|
+
const flat = rule === isContentKey && !keys ? flatValueRule(k, k) : void 0;
|
|
641
|
+
let result;
|
|
642
|
+
if (keys) result = omitInJsonObject(attrs[k], k, keys);
|
|
643
|
+
else if (flat) result = omitFlat(attrs[k], k, k, flat[0], flat[1]);
|
|
644
|
+
else if (rule(k)) result = [CONTENT_OMITTED_MARKER, 1];
|
|
645
|
+
else if (VALUE_RULE_PREFIXES.has(k)) result = omitBelow(attrs[k], k);
|
|
646
|
+
else continue;
|
|
647
|
+
attrs[k] = result[0];
|
|
648
|
+
n += result[1];
|
|
649
|
+
}
|
|
354
650
|
return n;
|
|
355
651
|
}
|
|
652
|
+
function stripOwned(holder, rule = isContentKey) {
|
|
653
|
+
const attrs = holder.attributes;
|
|
654
|
+
if (!attrs || typeof attrs !== "object" || !Object.keys(attrs).some((k) => rule(k) || reachesValueRule(k))) {
|
|
655
|
+
return 0;
|
|
656
|
+
}
|
|
657
|
+
const copy = { ...attrs };
|
|
658
|
+
try {
|
|
659
|
+
holder.attributes = copy;
|
|
660
|
+
} catch {
|
|
661
|
+
return stripAttributes(attrs, rule);
|
|
662
|
+
}
|
|
663
|
+
if (holder.attributes !== copy) return stripAttributes(attrs, rule);
|
|
664
|
+
return stripAttributes(copy, rule);
|
|
665
|
+
}
|
|
356
666
|
function stripContent(span) {
|
|
357
667
|
let stripped = 0;
|
|
358
668
|
if (span.attributes && typeof span.attributes === "object") {
|
|
@@ -361,14 +671,15 @@ function stripContent(span) {
|
|
|
361
671
|
if (Array.isArray(span.events)) {
|
|
362
672
|
for (const event of span.events) {
|
|
363
673
|
if (event?.attributes && typeof event.attributes === "object") {
|
|
364
|
-
|
|
674
|
+
const messageEvent = typeof event.name === "string" && isContentEvent(event.name);
|
|
675
|
+
stripped += stripOwned(event, messageEvent ? isContentEventAttribute : isContentKey);
|
|
365
676
|
}
|
|
366
677
|
}
|
|
367
678
|
}
|
|
368
679
|
if (Array.isArray(span.links)) {
|
|
369
680
|
for (const link of span.links) {
|
|
370
681
|
if (link?.attributes && typeof link.attributes === "object") {
|
|
371
|
-
stripped +=
|
|
682
|
+
stripped += stripOwned(link);
|
|
372
683
|
}
|
|
373
684
|
}
|
|
374
685
|
}
|
|
@@ -1200,7 +1511,7 @@ function resolveConfig(config) {
|
|
|
1200
1511
|
const environment = config?.environment || env.RISICARE_ENVIRONMENT || "development";
|
|
1201
1512
|
const serviceName = config?.serviceName ?? env.RISICARE_SERVICE_NAME;
|
|
1202
1513
|
const serviceVersion = config?.serviceVersion ?? env.RISICARE_SERVICE_VERSION;
|
|
1203
|
-
const traceContent = config?.traceContent ?? parseBool(env.RISICARE_TRACE_CONTENT,
|
|
1514
|
+
const traceContent = config?.traceContent ?? parseBool(env.RISICARE_TRACE_CONTENT, true);
|
|
1204
1515
|
const sampleRateRaw = config?.sampleRate ?? parseFloat(env.RISICARE_SAMPLE_RATE ?? "1.0");
|
|
1205
1516
|
const debug2 = config?.debug ?? parseBool(env.RISICARE_DEBUG, false);
|
|
1206
1517
|
const compress = config?.compress ?? parseBool(env.RISICARE_COMPRESS, false);
|
|
@@ -2405,7 +2716,7 @@ function markCancel(span, error) {
|
|
|
2405
2716
|
}
|
|
2406
2717
|
|
|
2407
2718
|
// src/version.ts
|
|
2408
|
-
var SDK_VERSION = "0.
|
|
2719
|
+
var SDK_VERSION = "0.10.0";
|
|
2409
2720
|
|
|
2410
2721
|
// src/exporters/quota.ts
|
|
2411
2722
|
var QUOTA_REASON = "monthly_quota_exceeded";
|
|
@@ -4501,7 +4812,10 @@ function init(config) {
|
|
|
4501
4812
|
"environment",
|
|
4502
4813
|
"serviceName",
|
|
4503
4814
|
"serviceVersion",
|
|
4504
|
-
"sampleRate"
|
|
4815
|
+
"sampleRate",
|
|
4816
|
+
// Capture is on by default (R9): a library's early init() must not
|
|
4817
|
+
// make the program's traceContent: false void in silence.
|
|
4818
|
+
"traceContent"
|
|
4505
4819
|
];
|
|
4506
4820
|
for (const k of checkedKeys) {
|
|
4507
4821
|
if (incoming[k] !== existing.config[k]) {
|