@shivaedev/server 0.34.0 → 0.34.2
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/CHANGELOG.md +13 -0
- package/README.md +5 -5
- package/dist/adapters/defaultTraceStore.d.ts +7 -0
- package/dist/adapters/defaultTraceStore.d.ts.map +1 -0
- package/dist/adapters/defaultTraceStore.js +17 -0
- package/dist/adapters/defaultTraceStore.js.map +1 -0
- package/dist/localTracing.d.ts +1 -1
- package/dist/localTracing.d.ts.map +1 -1
- package/dist/localTracing.js +14 -1
- package/dist/localTracing.js.map +1 -1
- package/dist/otlpTracing.js +2 -2
- package/dist/otlpTracing.js.map +1 -1
- package/package.json +12 -12
- package/src/adapters/defaultTraceStore.ts +17 -0
- package/src/localTracing.ts +15 -1
- package/src/otlpTracing.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.34.2 - 2026-11-18
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
|
|
7
|
+
- In development without an OTLP endpoint, `appHost`, `otlpTracing` and `localTracing()` record traces to `node_modules/.cache/@shivaedev/server/traces.db` in the working directory instead of `.platform/traces.db`, so an application that never added `.platform/` to its ignore file can no longer commit the store. A working directory without a `node_modules` folder records to a folder of the system's temporary directory and logs the file's path at startup. `PLATFORM_TRACE_STORE` and `localTracing({ path })` still choose another file. Delete an existing `.platform/` folder, with `git rm -r --cached .platform` first if it was committed; its ignore entry is no longer needed.
|
|
8
|
+
|
|
9
|
+
## 0.34.1 - 2026-11-11
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
- Update `@shivaedev/admin` from 0.24.3 to 0.25.0.
|
|
14
|
+
- Update `@shivaedev/identity` from 0.31.2 to 0.32.0.
|
|
15
|
+
|
|
3
16
|
## 0.34.0 - 2026-11-11
|
|
4
17
|
|
|
5
18
|
### Added
|
package/README.md
CHANGED
|
@@ -312,17 +312,17 @@ For existing Railway services, enable manual tracing per service and environment
|
|
|
312
312
|
Set `browserErrors: { log: true, includeUserId: true, requireSession: true }` on `appHost` for the recommended signed-in application setting. `log` writes one Error log with the masked message and stack per accepted report, including when OTLP export is off. `includeUserId` resolves the session and adds `user.id` to the HTTP span and error report when signed in. `requireSession` rejects signed-out reports with 401; a session-provider outage returns 503. Session lookups use the host's session and origin policy. With no session policy, requiring a session rejects reports. All three options default to false, preserving reports before sign-in without session lookups or an extra log line. `browserErrorRoute(trustedProxy?, options?)` accepts the same options when composed directly.
|
|
313
313
|
|
|
314
314
|
|
|
315
|
-
With `NODE_ENV=development` and no OTLP endpoint, `appHost` and `otlpTracing` record to
|
|
315
|
+
With `NODE_ENV=development` and no OTLP endpoint, `appHost` and `otlpTracing` record to `node_modules/.cache/@shivaedev/server/traces.db` in the working directory using Node's SQLite support, so the store stays out of Git through the ignore entry the application already has for `node_modules`. `runDevelopment` sets this mode for its child processes. A working directory without a `node_modules` folder gets none: the store is then `traces.db` in a folder of the system's temporary directory, and a log line at startup names the file. Set `PLATFORM_TRACE_STORE` to choose another file and `PLATFORM_TRACE_INDEXED_ATTRIBUTES=orderId,projectId` to index application attributes. Indexed values use the same redaction as the stored spans. An explicit OTLP endpoint takes precedence; other modes without an endpoint keep export disabled.
|
|
316
316
|
|
|
317
317
|
Records flush every second on a live maintenance clock and when their scope closes. Application clock jumps do not replay flush intervals. The store retains the latest five completed recorder runs, deleting older spans, logs and attribute indexes when a recorder closes. Active recorders remain writable until their scopes close. Logs use the existing `effect.log` diagnostic spans; the `logs` view exposes their parent span ID and trace ID. Open the file with any SQLite viewer, or inspect it directly:
|
|
318
318
|
|
|
319
319
|
```sh
|
|
320
|
-
sqlite3
|
|
321
|
-
sqlite3
|
|
322
|
-
sqlite3
|
|
320
|
+
sqlite3 node_modules/.cache/@shivaedev/server/traces.db "SELECT name, trace_id, span_id, data FROM spans ORDER BY started_at_millis DESC LIMIT 20"
|
|
321
|
+
sqlite3 node_modules/.cache/@shivaedev/server/traces.db "SELECT trace_id, span_id, data FROM logs ORDER BY at_millis DESC LIMIT 20"
|
|
322
|
+
sqlite3 node_modules/.cache/@shivaedev/server/traces.db "SELECT span_id FROM span_attributes WHERE key = 'orderId' AND value = 'order-42'"
|
|
323
323
|
```
|
|
324
324
|
|
|
325
|
-
For explicit composition, provide `localTracing({ path, indexedAttributes, retainedRuns, flushInterval, clock })` from `@shivaedev/server/localTracing.ts` to the application's Layer. All options are optional; `flushInterval` is milliseconds, and `retainedRuns` is a positive integer. Supply a native `clock` to control flush timing in stories; span timestamps still follow the application clock. It uses `RedactionPolicy`, including host schema sensitivity, and preserves the application's installed tracer and console loggers. Local recording and OTLP export are alternative sinks; compose one per application scope.
|
|
325
|
+
For explicit composition, provide `localTracing({ path, indexedAttributes, retainedRuns, flushInterval, clock })` from `@shivaedev/server/localTracing.ts` to the application's Layer. All options are optional; `path` defaults to the same store, `flushInterval` is milliseconds, and `retainedRuns` is a positive integer. Supply a native `clock` to control flush timing in stories; span timestamps still follow the application clock. It uses `RedactionPolicy`, including host schema sensitivity, and preserves the application's installed tracer and console loggers. Local recording and OTLP export are alternative sinks; compose one per application scope.
|
|
326
326
|
|
|
327
327
|
Exported HTTP server spans use `{method} {route}` with `http.route` for matched RPC and router paths, including parameter templates; unmatched requests use the method alone. `appHost` continues incoming W3C `traceparent` context in RPC handling, including one sent by an edge proxy, whether or not an exporter is configured.
|
|
328
328
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaultTraceStore.d.ts","sourceRoot":"","sources":["../../src/adapters/defaultTraceStore.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,eAAO,MAAM,iBAAiB;;;;gBAS5B,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import process from "node:process";
|
|
6
|
+
import { Effect } from "effect";
|
|
7
|
+
export const defaultTraceStore = Effect.sync(() => {
|
|
8
|
+
const workingDirectory = process.cwd();
|
|
9
|
+
const installed = join(workingDirectory, "node_modules");
|
|
10
|
+
if (existsSync(installed)) {
|
|
11
|
+
return { path: join(installed, ".cache", "@shivaedev", "server", "traces.db"), temporary: false, workingDirectory };
|
|
12
|
+
}
|
|
13
|
+
// No node_modules folder is created here: an ignore rule anchored at a repository's root would not cover it, and the store could be committed.
|
|
14
|
+
const folder = `shivaedev-server-${createHash("sha256").update(workingDirectory).digest("hex").slice(0, 12)}`;
|
|
15
|
+
return { path: join(tmpdir(), folder, "traces.db"), temporary: true, workingDirectory };
|
|
16
|
+
});
|
|
17
|
+
//# sourceMappingURL=defaultTraceStore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaultTraceStore.js","sourceRoot":"","sources":["../../src/adapters/defaultTraceStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE;IACjD,MAAM,gBAAgB,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IACvC,MAAM,SAAS,GAAG,IAAI,CAAC,gBAAgB,EAAE,cAAc,CAAC,CAAC;IACzD,IAAI,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QAC3B,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,WAAW,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,gBAAgB,EAAE,CAAC;IACrH,CAAC;IACD,+IAA+I;IAC/I,MAAM,MAAM,GAAG,oBAAoB,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC;IAC9G,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAC;AACzF,CAAC,CAAC,CAAC"}
|
package/dist/localTracing.d.ts
CHANGED
|
@@ -6,5 +6,5 @@ export interface LocalTracingOptions {
|
|
|
6
6
|
readonly path?: string;
|
|
7
7
|
readonly retainedRuns?: number;
|
|
8
8
|
}
|
|
9
|
-
export declare function localTracing({ clock, path, indexedAttributes, retainedRuns, flushInterval, }?: LocalTracingOptions): Layer.Layer<never, import("effect/Cause").UnknownError, never>;
|
|
9
|
+
export declare function localTracing({ clock, path: chosen, indexedAttributes, retainedRuns, flushInterval, }?: LocalTracingOptions): Layer.Layer<never, import("effect/Cause").UnknownError, never>;
|
|
10
10
|
//# sourceMappingURL=localTracing.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localTracing.d.ts","sourceRoot":"","sources":["../src/localTracing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAU,KAAK,EAAU,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"localTracing.d.ts","sourceRoot":"","sources":["../src/localTracing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAU,KAAK,EAAU,MAAM,QAAQ,CAAC;AAQtD,MAAM,WAAW,mBAAmB;IACnC,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC;IAC7B,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/C,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;CAC/B;AAcD,wBAAgB,YAAY,CAAC,EAC5B,KAAkC,EAClC,IAAI,EAAE,MAAM,EACZ,iBAAsB,EACtB,YAAgB,EAChB,aAAoB,GACpB,GAAE,mBAAwB,kEA0C1B"}
|
package/dist/localTracing.js
CHANGED
|
@@ -1,14 +1,27 @@
|
|
|
1
1
|
import { Clock, Effect, Layer, Tracer } from "effect";
|
|
2
|
+
import { defaultTraceStore } from "#adapters/defaultTraceStore.ts";
|
|
2
3
|
import { localTraceDatabase } from "#adapters/localTraceDatabase.ts";
|
|
3
4
|
import { redactingDiagnostics } from "#adapters/redactingDiagnostics.ts";
|
|
4
5
|
import { traceDiagnostics } from "#adapters/traceDiagnostics.ts";
|
|
5
6
|
import { localTraceRow } from "#localTraceRow.ts";
|
|
6
7
|
import { RedactionPolicy } from "#RedactionPolicy.ts";
|
|
7
|
-
|
|
8
|
+
// Untraced: the recorder is still being built, so a span here would reach the application's own tracer as one of its spans.
|
|
9
|
+
const storePath = Effect.fnUntraced(function* (chosen) {
|
|
10
|
+
if (chosen !== undefined) {
|
|
11
|
+
return chosen;
|
|
12
|
+
}
|
|
13
|
+
const store = yield* defaultTraceStore;
|
|
14
|
+
if (store.temporary) {
|
|
15
|
+
yield* Effect.logInfo(`Development traces are recorded to ${store.path}, because ${store.workingDirectory} has no node_modules folder.`);
|
|
16
|
+
}
|
|
17
|
+
return store.path;
|
|
18
|
+
});
|
|
19
|
+
export function localTracing({ clock = Clock.Clock.defaultValue(), path: chosen, indexedAttributes = [], retainedRuns = 5, flushInterval = 1000, } = {}) {
|
|
8
20
|
return Layer.unwrap(Effect.gen(function* () {
|
|
9
21
|
const policy = yield* RedactionPolicy;
|
|
10
22
|
const underlying = yield* Tracer.Tracer;
|
|
11
23
|
const startedAtMillis = yield* Clock.currentTimeMillis;
|
|
24
|
+
const path = yield* storePath(chosen);
|
|
12
25
|
const database = yield* Effect.acquireRelease(Effect.try(() => localTraceDatabase(path, retainedRuns, indexedAttributes, startedAtMillis)), (db) => Effect.sync(() => db.close()));
|
|
13
26
|
let pending = [];
|
|
14
27
|
const flush = Effect.sync(() => {
|
package/dist/localTracing.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localTracing.js","sourceRoot":"","sources":["../src/localTracing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAA4C,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAC5F,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAUtD,MAAM,UAAU,YAAY,CAAC,EAC5B,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,YAAY,EAAE,EAClC,IAAI,
|
|
1
|
+
{"version":3,"file":"localTracing.js","sourceRoot":"","sources":["../src/localTracing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,gBAAg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AI,EAAE,UAAU,IAAI,EAAE,CAAC,CAAC,CAAC;oBAC5C,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC;gBAC/B,CAAC,CAAC;gBACF,IAAI,CAAC,GAAG,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE;oBACzB,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;oBAChB,MAAM,GAAG,GAAG,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;oBAChD,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;wBACvB,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;oBACnB,CAAC;gBACF,CAAC,CAAC;gBACF,OAAO,IAAI,CAAC;YACb,CAAC;SACD,CAAC,CAAC;QACH,OAAO,oBAAoB,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,gBAAgB,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;IAC1I,CAAC,CAAC,CACF,CAAC;AACH,CAAC"}
|
package/dist/otlpTracing.js
CHANGED
|
@@ -18,14 +18,14 @@ export const otlpTracing = Layer.effectContext(Effect.gen(function* () {
|
|
|
18
18
|
if (endpoint === undefined) {
|
|
19
19
|
const mode = yield* Config.String("NODE_ENV").pipe(Config.withDefault("production"));
|
|
20
20
|
if (mode === "development") {
|
|
21
|
-
const path = yield* Config.String("PLATFORM_TRACE_STORE").pipe(Config.withDefault(
|
|
21
|
+
const path = yield* Config.String("PLATFORM_TRACE_STORE").pipe(Config.withDefault(undefined));
|
|
22
22
|
const indexed = yield* Config.String("PLATFORM_TRACE_INDEXED_ATTRIBUTES").pipe(Config.withDefault(""));
|
|
23
23
|
return yield* Layer.build(localTracing({
|
|
24
24
|
indexedAttributes: indexed
|
|
25
25
|
.split(",")
|
|
26
26
|
.map((key) => key.trim())
|
|
27
27
|
.filter(Boolean),
|
|
28
|
-
path,
|
|
28
|
+
...(path === undefined ? {} : { path }),
|
|
29
29
|
})).pipe(Effect.mapError((cause) => new Config.ConfigError(new ConfigProvider.SourceError({ cause, message: "Cannot open local trace store" }))));
|
|
30
30
|
}
|
|
31
31
|
return Context.empty();
|
package/dist/otlpTracing.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otlpTracing.js","sourceRoot":"","sources":["../src/otlpTracing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChF,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAElE,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,KAAK,OAAO,IAAI,GAAG,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC;AAExH,MAAM,CAAC,MAAM,WAAW,GAA2C,KAAK,CAAC,aAAa,CACrF,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IACnB,MAAM,cAAc,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,MA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CAAC,gBAAgB,CAAC,EACpC,KAAK,CAAC,YAAY,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CAC/E,CACD,CAAC;AACH,CAAC,CAAC,CACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shivaedev/server",
|
|
3
|
-
"version": "0.34.
|
|
3
|
+
"version": "0.34.2",
|
|
4
4
|
"description": "The Effect application host: HTTP and RPC serving, health, OTLP export, database and migrations, and development mode",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"effect"
|
|
@@ -47,26 +47,26 @@
|
|
|
47
47
|
],
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@shivaedev/changes": "0.12.0",
|
|
50
|
-
"@shivaedev/contract": "0.
|
|
50
|
+
"@shivaedev/contract": "0.45.0",
|
|
51
51
|
"@shivaedev/errors": "0.12.0",
|
|
52
52
|
"@shivaedev/http": "0.8.2",
|
|
53
|
-
"@shivaedev/identity": "0.
|
|
53
|
+
"@shivaedev/identity": "0.32.1",
|
|
54
54
|
"@shivaedev/local-postgres": "0.16.1",
|
|
55
|
-
"@shivaedev/sql": "0.
|
|
55
|
+
"@shivaedev/sql": "0.48.0"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@effect/platform-node": "4.1.2",
|
|
59
59
|
"@effect/sql-pg": "4.1.2",
|
|
60
60
|
"@effect/vitest": "4.1.2",
|
|
61
61
|
"@shivaedev/access": "0.6.3",
|
|
62
|
-
"@shivaedev/admin": "0.
|
|
63
|
-
"@shivaedev/jobs": "0.42.
|
|
64
|
-
"@shivaedev/quality": "0.
|
|
65
|
-
"@shivaedev/rate-limit": "0.6.
|
|
62
|
+
"@shivaedev/admin": "0.26.0",
|
|
63
|
+
"@shivaedev/jobs": "0.42.3",
|
|
64
|
+
"@shivaedev/quality": "0.78.1",
|
|
65
|
+
"@shivaedev/rate-limit": "0.6.11",
|
|
66
66
|
"@shivaedev/service": "0.9.1",
|
|
67
|
-
"@shivaedev/test-kits": "0.
|
|
68
|
-
"@shivaedev/test-sql": "0.
|
|
69
|
-
"@shivaedev/test-story": "0.47.
|
|
67
|
+
"@shivaedev/test-kits": "0.13.0",
|
|
68
|
+
"@shivaedev/test-sql": "0.25.1",
|
|
69
|
+
"@shivaedev/test-story": "0.47.2",
|
|
70
70
|
"@types/node": "24.19.2",
|
|
71
71
|
"better-auth": "1.7.16",
|
|
72
72
|
"effect": "4.1.2",
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"@effect/platform-node": "4.1.2",
|
|
79
79
|
"@effect/sql-pg": "4.1.2",
|
|
80
80
|
"@effect/vitest": "4.1.2",
|
|
81
|
-
"@shivaedev/admin": "0.
|
|
81
|
+
"@shivaedev/admin": "0.26.0",
|
|
82
82
|
"better-auth": "1.7.16",
|
|
83
83
|
"effect": "4.1.2"
|
|
84
84
|
},
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import process from "node:process";
|
|
6
|
+
import { Effect } from "effect";
|
|
7
|
+
|
|
8
|
+
export const defaultTraceStore = Effect.sync(() => {
|
|
9
|
+
const workingDirectory = process.cwd();
|
|
10
|
+
const installed = join(workingDirectory, "node_modules");
|
|
11
|
+
if (existsSync(installed)) {
|
|
12
|
+
return { path: join(installed, ".cache", "@shivaedev", "server", "traces.db"), temporary: false, workingDirectory };
|
|
13
|
+
}
|
|
14
|
+
// No node_modules folder is created here: an ignore rule anchored at a repository's root would not cover it, and the store could be committed.
|
|
15
|
+
const folder = `shivaedev-server-${createHash("sha256").update(workingDirectory).digest("hex").slice(0, 12)}`;
|
|
16
|
+
return { path: join(tmpdir(), folder, "traces.db"), temporary: true, workingDirectory };
|
|
17
|
+
});
|
package/src/localTracing.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Clock, Effect, Layer, Tracer } from "effect";
|
|
2
|
+
import { defaultTraceStore } from "#adapters/defaultTraceStore.ts";
|
|
2
3
|
import { localTraceDatabase } from "#adapters/localTraceDatabase.ts";
|
|
3
4
|
import { redactingDiagnostics } from "#adapters/redactingDiagnostics.ts";
|
|
4
5
|
import { traceDiagnostics } from "#adapters/traceDiagnostics.ts";
|
|
@@ -13,9 +14,21 @@ export interface LocalTracingOptions {
|
|
|
13
14
|
readonly retainedRuns?: number;
|
|
14
15
|
}
|
|
15
16
|
|
|
17
|
+
// Untraced: the recorder is still being built, so a span here would reach the application's own tracer as one of its spans.
|
|
18
|
+
const storePath = Effect.fnUntraced(function* (chosen: string | undefined) {
|
|
19
|
+
if (chosen !== undefined) {
|
|
20
|
+
return chosen;
|
|
21
|
+
}
|
|
22
|
+
const store = yield* defaultTraceStore;
|
|
23
|
+
if (store.temporary) {
|
|
24
|
+
yield* Effect.logInfo(`Development traces are recorded to ${store.path}, because ${store.workingDirectory} has no node_modules folder.`);
|
|
25
|
+
}
|
|
26
|
+
return store.path;
|
|
27
|
+
});
|
|
28
|
+
|
|
16
29
|
export function localTracing({
|
|
17
30
|
clock = Clock.Clock.defaultValue(),
|
|
18
|
-
path
|
|
31
|
+
path: chosen,
|
|
19
32
|
indexedAttributes = [],
|
|
20
33
|
retainedRuns = 5,
|
|
21
34
|
flushInterval = 1000,
|
|
@@ -25,6 +38,7 @@ export function localTracing({
|
|
|
25
38
|
const policy = yield* RedactionPolicy;
|
|
26
39
|
const underlying = yield* Tracer.Tracer;
|
|
27
40
|
const startedAtMillis = yield* Clock.currentTimeMillis;
|
|
41
|
+
const path = yield* storePath(chosen);
|
|
28
42
|
const database = yield* Effect.acquireRelease(
|
|
29
43
|
Effect.try(() => localTraceDatabase(path, retainedRuns, indexedAttributes, startedAtMillis)),
|
|
30
44
|
(db) => Effect.sync(() => db.close()),
|
package/src/otlpTracing.ts
CHANGED
|
@@ -25,7 +25,7 @@ export const otlpTracing: Layer.Layer<never, Config.ConfigError> = Layer.effectC
|
|
|
25
25
|
if (endpoint === undefined) {
|
|
26
26
|
const mode = yield* Config.String("NODE_ENV").pipe(Config.withDefault("production"));
|
|
27
27
|
if (mode === "development") {
|
|
28
|
-
const path = yield* Config.String("PLATFORM_TRACE_STORE").pipe(Config.withDefault(
|
|
28
|
+
const path = yield* Config.String("PLATFORM_TRACE_STORE").pipe(Config.withDefault(undefined));
|
|
29
29
|
const indexed = yield* Config.String("PLATFORM_TRACE_INDEXED_ATTRIBUTES").pipe(Config.withDefault(""));
|
|
30
30
|
return yield* Layer.build(
|
|
31
31
|
localTracing({
|
|
@@ -33,7 +33,7 @@ export const otlpTracing: Layer.Layer<never, Config.ConfigError> = Layer.effectC
|
|
|
33
33
|
.split(",")
|
|
34
34
|
.map((key) => key.trim())
|
|
35
35
|
.filter(Boolean),
|
|
36
|
-
path,
|
|
36
|
+
...(path === undefined ? {} : { path }),
|
|
37
37
|
}),
|
|
38
38
|
).pipe(
|
|
39
39
|
Effect.mapError((cause) => new Config.ConfigError(new ConfigProvider.SourceError({ cause, message: "Cannot open local trace store" }))),
|