@peac/telemetry 0.16.0 → 0.16.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/attributes.d.ts +5 -0
- package/dist/attributes.d.ts.map +1 -1
- package/dist/index.cjs +5 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +5 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/attributes.d.ts
CHANGED
|
@@ -11,6 +11,11 @@ export declare const PEAC_ATTRS: {
|
|
|
11
11
|
readonly VERSION: "peac.version";
|
|
12
12
|
readonly EVENT: "peac.event";
|
|
13
13
|
readonly RECEIPT_HASH: "peac.receipt.hash";
|
|
14
|
+
readonly RECORD_REF: "peac.record.ref";
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated `peac.receipt.ref` remains dual-emitted for one minor release window
|
|
17
|
+
* for compatibility. New consumers should read `peac.record.ref`.
|
|
18
|
+
*/
|
|
14
19
|
readonly RECEIPT_REF: "peac.receipt.ref";
|
|
15
20
|
readonly POLICY_HASH: "peac.policy.hash";
|
|
16
21
|
readonly DECISION: "peac.decision";
|
package/dist/attributes.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attributes.d.ts","sourceRoot":"","sources":["../src/attributes.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,eAAO,MAAM,UAAU
|
|
1
|
+
{"version":3,"file":"attributes.d.ts","sourceRoot":"","sources":["../src/attributes.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,eAAO,MAAM,UAAU;;;;;IAOrB;;;OAGG;;;;;;;;;;;;;;;;;CAuBK,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,WAAW;;;;CAId,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,YAAY;;;;;;CASf,CAAC;AAEX;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB;;;CAG3B,CAAC"}
|
package/dist/index.cjs
CHANGED
|
@@ -30,6 +30,11 @@ var PEAC_ATTRS = {
|
|
|
30
30
|
VERSION: "peac.version",
|
|
31
31
|
EVENT: "peac.event",
|
|
32
32
|
RECEIPT_HASH: "peac.receipt.hash",
|
|
33
|
+
RECORD_REF: "peac.record.ref",
|
|
34
|
+
/**
|
|
35
|
+
* @deprecated `peac.receipt.ref` remains dual-emitted for one minor release window
|
|
36
|
+
* for compatibility. New consumers should read `peac.record.ref`.
|
|
37
|
+
*/
|
|
33
38
|
RECEIPT_REF: "peac.receipt.ref",
|
|
34
39
|
POLICY_HASH: "peac.policy.hash",
|
|
35
40
|
DECISION: "peac.decision",
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +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,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 RECEIPT_REF: 'peac.receipt.ref',\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"]}
|
|
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,UAAA,EAAY,iBAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMZ,WAAA,EAAa,kBAAA;AAAA,EACb,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 RECORD_REF: 'peac.record.ref',\n\n /**\n * @deprecated `peac.receipt.ref` remains dual-emitted for one minor release window\n * for compatibility. New consumers should read `peac.record.ref`.\n */\n RECEIPT_REF: 'peac.receipt.ref',\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
CHANGED
|
@@ -28,6 +28,11 @@ var PEAC_ATTRS = {
|
|
|
28
28
|
VERSION: "peac.version",
|
|
29
29
|
EVENT: "peac.event",
|
|
30
30
|
RECEIPT_HASH: "peac.receipt.hash",
|
|
31
|
+
RECORD_REF: "peac.record.ref",
|
|
32
|
+
/**
|
|
33
|
+
* @deprecated `peac.receipt.ref` remains dual-emitted for one minor release window
|
|
34
|
+
* for compatibility. New consumers should read `peac.record.ref`.
|
|
35
|
+
*/
|
|
31
36
|
RECEIPT_REF: "peac.receipt.ref",
|
|
32
37
|
POLICY_HASH: "peac.policy.hash",
|
|
33
38
|
DECISION: "peac.decision",
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +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,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 RECEIPT_REF: 'peac.receipt.ref',\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"]}
|
|
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,UAAA,EAAY,iBAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMZ,WAAA,EAAa,kBAAA;AAAA,EACb,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 RECORD_REF: 'peac.record.ref',\n\n /**\n * @deprecated `peac.receipt.ref` remains dual-emitted for one minor release window\n * for compatibility. New consumers should read `peac.record.ref`.\n */\n RECEIPT_REF: 'peac.receipt.ref',\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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@peac/telemetry",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.2",
|
|
4
4
|
"description": "Telemetry interfaces and no-op implementation for PEAC protocol",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"author": "PEAC Protocol Contributors",
|
|
26
26
|
"license": "Apache-2.0",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@peac/kernel": "0.16.
|
|
28
|
+
"@peac/kernel": "0.16.2"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/node": "^22.19.11",
|