@adea-ai/telemetry 4.1.2 → 4.2.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/README.md +6 -6
- package/dist/redaction.js +36 -15
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -41,19 +41,19 @@ import { createSentryErrorTracker } from '@adea-ai/telemetry/sentry'
|
|
|
41
41
|
|
|
42
42
|
## What's inside
|
|
43
43
|
|
|
44
|
-
- **Structured logging
|
|
44
|
+
- **Structured logging**: `createStructuredLogger` / `jsonLogger` emit
|
|
45
45
|
redacted JSON lines to stdout/stderr.
|
|
46
|
-
- **Redaction
|
|
46
|
+
- **Redaction**: `redactTelemetryValue` scrubs sensitive keys, bearer
|
|
47
47
|
tokens, GitHub/AWS/Slack/Stripe/Google credentials, URL credentials, and PEM
|
|
48
48
|
blocks from arbitrary values; `redactDiagnostics` applies substring-based
|
|
49
49
|
key matching with an explicit allowlist for diagnostics payloads.
|
|
50
|
-
- **Trace context
|
|
50
|
+
- **Trace context**: W3C-style `traceparent` extraction/injection for
|
|
51
51
|
cross-service correlation.
|
|
52
|
-
- **Sampling
|
|
52
|
+
- **Sampling**: `createDeterministicSamplingPolicy` for stable,
|
|
53
53
|
hash-based span sampling.
|
|
54
|
-
- **Adapters
|
|
54
|
+
- **Adapters**: OpenTelemetry metrics/traces, Sentry error tracking, and a
|
|
55
55
|
LangSmith trace adapter (port-injected, dependency-free).
|
|
56
|
-
- **Catalog** (`@adea-ai/telemetry/catalog`)
|
|
56
|
+
- **Catalog** (`@adea-ai/telemetry/catalog`): the Control Plane's canonical
|
|
57
57
|
execution-trace span names, operational metric names, and diagnostic
|
|
58
58
|
queries.
|
|
59
59
|
|
package/dist/redaction.js
CHANGED
|
@@ -62,7 +62,10 @@ const secretsInText = [
|
|
|
62
62
|
replacement: '[REDACTED_PATH]',
|
|
63
63
|
},
|
|
64
64
|
];
|
|
65
|
+
const mayContainSecretText = /[:=/]|bearer|gh[pousr]_|github_pat_|akia|asia|xox[baprs]-|_live_|aiza|-----begin|localhost|127/i;
|
|
65
66
|
function redactText(value) {
|
|
67
|
+
if (!mayContainSecretText.test(value))
|
|
68
|
+
return value;
|
|
66
69
|
return secretsInText.reduce((redacted, { pattern, replacement }) => redacted.replace(pattern, replacement), value);
|
|
67
70
|
}
|
|
68
71
|
const sensitiveKeySuffix = /(?:token|secret|password|passwd|passphrase|credentials?|apikey|privatekey|accesskey|secretkey|signingkey|encryptionkey|cookie|authorization)$/;
|
|
@@ -91,26 +94,42 @@ function redact(value, seen) {
|
|
|
91
94
|
if (seen.has(value))
|
|
92
95
|
return '[Circular]';
|
|
93
96
|
seen.add(value);
|
|
97
|
+
let result;
|
|
94
98
|
if (Array.isArray(value))
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
+
result = value.map((item) => redact(item, seen));
|
|
100
|
+
else {
|
|
101
|
+
const record = {};
|
|
102
|
+
for (const [key, nested] of Object.entries(value)) {
|
|
103
|
+
setOwn(record, key, isSensitiveKey(key) ? '[REDACTED]' : redact(nested, seen));
|
|
104
|
+
}
|
|
105
|
+
result = record;
|
|
99
106
|
}
|
|
107
|
+
seen.delete(value);
|
|
100
108
|
return result;
|
|
101
109
|
}
|
|
102
110
|
export function sanitizeAttributes(attributes) {
|
|
103
111
|
const sanitized = {};
|
|
104
112
|
for (const [key, value] of Object.entries(attributes)) {
|
|
105
113
|
if (isSensitiveKey(key))
|
|
106
|
-
sanitized
|
|
114
|
+
setOwn(sanitized, key, '[REDACTED]');
|
|
107
115
|
else if (typeof value === 'boolean' || typeof value === 'number')
|
|
108
|
-
sanitized
|
|
116
|
+
setOwn(sanitized, key, value);
|
|
109
117
|
else if (typeof value === 'string')
|
|
110
|
-
sanitized
|
|
118
|
+
setOwn(sanitized, key, redactText(value));
|
|
111
119
|
}
|
|
112
120
|
return sanitized;
|
|
113
121
|
}
|
|
122
|
+
function setOwn(record, key, value) {
|
|
123
|
+
if (key === '__proto__')
|
|
124
|
+
Object.defineProperty(record, key, {
|
|
125
|
+
value,
|
|
126
|
+
enumerable: true,
|
|
127
|
+
writable: true,
|
|
128
|
+
configurable: true,
|
|
129
|
+
});
|
|
130
|
+
else
|
|
131
|
+
record[key] = value;
|
|
132
|
+
}
|
|
114
133
|
const diagnosticRedactedValue = '[REDACTED]';
|
|
115
134
|
const diagnosticCircularValue = '[Circular]';
|
|
116
135
|
const diagnosticSensitiveKey = /authorization|cookie|credential|password|private.?key|secret|token|api.?key/i;
|
|
@@ -126,14 +145,16 @@ function redactDiagnosticValue(value, explicitKeys, seen) {
|
|
|
126
145
|
if (seen.has(value))
|
|
127
146
|
return diagnosticCircularValue;
|
|
128
147
|
seen.add(value);
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
148
|
+
const result = Array.isArray(value)
|
|
149
|
+
? value.map((item) => redactDiagnosticValue(item, explicitKeys, seen))
|
|
150
|
+
: Object.fromEntries(Object.entries(value).map(([key, item]) => [
|
|
151
|
+
key,
|
|
152
|
+
isSensitiveDiagnosticKey(key, explicitKeys)
|
|
153
|
+
? diagnosticRedactedValue
|
|
154
|
+
: redactDiagnosticValue(item, explicitKeys, seen),
|
|
155
|
+
]));
|
|
156
|
+
seen.delete(value);
|
|
157
|
+
return result;
|
|
137
158
|
}
|
|
138
159
|
function isSensitiveDiagnosticKey(key, explicitKeys) {
|
|
139
160
|
return diagnosticSensitiveKey.test(key) || explicitKeys.has(normalizeDiagnosticKey(key));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adea-ai/telemetry",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"description": "Fail-open observability toolkit: structured logging, secret redaction, trace-context propagation, deterministic sampling, and pluggable OpenTelemetry, Sentry, and LangSmith adapters.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"langsmith",
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
"dist"
|
|
24
24
|
],
|
|
25
25
|
"type": "module",
|
|
26
|
+
"sideEffects": false,
|
|
26
27
|
"browser": false,
|
|
27
28
|
"types": "./dist/index.d.ts",
|
|
28
29
|
"exports": {
|