@adea-ai/telemetry 4.2.0 → 4.2.1

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/index.d.ts CHANGED
@@ -9,7 +9,7 @@ export type { OperationsMetricEmitter, OperationsMetricName, OperationsMetricPoi
9
9
  export { OperationsMeasurementLifecycle } from './operations-lifecycle.js';
10
10
  export { DEFAULT_OPERATIONS_MEASUREMENT_CLOSE_TIMEOUT_MS, DEFAULT_OPERATIONS_MEASUREMENT_PASS_TIMEOUT_MS, } from './operations-lifecycle.js';
11
11
  export type { OperationsMeasurementContext, OperationsMeasurementLifecycleOptions, } from './operations-lifecycle.js';
12
- export { redactDiagnostics, redactTelemetryValue, sanitizeAttributes } from './redaction.js';
12
+ export { redactDiagnostics, redactTelemetryValue, registerTelemetryTextRedactor, sanitizeAttributes, } from './redaction.js';
13
13
  export { createTelemetry, Telemetry } from './telemetry.js';
14
14
  export { createLangSmithTraceAdapter } from './langsmith.js';
15
15
  export type { LangSmithClientPort, LangSmithRunPort } from './langsmith.js';
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ export { createStructuredLogger, jsonLogger } from './logger.js';
5
5
  export { createOperationsMetricEmitter, isOperationsMetricCataloged, operationsMetricNames, operationsStorageNamespaces, } from './operations.js';
6
6
  export { OperationsMeasurementLifecycle } from './operations-lifecycle.js';
7
7
  export { DEFAULT_OPERATIONS_MEASUREMENT_CLOSE_TIMEOUT_MS, DEFAULT_OPERATIONS_MEASUREMENT_PASS_TIMEOUT_MS, } from './operations-lifecycle.js';
8
- export { redactDiagnostics, redactTelemetryValue, sanitizeAttributes } from './redaction.js';
8
+ export { redactDiagnostics, redactTelemetryValue, registerTelemetryTextRedactor, sanitizeAttributes, } from './redaction.js';
9
9
  export { createTelemetry, Telemetry } from './telemetry.js';
10
10
  export { createLangSmithTraceAdapter } from './langsmith.js';
11
11
  export { createDeterministicSamplingPolicy } from './sampling.js';
@@ -1,4 +1,5 @@
1
1
  import type { SpanOutcome } from './types.js';
2
+ export declare function registerTelemetryTextRedactor(redactor: (text: string) => string): () => void;
2
3
  export declare function redactTelemetryValue(value: unknown): unknown;
3
4
  export declare function sanitizeSpanOutcome(outcome: SpanOutcome): SpanOutcome;
4
5
  export declare function sanitizeAttributes(attributes: Readonly<Record<string, unknown>>): Readonly<Record<string, boolean | number | string>>;
package/dist/redaction.js CHANGED
@@ -63,7 +63,23 @@ const secretsInText = [
63
63
  },
64
64
  ];
65
65
  const mayContainSecretText = /[:=/]|bearer|gh[pousr]_|github_pat_|akia|asia|xox[baprs]-|_live_|aiza|-----begin|localhost|127/i;
66
- function redactText(value) {
66
+ const textRedactors = new Set();
67
+ export function registerTelemetryTextRedactor(redactor) {
68
+ textRedactors.add(redactor);
69
+ return () => {
70
+ textRedactors.delete(redactor);
71
+ };
72
+ }
73
+ function redactText(input) {
74
+ let value = input;
75
+ for (const redactor of textRedactors) {
76
+ try {
77
+ value = redactor(value);
78
+ }
79
+ catch {
80
+ return '[REDACTED]';
81
+ }
82
+ }
67
83
  if (!mayContainSecretText.test(value))
68
84
  return value;
69
85
  return secretsInText.reduce((redacted, { pattern, replacement }) => redacted.replace(pattern, replacement), value);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adea-ai/telemetry",
3
- "version": "4.2.0",
3
+ "version": "4.2.1",
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",