@peac/telemetry 0.10.9 → 0.10.11
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/LICENSE +1 -1
- package/dist/index.cjs +82 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.mjs +72 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +15 -9
- package/dist/attributes.js +0 -67
- package/dist/attributes.js.map +0 -1
- package/dist/index.js +0 -55
- package/dist/index.js.map +0 -1
- package/dist/noop.js +0 -21
- package/dist/noop.js.map +0 -1
- package/dist/provider.js +0 -65
- package/dist/provider.js.map +0 -1
- package/dist/types.js +0 -9
- package/dist/types.js.map +0 -1
package/LICENSE
CHANGED
|
@@ -175,7 +175,7 @@ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
|
175
175
|
|
|
176
176
|
END OF TERMS AND CONDITIONS
|
|
177
177
|
|
|
178
|
-
Copyright 2025 PEAC Protocol Contributors
|
|
178
|
+
Copyright 2025-2026 PEAC Protocol Contributors
|
|
179
179
|
|
|
180
180
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
181
|
you may not use this file except in compliance with the License.
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/noop.ts
|
|
4
|
+
var noopProvider = {
|
|
5
|
+
onReceiptIssued: () => {
|
|
6
|
+
},
|
|
7
|
+
onReceiptVerified: () => {
|
|
8
|
+
},
|
|
9
|
+
onAccessDecision: () => {
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
// src/provider.ts
|
|
14
|
+
var providerRef = {
|
|
15
|
+
current: void 0
|
|
16
|
+
};
|
|
17
|
+
function setTelemetryProvider(provider) {
|
|
18
|
+
providerRef.current = provider;
|
|
19
|
+
}
|
|
20
|
+
function getTelemetryProvider() {
|
|
21
|
+
return providerRef.current;
|
|
22
|
+
}
|
|
23
|
+
function isTelemetryEnabled() {
|
|
24
|
+
return providerRef.current !== void 0;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// src/attributes.ts
|
|
28
|
+
var PEAC_ATTRS = {
|
|
29
|
+
// Core (always emitted)
|
|
30
|
+
VERSION: "peac.version",
|
|
31
|
+
EVENT: "peac.event",
|
|
32
|
+
RECEIPT_HASH: "peac.receipt.hash",
|
|
33
|
+
POLICY_HASH: "peac.policy.hash",
|
|
34
|
+
DECISION: "peac.decision",
|
|
35
|
+
REASON_CODE: "peac.reason_code",
|
|
36
|
+
ISSUER: "peac.issuer",
|
|
37
|
+
ISSUER_HASH: "peac.issuer_hash",
|
|
38
|
+
KID: "peac.kid",
|
|
39
|
+
VALID: "peac.valid",
|
|
40
|
+
// HTTP (privacy-safe, stable OTel semconv)
|
|
41
|
+
HTTP_METHOD: "http.request.method",
|
|
42
|
+
HTTP_PATH: "url.path",
|
|
43
|
+
// No query string
|
|
44
|
+
HTTP_HOST_HASH: "peac.http.host_hash",
|
|
45
|
+
HTTP_CLIENT_HASH: "peac.http.client_hash",
|
|
46
|
+
// Payment (balanced/custom mode only)
|
|
47
|
+
PAYMENT_RAIL: "peac.payment.rail",
|
|
48
|
+
PAYMENT_AMOUNT: "peac.payment.amount",
|
|
49
|
+
PAYMENT_CURRENCY: "peac.payment.currency",
|
|
50
|
+
// Duration
|
|
51
|
+
DURATION_MS: "peac.duration_ms"
|
|
52
|
+
};
|
|
53
|
+
var PEAC_EVENTS = {
|
|
54
|
+
RECEIPT_ISSUED: "peac.receipt.issued",
|
|
55
|
+
RECEIPT_VERIFIED: "peac.receipt.verified",
|
|
56
|
+
ACCESS_DECISION: "peac.access.decision"
|
|
57
|
+
};
|
|
58
|
+
var PEAC_METRICS = {
|
|
59
|
+
// Counters
|
|
60
|
+
RECEIPTS_ISSUED: "peac.receipts.issued",
|
|
61
|
+
RECEIPTS_VERIFIED: "peac.receipts.verified",
|
|
62
|
+
ACCESS_DECISIONS: "peac.access.decisions",
|
|
63
|
+
// Histograms
|
|
64
|
+
ISSUE_DURATION: "peac.issue.duration",
|
|
65
|
+
VERIFY_DURATION: "peac.verify.duration"
|
|
66
|
+
};
|
|
67
|
+
var TRACE_CONTEXT_EXTENSIONS = {
|
|
68
|
+
TRACEPARENT: "w3c/traceparent",
|
|
69
|
+
TRACESTATE: "w3c/tracestate"
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
exports.PEAC_ATTRS = PEAC_ATTRS;
|
|
73
|
+
exports.PEAC_EVENTS = PEAC_EVENTS;
|
|
74
|
+
exports.PEAC_METRICS = PEAC_METRICS;
|
|
75
|
+
exports.TRACE_CONTEXT_EXTENSIONS = TRACE_CONTEXT_EXTENSIONS;
|
|
76
|
+
exports.getTelemetryProvider = getTelemetryProvider;
|
|
77
|
+
exports.isTelemetryEnabled = isTelemetryEnabled;
|
|
78
|
+
exports.noopProvider = noopProvider;
|
|
79
|
+
exports.providerRef = providerRef;
|
|
80
|
+
exports.setTelemetryProvider = setTelemetryProvider;
|
|
81
|
+
//# sourceMappingURL=index.cjs.map
|
|
82
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/noop.ts","../src/provider.ts","../src/attributes.ts"],"names":[],"mappings":";;;AAeO,IAAM,YAAA,GAAkC;AAAA,EAC7C,iBAAiB,MAAM;AAAA,EAAC,CAAA;AAAA,EACxB,mBAAmB,MAAM;AAAA,EAAC,CAAA;AAAA,EAC1B,kBAAkB,MAAM;AAAA,EAAC;AAC3B;;;ACSO,IAAM,WAAA,GAA+C;AAAA,EAC1D,OAAA,EAAS;AACX;AAUO,SAAS,qBAAqB,QAAA,EAA+C;AAClF,EAAA,WAAA,CAAY,OAAA,GAAU,QAAA;AACxB;AAUO,SAAS,oBAAA,GAAsD;AACpE,EAAA,OAAO,WAAA,CAAY,OAAA;AACrB;AAOO,SAAS,kBAAA,GAA8B;AAC5C,EAAA,OAAO,YAAY,OAAA,KAAY,MAAA;AACjC;;;ACrDO,IAAM,UAAA,GAAa;AAAA;AAAA,EAExB,OAAA,EAAS,cAAA;AAAA,EACT,KAAA,EAAO,YAAA;AAAA,EACP,YAAA,EAAc,mBAAA;AAAA,EACd,WAAA,EAAa,kBAAA;AAAA,EACb,QAAA,EAAU,eAAA;AAAA,EACV,WAAA,EAAa,kBAAA;AAAA,EACb,MAAA,EAAQ,aAAA;AAAA,EACR,WAAA,EAAa,kBAAA;AAAA,EACb,GAAA,EAAK,UAAA;AAAA,EACL,KAAA,EAAO,YAAA;AAAA;AAAA,EAGP,WAAA,EAAa,qBAAA;AAAA,EACb,SAAA,EAAW,UAAA;AAAA;AAAA,EACX,cAAA,EAAgB,qBAAA;AAAA,EAChB,gBAAA,EAAkB,uBAAA;AAAA;AAAA,EAGlB,YAAA,EAAc,mBAAA;AAAA,EACd,cAAA,EAAgB,qBAAA;AAAA,EAChB,gBAAA,EAAkB,uBAAA;AAAA;AAAA,EAGlB,WAAA,EAAa;AACf;AAKO,IAAM,WAAA,GAAc;AAAA,EACzB,cAAA,EAAgB,qBAAA;AAAA,EAChB,gBAAA,EAAkB,uBAAA;AAAA,EAClB,eAAA,EAAiB;AACnB;AAKO,IAAM,YAAA,GAAe;AAAA;AAAA,EAE1B,eAAA,EAAiB,sBAAA;AAAA,EACjB,iBAAA,EAAmB,wBAAA;AAAA,EACnB,gBAAA,EAAkB,uBAAA;AAAA;AAAA,EAGlB,cAAA,EAAgB,qBAAA;AAAA,EAChB,eAAA,EAAiB;AACnB;AAQO,IAAM,wBAAA,GAA2B;AAAA,EACtC,WAAA,EAAa,iBAAA;AAAA,EACb,UAAA,EAAY;AACd","file":"index.cjs","sourcesContent":["/**\n * @peac/telemetry - No-op telemetry provider\n *\n * This provider does nothing. Use it when telemetry is disabled\n * or when you need a fallback provider.\n */\n\nimport type { TelemetryProvider } from './types.js';\n\n/**\n * No-op telemetry provider\n *\n * All methods are empty functions that do nothing.\n * Use this as the default when no telemetry is configured.\n */\nexport const noopProvider: TelemetryProvider = {\n onReceiptIssued: () => {},\n onReceiptVerified: () => {},\n onAccessDecision: () => {},\n};\n","/**\n * @peac/telemetry - Provider registry\n *\n * Zero-throw provider ref pattern for hot-path performance.\n * When undefined, telemetry is disabled with NO function calls.\n */\n\nimport type { TelemetryProvider } from './types.js';\n\n/**\n * Singleton provider reference for zero-overhead hot path.\n *\n * When undefined, telemetry is disabled with NO function calls\n * beyond the initial `if (!p)` check.\n *\n * @example\n * ```typescript\n * // In hot path (issue/verify)\n * const p = providerRef.current;\n * if (p) {\n * try {\n * p.onReceiptIssued({ receiptHash: '...' });\n * } catch {\n * // Telemetry MUST NOT break core flow\n * }\n * }\n * ```\n */\nexport const providerRef: { current?: TelemetryProvider } = {\n current: undefined,\n};\n\n/**\n * Set the telemetry provider.\n *\n * Idempotent, no-throw, safe to call multiple times.\n * Pass undefined to disable telemetry.\n *\n * @param provider - The provider to use, or undefined to disable\n */\nexport function setTelemetryProvider(provider: TelemetryProvider | undefined): void {\n providerRef.current = provider;\n}\n\n/**\n * Get the current telemetry provider.\n *\n * Returns undefined if no provider is set (telemetry disabled).\n *\n * For hot paths, prefer direct access to `providerRef.current`\n * to avoid the function call overhead.\n */\nexport function getTelemetryProvider(): TelemetryProvider | undefined {\n return providerRef.current;\n}\n\n/**\n * Check if telemetry is enabled.\n *\n * Convenience function for conditional logic outside hot paths.\n */\nexport function isTelemetryEnabled(): boolean {\n return providerRef.current !== undefined;\n}\n","/**\n * @peac/telemetry - Attribute constants\n *\n * Standard attribute names for PEAC telemetry.\n * Uses stable OTel semantic conventions where applicable.\n */\n\n/**\n * PEAC-specific attribute names\n */\nexport const PEAC_ATTRS = {\n // Core (always emitted)\n VERSION: 'peac.version',\n EVENT: 'peac.event',\n RECEIPT_HASH: 'peac.receipt.hash',\n POLICY_HASH: 'peac.policy.hash',\n DECISION: 'peac.decision',\n REASON_CODE: 'peac.reason_code',\n ISSUER: 'peac.issuer',\n ISSUER_HASH: 'peac.issuer_hash',\n KID: 'peac.kid',\n VALID: 'peac.valid',\n\n // HTTP (privacy-safe, stable OTel semconv)\n HTTP_METHOD: 'http.request.method',\n HTTP_PATH: 'url.path', // No query string\n HTTP_HOST_HASH: 'peac.http.host_hash',\n HTTP_CLIENT_HASH: 'peac.http.client_hash',\n\n // Payment (balanced/custom mode only)\n PAYMENT_RAIL: 'peac.payment.rail',\n PAYMENT_AMOUNT: 'peac.payment.amount',\n PAYMENT_CURRENCY: 'peac.payment.currency',\n\n // Duration\n DURATION_MS: 'peac.duration_ms',\n} as const;\n\n/**\n * PEAC event names\n */\nexport const PEAC_EVENTS = {\n RECEIPT_ISSUED: 'peac.receipt.issued',\n RECEIPT_VERIFIED: 'peac.receipt.verified',\n ACCESS_DECISION: 'peac.access.decision',\n} as const;\n\n/**\n * PEAC metric names\n */\nexport const PEAC_METRICS = {\n // Counters\n RECEIPTS_ISSUED: 'peac.receipts.issued',\n RECEIPTS_VERIFIED: 'peac.receipts.verified',\n ACCESS_DECISIONS: 'peac.access.decisions',\n\n // Histograms\n ISSUE_DURATION: 'peac.issue.duration',\n VERIFY_DURATION: 'peac.verify.duration',\n} as const;\n\n/**\n * Extension keys for trace context binding\n *\n * Uses w3c/ namespace for vendor neutrality.\n * W3C owns the Trace Context spec; OTel implements it.\n */\nexport const TRACE_CONTEXT_EXTENSIONS = {\n TRACEPARENT: 'w3c/traceparent',\n TRACESTATE: 'w3c/tracestate',\n} as const;\n"]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// src/noop.ts
|
|
2
|
+
var noopProvider = {
|
|
3
|
+
onReceiptIssued: () => {
|
|
4
|
+
},
|
|
5
|
+
onReceiptVerified: () => {
|
|
6
|
+
},
|
|
7
|
+
onAccessDecision: () => {
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
// src/provider.ts
|
|
12
|
+
var providerRef = {
|
|
13
|
+
current: void 0
|
|
14
|
+
};
|
|
15
|
+
function setTelemetryProvider(provider) {
|
|
16
|
+
providerRef.current = provider;
|
|
17
|
+
}
|
|
18
|
+
function getTelemetryProvider() {
|
|
19
|
+
return providerRef.current;
|
|
20
|
+
}
|
|
21
|
+
function isTelemetryEnabled() {
|
|
22
|
+
return providerRef.current !== void 0;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// src/attributes.ts
|
|
26
|
+
var PEAC_ATTRS = {
|
|
27
|
+
// Core (always emitted)
|
|
28
|
+
VERSION: "peac.version",
|
|
29
|
+
EVENT: "peac.event",
|
|
30
|
+
RECEIPT_HASH: "peac.receipt.hash",
|
|
31
|
+
POLICY_HASH: "peac.policy.hash",
|
|
32
|
+
DECISION: "peac.decision",
|
|
33
|
+
REASON_CODE: "peac.reason_code",
|
|
34
|
+
ISSUER: "peac.issuer",
|
|
35
|
+
ISSUER_HASH: "peac.issuer_hash",
|
|
36
|
+
KID: "peac.kid",
|
|
37
|
+
VALID: "peac.valid",
|
|
38
|
+
// HTTP (privacy-safe, stable OTel semconv)
|
|
39
|
+
HTTP_METHOD: "http.request.method",
|
|
40
|
+
HTTP_PATH: "url.path",
|
|
41
|
+
// No query string
|
|
42
|
+
HTTP_HOST_HASH: "peac.http.host_hash",
|
|
43
|
+
HTTP_CLIENT_HASH: "peac.http.client_hash",
|
|
44
|
+
// Payment (balanced/custom mode only)
|
|
45
|
+
PAYMENT_RAIL: "peac.payment.rail",
|
|
46
|
+
PAYMENT_AMOUNT: "peac.payment.amount",
|
|
47
|
+
PAYMENT_CURRENCY: "peac.payment.currency",
|
|
48
|
+
// Duration
|
|
49
|
+
DURATION_MS: "peac.duration_ms"
|
|
50
|
+
};
|
|
51
|
+
var PEAC_EVENTS = {
|
|
52
|
+
RECEIPT_ISSUED: "peac.receipt.issued",
|
|
53
|
+
RECEIPT_VERIFIED: "peac.receipt.verified",
|
|
54
|
+
ACCESS_DECISION: "peac.access.decision"
|
|
55
|
+
};
|
|
56
|
+
var PEAC_METRICS = {
|
|
57
|
+
// Counters
|
|
58
|
+
RECEIPTS_ISSUED: "peac.receipts.issued",
|
|
59
|
+
RECEIPTS_VERIFIED: "peac.receipts.verified",
|
|
60
|
+
ACCESS_DECISIONS: "peac.access.decisions",
|
|
61
|
+
// Histograms
|
|
62
|
+
ISSUE_DURATION: "peac.issue.duration",
|
|
63
|
+
VERIFY_DURATION: "peac.verify.duration"
|
|
64
|
+
};
|
|
65
|
+
var TRACE_CONTEXT_EXTENSIONS = {
|
|
66
|
+
TRACEPARENT: "w3c/traceparent",
|
|
67
|
+
TRACESTATE: "w3c/tracestate"
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export { PEAC_ATTRS, PEAC_EVENTS, PEAC_METRICS, TRACE_CONTEXT_EXTENSIONS, getTelemetryProvider, isTelemetryEnabled, noopProvider, providerRef, setTelemetryProvider };
|
|
71
|
+
//# sourceMappingURL=index.mjs.map
|
|
72
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/noop.ts","../src/provider.ts","../src/attributes.ts"],"names":[],"mappings":";AAeO,IAAM,YAAA,GAAkC;AAAA,EAC7C,iBAAiB,MAAM;AAAA,EAAC,CAAA;AAAA,EACxB,mBAAmB,MAAM;AAAA,EAAC,CAAA;AAAA,EAC1B,kBAAkB,MAAM;AAAA,EAAC;AAC3B;;;ACSO,IAAM,WAAA,GAA+C;AAAA,EAC1D,OAAA,EAAS;AACX;AAUO,SAAS,qBAAqB,QAAA,EAA+C;AAClF,EAAA,WAAA,CAAY,OAAA,GAAU,QAAA;AACxB;AAUO,SAAS,oBAAA,GAAsD;AACpE,EAAA,OAAO,WAAA,CAAY,OAAA;AACrB;AAOO,SAAS,kBAAA,GAA8B;AAC5C,EAAA,OAAO,YAAY,OAAA,KAAY,MAAA;AACjC;;;ACrDO,IAAM,UAAA,GAAa;AAAA;AAAA,EAExB,OAAA,EAAS,cAAA;AAAA,EACT,KAAA,EAAO,YAAA;AAAA,EACP,YAAA,EAAc,mBAAA;AAAA,EACd,WAAA,EAAa,kBAAA;AAAA,EACb,QAAA,EAAU,eAAA;AAAA,EACV,WAAA,EAAa,kBAAA;AAAA,EACb,MAAA,EAAQ,aAAA;AAAA,EACR,WAAA,EAAa,kBAAA;AAAA,EACb,GAAA,EAAK,UAAA;AAAA,EACL,KAAA,EAAO,YAAA;AAAA;AAAA,EAGP,WAAA,EAAa,qBAAA;AAAA,EACb,SAAA,EAAW,UAAA;AAAA;AAAA,EACX,cAAA,EAAgB,qBAAA;AAAA,EAChB,gBAAA,EAAkB,uBAAA;AAAA;AAAA,EAGlB,YAAA,EAAc,mBAAA;AAAA,EACd,cAAA,EAAgB,qBAAA;AAAA,EAChB,gBAAA,EAAkB,uBAAA;AAAA;AAAA,EAGlB,WAAA,EAAa;AACf;AAKO,IAAM,WAAA,GAAc;AAAA,EACzB,cAAA,EAAgB,qBAAA;AAAA,EAChB,gBAAA,EAAkB,uBAAA;AAAA,EAClB,eAAA,EAAiB;AACnB;AAKO,IAAM,YAAA,GAAe;AAAA;AAAA,EAE1B,eAAA,EAAiB,sBAAA;AAAA,EACjB,iBAAA,EAAmB,wBAAA;AAAA,EACnB,gBAAA,EAAkB,uBAAA;AAAA;AAAA,EAGlB,cAAA,EAAgB,qBAAA;AAAA,EAChB,eAAA,EAAiB;AACnB;AAQO,IAAM,wBAAA,GAA2B;AAAA,EACtC,WAAA,EAAa,iBAAA;AAAA,EACb,UAAA,EAAY;AACd","file":"index.mjs","sourcesContent":["/**\n * @peac/telemetry - No-op telemetry provider\n *\n * This provider does nothing. Use it when telemetry is disabled\n * or when you need a fallback provider.\n */\n\nimport type { TelemetryProvider } from './types.js';\n\n/**\n * No-op telemetry provider\n *\n * All methods are empty functions that do nothing.\n * Use this as the default when no telemetry is configured.\n */\nexport const noopProvider: TelemetryProvider = {\n onReceiptIssued: () => {},\n onReceiptVerified: () => {},\n onAccessDecision: () => {},\n};\n","/**\n * @peac/telemetry - Provider registry\n *\n * Zero-throw provider ref pattern for hot-path performance.\n * When undefined, telemetry is disabled with NO function calls.\n */\n\nimport type { TelemetryProvider } from './types.js';\n\n/**\n * Singleton provider reference for zero-overhead hot path.\n *\n * When undefined, telemetry is disabled with NO function calls\n * beyond the initial `if (!p)` check.\n *\n * @example\n * ```typescript\n * // In hot path (issue/verify)\n * const p = providerRef.current;\n * if (p) {\n * try {\n * p.onReceiptIssued({ receiptHash: '...' });\n * } catch {\n * // Telemetry MUST NOT break core flow\n * }\n * }\n * ```\n */\nexport const providerRef: { current?: TelemetryProvider } = {\n current: undefined,\n};\n\n/**\n * Set the telemetry provider.\n *\n * Idempotent, no-throw, safe to call multiple times.\n * Pass undefined to disable telemetry.\n *\n * @param provider - The provider to use, or undefined to disable\n */\nexport function setTelemetryProvider(provider: TelemetryProvider | undefined): void {\n providerRef.current = provider;\n}\n\n/**\n * Get the current telemetry provider.\n *\n * Returns undefined if no provider is set (telemetry disabled).\n *\n * For hot paths, prefer direct access to `providerRef.current`\n * to avoid the function call overhead.\n */\nexport function getTelemetryProvider(): TelemetryProvider | undefined {\n return providerRef.current;\n}\n\n/**\n * Check if telemetry is enabled.\n *\n * Convenience function for conditional logic outside hot paths.\n */\nexport function isTelemetryEnabled(): boolean {\n return providerRef.current !== undefined;\n}\n","/**\n * @peac/telemetry - Attribute constants\n *\n * Standard attribute names for PEAC telemetry.\n * Uses stable OTel semantic conventions where applicable.\n */\n\n/**\n * PEAC-specific attribute names\n */\nexport const PEAC_ATTRS = {\n // Core (always emitted)\n VERSION: 'peac.version',\n EVENT: 'peac.event',\n RECEIPT_HASH: 'peac.receipt.hash',\n POLICY_HASH: 'peac.policy.hash',\n DECISION: 'peac.decision',\n REASON_CODE: 'peac.reason_code',\n ISSUER: 'peac.issuer',\n ISSUER_HASH: 'peac.issuer_hash',\n KID: 'peac.kid',\n VALID: 'peac.valid',\n\n // HTTP (privacy-safe, stable OTel semconv)\n HTTP_METHOD: 'http.request.method',\n HTTP_PATH: 'url.path', // No query string\n HTTP_HOST_HASH: 'peac.http.host_hash',\n HTTP_CLIENT_HASH: 'peac.http.client_hash',\n\n // Payment (balanced/custom mode only)\n PAYMENT_RAIL: 'peac.payment.rail',\n PAYMENT_AMOUNT: 'peac.payment.amount',\n PAYMENT_CURRENCY: 'peac.payment.currency',\n\n // Duration\n DURATION_MS: 'peac.duration_ms',\n} as const;\n\n/**\n * PEAC event names\n */\nexport const PEAC_EVENTS = {\n RECEIPT_ISSUED: 'peac.receipt.issued',\n RECEIPT_VERIFIED: 'peac.receipt.verified',\n ACCESS_DECISION: 'peac.access.decision',\n} as const;\n\n/**\n * PEAC metric names\n */\nexport const PEAC_METRICS = {\n // Counters\n RECEIPTS_ISSUED: 'peac.receipts.issued',\n RECEIPTS_VERIFIED: 'peac.receipts.verified',\n ACCESS_DECISIONS: 'peac.access.decisions',\n\n // Histograms\n ISSUE_DURATION: 'peac.issue.duration',\n VERIFY_DURATION: 'peac.verify.duration',\n} as const;\n\n/**\n * Extension keys for trace context binding\n *\n * Uses w3c/ namespace for vendor neutrality.\n * W3C owns the Trace Context spec; OTel implements it.\n */\nexport const TRACE_CONTEXT_EXTENSIONS = {\n TRACEPARENT: 'w3c/traceparent',\n TRACESTATE: 'w3c/tracestate',\n} as const;\n"]}
|
package/package.json
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@peac/telemetry",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.11",
|
|
4
4
|
"description": "Telemetry interfaces and no-op implementation for PEAC protocol",
|
|
5
|
-
"main": "dist/index.
|
|
5
|
+
"main": "dist/index.cjs",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": {
|
|
9
9
|
"types": "./dist/index.d.ts",
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
|
|
10
|
+
"import": "./dist/index.mjs",
|
|
11
|
+
"require": "./dist/index.cjs",
|
|
12
|
+
"default": "./dist/index.mjs"
|
|
13
|
+
},
|
|
14
|
+
"./package.json": "./package.json"
|
|
13
15
|
},
|
|
14
16
|
"files": [
|
|
15
17
|
"dist",
|
|
@@ -23,19 +25,23 @@
|
|
|
23
25
|
"author": "PEAC Protocol contributors",
|
|
24
26
|
"license": "Apache-2.0",
|
|
25
27
|
"dependencies": {
|
|
26
|
-
"@peac/kernel": "0.10.
|
|
28
|
+
"@peac/kernel": "0.10.11"
|
|
27
29
|
},
|
|
28
30
|
"devDependencies": {
|
|
29
31
|
"@types/node": "^20.10.0",
|
|
30
32
|
"typescript": "^5.3.3",
|
|
31
|
-
"vitest": "^
|
|
33
|
+
"vitest": "^4.0.0",
|
|
34
|
+
"tsup": "^8.0.0"
|
|
32
35
|
},
|
|
33
36
|
"sideEffects": false,
|
|
34
37
|
"scripts": {
|
|
35
|
-
"
|
|
38
|
+
"prebuild": "rm -rf dist",
|
|
39
|
+
"build": "pnpm run build:js && pnpm run build:types",
|
|
36
40
|
"typecheck": "tsc --noEmit",
|
|
37
41
|
"test": "vitest run",
|
|
38
42
|
"test:watch": "vitest",
|
|
39
|
-
"clean": "rm -rf dist"
|
|
43
|
+
"clean": "rm -rf dist",
|
|
44
|
+
"build:js": "tsup",
|
|
45
|
+
"build:types": "rm -f dist/.tsbuildinfo && tsc && rm -f dist/.tsbuildinfo"
|
|
40
46
|
}
|
|
41
47
|
}
|
package/dist/attributes.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @peac/telemetry - Attribute constants
|
|
4
|
-
*
|
|
5
|
-
* Standard attribute names for PEAC telemetry.
|
|
6
|
-
* Uses stable OTel semantic conventions where applicable.
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.TRACE_CONTEXT_EXTENSIONS = exports.PEAC_METRICS = exports.PEAC_EVENTS = exports.PEAC_ATTRS = void 0;
|
|
10
|
-
/**
|
|
11
|
-
* PEAC-specific attribute names
|
|
12
|
-
*/
|
|
13
|
-
exports.PEAC_ATTRS = {
|
|
14
|
-
// Core (always emitted)
|
|
15
|
-
VERSION: 'peac.version',
|
|
16
|
-
EVENT: 'peac.event',
|
|
17
|
-
RECEIPT_HASH: 'peac.receipt.hash',
|
|
18
|
-
POLICY_HASH: 'peac.policy.hash',
|
|
19
|
-
DECISION: 'peac.decision',
|
|
20
|
-
REASON_CODE: 'peac.reason_code',
|
|
21
|
-
ISSUER: 'peac.issuer',
|
|
22
|
-
ISSUER_HASH: 'peac.issuer_hash',
|
|
23
|
-
KID: 'peac.kid',
|
|
24
|
-
VALID: 'peac.valid',
|
|
25
|
-
// HTTP (privacy-safe, stable OTel semconv)
|
|
26
|
-
HTTP_METHOD: 'http.request.method',
|
|
27
|
-
HTTP_PATH: 'url.path', // No query string
|
|
28
|
-
HTTP_HOST_HASH: 'peac.http.host_hash',
|
|
29
|
-
HTTP_CLIENT_HASH: 'peac.http.client_hash',
|
|
30
|
-
// Payment (balanced/custom mode only)
|
|
31
|
-
PAYMENT_RAIL: 'peac.payment.rail',
|
|
32
|
-
PAYMENT_AMOUNT: 'peac.payment.amount',
|
|
33
|
-
PAYMENT_CURRENCY: 'peac.payment.currency',
|
|
34
|
-
// Duration
|
|
35
|
-
DURATION_MS: 'peac.duration_ms',
|
|
36
|
-
};
|
|
37
|
-
/**
|
|
38
|
-
* PEAC event names
|
|
39
|
-
*/
|
|
40
|
-
exports.PEAC_EVENTS = {
|
|
41
|
-
RECEIPT_ISSUED: 'peac.receipt.issued',
|
|
42
|
-
RECEIPT_VERIFIED: 'peac.receipt.verified',
|
|
43
|
-
ACCESS_DECISION: 'peac.access.decision',
|
|
44
|
-
};
|
|
45
|
-
/**
|
|
46
|
-
* PEAC metric names
|
|
47
|
-
*/
|
|
48
|
-
exports.PEAC_METRICS = {
|
|
49
|
-
// Counters
|
|
50
|
-
RECEIPTS_ISSUED: 'peac.receipts.issued',
|
|
51
|
-
RECEIPTS_VERIFIED: 'peac.receipts.verified',
|
|
52
|
-
ACCESS_DECISIONS: 'peac.access.decisions',
|
|
53
|
-
// Histograms
|
|
54
|
-
ISSUE_DURATION: 'peac.issue.duration',
|
|
55
|
-
VERIFY_DURATION: 'peac.verify.duration',
|
|
56
|
-
};
|
|
57
|
-
/**
|
|
58
|
-
* Extension keys for trace context binding
|
|
59
|
-
*
|
|
60
|
-
* Uses w3c/ namespace for vendor neutrality.
|
|
61
|
-
* W3C owns the Trace Context spec; OTel implements it.
|
|
62
|
-
*/
|
|
63
|
-
exports.TRACE_CONTEXT_EXTENSIONS = {
|
|
64
|
-
TRACEPARENT: 'w3c/traceparent',
|
|
65
|
-
TRACESTATE: 'w3c/tracestate',
|
|
66
|
-
};
|
|
67
|
-
//# sourceMappingURL=attributes.js.map
|
package/dist/attributes.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"attributes.js","sourceRoot":"","sources":["../src/attributes.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH;;GAEG;AACU,QAAA,UAAU,GAAG;IACxB,wBAAwB;IACxB,OAAO,EAAE,cAAc;IACvB,KAAK,EAAE,YAAY;IACnB,YAAY,EAAE,mBAAmB;IACjC,WAAW,EAAE,kBAAkB;IAC/B,QAAQ,EAAE,eAAe;IACzB,WAAW,EAAE,kBAAkB;IAC/B,MAAM,EAAE,aAAa;IACrB,WAAW,EAAE,kBAAkB;IAC/B,GAAG,EAAE,UAAU;IACf,KAAK,EAAE,YAAY;IAEnB,2CAA2C;IAC3C,WAAW,EAAE,qBAAqB;IAClC,SAAS,EAAE,UAAU,EAAE,kBAAkB;IACzC,cAAc,EAAE,qBAAqB;IACrC,gBAAgB,EAAE,uBAAuB;IAEzC,sCAAsC;IACtC,YAAY,EAAE,mBAAmB;IACjC,cAAc,EAAE,qBAAqB;IACrC,gBAAgB,EAAE,uBAAuB;IAEzC,WAAW;IACX,WAAW,EAAE,kBAAkB;CACvB,CAAC;AAEX;;GAEG;AACU,QAAA,WAAW,GAAG;IACzB,cAAc,EAAE,qBAAqB;IACrC,gBAAgB,EAAE,uBAAuB;IACzC,eAAe,EAAE,sBAAsB;CAC/B,CAAC;AAEX;;GAEG;AACU,QAAA,YAAY,GAAG;IAC1B,WAAW;IACX,eAAe,EAAE,sBAAsB;IACvC,iBAAiB,EAAE,wBAAwB;IAC3C,gBAAgB,EAAE,uBAAuB;IAEzC,aAAa;IACb,cAAc,EAAE,qBAAqB;IACrC,eAAe,EAAE,sBAAsB;CAC/B,CAAC;AAEX;;;;;GAKG;AACU,QAAA,wBAAwB,GAAG;IACtC,WAAW,EAAE,iBAAiB;IAC9B,UAAU,EAAE,gBAAgB;CACpB,CAAC"}
|
package/dist/index.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @peac/telemetry
|
|
4
|
-
*
|
|
5
|
-
* Telemetry interfaces and no-op implementation for PEAC protocol.
|
|
6
|
-
*
|
|
7
|
-
* This package provides:
|
|
8
|
-
* - Core telemetry interfaces (TelemetryProvider, inputs, config)
|
|
9
|
-
* - No-op provider for when telemetry is disabled
|
|
10
|
-
* - Provider registry for global telemetry configuration
|
|
11
|
-
* - Attribute constants for consistent naming
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```typescript
|
|
15
|
-
* import {
|
|
16
|
-
* setTelemetryProvider,
|
|
17
|
-
* providerRef,
|
|
18
|
-
* noopProvider,
|
|
19
|
-
* PEAC_ATTRS,
|
|
20
|
-
* } from '@peac/telemetry';
|
|
21
|
-
*
|
|
22
|
-
* // Enable telemetry with a custom provider
|
|
23
|
-
* setTelemetryProvider(myOtelProvider);
|
|
24
|
-
*
|
|
25
|
-
* // In hot path (zero overhead when disabled)
|
|
26
|
-
* const p = providerRef.current;
|
|
27
|
-
* if (p) {
|
|
28
|
-
* try {
|
|
29
|
-
* p.onReceiptIssued({ receiptHash: '...' });
|
|
30
|
-
* } catch {
|
|
31
|
-
* // Telemetry MUST NOT break core flow
|
|
32
|
-
* }
|
|
33
|
-
* }
|
|
34
|
-
* ```
|
|
35
|
-
*
|
|
36
|
-
* @packageDocumentation
|
|
37
|
-
*/
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.TRACE_CONTEXT_EXTENSIONS = exports.PEAC_METRICS = exports.PEAC_EVENTS = exports.PEAC_ATTRS = exports.isTelemetryEnabled = exports.getTelemetryProvider = exports.setTelemetryProvider = exports.providerRef = exports.noopProvider = void 0;
|
|
40
|
-
// No-op provider
|
|
41
|
-
var noop_js_1 = require("./noop.js");
|
|
42
|
-
Object.defineProperty(exports, "noopProvider", { enumerable: true, get: function () { return noop_js_1.noopProvider; } });
|
|
43
|
-
// Provider registry
|
|
44
|
-
var provider_js_1 = require("./provider.js");
|
|
45
|
-
Object.defineProperty(exports, "providerRef", { enumerable: true, get: function () { return provider_js_1.providerRef; } });
|
|
46
|
-
Object.defineProperty(exports, "setTelemetryProvider", { enumerable: true, get: function () { return provider_js_1.setTelemetryProvider; } });
|
|
47
|
-
Object.defineProperty(exports, "getTelemetryProvider", { enumerable: true, get: function () { return provider_js_1.getTelemetryProvider; } });
|
|
48
|
-
Object.defineProperty(exports, "isTelemetryEnabled", { enumerable: true, get: function () { return provider_js_1.isTelemetryEnabled; } });
|
|
49
|
-
// Attribute constants
|
|
50
|
-
var attributes_js_1 = require("./attributes.js");
|
|
51
|
-
Object.defineProperty(exports, "PEAC_ATTRS", { enumerable: true, get: function () { return attributes_js_1.PEAC_ATTRS; } });
|
|
52
|
-
Object.defineProperty(exports, "PEAC_EVENTS", { enumerable: true, get: function () { return attributes_js_1.PEAC_EVENTS; } });
|
|
53
|
-
Object.defineProperty(exports, "PEAC_METRICS", { enumerable: true, get: function () { return attributes_js_1.PEAC_METRICS; } });
|
|
54
|
-
Object.defineProperty(exports, "TRACE_CONTEXT_EXTENSIONS", { enumerable: true, get: function () { return attributes_js_1.TRACE_CONTEXT_EXTENSIONS; } });
|
|
55
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;;;AAeH,iBAAiB;AACjB,qCAAyC;AAAhC,uGAAA,YAAY,OAAA;AAErB,oBAAoB;AACpB,6CAKuB;AAJrB,0GAAA,WAAW,OAAA;AACX,mHAAA,oBAAoB,OAAA;AACpB,mHAAA,oBAAoB,OAAA;AACpB,iHAAA,kBAAkB,OAAA;AAGpB,sBAAsB;AACtB,iDAAkG;AAAzF,2GAAA,UAAU,OAAA;AAAE,4GAAA,WAAW,OAAA;AAAE,6GAAA,YAAY,OAAA;AAAE,yHAAA,wBAAwB,OAAA"}
|
package/dist/noop.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @peac/telemetry - No-op telemetry provider
|
|
4
|
-
*
|
|
5
|
-
* This provider does nothing. Use it when telemetry is disabled
|
|
6
|
-
* or when you need a fallback provider.
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.noopProvider = void 0;
|
|
10
|
-
/**
|
|
11
|
-
* No-op telemetry provider
|
|
12
|
-
*
|
|
13
|
-
* All methods are empty functions that do nothing.
|
|
14
|
-
* Use this as the default when no telemetry is configured.
|
|
15
|
-
*/
|
|
16
|
-
exports.noopProvider = {
|
|
17
|
-
onReceiptIssued: () => { },
|
|
18
|
-
onReceiptVerified: () => { },
|
|
19
|
-
onAccessDecision: () => { },
|
|
20
|
-
};
|
|
21
|
-
//# sourceMappingURL=noop.js.map
|
package/dist/noop.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"noop.js","sourceRoot":"","sources":["../src/noop.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAIH;;;;;GAKG;AACU,QAAA,YAAY,GAAsB;IAC7C,eAAe,EAAE,GAAG,EAAE,GAAE,CAAC;IACzB,iBAAiB,EAAE,GAAG,EAAE,GAAE,CAAC;IAC3B,gBAAgB,EAAE,GAAG,EAAE,GAAE,CAAC;CAC3B,CAAC"}
|
package/dist/provider.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @peac/telemetry - Provider registry
|
|
4
|
-
*
|
|
5
|
-
* Zero-throw provider ref pattern for hot-path performance.
|
|
6
|
-
* When undefined, telemetry is disabled with NO function calls.
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.providerRef = void 0;
|
|
10
|
-
exports.setTelemetryProvider = setTelemetryProvider;
|
|
11
|
-
exports.getTelemetryProvider = getTelemetryProvider;
|
|
12
|
-
exports.isTelemetryEnabled = isTelemetryEnabled;
|
|
13
|
-
/**
|
|
14
|
-
* Singleton provider reference for zero-overhead hot path.
|
|
15
|
-
*
|
|
16
|
-
* When undefined, telemetry is disabled with NO function calls
|
|
17
|
-
* beyond the initial `if (!p)` check.
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* ```typescript
|
|
21
|
-
* // In hot path (issue/verify)
|
|
22
|
-
* const p = providerRef.current;
|
|
23
|
-
* if (p) {
|
|
24
|
-
* try {
|
|
25
|
-
* p.onReceiptIssued({ receiptHash: '...' });
|
|
26
|
-
* } catch {
|
|
27
|
-
* // Telemetry MUST NOT break core flow
|
|
28
|
-
* }
|
|
29
|
-
* }
|
|
30
|
-
* ```
|
|
31
|
-
*/
|
|
32
|
-
exports.providerRef = {
|
|
33
|
-
current: undefined,
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* Set the telemetry provider.
|
|
37
|
-
*
|
|
38
|
-
* Idempotent, no-throw, safe to call multiple times.
|
|
39
|
-
* Pass undefined to disable telemetry.
|
|
40
|
-
*
|
|
41
|
-
* @param provider - The provider to use, or undefined to disable
|
|
42
|
-
*/
|
|
43
|
-
function setTelemetryProvider(provider) {
|
|
44
|
-
exports.providerRef.current = provider;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Get the current telemetry provider.
|
|
48
|
-
*
|
|
49
|
-
* Returns undefined if no provider is set (telemetry disabled).
|
|
50
|
-
*
|
|
51
|
-
* For hot paths, prefer direct access to `providerRef.current`
|
|
52
|
-
* to avoid the function call overhead.
|
|
53
|
-
*/
|
|
54
|
-
function getTelemetryProvider() {
|
|
55
|
-
return exports.providerRef.current;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Check if telemetry is enabled.
|
|
59
|
-
*
|
|
60
|
-
* Convenience function for conditional logic outside hot paths.
|
|
61
|
-
*/
|
|
62
|
-
function isTelemetryEnabled() {
|
|
63
|
-
return exports.providerRef.current !== undefined;
|
|
64
|
-
}
|
|
65
|
-
//# sourceMappingURL=provider.js.map
|
package/dist/provider.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAmCH,oDAEC;AAUD,oDAEC;AAOD,gDAEC;AAtDD;;;;;;;;;;;;;;;;;;GAkBG;AACU,QAAA,WAAW,GAAoC;IAC1D,OAAO,EAAE,SAAS;CACnB,CAAC;AAEF;;;;;;;GAOG;AACH,SAAgB,oBAAoB,CAAC,QAAuC;IAC1E,mBAAW,CAAC,OAAO,GAAG,QAAQ,CAAC;AACjC,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,oBAAoB;IAClC,OAAO,mBAAW,CAAC,OAAO,CAAC;AAC7B,CAAC;AAED;;;;GAIG;AACH,SAAgB,kBAAkB;IAChC,OAAO,mBAAW,CAAC,OAAO,KAAK,SAAS,CAAC;AAC3C,CAAC"}
|
package/dist/types.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @peac/telemetry - Telemetry types and interfaces
|
|
4
|
-
*
|
|
5
|
-
* This module defines the core telemetry interfaces for PEAC protocol.
|
|
6
|
-
* These are runtime-portable and have no external dependencies.
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
//# sourceMappingURL=types.js.map
|
package/dist/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA;;;;;GAKG"}
|