@adea-ai/telemetry 4.1.1 → 4.1.2
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/dist/catalog.d.ts +1 -1
- package/dist/catalog.js +5 -0
- package/dist/consistency.d.ts +13 -0
- package/dist/consistency.js +53 -0
- package/dist/index.d.ts +1 -1
- package/dist/redaction.js +4 -2
- package/package.json +3 -3
package/dist/catalog.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const executionTraceSpans: readonly ['execution.root', 'plan.compile', 'workflow.run', 'runtime.route', 'runtime.start', 'model.call', 'tool.authorize', 'tool.execute', 'sandbox.execute', 'approval.wait', 'artifact.promote', 'usage.settle', 'execution.cleanup'];
|
|
2
|
-
export declare const operationalMetrics: readonly ['control.api.request.duration', 'control.api.error.count', 'control.command_inbox.duplicate.count', 'control.command_inbox.conflict.count', 'workflow.backlog.count', 'workflow.replay.count', 'runtime.available.count', 'model.call.duration', 'model.call.error.count', 'tool.call.duration', 'tool.call.error.count', 'execution.reconciliation.count', 'execution.manual_intervention.count', 'context.provider_resolution.count', 'memory.write.decision.count', 'usage.cost.usd', 'execution.queue.latency', 'execution.human.latency', 'execution.retry.age', 'execution.reconciliation.age', 'storage.retained.bytes', 'storage.rewritten.bytes', 'storage.growth.bytes', 'runtime.active_object.count', 'operations.operating_cost.usd'];
|
|
2
|
+
export declare const operationalMetrics: readonly ['control.api.request.duration', 'control.api.error.count', 'control.command_inbox.duplicate.count', 'control.command_inbox.conflict.count', 'workflow.backlog.count', 'workflow.replay.count', 'runtime.available.count', 'model.call.duration', 'model.call.error.count', 'tool.call.duration', 'tool.call.error.count', 'execution.reconciliation.count', 'execution.manual_intervention.count', 'context.provider_resolution.count', 'context.provider_read.count', 'context.provider_read.duration', 'context.contribution.count', 'memory.write.decision.count', 'memory.write.outcome.count', 'runtime.progress.sequence_gap.count', 'usage.cost.usd', 'execution.queue.latency', 'execution.human.latency', 'execution.retry.age', 'execution.reconciliation.age', 'storage.retained.bytes', 'storage.rewritten.bytes', 'storage.growth.bytes', 'runtime.active_object.count', 'operations.operating_cost.usd'];
|
|
3
3
|
export type ExecutionTraceSpanName = (typeof executionTraceSpans)[number];
|
|
4
4
|
export type OperationalMetricName = (typeof operationalMetrics)[number];
|
|
5
5
|
export interface DiagnosticQuery {
|
package/dist/catalog.js
CHANGED
|
@@ -28,7 +28,12 @@ export const operationalMetrics = [
|
|
|
28
28
|
'execution.reconciliation.count',
|
|
29
29
|
'execution.manual_intervention.count',
|
|
30
30
|
'context.provider_resolution.count',
|
|
31
|
+
'context.provider_read.count',
|
|
32
|
+
'context.provider_read.duration',
|
|
33
|
+
'context.contribution.count',
|
|
31
34
|
'memory.write.decision.count',
|
|
35
|
+
'memory.write.outcome.count',
|
|
36
|
+
'runtime.progress.sequence_gap.count',
|
|
32
37
|
'usage.cost.usd',
|
|
33
38
|
'execution.queue.latency',
|
|
34
39
|
'execution.human.latency',
|
package/dist/consistency.d.ts
CHANGED
|
@@ -4,14 +4,27 @@ export declare const consistencyMetricNames: {
|
|
|
4
4
|
readonly commandInboxConflict: 'control.command_inbox.conflict.count';
|
|
5
5
|
readonly contextProviderResolution: 'context.provider_resolution.count';
|
|
6
6
|
readonly memoryWriteDecision: 'memory.write.decision.count';
|
|
7
|
+
readonly contextProviderRead: 'context.provider_read.count';
|
|
8
|
+
readonly contextProviderReadDuration: 'context.provider_read.duration';
|
|
9
|
+
readonly contextContribution: 'context.contribution.count';
|
|
10
|
+
readonly memoryWriteOutcome: 'memory.write.outcome.count';
|
|
11
|
+
readonly runtimeProgressSequenceGap: 'runtime.progress.sequence_gap.count';
|
|
7
12
|
readonly executionReconciliation: 'execution.reconciliation.count';
|
|
8
13
|
readonly executionManualIntervention: 'execution.manual_intervention.count';
|
|
9
14
|
};
|
|
10
15
|
export type CommandInboxAcceptanceOutcome = 'accepted' | 'duplicate' | 'conflict';
|
|
16
|
+
export type ContextProviderReadOutcome = 'ok' | 'timeout' | 'error' | 'scope_denied' | 'rejected' | 'revoked' | 'unavailable';
|
|
17
|
+
export type ContextContributionOutcome = 'cache_hit' | 'rebuilt' | 'fetched' | 'rejected';
|
|
18
|
+
export type MemoryWriteOutcome = 'duplicate' | 'conflict' | 'committed' | 'reconciled' | 'rejected' | 'ambiguous';
|
|
19
|
+
export type RuntimeProgressSequenceAnomaly = 'gap' | 'regression';
|
|
11
20
|
export interface ConsistencyMetricEmitter {
|
|
12
21
|
recordAcceptanceOutcome(outcome: CommandInboxAcceptanceOutcome): void;
|
|
13
22
|
recordResolution(outcome: string, reasonCategory: string): void;
|
|
14
23
|
recordApprovalDecision(decision: string): void;
|
|
24
|
+
recordProviderRead(outcome: ContextProviderReadOutcome, durationMs: number): void;
|
|
25
|
+
recordContribution(outcome: ContextContributionOutcome): void;
|
|
26
|
+
recordMemoryWriteOutcome(outcome: MemoryWriteOutcome): void;
|
|
27
|
+
recordSequenceAnomaly(kind: RuntimeProgressSequenceAnomaly): void;
|
|
15
28
|
recordCheckpoint(input: {
|
|
16
29
|
readonly reason: string;
|
|
17
30
|
readonly state: string;
|
package/dist/consistency.js
CHANGED
|
@@ -4,6 +4,11 @@ export const consistencyMetricNames = {
|
|
|
4
4
|
commandInboxConflict: 'control.command_inbox.conflict.count',
|
|
5
5
|
contextProviderResolution: 'context.provider_resolution.count',
|
|
6
6
|
memoryWriteDecision: 'memory.write.decision.count',
|
|
7
|
+
contextProviderRead: 'context.provider_read.count',
|
|
8
|
+
contextProviderReadDuration: 'context.provider_read.duration',
|
|
9
|
+
contextContribution: 'context.contribution.count',
|
|
10
|
+
memoryWriteOutcome: 'memory.write.outcome.count',
|
|
11
|
+
runtimeProgressSequenceGap: 'runtime.progress.sequence_gap.count',
|
|
7
12
|
executionReconciliation: 'execution.reconciliation.count',
|
|
8
13
|
executionManualIntervention: 'execution.manual_intervention.count',
|
|
9
14
|
};
|
|
@@ -28,6 +33,25 @@ const providerResolutionReasonCategories = new Set([
|
|
|
28
33
|
'PROVIDER_BUDGET_EXCEEDED',
|
|
29
34
|
]);
|
|
30
35
|
const memoryWriteDecisions = new Set(['approved', 'denied', 'expired']);
|
|
36
|
+
const providerReadOutcomes = new Set([
|
|
37
|
+
'ok',
|
|
38
|
+
'timeout',
|
|
39
|
+
'error',
|
|
40
|
+
'scope_denied',
|
|
41
|
+
'rejected',
|
|
42
|
+
'revoked',
|
|
43
|
+
'unavailable',
|
|
44
|
+
]);
|
|
45
|
+
const contributionOutcomes = new Set(['cache_hit', 'rebuilt', 'fetched', 'rejected']);
|
|
46
|
+
const memoryWriteOutcomes = new Set([
|
|
47
|
+
'duplicate',
|
|
48
|
+
'conflict',
|
|
49
|
+
'committed',
|
|
50
|
+
'reconciled',
|
|
51
|
+
'rejected',
|
|
52
|
+
'ambiguous',
|
|
53
|
+
]);
|
|
54
|
+
const sequenceGapKinds = new Set(['gap', 'regression']);
|
|
31
55
|
const reconciliationReasons = new Set([
|
|
32
56
|
'accepted_unstarted',
|
|
33
57
|
'stale_heartbeat',
|
|
@@ -50,6 +74,15 @@ export function createConsistencyMetricEmitter(adapter, serviceName) {
|
|
|
50
74
|
catch {
|
|
51
75
|
}
|
|
52
76
|
}
|
|
77
|
+
function record(name, value, labels) {
|
|
78
|
+
if (!Number.isFinite(value) || value < 0)
|
|
79
|
+
return;
|
|
80
|
+
try {
|
|
81
|
+
adapter.record(name, value, sanitizeAttributes({ 'service.name': serviceName, ...labels }));
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
}
|
|
85
|
+
}
|
|
53
86
|
return {
|
|
54
87
|
recordAcceptanceOutcome(outcome) {
|
|
55
88
|
if (!commandInboxOutcomes.has(outcome) || outcome === 'accepted')
|
|
@@ -69,6 +102,26 @@ export function createConsistencyMetricEmitter(adapter, serviceName) {
|
|
|
69
102
|
decision: boundedLabel(decision, memoryWriteDecisions),
|
|
70
103
|
});
|
|
71
104
|
},
|
|
105
|
+
recordProviderRead(outcome, durationMs) {
|
|
106
|
+
const label = boundedLabel(outcome, providerReadOutcomes);
|
|
107
|
+
add(consistencyMetricNames.contextProviderRead, { outcome: label });
|
|
108
|
+
record(consistencyMetricNames.contextProviderReadDuration, durationMs, { outcome: label });
|
|
109
|
+
},
|
|
110
|
+
recordContribution(outcome) {
|
|
111
|
+
add(consistencyMetricNames.contextContribution, {
|
|
112
|
+
outcome: boundedLabel(outcome, contributionOutcomes),
|
|
113
|
+
});
|
|
114
|
+
},
|
|
115
|
+
recordMemoryWriteOutcome(outcome) {
|
|
116
|
+
add(consistencyMetricNames.memoryWriteOutcome, {
|
|
117
|
+
outcome: boundedLabel(outcome, memoryWriteOutcomes),
|
|
118
|
+
});
|
|
119
|
+
},
|
|
120
|
+
recordSequenceAnomaly(kind) {
|
|
121
|
+
add(consistencyMetricNames.runtimeProgressSequenceGap, {
|
|
122
|
+
kind: boundedLabel(kind, sequenceGapKinds),
|
|
123
|
+
});
|
|
124
|
+
},
|
|
72
125
|
recordCheckpoint(input) {
|
|
73
126
|
const reason = boundedLabel(input.reason, reconciliationReasons);
|
|
74
127
|
add(consistencyMetricNames.executionReconciliation, {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { createConsoleMetricAdapter, createConsoleTraceAdapter, DEFAULT_CONSOLE_SLOW_SPAN_MS, type ConsoleTraceAdapterOptions, } from './console.js';
|
|
2
2
|
export { consistencyMetricNames, createConsistencyMetricEmitter } from './consistency.js';
|
|
3
|
-
export type { CommandInboxAcceptanceOutcome, ConsistencyMetricEmitter } from './consistency.js';
|
|
3
|
+
export type { CommandInboxAcceptanceOutcome, ConsistencyMetricEmitter, ContextContributionOutcome, ContextProviderReadOutcome, MemoryWriteOutcome, RuntimeProgressSequenceAnomaly, } from './consistency.js';
|
|
4
4
|
export { extractTraceContext, injectTraceContext, semanticAttributes, traceIdFromContext, } from './context.js';
|
|
5
5
|
export { createStructuredLogger, jsonLogger } from './logger.js';
|
|
6
6
|
export type { StructuredLoggerOptions } from './logger.js';
|
package/dist/redaction.js
CHANGED
|
@@ -27,7 +27,7 @@ const sensitiveKeys = new Set([
|
|
|
27
27
|
]);
|
|
28
28
|
const secretsInText = [
|
|
29
29
|
{
|
|
30
|
-
pattern: /(access[_-]?token|api[_-]?key|authorization|client[_-]?secret|cookie|credential(?:[_-]?ref)?|encryption[_-]?key|file[_-]?contents?|id[_-]?token|model[_-]?input|passw(?:or)?d|private[_-]?key|prompt|refresh[_-]?token|secret(?:[_-]?(?:access[_-]?key|key|value))?|signing[_-]?key|token|tool[_-]?input)\s*[:=]\s*(?:Bearer\s+)?[^\s,;]+/gi,
|
|
30
|
+
pattern: /(access[_-]?token|api[_-]?key|authorization|client[_-]?secret|cookie|credential(?:[_-]?ref)?|encryption[_-]?key|file[_-]?contents?|id[_-]?token|model[_-]?input|passw(?:or)?d|passphrase|private[_-]?key|prompt|refresh[_-]?token|secret(?:[_-]?(?:access[_-]?key|key|value))?|signing[_-]?key|token|tool[_-]?input)\s*[:=]\s*(?:Bearer\s+)?[^\s,;]+/gi,
|
|
31
31
|
replacement: '$1=[REDACTED]',
|
|
32
32
|
},
|
|
33
33
|
{ pattern: /\bBearer\s+[^\s,;]+/gi, replacement: 'Bearer [REDACTED]' },
|
|
@@ -65,8 +65,10 @@ const secretsInText = [
|
|
|
65
65
|
function redactText(value) {
|
|
66
66
|
return secretsInText.reduce((redacted, { pattern, replacement }) => redacted.replace(pattern, replacement), value);
|
|
67
67
|
}
|
|
68
|
+
const sensitiveKeySuffix = /(?:token|secret|password|passwd|passphrase|credentials?|apikey|privatekey|accesskey|secretkey|signingkey|encryptionkey|cookie|authorization)$/;
|
|
68
69
|
function isSensitiveKey(key) {
|
|
69
|
-
|
|
70
|
+
const normalized = key.replace(/[^a-z0-9]/gi, '').toLowerCase();
|
|
71
|
+
return sensitiveKeys.has(normalized) || sensitiveKeySuffix.test(normalized);
|
|
70
72
|
}
|
|
71
73
|
export function redactTelemetryValue(value) {
|
|
72
74
|
return redact(value, new WeakSet());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adea-ai/telemetry",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.2",
|
|
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",
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@opentelemetry/api": "1.10.0",
|
|
61
|
-
"@opentelemetry/sdk-metrics": "3.
|
|
62
|
-
"@sentry/node": "11.
|
|
61
|
+
"@opentelemetry/sdk-metrics": "3.1.1",
|
|
62
|
+
"@sentry/node": "11.12.0"
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
65
|
"@opentelemetry/api": "^1.9.0",
|