@adea-ai/telemetry 3.0.0 → 3.0.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/console.d.ts CHANGED
@@ -1,3 +1,7 @@
1
1
  import type { MetricAdapter, StructuredLogger, TraceAdapter } from './types.js';
2
- export declare function createConsoleTraceAdapter(logger: StructuredLogger): TraceAdapter;
2
+ export interface ConsoleTraceAdapterOptions {
3
+ readonly slowSpanMs?: number;
4
+ }
5
+ export declare const DEFAULT_CONSOLE_SLOW_SPAN_MS = 1000;
6
+ export declare function createConsoleTraceAdapter(logger: StructuredLogger, options?: ConsoleTraceAdapterOptions): TraceAdapter;
3
7
  export declare function createConsoleMetricAdapter(logger: StructuredLogger): MetricAdapter;
package/dist/console.js CHANGED
@@ -1,7 +1,12 @@
1
1
  import { randomBytes } from 'node:crypto';
2
2
  import { performance } from 'node:perf_hooks';
3
3
  import { traceIdFromContext } from './context.js';
4
- export function createConsoleTraceAdapter(logger) {
4
+ export const DEFAULT_CONSOLE_SLOW_SPAN_MS = 1_000;
5
+ export function createConsoleTraceAdapter(logger, options = {}) {
6
+ const slowSpanMs = options.slowSpanMs ?? DEFAULT_CONSOLE_SLOW_SPAN_MS;
7
+ if (!Number.isFinite(slowSpanMs) || slowSpanMs < 0) {
8
+ throw new Error('INVALID_CONSOLE_SLOW_SPAN_MS');
9
+ }
5
10
  return {
6
11
  startSpan(input) {
7
12
  const startedAt = performance.now();
@@ -9,12 +14,15 @@ export function createConsoleTraceAdapter(logger) {
9
14
  return {
10
15
  context,
11
16
  end(outcome) {
17
+ const durationMs = Math.max(0, Math.round(performance.now() - startedAt));
18
+ if (outcome.status !== 'error' && durationMs < slowSpanMs)
19
+ return;
12
20
  logger.write({
13
21
  level: outcome.status === 'error' ? 'error' : 'info',
14
22
  event: 'telemetry.span.completed',
15
23
  metadata: input.attributes,
16
24
  details: {
17
- durationMs: Math.max(0, Math.round(performance.now() - startedAt)),
25
+ durationMs,
18
26
  name: input.name,
19
27
  spanId: context.traceparent.split('-')[2],
20
28
  status: outcome.status,
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { createConsoleMetricAdapter, createConsoleTraceAdapter } from './console.js';
1
+ export { createConsoleMetricAdapter, createConsoleTraceAdapter, DEFAULT_CONSOLE_SLOW_SPAN_MS, type ConsoleTraceAdapterOptions, } from './console.js';
2
2
  export { consistencyMetricNames, createConsistencyMetricEmitter } from './consistency.js';
3
3
  export type { CommandInboxAcceptanceOutcome, ConsistencyMetricEmitter } from './consistency.js';
4
4
  export { extractTraceContext, injectTraceContext, semanticAttributes, traceIdFromContext, } from './context.js';
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export { createConsoleMetricAdapter, createConsoleTraceAdapter } from './console.js';
1
+ export { createConsoleMetricAdapter, createConsoleTraceAdapter, DEFAULT_CONSOLE_SLOW_SPAN_MS, } from './console.js';
2
2
  export { consistencyMetricNames, createConsistencyMetricEmitter } from './consistency.js';
3
3
  export { extractTraceContext, injectTraceContext, semanticAttributes, traceIdFromContext, } from './context.js';
4
4
  export { createStructuredLogger, jsonLogger } from './logger.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adea-ai/telemetry",
3
- "version": "3.0.0",
3
+ "version": "3.0.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",