@mastra/observability 1.17.0-alpha.0 → 1.17.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 +40 -0
- package/dist/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/index.cjs +85 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +85 -26
- package/dist/index.js.map +1 -1
- package/dist/span_processors/sensitive-data-filter.d.ts +22 -3
- package/dist/span_processors/sensitive-data-filter.d.ts.map +1 -1
- package/package.json +6 -6
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { SpanOutputProcessor, AnySpan } from '@mastra/core/observability';
|
|
2
|
-
export type RedactionStyle = 'full' | 'partial';
|
|
2
|
+
export type RedactionStyle = 'full' | 'partial' | 'indexed';
|
|
3
3
|
/**
|
|
4
4
|
* Options for configuring the SensitiveDataFilter.
|
|
5
5
|
*/
|
|
@@ -21,6 +21,13 @@ export interface SensitiveDataFilterOptions {
|
|
|
21
21
|
* Style of redaction to use:
|
|
22
22
|
* - "full": always replace with redactionToken.
|
|
23
23
|
* - "partial": show 3 characters from the start and end, redact the middle.
|
|
24
|
+
* - "indexed": replace each unique value with a stable token derived from the
|
|
25
|
+
* matched field name, e.g. `[APIKEY_1]`. The same value maps to the same
|
|
26
|
+
* token across the spans of a trace while the trace's mapping is retained,
|
|
27
|
+
* so redacted values stay correlatable without exposing the raw value.
|
|
28
|
+
* Mapping is scoped per trace and bounded: state is kept for the 1000 most
|
|
29
|
+
* recently used traces, and each trace tracks up to 1000 unique values
|
|
30
|
+
* (further new values fall back to the full redaction token).
|
|
24
31
|
*
|
|
25
32
|
* Default: "full"
|
|
26
33
|
*/
|
|
@@ -32,8 +39,10 @@ export interface SensitiveDataFilterOptions {
|
|
|
32
39
|
* An SpanOutputProcessor that redacts sensitive information from span fields.
|
|
33
40
|
*
|
|
34
41
|
* - Sensitive keys are matched case-insensitively, normalized to remove separators.
|
|
35
|
-
* - Sensitive values are redacted using
|
|
42
|
+
* - Sensitive values are redacted using full, partial, or indexed redaction.
|
|
36
43
|
* - Partial redaction always keeps 3 chars at the start and end.
|
|
44
|
+
* - Indexed redaction assigns each unique value a stable `[LABEL_N]` token,
|
|
45
|
+
* consistent across all spans of a trace.
|
|
37
46
|
* - JSON strings containing sensitive fields are parsed and redacted.
|
|
38
47
|
* - If filtering a field fails, the field is replaced with:
|
|
39
48
|
* `{ error: { processor: "sensitive-data-filter" } }`
|
|
@@ -43,6 +52,7 @@ export declare class SensitiveDataFilter implements SpanOutputProcessor {
|
|
|
43
52
|
private sensitiveFields;
|
|
44
53
|
private redactionToken;
|
|
45
54
|
private redactionStyle;
|
|
55
|
+
private traceStates;
|
|
46
56
|
constructor(options?: SensitiveDataFilterOptions);
|
|
47
57
|
/**
|
|
48
58
|
* Process a span by filtering sensitive data across its key fields.
|
|
@@ -52,6 +62,12 @@ export declare class SensitiveDataFilter implements SpanOutputProcessor {
|
|
|
52
62
|
* @returns A new span with sensitive values redacted
|
|
53
63
|
*/
|
|
54
64
|
process(span: AnySpan): AnySpan;
|
|
65
|
+
/**
|
|
66
|
+
* Get (or create) the indexed-redaction state for a trace.
|
|
67
|
+
* Uses the Map's insertion order as an LRU: accessed traces are re-inserted,
|
|
68
|
+
* and the least recently used trace is evicted once the cap is exceeded.
|
|
69
|
+
*/
|
|
70
|
+
private getTraceState;
|
|
55
71
|
/**
|
|
56
72
|
* Recursively filter objects/arrays for sensitive keys.
|
|
57
73
|
* Handles circular references by replacing with a marker.
|
|
@@ -83,8 +99,11 @@ export declare class SensitiveDataFilter implements SpanOutputProcessor {
|
|
|
83
99
|
* Redact a sensitive value.
|
|
84
100
|
* - Full style: replaces with a fixed token.
|
|
85
101
|
* - Partial style: shows 3 chars at start and end, hides the middle.
|
|
102
|
+
* - Indexed style: replaces with a stable `[LABEL_N]` token, where the label
|
|
103
|
+
* comes from the normalized field name and the same value always maps to
|
|
104
|
+
* the same token within a trace.
|
|
86
105
|
*
|
|
87
|
-
* Non-string values are converted to strings before partial redaction.
|
|
106
|
+
* Non-string values are converted to strings before partial or indexed redaction.
|
|
88
107
|
*/
|
|
89
108
|
private redactValue;
|
|
90
109
|
shutdown(): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sensitive-data-filter.d.ts","sourceRoot":"","sources":["../../src/span_processors/sensitive-data-filter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sensitive-data-filter.d.ts","sourceRoot":"","sources":["../../src/span_processors/sensitive-data-filter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAE/E,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,CAAC;AA0B5D;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAE3B;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;;;;;;;;;;;OAaG;IACH,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC;AAED;;;;;;;;;;;;;GAaG;AACH,qBAAa,mBAAoB,YAAW,mBAAmB;IAC7D,IAAI,SAA2B;IAC/B,OAAO,CAAC,eAAe,CAAW;IAClC,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,WAAW,CAA4C;gBAEnD,OAAO,GAAE,0BAA+B;IAyBpD;;;;;;OAMG;IACH,OAAO,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO;IAU/B;;;;OAIG;IACH,OAAO,CAAC,aAAa;IAgBrB;;;;OAIG;IACH,OAAO,CAAC,UAAU;IA8ClB,OAAO,CAAC,SAAS;IAQjB;;;OAGG;IACH,OAAO,CAAC,YAAY;IAIpB;;;;;;;;OAQG;IACH,OAAO,CAAC,WAAW;IAOnB;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IAmBxB;;;;;;;;;OASG;IACH,OAAO,CAAC,WAAW;IA8Bb,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAGhC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/observability",
|
|
3
|
-
"version": "1.17.0
|
|
3
|
+
"version": "1.17.0",
|
|
4
4
|
"description": "Core observability package for Mastra - includes tracing and scoring features",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -32,11 +32,11 @@
|
|
|
32
32
|
"typescript": "^6.0.3",
|
|
33
33
|
"vitest": "4.1.10",
|
|
34
34
|
"zod": "^4.4.3",
|
|
35
|
-
"@internal/
|
|
36
|
-
"@internal/
|
|
37
|
-
"@internal/ai-sdk-
|
|
38
|
-
"@internal/
|
|
39
|
-
"@mastra/core": "1.59.0
|
|
35
|
+
"@internal/lint": "0.0.123",
|
|
36
|
+
"@internal/types-builder": "0.0.98",
|
|
37
|
+
"@internal/ai-sdk-v4": "0.0.70",
|
|
38
|
+
"@internal/ai-sdk-v5": "0.0.70",
|
|
39
|
+
"@mastra/core": "1.59.0"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"@mastra/core": ">=1.16.0-0 <2.0.0-0",
|