@contractspec/lib.observability 3.7.5 → 3.7.7
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/AGENTS.md +46 -21
- package/CHANGELOG.md +10 -0
- package/README.md +56 -63
- package/dist/index.d.ts +12 -12
- package/dist/index.js +298 -298
- package/dist/logging/index.js +1 -1
- package/dist/metrics/index.d.ts +1 -1
- package/dist/node/index.js +298 -298
- package/dist/node/logging/index.js +1 -1
- package/dist/node/tracing/middleware.js +24 -24
- package/dist/tracing/middleware.js +24 -24
- package/package.json +8 -8
package/AGENTS.md
CHANGED
|
@@ -2,33 +2,58 @@
|
|
|
2
2
|
|
|
3
3
|
Scope: `packages/libs/observability/*`
|
|
4
4
|
|
|
5
|
-
OpenTelemetry-based observability primitives.
|
|
5
|
+
OpenTelemetry-based observability primitives.
|
|
6
6
|
|
|
7
7
|
## Quick Context
|
|
8
8
|
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
9
|
+
- Layer: `lib`.
|
|
10
|
+
- Package visibility: published package.
|
|
11
|
+
- Primary consumers are other libs, modules, bundles, and apps in the monorepo.
|
|
12
|
+
- Related packages: `@contractspec/lib.contracts-integrations`, `@contractspec/lib.contracts-spec`, `@contractspec/lib.lifecycle`, `@contractspec/tool.bun`, `@contractspec/tool.typescript`.
|
|
13
|
+
|
|
14
|
+
## Architecture
|
|
15
|
+
|
|
16
|
+
- `src/anomaly` is part of the package's public or composition surface.
|
|
17
|
+
- `src/index.ts` is the root public barrel and package entrypoint.
|
|
18
|
+
- `src/intent` is part of the package's public or composition surface.
|
|
19
|
+
- `src/logging` is part of the package's public or composition surface.
|
|
20
|
+
- `src/metrics` is part of the package's public or composition surface.
|
|
21
|
+
- `src/pipeline/` contains pipeline stages and orchestration helpers.
|
|
22
|
+
- `src/telemetry` is part of the package's public or composition surface.
|
|
23
|
+
|
|
24
|
+
## Public Surface
|
|
25
|
+
|
|
26
|
+
- Export `.` resolves through `./src/index.ts`.
|
|
27
|
+
- Export `./anomaly/alert-manager` resolves through `./src/anomaly/alert-manager.ts`.
|
|
28
|
+
- Export `./anomaly/anomaly-detector` resolves through `./src/anomaly/anomaly-detector.ts`.
|
|
29
|
+
- Export `./anomaly/baseline-calculator` resolves through `./src/anomaly/baseline-calculator.ts`.
|
|
30
|
+
- Export `./anomaly/root-cause-analyzer` resolves through `./src/anomaly/root-cause-analyzer.ts`.
|
|
31
|
+
- Export `./intent/aggregator` resolves through `./src/intent/aggregator.ts`.
|
|
32
|
+
- Export `./intent/detector` resolves through `./src/intent/detector.ts`.
|
|
33
|
+
- Export `./logging` resolves through `./src/logging/index.ts`.
|
|
34
|
+
- Export `./metrics` resolves through `./src/metrics/index.ts`.
|
|
35
|
+
- Export `./pipeline/evolution-pipeline` resolves through `./src/pipeline/evolution-pipeline.ts`.
|
|
36
|
+
- The package publishes 18 total export subpaths; keep docs aligned with `package.json`.
|
|
22
37
|
|
|
23
38
|
## Guardrails
|
|
24
39
|
|
|
25
|
-
- OTel span and metric naming conventions must stay consistent across the platform
|
|
26
|
-
- Pipeline interfaces are adapter boundaries — do not leak vendor-specific details
|
|
27
|
-
- Anomaly detection thresholds affect alerting; changes require validation
|
|
40
|
+
- OTel span and metric naming conventions must stay consistent across the platform.
|
|
41
|
+
- Pipeline interfaces are adapter boundaries — do not leak vendor-specific details.
|
|
42
|
+
- Anomaly detection thresholds affect alerting; changes require validation.
|
|
43
|
+
- Changes here can affect downstream packages such as `@contractspec/lib.contracts-integrations`, `@contractspec/lib.contracts-spec`, `@contractspec/lib.lifecycle`, `@contractspec/tool.bun`, `@contractspec/tool.typescript`.
|
|
28
44
|
|
|
29
45
|
## Local Commands
|
|
30
46
|
|
|
31
|
-
-
|
|
32
|
-
-
|
|
33
|
-
-
|
|
34
|
-
-
|
|
47
|
+
- `bun run dev` — contractspec-bun-build dev
|
|
48
|
+
- `bun run build` — bun run prebuild && bun run build:bundle && bun run build:types
|
|
49
|
+
- `bun run test` — bun test --pass-with-no-tests
|
|
50
|
+
- `bun run lint` — bun lint:fix
|
|
51
|
+
- `bun run lint:check` — biome check .
|
|
52
|
+
- `bun run lint:fix` — biome check --write --unsafe --only=nursery/useSortedClasses . && biome check --write .
|
|
53
|
+
- `bun run typecheck` — tsc --noEmit
|
|
54
|
+
- `bun run publish:pkg` — bun publish --tolerate-republish --ignore-scripts --verbose
|
|
55
|
+
- `bun run publish:pkg:canary` — bun publish:pkg --tag canary
|
|
56
|
+
- `bun run clean` — rimraf dist .turbo
|
|
57
|
+
- `bun run build:bundle` — contractspec-bun-build transpile
|
|
58
|
+
- `bun run build:types` — contractspec-bun-build types
|
|
59
|
+
- `bun run prebuild` — contractspec-bun-build prebuild
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @contractspec/lib.observability
|
|
2
2
|
|
|
3
|
+
## 3.7.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fix: release manifest
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @contractspec/lib.contracts-integrations@3.7.6
|
|
10
|
+
- @contractspec/lib.contracts-spec@3.7.6
|
|
11
|
+
- @contractspec/lib.lifecycle@3.7.6
|
|
12
|
+
|
|
3
13
|
## 3.7.5
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -1,85 +1,78 @@
|
|
|
1
1
|
# @contractspec/lib.observability
|
|
2
2
|
|
|
3
|
-
Website: https://contractspec.io
|
|
3
|
+
Website: https://contractspec.io
|
|
4
4
|
|
|
5
|
+
**OpenTelemetry-based observability primitives.**
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
## What It Provides
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
9
|
+
- **Layer**: lib.
|
|
10
|
+
- **Consumers**: evolution, progressive-delivery, bundles.
|
|
11
|
+
- `src/pipeline/` contains pipeline stages and orchestration helpers.
|
|
12
|
+
- Related ContractSpec packages include `@contractspec/lib.contracts-integrations`, `@contractspec/lib.contracts-spec`, `@contractspec/lib.lifecycle`, `@contractspec/tool.bun`, `@contractspec/tool.typescript`.
|
|
13
|
+
- `src/pipeline/` contains pipeline stages and orchestration helpers.
|
|
13
14
|
|
|
14
15
|
## Installation
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
npm install @contractspec/lib.observability @opentelemetry/api
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
## Quick Start
|
|
21
|
-
|
|
22
|
-
### Tracing
|
|
23
|
-
|
|
24
|
-
```typescript
|
|
25
|
-
import { traceAsync } from '@contractspec/lib.observability/tracing';
|
|
26
|
-
|
|
27
|
-
await traceAsync('process_order', async (span) => {
|
|
28
|
-
span.setAttribute('order_id', order.id);
|
|
29
|
-
await db.save(order);
|
|
30
|
-
});
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
### Metrics
|
|
34
|
-
|
|
35
|
-
```typescript
|
|
36
|
-
import { createCounter } from '@contractspec/lib.observability/metrics';
|
|
37
|
-
|
|
38
|
-
const ordersCounter = createCounter('orders_total');
|
|
39
|
-
ordersCounter.add(1, { status: 'success' });
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
### Middleware
|
|
43
|
-
|
|
44
|
-
```typescript
|
|
45
|
-
import { createTracingMiddleware } from '@contractspec/lib.observability/tracing/middleware';
|
|
46
|
-
|
|
47
|
-
app.use(createTracingMiddleware());
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
## Documentation
|
|
51
|
-
|
|
52
|
-
Full docs: https://contractspec.io/docs/libraries/observability
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
17
|
+
`npm install @contractspec/lib.observability`
|
|
72
18
|
|
|
19
|
+
or
|
|
73
20
|
|
|
21
|
+
`bun add @contractspec/lib.observability`
|
|
74
22
|
|
|
23
|
+
## Usage
|
|
75
24
|
|
|
25
|
+
Import the root entrypoint from `@contractspec/lib.observability`, or choose a documented subpath when you only need one part of the package surface.
|
|
76
26
|
|
|
27
|
+
## Architecture
|
|
77
28
|
|
|
29
|
+
- `src/anomaly` is part of the package's public or composition surface.
|
|
30
|
+
- `src/index.ts` is the root public barrel and package entrypoint.
|
|
31
|
+
- `src/intent` is part of the package's public or composition surface.
|
|
32
|
+
- `src/logging` is part of the package's public or composition surface.
|
|
33
|
+
- `src/metrics` is part of the package's public or composition surface.
|
|
34
|
+
- `src/pipeline/` contains pipeline stages and orchestration helpers.
|
|
35
|
+
- `src/telemetry` is part of the package's public or composition surface.
|
|
78
36
|
|
|
37
|
+
## Public Entry Points
|
|
79
38
|
|
|
39
|
+
- Export `.` resolves through `./src/index.ts`.
|
|
40
|
+
- Export `./anomaly/alert-manager` resolves through `./src/anomaly/alert-manager.ts`.
|
|
41
|
+
- Export `./anomaly/anomaly-detector` resolves through `./src/anomaly/anomaly-detector.ts`.
|
|
42
|
+
- Export `./anomaly/baseline-calculator` resolves through `./src/anomaly/baseline-calculator.ts`.
|
|
43
|
+
- Export `./anomaly/root-cause-analyzer` resolves through `./src/anomaly/root-cause-analyzer.ts`.
|
|
44
|
+
- Export `./intent/aggregator` resolves through `./src/intent/aggregator.ts`.
|
|
45
|
+
- Export `./intent/detector` resolves through `./src/intent/detector.ts`.
|
|
46
|
+
- Export `./logging` resolves through `./src/logging/index.ts`.
|
|
47
|
+
- Export `./metrics` resolves through `./src/metrics/index.ts`.
|
|
48
|
+
- Export `./pipeline/evolution-pipeline` resolves through `./src/pipeline/evolution-pipeline.ts`.
|
|
49
|
+
- The package publishes 18 total export subpaths; keep docs aligned with `package.json`.
|
|
80
50
|
|
|
51
|
+
## Local Commands
|
|
81
52
|
|
|
53
|
+
- `bun run dev` — contractspec-bun-build dev
|
|
54
|
+
- `bun run build` — bun run prebuild && bun run build:bundle && bun run build:types
|
|
55
|
+
- `bun run test` — bun test --pass-with-no-tests
|
|
56
|
+
- `bun run lint` — bun lint:fix
|
|
57
|
+
- `bun run lint:check` — biome check .
|
|
58
|
+
- `bun run lint:fix` — biome check --write --unsafe --only=nursery/useSortedClasses . && biome check --write .
|
|
59
|
+
- `bun run typecheck` — tsc --noEmit
|
|
60
|
+
- `bun run publish:pkg` — bun publish --tolerate-republish --ignore-scripts --verbose
|
|
61
|
+
- `bun run publish:pkg:canary` — bun publish:pkg --tag canary
|
|
62
|
+
- `bun run clean` — rimraf dist .turbo
|
|
63
|
+
- `bun run build:bundle` — contractspec-bun-build transpile
|
|
64
|
+
- `bun run build:types` — contractspec-bun-build types
|
|
65
|
+
- `bun run prebuild` — contractspec-bun-build prebuild
|
|
82
66
|
|
|
67
|
+
## Recent Updates
|
|
83
68
|
|
|
69
|
+
- Replace eslint+prettier by biomejs to optimize speed.
|
|
70
|
+
- Circular import issue.
|
|
71
|
+
- Normalize formatting across contracts-integrations, composio, and observability.
|
|
72
|
+
- Add AI provider ranking system with ranking-driven model selection.
|
|
84
73
|
|
|
74
|
+
## Notes
|
|
85
75
|
|
|
76
|
+
- OTel span and metric naming conventions must stay consistent across the platform.
|
|
77
|
+
- Pipeline interfaces are adapter boundaries — do not leak vendor-specific details.
|
|
78
|
+
- Anomaly detection thresholds affect alerting; changes require validation.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export { Logger, logger } from './logging';
|
|
6
|
-
export { createTracingMiddleware, type TracingMiddlewareOptions, } from './tracing/middleware';
|
|
1
|
+
export { AlertManager } from './anomaly/alert-manager';
|
|
2
|
+
export { AnomalyDetector, type AnomalySignal, type AnomalyThresholds, } from './anomaly/anomaly-detector';
|
|
3
|
+
export { BaselineCalculator } from './anomaly/baseline-calculator';
|
|
4
|
+
export { type RootCauseAnalysis, RootCauseAnalyzer, } from './anomaly/root-cause-analyzer';
|
|
7
5
|
export { IntentAggregator, type IntentAggregatorSnapshot, type TelemetrySample, } from './intent/aggregator';
|
|
8
6
|
export { IntentDetector, type IntentSignal, type IntentSignalType, } from './intent/detector';
|
|
7
|
+
export type { LogEntry, LogLevel } from './logging';
|
|
8
|
+
export { Logger, logger } from './logging';
|
|
9
|
+
export { createCounter, createHistogram, createUpDownCounter, getMeter, standardMetrics, } from './metrics';
|
|
9
10
|
export { EvolutionPipeline, type EvolutionPipelineEvent, type EvolutionPipelineOptions, } from './pipeline/evolution-pipeline';
|
|
10
11
|
export { LifecycleKpiPipeline, type LifecycleKpiPipelineOptions, type LifecyclePipelineEvent, } from './pipeline/lifecycle-pipeline';
|
|
11
|
-
export {
|
|
12
|
+
export { type ModelSelectionEventProperties, ModelSelectionTelemetry, } from './telemetry/model-selection-telemetry';
|
|
12
13
|
export { PosthogBaselineReader } from './telemetry/posthog-baseline-reader';
|
|
13
|
-
export
|
|
14
|
-
export {
|
|
15
|
-
export {
|
|
16
|
-
export {
|
|
17
|
-
export { AlertManager } from './anomaly/alert-manager';
|
|
14
|
+
export { PosthogTelemetryProvider, type PosthogTelemetryProviderOptions, } from './telemetry/posthog-telemetry';
|
|
15
|
+
export { getTracer, traceAsync, traceSync } from './tracing';
|
|
16
|
+
export { createTracingMiddleware, type TracingMiddlewareOptions, } from './tracing/middleware';
|
|
17
|
+
export { type ModelSelectionSpanAttributes, type ModelSelectionSpanInput, traceModelSelection, } from './tracing/model-selection.span';
|