@chidchanun/bcp 0.2.16 → 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.
- package/README.md +152 -271
- package/docs/README.md +40 -34
- package/docs/api-manifest.json +13 -13
- package/docs/api-reference.md +225 -283
- package/docs/docs-web-manifest.json +4 -2
- package/docs/observability-v3.md +402 -0
- package/docs/platform-manifest.json +16 -4
- package/docs/releases/0.2.17.md +166 -0
- package/package.json +2 -2
- package/packages/client/src/observability.mjs +1251 -0
- package/packages/client/src/observability.ts +37 -0
- package/packages/server/src/observability-v3.ts +878 -0
package/docs/api-reference.md
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
# API Reference
|
|
2
2
|
|
|
3
|
-
BCP Framework exposes
|
|
3
|
+
BCP Framework exposes supported package entrypoints through the `bcp` package. Application code should import these public entrypoints instead of private implementation files under `packages/`.
|
|
4
4
|
|
|
5
5
|
The machine-readable source for this page is `docs/api-manifest.json`.
|
|
6
6
|
|
|
7
7
|
## `bcp`
|
|
8
8
|
|
|
9
|
-
Universal React application APIs.
|
|
9
|
+
Universal React application APIs for routing, navigation, layouts, metadata, loaders, route guards, form actions and islands.
|
|
10
10
|
|
|
11
|
-
Common exports include `Form`, `Link`, `createIsland`, `navigate`, `notFound
|
|
11
|
+
Common exports include `Form`, `Link`, `createIsland`, `navigate`, `notFound` and loader/action/guard hooks.
|
|
12
12
|
|
|
13
13
|
Related guides: [Routing](routing.md), [Server Data Loaders](server-data-loaders.md), [Route Guards](route-guards.md), [Form Actions](form-actions.md), [Testing Platform](testing-platform.md).
|
|
14
14
|
|
|
@@ -26,70 +26,37 @@ Related guide: [Hydration](hydration.md).
|
|
|
26
26
|
|
|
27
27
|
## `bcp/cache`
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
Backward-compatible request/data caching plus Cache Platform v2 shared-store APIs.
|
|
30
30
|
|
|
31
|
-
Legacy
|
|
31
|
+
Legacy APIs:
|
|
32
32
|
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
revalidateTag,
|
|
41
|
-
} from "bcp/cache";
|
|
33
|
+
```text
|
|
34
|
+
cache
|
|
35
|
+
dedupe
|
|
36
|
+
clearCache
|
|
37
|
+
getCacheStats
|
|
38
|
+
revalidateTag
|
|
39
|
+
revalidatePath
|
|
42
40
|
```
|
|
43
41
|
|
|
44
|
-
Cache Platform v2
|
|
42
|
+
Cache Platform v2 APIs:
|
|
45
43
|
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
createRedisCacheLockAdapter,
|
|
54
|
-
type CacheAdapter,
|
|
55
|
-
type CacheAdapterEntry,
|
|
56
|
-
type CacheAdapterSetOptions,
|
|
57
|
-
type CacheGetOrSetOptions,
|
|
58
|
-
type CacheLockAdapter,
|
|
59
|
-
type CacheMetricsRegistryLike,
|
|
60
|
-
type CacheMetricsSink,
|
|
61
|
-
type CacheStore,
|
|
62
|
-
type CacheStoreEvent,
|
|
63
|
-
type CacheStoreOptions,
|
|
64
|
-
type CacheStoreSetOptions,
|
|
65
|
-
type CacheStoreStats,
|
|
66
|
-
type MemoryCacheAdapter,
|
|
67
|
-
type MemoryCacheLockAdapter,
|
|
68
|
-
type RedisCacheAdapter,
|
|
69
|
-
type RedisCacheAdapterOptions,
|
|
70
|
-
type RedisCacheCommandClient,
|
|
71
|
-
type RedisCacheLockAdapter,
|
|
72
|
-
type RedisCacheLockAdapterOptions,
|
|
73
|
-
} from "bcp/cache";
|
|
44
|
+
```text
|
|
45
|
+
createCacheStore
|
|
46
|
+
createMemoryCacheAdapter
|
|
47
|
+
createMemoryCacheLockAdapter
|
|
48
|
+
createRedisCacheAdapter
|
|
49
|
+
createRedisCacheLockAdapter
|
|
50
|
+
createCacheMetrics
|
|
74
51
|
```
|
|
75
52
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
`getOrSet()` always provides local singleflight deduplication. When a `CacheLockAdapter` is supplied, cache fills can also coordinate across multiple application instances with owner-scoped leases, optional renewal and configurable contention timeout behavior.
|
|
79
|
-
|
|
80
|
-
`createRedisCacheAdapter()` and `createRedisCacheLockAdapter()` use a minimal `sendCommand()` client contract. BCP does not install or own a Redis library/connection. The default namespace is `bcp:{cache}` for Redis Cluster hash-slot locality.
|
|
81
|
-
|
|
82
|
-
Cache Store v2 uses millisecond TTL (`ttlMs`), while the original `cache()` API keeps its existing `revalidate`-seconds contract.
|
|
53
|
+
Public contracts include `CacheAdapter`, `CacheLockAdapter`, `CacheStore`, cache statistics/options and Redis command-client adapter types.
|
|
83
54
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
Prepared npm packages compile the runtime entrypoint to `packages/client/src/cache.mjs`.
|
|
87
|
-
|
|
88
|
-
Related guides: [Caching](caching.md), [Cache Platform v2](cache-platform-v2.md), [Observability Platform v2](observability.md).
|
|
55
|
+
Related guides: [Caching](caching.md), [Cache Platform v2](cache-platform-v2.md), [Observability Platform v3](observability-v3.md).
|
|
89
56
|
|
|
90
57
|
## `bcp/config`
|
|
91
58
|
|
|
92
|
-
Typed
|
|
59
|
+
Typed BCP configuration, environment-schema validation and diagnostics APIs.
|
|
93
60
|
|
|
94
61
|
Related guides: [Configuration](configuration.md), [Environment Validation](environment-validation.md).
|
|
95
62
|
|
|
@@ -107,323 +74,300 @@ Related guide: [Error Handling](error-handling.md).
|
|
|
107
74
|
|
|
108
75
|
## `bcp/database`
|
|
109
76
|
|
|
110
|
-
Server-only
|
|
77
|
+
Server-only provider-neutral SQL APIs for MySQL, PostgreSQL and SQLite.
|
|
111
78
|
|
|
112
|
-
|
|
79
|
+
Core capabilities include query/execute, transactions, lifecycle, migration stores and migration execution.
|
|
113
80
|
|
|
114
|
-
Related guides: [Database](database.md), [Database Migrations](database-migrations.md), [Transactional Outbox & Events](transactional-outbox-events.md), [Testing Platform](testing-platform.md).
|
|
81
|
+
Related guides: [Database](database.md), [Database Migrations](database-migrations.md), [Transactional Outbox & Events](transactional-outbox-events.md), [Testing Platform](testing-platform.md), [Observability Platform v3](observability-v3.md).
|
|
115
82
|
|
|
116
83
|
## `bcp/auth`
|
|
117
84
|
|
|
118
|
-
Server-only
|
|
85
|
+
Server-only Authentication Platform v2 and Authorization & Security v2 APIs.
|
|
119
86
|
|
|
120
|
-
|
|
87
|
+
Capabilities include JWT-cookie sessions, optional server-side session stores, revocation, logout-all, idle timeout, role/permission guards, policies, same-origin protection and auth/guest guards.
|
|
121
88
|
|
|
122
|
-
Related guides: [Authentication](authentication.md), [Auth Session Stores](auth-session-store.md), [Auth Route Guards](auth-route-guards.md), [Authorization & Security v2](authorization-security.md), [JWT Sessions](session-auth.md)
|
|
89
|
+
Related guides: [Authentication](authentication.md), [Auth Session Stores](auth-session-store.md), [Auth Route Guards](auth-route-guards.md), [Authorization & Security v2](authorization-security.md), [JWT Sessions](session-auth.md).
|
|
123
90
|
|
|
124
91
|
## `bcp/jobs`
|
|
125
92
|
|
|
126
|
-
Server-only
|
|
127
|
-
|
|
128
|
-
Core queue APIs include `createJobQueue()`, `createMemoryJobQueueAdapter()`, queue/worker records, retry/backoff, visibility leases, heartbeat renewal, stale recovery, DLQ operations, retention cleanup and queue statistics.
|
|
93
|
+
Server-only background jobs, scheduling and durable job APIs.
|
|
129
94
|
|
|
130
|
-
|
|
95
|
+
Core queue APIs include:
|
|
131
96
|
|
|
132
|
-
|
|
97
|
+
```text
|
|
98
|
+
createJobQueue
|
|
99
|
+
createMemoryJobQueueAdapter
|
|
100
|
+
createRedisJobQueueAdapter
|
|
101
|
+
createJobScheduler
|
|
102
|
+
createMemoryJobScheduleStore
|
|
103
|
+
createRedisJobScheduleStore
|
|
104
|
+
nextCronTime
|
|
105
|
+
nextScheduleTime
|
|
106
|
+
```
|
|
133
107
|
|
|
134
|
-
|
|
108
|
+
Capabilities include delay, retry/backoff, worker concurrency, cancellation, visibility leases, heartbeat renewal, stale recovery, DLQ/requeue, retention cleanup, queue statistics and recurring interval/UTC cron schedules.
|
|
135
109
|
|
|
136
|
-
|
|
110
|
+
Processing remains at-least-once; non-repeatable external side effects should use application-level idempotency.
|
|
137
111
|
|
|
138
|
-
Related guides: [Background Jobs
|
|
112
|
+
Related guides: [Background Jobs](background-jobs.md), [Job Scheduling](job-scheduling.md), [Durable Jobs](durable-jobs.md), [Observability Platform v3](observability-v3.md).
|
|
139
113
|
|
|
140
114
|
## `bcp/workflow`
|
|
141
115
|
|
|
142
|
-
Server-only Workflow Orchestration APIs
|
|
143
|
-
|
|
144
|
-
```ts
|
|
145
|
-
import {
|
|
146
|
-
createMemoryWorkflowStore,
|
|
147
|
-
createWorkflow,
|
|
148
|
-
} from "bcp/workflow";
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
`createWorkflow()` defines persistent server-side workflows with sequential steps, parallel groups, per-step retry policies, persisted delays and compensation handlers.
|
|
152
|
-
|
|
153
|
-
Workflow controls include:
|
|
116
|
+
Server-only Workflow Orchestration APIs.
|
|
154
117
|
|
|
155
118
|
```text
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
get()
|
|
159
|
-
list()
|
|
160
|
-
resume()
|
|
161
|
-
retry()
|
|
162
|
-
cancel()
|
|
163
|
-
compensate()
|
|
164
|
-
close()
|
|
119
|
+
createWorkflow
|
|
120
|
+
createMemoryWorkflowStore
|
|
165
121
|
```
|
|
166
122
|
|
|
167
|
-
|
|
123
|
+
Workflow controls include `start`, `run`, `get`, `list`, `resume`, `retry`, `cancel`, `compensate` and `close`.
|
|
168
124
|
|
|
169
|
-
|
|
125
|
+
Capabilities include sequential/parallel steps, per-step retry, persisted delays, compensation, run leases and optional execution through `bcp/jobs`.
|
|
170
126
|
|
|
171
|
-
Related guides: [Workflow Orchestration](workflow-orchestration.md), [Durable Jobs
|
|
127
|
+
Related guides: [Workflow Orchestration](workflow-orchestration.md), [Durable Jobs](durable-jobs.md), [Observability Platform v3](observability-v3.md).
|
|
172
128
|
|
|
173
129
|
## `bcp/events`
|
|
174
130
|
|
|
175
|
-
Server-only Transactional Outbox & Events APIs
|
|
131
|
+
Server-only Transactional Outbox & Events APIs.
|
|
176
132
|
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
createTransactionalOutbox,
|
|
185
|
-
} from "bcp/events";
|
|
133
|
+
```text
|
|
134
|
+
createTransactionalOutbox
|
|
135
|
+
createMemoryOutboxStore
|
|
136
|
+
createSqlOutboxStore
|
|
137
|
+
createOutboxMigrationSql
|
|
138
|
+
createOutboxDispatcher
|
|
139
|
+
createEventBus
|
|
186
140
|
```
|
|
187
141
|
|
|
188
|
-
|
|
142
|
+
SQL outbox storage supports MySQL, PostgreSQL and SQLite. Dispatch supports batched claims, leases, stale recovery, retry/backoff, terminal failure, durable-job handoff and custom publishing.
|
|
189
143
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
`createOutboxDispatcher()` supports batched claims, leases, stale recovery, retry/backoff, terminal failure, job-queue handoff, custom publishing, local event-bus delivery and runner lifecycle.
|
|
193
|
-
|
|
194
|
-
Delivery is at-least-once; consumers should use idempotency controls for non-repeatable side effects.
|
|
195
|
-
|
|
196
|
-
Related guides: [Transactional Outbox & Events](transactional-outbox-events.md), [Database](database.md), [Durable Jobs Platform](durable-jobs.md), [Realtime Platform](realtime-platform.md), [Testing Platform](testing-platform.md), [Observability Platform v2](observability.md).
|
|
144
|
+
Related guides: [Transactional Outbox & Events](transactional-outbox-events.md), [Database](database.md), [Durable Jobs](durable-jobs.md), [Observability Platform v3](observability-v3.md).
|
|
197
145
|
|
|
198
146
|
## `bcp/realtime`
|
|
199
147
|
|
|
200
|
-
Server-only
|
|
148
|
+
Server-only realtime APIs for channels/rooms, broker delivery, presence, channel authorization, socket adapters, heartbeat and Server-Sent Events.
|
|
201
149
|
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
createRealtimeSseResponse,
|
|
208
|
-
type RealtimeAuthenticate,
|
|
209
|
-
type RealtimeAuthorizeChannel,
|
|
210
|
-
type RealtimeBroker,
|
|
211
|
-
type RealtimeBroadcastOptions,
|
|
212
|
-
type RealtimeConnection,
|
|
213
|
-
type RealtimeEnvelope,
|
|
214
|
-
type RealtimeEventContext,
|
|
215
|
-
type RealtimeEventHandler,
|
|
216
|
-
type RealtimeHeartbeatOptions,
|
|
217
|
-
type RealtimeHeartbeatRunner,
|
|
218
|
-
type RealtimeHub,
|
|
219
|
-
type RealtimeJoinOptions,
|
|
220
|
-
type RealtimeOptions,
|
|
221
|
-
type RealtimePresenceMember,
|
|
222
|
-
type RealtimePresenceStore,
|
|
223
|
-
type RealtimeSocket,
|
|
224
|
-
type RealtimeSseOptions,
|
|
225
|
-
} from "bcp/realtime";
|
|
150
|
+
```text
|
|
151
|
+
createRealtime
|
|
152
|
+
createMemoryRealtimeBroker
|
|
153
|
+
createMemoryRealtimePresenceStore
|
|
154
|
+
createRealtimeSseResponse
|
|
226
155
|
```
|
|
227
156
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
`RealtimeBroker` is the cross-hub pub/sub boundary and `RealtimePresenceStore` is the channel-presence boundary. Built-in memory implementations are intended for tests/single-process use; shared deployments can supply provider adapters.
|
|
231
|
-
|
|
232
|
-
`RealtimeOptions.authenticate` can resolve identity from a Request/connection payload, while `authorizeChannel` runs before channel membership is accepted.
|
|
157
|
+
BCP intentionally does not install a WebSocket server library. Applications adapt the selected provider through `RealtimeSocket`.
|
|
233
158
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
`hub.sse()` and `createRealtimeSseResponse()` expose Web-standard Server-Sent Events responses with abort, filtering, retry hint and keep-alive options.
|
|
237
|
-
|
|
238
|
-
Realtime delivery is transient. Use database/outbox/jobs/workflows for durable state and refetch durable state/history after reconnect when catch-up is required.
|
|
239
|
-
|
|
240
|
-
Related guides: [Realtime Platform](realtime-platform.md), [Authentication](authentication.md), [Testing Platform](testing-platform.md), [Observability Platform v2](observability.md).
|
|
159
|
+
Related guides: [Realtime Platform](realtime-platform.md), [Testing Platform](testing-platform.md), [Observability Platform v3](observability-v3.md).
|
|
241
160
|
|
|
242
161
|
## `bcp/testing`
|
|
243
162
|
|
|
244
|
-
Server-only
|
|
245
|
-
|
|
246
|
-
```ts
|
|
247
|
-
import {
|
|
248
|
-
createFakeClock,
|
|
249
|
-
createJobTestHarness,
|
|
250
|
-
createOutboxTestHarness,
|
|
251
|
-
createRealtimeTestHarness,
|
|
252
|
-
createRealtimeTestSocket,
|
|
253
|
-
createRouteTestHandler,
|
|
254
|
-
createSequenceIdFactory,
|
|
255
|
-
createTestApp,
|
|
256
|
-
createTestAuthSession,
|
|
257
|
-
createTestFormData,
|
|
258
|
-
createWorkflowTestHarness,
|
|
259
|
-
expectResponse,
|
|
260
|
-
readSseEvents,
|
|
261
|
-
runTestMiddleware,
|
|
262
|
-
runTestPageAction,
|
|
263
|
-
runTestPageGuards,
|
|
264
|
-
runTestPageLoader,
|
|
265
|
-
withTestTransaction,
|
|
266
|
-
type CreateTestAuthSessionOptions,
|
|
267
|
-
type FakeClock,
|
|
268
|
-
type JobTestHarness,
|
|
269
|
-
type OutboxTestHarness,
|
|
270
|
-
type ParsedSseEvent,
|
|
271
|
-
type RealtimeTestConnection,
|
|
272
|
-
type RealtimeTestHarness,
|
|
273
|
-
type RealtimeTestSocket,
|
|
274
|
-
type TestApp,
|
|
275
|
-
type TestAppOptions,
|
|
276
|
-
type TestAuthSession,
|
|
277
|
-
type TestPageActionOptions,
|
|
278
|
-
type TestPageContextOptions,
|
|
279
|
-
type TestPageGuardOptions,
|
|
280
|
-
type TestRequestHandler,
|
|
281
|
-
type TestRequestOptions,
|
|
282
|
-
type TestResponseExpectation,
|
|
283
|
-
type TestRouteFunction,
|
|
284
|
-
type TestRouteHandlerOptions,
|
|
285
|
-
type TestRouteMethod,
|
|
286
|
-
type TestRouteModule,
|
|
287
|
-
type TestTransactionDatabase,
|
|
288
|
-
type WorkflowTestHarness,
|
|
289
|
-
} from "bcp/testing";
|
|
290
|
-
```
|
|
163
|
+
Server-only framework-native testing utilities. BCP does not require Jest or Vitest.
|
|
291
164
|
|
|
292
|
-
|
|
165
|
+
Important APIs include:
|
|
293
166
|
|
|
294
|
-
|
|
167
|
+
```text
|
|
168
|
+
createTestApp
|
|
169
|
+
createRouteTestHandler
|
|
170
|
+
expectResponse
|
|
171
|
+
createTestAuthSession
|
|
172
|
+
withTestTransaction
|
|
173
|
+
runTestMiddleware
|
|
174
|
+
runTestPageLoader
|
|
175
|
+
runTestPageGuards
|
|
176
|
+
runTestPageAction
|
|
177
|
+
createFakeClock
|
|
178
|
+
createSequenceIdFactory
|
|
179
|
+
createJobTestHarness
|
|
180
|
+
createWorkflowTestHarness
|
|
181
|
+
createOutboxTestHarness
|
|
182
|
+
createRealtimeTestSocket
|
|
183
|
+
createRealtimeTestHarness
|
|
184
|
+
readSseEvents
|
|
185
|
+
```
|
|
295
186
|
|
|
296
|
-
|
|
187
|
+
Related guide: [Testing Platform](testing-platform.md).
|
|
297
188
|
|
|
298
|
-
|
|
189
|
+
## `bcp/plugins`
|
|
299
190
|
|
|
300
|
-
|
|
191
|
+
Server-only Plugin & Module Platform APIs.
|
|
301
192
|
|
|
302
|
-
|
|
193
|
+
```text
|
|
194
|
+
definePlugin
|
|
195
|
+
defineModule
|
|
196
|
+
createPluginHost
|
|
197
|
+
createPluginServiceRegistry
|
|
198
|
+
createPluginHookBus
|
|
199
|
+
```
|
|
303
200
|
|
|
304
|
-
|
|
201
|
+
Capabilities include required/optional dependency ordering, setup/start/stop/dispose lifecycle, startup rollback, typed configuration parsing, shared services and awaited in-process hooks.
|
|
305
202
|
|
|
306
|
-
|
|
203
|
+
Related guides: [Plugin & Module Platform](plugin-module-platform.md), [Configuration](configuration.md), [Observability Platform v3](observability-v3.md).
|
|
307
204
|
|
|
308
|
-
|
|
205
|
+
## `bcp/observability`
|
|
309
206
|
|
|
310
|
-
|
|
207
|
+
Server-only metrics, health and tracing APIs.
|
|
311
208
|
|
|
312
|
-
###
|
|
209
|
+
### Observability Platform v2
|
|
313
210
|
|
|
314
|
-
|
|
211
|
+
Existing APIs remain supported:
|
|
315
212
|
|
|
316
213
|
```text
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
jsonMatches()
|
|
214
|
+
createMetricsRegistry
|
|
215
|
+
createMetricsResponse
|
|
216
|
+
createRequestMetricsMiddleware
|
|
217
|
+
createHealthRegistry
|
|
322
218
|
```
|
|
323
219
|
|
|
324
|
-
|
|
220
|
+
The metrics registry provides counters, gauges, histograms and Prometheus exposition. Health checks provide readiness/liveness-style reports with timeout support.
|
|
325
221
|
|
|
326
|
-
###
|
|
222
|
+
### Observability Platform v3 — 0.2.17
|
|
327
223
|
|
|
328
|
-
|
|
224
|
+
Tracing APIs:
|
|
329
225
|
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
226
|
+
```ts
|
|
227
|
+
import {
|
|
228
|
+
createCompositeTraceSpanExporter,
|
|
229
|
+
createMemoryTraceSpanExporter,
|
|
230
|
+
createRequestTracingMiddleware,
|
|
231
|
+
createTraceCarrier,
|
|
232
|
+
createTraceMetricsExporter,
|
|
233
|
+
createTracer,
|
|
234
|
+
currentTraceContext,
|
|
235
|
+
extractTraceCarrier,
|
|
236
|
+
extractTraceHeaders,
|
|
237
|
+
formatTraceparent,
|
|
238
|
+
getTraceLogFields,
|
|
239
|
+
injectTraceHeaders,
|
|
240
|
+
parseTraceparent,
|
|
241
|
+
runWithTraceCarrier,
|
|
242
|
+
runWithTraceContext,
|
|
243
|
+
} from "bcp/observability";
|
|
244
|
+
```
|
|
335
245
|
|
|
336
|
-
|
|
246
|
+
Important public types:
|
|
337
247
|
|
|
338
|
-
|
|
248
|
+
```text
|
|
249
|
+
Tracer
|
|
250
|
+
TracerOptions
|
|
251
|
+
TraceContext
|
|
252
|
+
TraceCarrier
|
|
253
|
+
TraceSpan
|
|
254
|
+
TraceSpanRecord
|
|
255
|
+
TraceSpanEvent
|
|
256
|
+
TraceSpanExporter
|
|
257
|
+
TraceSpanKind
|
|
258
|
+
TraceSpanStatus
|
|
259
|
+
TraceAttributes
|
|
260
|
+
TraceIdFactory
|
|
261
|
+
StartTraceSpanOptions
|
|
262
|
+
RequestTracingOptions
|
|
263
|
+
TraceMetricsOptions
|
|
264
|
+
```
|
|
339
265
|
|
|
340
|
-
`
|
|
266
|
+
`createTracer()` creates root/child spans. Active context is stored with Node `AsyncLocalStorage`, allowing nested awaited operations to inherit the current `traceId`, `correlationId` and parent span.
|
|
341
267
|
|
|
342
|
-
|
|
268
|
+
```ts
|
|
269
|
+
await tracer.withSpan(
|
|
270
|
+
"order.checkout",
|
|
271
|
+
async () => {
|
|
272
|
+
await tracer.withSpan(
|
|
273
|
+
"database.insert",
|
|
274
|
+
createOrder,
|
|
275
|
+
{
|
|
276
|
+
kind: "client",
|
|
277
|
+
}
|
|
278
|
+
);
|
|
279
|
+
}
|
|
280
|
+
);
|
|
281
|
+
```
|
|
343
282
|
|
|
344
|
-
|
|
283
|
+
Supported span kinds:
|
|
345
284
|
|
|
346
|
-
|
|
285
|
+
```text
|
|
286
|
+
internal
|
|
287
|
+
server
|
|
288
|
+
client
|
|
289
|
+
producer
|
|
290
|
+
consumer
|
|
291
|
+
```
|
|
347
292
|
|
|
348
|
-
|
|
293
|
+
Failed `withSpan()` callbacks are marked `error`, receive an `exception` event and rethrow the original application error.
|
|
349
294
|
|
|
350
|
-
|
|
295
|
+
### W3C propagation
|
|
351
296
|
|
|
352
|
-
`
|
|
297
|
+
`formatTraceparent()` / `parseTraceparent()` support W3C version `00` trace headers.
|
|
353
298
|
|
|
354
|
-
|
|
299
|
+
```ts
|
|
300
|
+
const headers =
|
|
301
|
+
new Headers();
|
|
355
302
|
|
|
356
|
-
|
|
303
|
+
injectTraceHeaders(
|
|
304
|
+
headers
|
|
305
|
+
);
|
|
306
|
+
```
|
|
357
307
|
|
|
358
|
-
`
|
|
308
|
+
`extractTraceHeaders()` reads `traceparent`, optional `tracestate` and `x-correlation-id`.
|
|
359
309
|
|
|
360
|
-
###
|
|
310
|
+
### Middleware tracing
|
|
361
311
|
|
|
362
|
-
|
|
312
|
+
```ts
|
|
313
|
+
export const middleware =
|
|
314
|
+
createRequestTracingMiddleware(
|
|
315
|
+
tracer
|
|
316
|
+
);
|
|
317
|
+
```
|
|
363
318
|
|
|
364
|
-
The
|
|
319
|
+
The middleware continues a valid incoming trace and adds active trace/correlation headers to the response.
|
|
365
320
|
|
|
366
|
-
|
|
321
|
+
### Non-HTTP propagation
|
|
367
322
|
|
|
368
|
-
|
|
323
|
+
```ts
|
|
324
|
+
const trace =
|
|
325
|
+
createTraceCarrier();
|
|
326
|
+
```
|
|
369
327
|
|
|
370
|
-
|
|
328
|
+
Transport that carrier through job payloads, workflow input, event metadata or realtime payloads, then restore it with:
|
|
371
329
|
|
|
372
330
|
```ts
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
defineModule,
|
|
378
|
-
definePlugin,
|
|
379
|
-
PluginDependencyError,
|
|
380
|
-
PluginLifecycleError,
|
|
381
|
-
type PluginConfigParser,
|
|
382
|
-
type PluginConfigSchema,
|
|
383
|
-
type PluginContext,
|
|
384
|
-
type PluginDefinition,
|
|
385
|
-
type PluginHookBus,
|
|
386
|
-
type PluginHookHandler,
|
|
387
|
-
type PluginHost,
|
|
388
|
-
type PluginHostOptions,
|
|
389
|
-
type PluginHostView,
|
|
390
|
-
type PluginModule,
|
|
391
|
-
type PluginRecord,
|
|
392
|
-
type PluginServiceKey,
|
|
393
|
-
type PluginServiceRegistry,
|
|
394
|
-
type PluginState,
|
|
395
|
-
} from "bcp/plugins";
|
|
331
|
+
runWithTraceCarrier(
|
|
332
|
+
payload.trace,
|
|
333
|
+
handler
|
|
334
|
+
);
|
|
396
335
|
```
|
|
397
336
|
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
`defineModule()` groups reusable plugin definitions while preserving one global host dependency graph.
|
|
337
|
+
BCP does not automatically mutate persisted job/workflow/event schemas in `0.2.17`.
|
|
401
338
|
|
|
402
|
-
|
|
339
|
+
### Exporters and metrics
|
|
403
340
|
|
|
404
|
-
`
|
|
341
|
+
`TraceSpanExporter` is provider-neutral. BCP supplies an in-memory exporter and a composite exporter.
|
|
405
342
|
|
|
406
|
-
|
|
343
|
+
`createTraceMetricsExporter()` converts completed spans into the existing metrics registry:
|
|
407
344
|
|
|
408
|
-
|
|
345
|
+
```text
|
|
346
|
+
bcp_trace_spans_total
|
|
347
|
+
bcp_trace_span_duration_seconds
|
|
348
|
+
```
|
|
409
349
|
|
|
410
|
-
`
|
|
350
|
+
Default labels are `kind` and `status`. Span names are opt-in to reduce accidental high cardinality.
|
|
411
351
|
|
|
412
|
-
|
|
352
|
+
`getTraceLogFields()` returns:
|
|
413
353
|
|
|
414
|
-
|
|
354
|
+
```text
|
|
355
|
+
traceId
|
|
356
|
+
spanId
|
|
357
|
+
correlationId
|
|
358
|
+
```
|
|
415
359
|
|
|
416
|
-
|
|
360
|
+
for structured log enrichment.
|
|
417
361
|
|
|
418
|
-
|
|
362
|
+
Prepared npm packages expose compiled `observability.mjs` as the runtime default for `bcp/observability`.
|
|
419
363
|
|
|
420
|
-
Related guides: [Observability Platform v2](observability.md), [Logging](development-logging.md), [Cache Platform v2](cache-platform-v2.md).
|
|
364
|
+
Related guides: [Observability Platform v2](observability.md), [Observability Platform v3](observability-v3.md), [Logging](development-logging.md), [Cache Platform v2](cache-platform-v2.md).
|
|
421
365
|
|
|
422
366
|
## `bcp/server`
|
|
423
367
|
|
|
424
|
-
Server request/runtime APIs including request context, cookies, CSRF
|
|
368
|
+
Server request/runtime APIs including request context, cookies, CSRF/same-origin protection, logging, graceful shutdown hooks, multipart upload helpers, storage adapters, file delivery, response helpers and low-level session primitives.
|
|
425
369
|
|
|
426
|
-
Related guides: [Server Request APIs](server-request-apis.md), [Authorization & Security v2](authorization-security.md), [File Upload](file-upload.md), [Storage](storage.md), [
|
|
370
|
+
Related guides: [Server Request APIs](server-request-apis.md), [Authorization & Security v2](authorization-security.md), [File Upload](file-upload.md), [Storage](storage.md), [Production Hardening](production-hardening.md), [Observability Platform v3](observability-v3.md).
|
|
427
371
|
|
|
428
372
|
## `bcp/server-only`
|
|
429
373
|
|
|
@@ -433,16 +377,14 @@ Server-only module boundary marker.
|
|
|
433
377
|
import "bcp/server-only";
|
|
434
378
|
```
|
|
435
379
|
|
|
436
|
-
Related guide: [Application Modules](application-modules.md).
|
|
437
|
-
|
|
438
380
|
## `bcp/middleware`
|
|
439
381
|
|
|
440
|
-
Middleware System v2
|
|
382
|
+
Middleware System v2 request/response pipeline types and helpers.
|
|
441
383
|
|
|
442
|
-
Related guides: [Middleware](middleware.md), [Testing Platform](testing-platform.md).
|
|
384
|
+
Related guides: [Middleware](middleware.md), [Testing Platform](testing-platform.md), [Observability Platform v3](observability-v3.md).
|
|
443
385
|
|
|
444
386
|
## Stability
|
|
445
387
|
|
|
446
|
-
Only
|
|
388
|
+
Only entrypoints listed in both `docs/platform-manifest.json` and `docs/api-manifest.json` are part of the documented platform surface.
|
|
447
389
|
|
|
448
|
-
Files under internal `packages/*` paths are
|
|
390
|
+
Files under internal `packages/*` paths are implementation details unless re-exported through a documented public package entrypoint.
|