@chidchanun/bcp 0.2.15 → 0.2.17

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.
@@ -0,0 +1,166 @@
1
+ # BCP Framework 0.2.17 — Observability Platform v3
2
+
3
+ State: **unreleased**
4
+
5
+ `0.2.17` adds provider-neutral distributed tracing and correlation to the existing `bcp/observability` package while preserving the metrics, Prometheus and health APIs introduced in Observability Platform v2.
6
+
7
+ ## Highlights
8
+
9
+ - `createTracer()` root/child span runtime
10
+ - Node `AsyncLocalStorage` trace context
11
+ - W3C `traceparent` parsing/formatting
12
+ - HTTP trace header injection/extraction
13
+ - stable `correlationId`
14
+ - `createRequestTracingMiddleware()` for Middleware System v2
15
+ - `createTraceCarrier()` / `runWithTraceCarrier()` for jobs/workflows/events/realtime payloads
16
+ - span attributes and events
17
+ - automatic error status/exception events for failed callbacks
18
+ - `createMemoryTraceSpanExporter()`
19
+ - `createCompositeTraceSpanExporter()`
20
+ - `createTraceMetricsExporter()`
21
+ - `getTraceLogFields()` for structured logging correlation
22
+ - compiled npm runtime `observability.mjs`
23
+
24
+ ## Public API additions
25
+
26
+ ```text
27
+ createTracer
28
+ currentTraceContext
29
+ runWithTraceContext
30
+ createTraceCarrier
31
+ extractTraceCarrier
32
+ runWithTraceCarrier
33
+ injectTraceHeaders
34
+ extractTraceHeaders
35
+ formatTraceparent
36
+ parseTraceparent
37
+ createRequestTracingMiddleware
38
+ createMemoryTraceSpanExporter
39
+ createCompositeTraceSpanExporter
40
+ createTraceMetricsExporter
41
+ getTraceLogFields
42
+ ```
43
+
44
+ New public types include:
45
+
46
+ ```text
47
+ TraceContext
48
+ TraceCarrier
49
+ TraceSpan
50
+ TraceSpanRecord
51
+ TraceSpanEvent
52
+ TraceSpanExporter
53
+ TraceSpanKind
54
+ TraceSpanStatus
55
+ TraceAttributes
56
+ Tracer
57
+ TracerOptions
58
+ StartTraceSpanOptions
59
+ RequestTracingOptions
60
+ TraceIdFactory
61
+ TraceMetricsOptions
62
+ ```
63
+
64
+ ## Trace model
65
+
66
+ A root operation owns a `traceId` and `correlationId`. Every nested span receives its own `spanId` while inheriting the trace and correlation identity.
67
+
68
+ ```text
69
+ traceId
70
+ |
71
+ +-- HTTP span
72
+ |
73
+ +-- database span
74
+ +-- cache span
75
+ +-- producer span
76
+ |
77
+ +-- consumer span
78
+ ```
79
+
80
+ Normal awaited asynchronous calls retain the active context through `AsyncLocalStorage`.
81
+
82
+ ## HTTP propagation
83
+
84
+ The request tracing middleware understands W3C version `00` `traceparent` headers and `x-correlation-id`.
85
+
86
+ Responses include the active span's `traceparent` plus the correlation ID unless `includeResponseHeaders: false` is configured.
87
+
88
+ ## Background propagation
89
+
90
+ `0.2.17` intentionally does not add mandatory tracing fields to job, workflow, outbox or realtime schemas.
91
+
92
+ Applications can explicitly transport:
93
+
94
+ ```ts
95
+ const trace =
96
+ createTraceCarrier();
97
+ ```
98
+
99
+ and restore it with:
100
+
101
+ ```ts
102
+ runWithTraceCarrier(
103
+ payload.trace,
104
+ handler
105
+ );
106
+ ```
107
+
108
+ This keeps tracing provider-neutral and avoids breaking existing persisted data.
109
+
110
+ ## Trace metrics
111
+
112
+ `createTraceMetricsExporter()` integrates completed spans with the existing metrics registry.
113
+
114
+ Default metrics:
115
+
116
+ ```text
117
+ bcp_trace_spans_total
118
+ bcp_trace_span_duration_seconds
119
+ ```
120
+
121
+ Default labels:
122
+
123
+ ```text
124
+ kind
125
+ status
126
+ ```
127
+
128
+ Span-name labels remain opt-in to reduce accidental high-cardinality metrics.
129
+
130
+ ## Exporter model
131
+
132
+ BCP ships an in-memory exporter for tests and a composite exporter for fan-out. Production collector/APM integration remains application-owned through `TraceSpanExporter`.
133
+
134
+ Exporter delivery failures are isolated from business execution.
135
+
136
+ ## Packaging
137
+
138
+ Prepared npm packages now compile `bcp/observability` into:
139
+
140
+ ```text
141
+ packages/client/src/observability.mjs
142
+ ```
143
+
144
+ The package smoke test imports this compiled runtime and exercises trace creation, context propagation and trace metrics.
145
+
146
+ ## Compatibility
147
+
148
+ - Previous baseline: `0.2.16`
149
+ - Intentional breaking changes: **none**
150
+ - Existing Observability v2 metrics/health APIs remain supported.
151
+ - Existing `bcp/observability` import path remains unchanged.
152
+
153
+ ## Validation
154
+
155
+ The release candidate must pass:
156
+
157
+ ```bash
158
+ npm run typecheck
159
+ npm run test:unit
160
+ npm run test:integration
161
+ npm run test:e2e
162
+ npm run test:package
163
+ npm run rc:check
164
+ ```
165
+
166
+ Do not tag or publish until the exact release commit passes the full validation sequence.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chidchanun/bcp",
3
- "version": "0.2.15",
3
+ "version": "0.2.17",
4
4
  "description": "BCP Framework - a React full-stack framework with file-based routing, SSR, APIs, middleware, islands, caching and standalone production builds.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "./cache": {
40
40
  "types": "./packages/client/src/cache.ts",
41
- "default": "./packages/client/src/cache.ts"
41
+ "default": "./packages/client/src/cache.mjs"
42
42
  },
43
43
  "./config": {
44
44
  "types": "./packages/client/src/config.ts",
@@ -95,7 +95,7 @@
95
95
  "./observability": {
96
96
  "types": "./packages/client/src/observability.ts",
97
97
  "browser": "./packages/client/src/server-only.browser.mjs",
98
- "default": "./packages/client/src/observability.ts"
98
+ "default": "./packages/client/src/observability.mjs"
99
99
  },
100
100
  "./server": {
101
101
  "types": "./packages/client/src/server.ts",