@smthrs/observability 1.0.0-rc.8 → 1.0.0-rc.9
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/cjs/JournalLogger.d.ts.map +1 -1
- package/dist/cjs/JournalLogger.js +16 -1
- package/dist/cjs/JournalLogger.js.map +2 -2
- package/dist/cjs/Otlp.d.ts +1 -1
- package/dist/cjs/Otlp.js +1 -1
- package/dist/cjs/Otlp.js.map +1 -1
- package/dist/esm/JournalLogger.d.ts.map +1 -1
- package/dist/esm/JournalLogger.js +23 -1
- package/dist/esm/JournalLogger.js.map +1 -1
- package/dist/esm/Otlp.d.ts +1 -1
- package/dist/esm/Otlp.js +1 -1
- package/package.json +2 -2
- package/src/JournalLogger.ts +24 -1
- package/src/Otlp.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JournalLogger.d.ts","sourceRoot":"","sources":["../../src/JournalLogger.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,OAAO,MAAM,yBAAyB,CAAA;AAClD,OAAO,KAAK,YAAY,MAAM,8BAA8B,CAAA;AAE5D,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAGrC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAErC,OAAO,KAAK,KAAK,QAAQ,MAAM,iBAAiB,CAAA;AAKhD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAKvC;;;;;GAKG;AACH,eAAO,MAAM,eAAe,QAAS,CAAA;AAErC;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,QAAc,CAAA;AAE/C;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,OAAQ,CAAA;AAE3C;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,KAAK,CAAA;AAEtC;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,mBAAmB,CAAA;AAElD;;;;;GAKG;AACH,eAAO,MAAM,eAAe,gBAAgB,CAAA;A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B,CAAC,IAAI,CAAA;AAEnE;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;EAGzB,CAAA;AAEF;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GAAG,OAAO,cAAc,CAAC,IAAI,CAAA;AAEvD;;;;;GAKG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;EAUvB,CAAA;AAEF;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG,OAAO,YAAY,CAAC,IAAI,CAAA;AAyUnD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,sBAAsB,GACjC,SAAS,OAAO,KACf,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,2BAA2B,EAAE,OAAO,CAAC,OAAO,CAsE/D,CAAA"}
|
|
@@ -144,10 +144,24 @@ const unitBytes = (code) => {
|
|
|
144
144
|
return 3;
|
|
145
145
|
};
|
|
146
146
|
const isLowSurrogate = (code) => code >= 56320 && code <= 57343;
|
|
147
|
+
const plainRun = /[\x20\x21\x23-\x5b\x5d-\x7f]*/y;
|
|
148
|
+
const plainStreak = 16;
|
|
147
149
|
const boundedPrefix = (value, limit) => {
|
|
148
150
|
let bytes = 0;
|
|
149
151
|
let index = 0;
|
|
152
|
+
let streak = 0;
|
|
150
153
|
while (index < value.length) {
|
|
154
|
+
if (streak >= plainStreak) {
|
|
155
|
+
plainRun.lastIndex = 0;
|
|
156
|
+
plainRun.test(value.slice(index, index + limit - bytes + 1));
|
|
157
|
+
const run = plainRun.lastIndex;
|
|
158
|
+
const admitted = Math.min(run, limit - bytes);
|
|
159
|
+
bytes += admitted;
|
|
160
|
+
index += admitted;
|
|
161
|
+
if (admitted < run) break;
|
|
162
|
+
streak = 0;
|
|
163
|
+
continue;
|
|
164
|
+
}
|
|
151
165
|
const code = value.charCodeAt(index);
|
|
152
166
|
let width = 1;
|
|
153
167
|
let cost;
|
|
@@ -162,6 +176,7 @@ const boundedPrefix = (value, limit) => {
|
|
|
162
176
|
if (bytes + cost > limit) break;
|
|
163
177
|
bytes += cost;
|
|
164
178
|
index += width;
|
|
179
|
+
streak = cost === 1 ? streak + 1 : 0;
|
|
165
180
|
}
|
|
166
181
|
return { text: value.slice(0, index), bytes };
|
|
167
182
|
};
|
|
@@ -211,7 +226,7 @@ const snapshotValue = (value, budget, ancestors, depth = 0) => {
|
|
|
211
226
|
try {
|
|
212
227
|
if (value instanceof Date) {
|
|
213
228
|
try {
|
|
214
|
-
return boundedText(
|
|
229
|
+
return boundedText(Date.prototype.toISOString.call(value), budget);
|
|
215
230
|
} catch {
|
|
216
231
|
return boundedText(unrenderableMarker, budget);
|
|
217
232
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/JournalLogger.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Non-blocking forwarding of bounded operational logs to the durable journal.\n *\n * @since 0.1.0\n */\n\nimport * as Journal from \"@smthrs/journal/Journal\"\nimport * as JournalEvent from \"@smthrs/journal/JournalEvent\"\nimport * as Redaction from \"@smthrs/journal/Redaction\"\nimport * as Cause from \"effect/Cause\"\nimport * as Context from \"effect/Context\"\nimport * as Effect from \"effect/Effect\"\nimport * as Layer from \"effect/Layer\"\nimport * as Logger from \"effect/Logger\"\nimport type * as LogLevel from \"effect/LogLevel\"\nimport * as EffectMetric from \"effect/Metric\"\nimport * as Option from \"effect/Option\"\nimport * as Queue from \"effect/Queue\"\nimport * as References from \"effect/References\"\nimport * as Schema from \"effect/Schema\"\nimport * as Tracer from \"effect/Tracer\"\nimport { schemaIssuePath } from \"./internal/schemaIssuePath.ts\"\nimport { droppedLogRecords } from \"./Metric.ts\"\n\n/**\n * Largest queue accepted by the forwarding logger.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const maximumCapacity = 65_536\n\n/**\n * Largest detached log payload admitted to the asynchronous queue.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const maximumSnapshotBytes = 1024 * 1024\n\n/**\n * Largest number of container members copied into one detached log payload.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const maximumSnapshotMembers = 4_096\n\n/**\n * Deepest container path copied into one detached log payload.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const maximumSnapshotDepth = 64\n\n/**\n * What a hostile or unreadable logged value becomes.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const unrenderableMarker = \"[Unrenderable]\"\n\n/**\n * What a value beyond a logger resource ceiling becomes.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const truncatedMarker = \"[Truncated]\"\n\n/**\n * Options for the journal forwarding logger.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport interface Options {\n /** The run every forwarded record is attributed to. */\n readonly runId: JournalEvent.RunId\n /** Queue depth, 1 through {@link maximumCapacity}. Defaults to 256. */\n readonly capacity?: number | undefined\n /**\n * Pins `References.MinimumLogLevel` for the whole application. Omitted, the\n * layer leaves that reference alone and Effect's own `Info` default applies.\n */\n readonly minimumLogLevel?: LogLevel.LogLevel | undefined\n /**\n * Keeps the ambient loggers alongside the forwarder. Defaults to `false`,\n * which replaces the ambient logger set.\n */\n readonly mergeWithExisting?: boolean | undefined\n}\n\n/**\n * A stable logger configuration refusal.\n *\n * @category errors\n * @since 1.0.0-rc.0\n */\nexport class InvalidJournalLoggerOptions extends Schema.TaggedError<InvalidJournalLoggerOptions>()(\n \"@smthrs/observability/InvalidJournalLoggerOptions\",\n {\n code: Schema.Literal(\"invalid_journal_logger_options\"),\n path: Schema.String,\n message: Schema.String\n }\n) {}\n\n/**\n * One typed failure retained from an Effect cause.\n *\n * @category schemas\n * @since 1.0.0-rc.0\n */\nexport const TelemetryFail = Schema.Struct({\n _tag: Schema.Literal(\"Fail\"),\n error: Schema.Unknown\n})\n\n/**\n * One unexpected defect retained from an Effect cause.\n *\n * @category schemas\n * @since 1.0.0-rc.0\n */\nexport const TelemetryDie = Schema.Struct({\n _tag: Schema.Literal(\"Die\"),\n defect: Schema.Unknown\n})\n\n/**\n * One interruption retained from an Effect cause.\n *\n * @category schemas\n * @since 1.0.0-rc.0\n */\nexport const TelemetryInterrupt = Schema.Struct({\n _tag: Schema.Literal(\"Interrupt\"),\n fiberId: Schema.NullOr(Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)))\n})\n\n/**\n * One reason in a persisted telemetry cause.\n *\n * @category schemas\n * @since 1.0.0-rc.0\n */\nexport const TelemetryCauseReason = Schema.Union([TelemetryFail, TelemetryDie, TelemetryInterrupt])\n\n/**\n * One reason in a persisted telemetry cause.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport type TelemetryCauseReason = typeof TelemetryCauseReason.Type\n\n/**\n * A versioned structural Effect cause.\n *\n * Effect 4 stores composed failures as an ordered reason list. The projection\n * preserves that order and each fail, defect, or interrupt discriminator.\n *\n * @category schemas\n * @since 1.0.0-rc.0\n */\nexport const TelemetryCause = Schema.Struct({\n version: Schema.Literal(1),\n reasons: Schema.Array(TelemetryCauseReason)\n})\n\n/**\n * A versioned structural Effect cause.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport type TelemetryCause = typeof TelemetryCause.Type\n\n/**\n * Runtime schema for the operational log payload written to the journal.\n *\n * @category schemas\n * @since 1.0.0-rc.0\n */\nexport const TelemetryLog = Schema.Struct({\n version: Schema.Literal(1),\n level: Schema.Literals([\"All\", \"Fatal\", \"Error\", \"Warn\", \"Info\", \"Debug\", \"Trace\", \"None\"]),\n message: Schema.Unknown,\n annotations: Schema.Record(Schema.String, Schema.Unknown),\n cause: TelemetryCause,\n fiberId: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),\n traceId: Schema.optionalKey(Schema.String),\n spanId: Schema.optionalKey(Schema.String),\n timestamp: Schema.String\n})\n\n/**\n * Versioned operational log payload written to the journal.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport type TelemetryLog = typeof TelemetryLog.Type\n\nconst sourceId = \"flows/observability/logger\" as JournalEvent.SourceId\nconst encoder = new TextEncoder()\n\nconst OptionsSchema = Schema.Struct({\n runId: JournalEvent.RunId,\n capacity: Schema.optional(\n Schema.Int.check(\n Schema.isGreaterThanOrEqualTo(1),\n Schema.isLessThanOrEqualTo(maximumCapacity)\n )\n ),\n minimumLogLevel: Schema.optional(\n Schema.Literals([\"All\", \"Fatal\", \"Error\", \"Warn\", \"Info\", \"Debug\", \"Trace\", \"None\"])\n ),\n mergeWithExisting: Schema.optional(Schema.Boolean)\n})\n\nconst validateOptions = (options: Options) =>\n Schema.decodeUnknownEffect(OptionsSchema)(options).pipe(\n Effect.mapError((cause) => {\n const path = schemaIssuePath(cause, \"options\")\n return new InvalidJournalLoggerOptions({\n code: \"invalid_journal_logger_options\",\n path,\n message: `journal logger ${path} is invalid`\n })\n })\n )\n\ninterface SnapshotBudget {\n bytes: number\n members: number\n}\n\nconst reserve = (budget: SnapshotBudget, bytes: number): boolean => {\n if (bytes > budget.bytes) return false\n budget.bytes -= bytes\n return true\n}\n\nconst textBytes = (value: string): number => encoder.encode(JSON.stringify(value)).byteLength\n\nconst quoteBytes = 2\nconst shortEscapes = new Set([0x08, 0x09, 0x0a, 0x0c, 0x0d])\n\n/** Bytes one non-surrogate code unit occupies inside a JSON string body. */\nconst unitBytes = (code: number): number => {\n if (code === 0x22 || code === 0x5c) return 2\n if (code < 0x20) return shortEscapes.has(code) ? 2 : 6\n if (code < 0x80) return 1\n if (code < 0x800) return 2\n return 3\n}\n\nconst isLowSurrogate = (code: number): boolean => code >= 0xdc00 && code <= 0xdfff\n\n/**\n * The longest prefix whose JSON string body fits `limit` bytes, measured in one\n * forward pass. A surrogate pair is admitted or refused whole, so the retained\n * text is well formed whenever the input is.\n */\nconst boundedPrefix = (value: string, limit: number): { readonly text: string; readonly bytes: number } => {\n let bytes = 0\n let index = 0\n while (index < value.length) {\n const code = value.charCodeAt(index)\n let width = 1\n let cost: number\n if (code >= 0xd800 && code <= 0xdbff && isLowSurrogate(value.charCodeAt(index + 1))) {\n width = 2\n cost = 4\n } else if (code >= 0xd800 && code <= 0xdfff) {\n cost = 6\n } else {\n cost = unitBytes(code)\n }\n if (bytes + cost > limit) break\n bytes += cost\n index += width\n }\n return { text: value.slice(0, index), bytes }\n}\n\nconst boundedText = (value: string, budget: SnapshotBudget): string => {\n if (value.length <= maximumSnapshotBytes && reserve(budget, textBytes(value))) return value\n const markerBytes = textBytes(truncatedMarker)\n const prefix = boundedPrefix(value, Math.max(0, budget.bytes - markerBytes - quoteBytes))\n budget.bytes = Math.max(0, budget.bytes - (prefix.bytes + quoteBytes) - markerBytes)\n return `${prefix.text}${truncatedMarker}`\n}\n\n/**\n * Error fields read through the prototype chain, in the order the snapshot\n * projects them before any own data property the error added.\n */\nconst standardErrorKeys = [\"name\", \"message\", \"stack\", \"cause\"] as const\n\n/** Reads inherited data fields without invoking accessors or walking forever. */\nconst errorField = (value: object, key: string): unknown => {\n let current: object | null = value\n for (let depth = 0; current !== null && depth <= maximumSnapshotDepth; depth++) {\n const descriptor = Object.getOwnPropertyDescriptor(current, key)\n if (descriptor !== undefined) return \"value\" in descriptor ? descriptor.value : unrenderableMarker\n current = Object.getPrototypeOf(current)\n }\n return current === null ? undefined : truncatedMarker\n}\n\nconst snapshotValue = (\n value: unknown,\n budget: SnapshotBudget,\n ancestors: WeakSet<object>,\n depth = 0\n): unknown => {\n if (budget.bytes <= 0) return truncatedMarker\n if (depth > maximumSnapshotDepth) return Redaction.depthMarker\n if (typeof value === \"string\") return boundedText(value, budget)\n if (typeof value === \"number\") {\n const projected = Number.isFinite(value) ? value : String(value)\n reserve(budget, String(projected).length)\n return projected\n }\n if (typeof value === \"boolean\" || value === null) {\n reserve(budget, value === null ? 4 : value ? 4 : 5)\n return value\n }\n if (typeof value === \"bigint\") return boundedText(`${value}n`, budget)\n if (value === undefined) return boundedText(\"[Undefined]\", budget)\n if (typeof value === \"function\") return boundedText(Redaction.functionMarker, budget)\n if (typeof value === \"symbol\") return boundedText(Redaction.symbolMarker, budget)\n try {\n if (ArrayBuffer.isView(value) || value instanceof ArrayBuffer) {\n return boundedText(Redaction.binaryMarker, budget)\n }\n } catch {\n return boundedText(unrenderableMarker, budget)\n }\n if (ancestors.has(value)) return boundedText(\"[Circular]\", budget)\n ancestors.add(value)\n try {\n if (value instanceof Date) {\n try {\n return boundedText(value.toISOString(), budget)\n } catch {\n return boundedText(unrenderableMarker, budget)\n }\n }\n if (value instanceof Error) {\n const record: Record<string, unknown> = Object.create(null)\n for (const key of standardErrorKeys.slice(0, budget.members)) {\n budget.members--\n try {\n record[key] = snapshotValue(errorField(value, key), budget, ancestors, depth + 1)\n } catch {\n record[key] = unrenderableMarker\n }\n }\n // Tagged failures (`_tag`, domain fields) and system errors (`code`,\n // `path`, `syscall`) keep their diagnostics as own data properties, so\n // the walk that projects plain records runs over the remaining keys.\n let names: ReadonlyArray<string>\n try {\n names = Object.getOwnPropertyNames(value).filter((key) =>\n !(standardErrorKeys as ReadonlyArray<string>).includes(key)\n )\n } catch {\n return record\n }\n let projected = 0\n let collided = false\n for (; projected < names.length && budget.members > 0; projected++) {\n budget.members--\n const key = names[projected]!\n const boundedKey = boundedText(key, budget)\n if (Object.hasOwn(record, boundedKey)) {\n collided = true\n continue\n }\n const descriptor = Object.getOwnPropertyDescriptor(value, key)\n record[boundedKey] = descriptor !== undefined && \"value\" in descriptor\n ? snapshotValue(descriptor.value, budget, ancestors, depth + 1)\n : unrenderableMarker\n }\n if (collided || projected < names.length) record[truncatedMarker] = truncatedMarker\n return record\n }\n if (Array.isArray(value)) {\n const output: Array<unknown> = []\n const length = value.length\n for (let index = 0; index < length && budget.members > 0; index++) {\n budget.members--\n const descriptor = Object.getOwnPropertyDescriptor(value, String(index))\n output.push(\n descriptor === undefined || !(\"value\" in descriptor)\n ? unrenderableMarker\n : snapshotValue(descriptor.value, budget, ancestors, depth + 1)\n )\n }\n if (output.length < length) output.push(truncatedMarker)\n return output\n }\n const record: Record<string, unknown> = Object.create(null)\n const names = Object.getOwnPropertyNames(value)\n for (let index = 0; index < names.length && budget.members > 0; index++) {\n budget.members--\n const key = names[index]!\n const descriptor = Object.getOwnPropertyDescriptor(value, key)\n const boundedKey = boundedText(key, budget)\n // A key truncated to fit the budget can read exactly like one already\n // copied. The first member keeps its slot; the later one is dropped and\n // the record is marked truncated below rather than silently overwritten.\n if (Object.hasOwn(record, boundedKey)) continue\n record[boundedKey] = descriptor !== undefined && \"value\" in descriptor\n ? snapshotValue(descriptor.value, budget, ancestors, depth + 1)\n : unrenderableMarker\n }\n if (Object.keys(record).length < names.length) record[truncatedMarker] = truncatedMarker\n return record\n } catch {\n return boundedText(unrenderableMarker, budget)\n } finally {\n ancestors.delete(value)\n }\n}\n\nconst snapshotCause = (cause: Cause.Cause<unknown>, budget: SnapshotBudget): TelemetryCause => ({\n version: 1,\n reasons: cause.reasons.slice(0, maximumSnapshotMembers).map((reason): TelemetryCauseReason => {\n switch (reason._tag) {\n case \"Fail\":\n return { _tag: \"Fail\", error: snapshotValue(reason.error, budget, new WeakSet()) }\n case \"Die\":\n return { _tag: \"Die\", defect: snapshotValue(reason.defect, budget, new WeakSet()) }\n case \"Interrupt\":\n return { _tag: \"Interrupt\", fiberId: reason.fiberId ?? null }\n }\n })\n})\n\nconst isTelemetryLog = Schema.is(TelemetryLog)\n\n/**\n * Annotations are a container in the durable schema, so a snapshot that spent\n * the budget names the loss inside a record instead of replacing the record\n * with a scalar the schema refuses.\n */\nconst snapshotAnnotations = (value: unknown, budget: SnapshotBudget): Readonly<Record<string, unknown>> => {\n const snapshot = snapshotValue(value, budget, new WeakSet())\n return typeof snapshot === \"object\" && snapshot !== null && !Array.isArray(snapshot)\n ? snapshot as Readonly<Record<string, unknown>>\n : { [truncatedMarker]: truncatedMarker }\n}\n\nconst snapshotLog = (options: Logger.Options<unknown>): TelemetryLog => {\n const budget: SnapshotBudget = {\n bytes: maximumSnapshotBytes,\n members: maximumSnapshotMembers\n }\n try {\n const span = Option.getOrUndefined(Context.getOption(options.fiber.context, Tracer.ParentSpan))\n const candidate: TelemetryLog = {\n version: 1,\n level: options.logLevel,\n message: snapshotValue(options.message, budget, new WeakSet()),\n annotations: snapshotAnnotations(options.fiber.getRef(References.CurrentLogAnnotations), budget),\n cause: snapshotCause(options.cause, budget),\n fiberId: options.fiber.id,\n ...(span === undefined ? {} : { traceId: span.traceId, spanId: span.spanId }),\n timestamp: options.date.toISOString()\n }\n const redacted = Redaction.redact(candidate, { onTooDeep: \"name\" }) as TelemetryLog\n // The durable row is only useful if the exported schema decodes it, so an\n // oversized or schema-invalid projection degrades to the total record\n // rather than to a payload every consumer throws on.\n return encoder.encode(JSON.stringify(redacted)).byteLength <= maximumSnapshotBytes && isTelemetryLog(redacted)\n ? redacted\n : { ...candidate, message: truncatedMarker, annotations: {}, cause: { version: 1, reasons: [] } }\n } catch {\n return {\n version: 1,\n level: options.logLevel,\n message: unrenderableMarker,\n annotations: {},\n cause: { version: 1, reasons: [] },\n fiberId: options.fiber.id,\n timestamp: options.date.toISOString()\n }\n }\n}\n\nconst makeLog = (options: Logger.Options<unknown>, runId: JournalEvent.RunId): JournalEvent.Input =>\n new JournalEvent.Input({\n runId,\n sourceId,\n // The journal owns the durable per-run/source allocation. A local counter\n // starts over when a layer is rebuilt and makes distinct records collide.\n eventType: \"telemetry.log\",\n payload: snapshotLog(options),\n meta: {\n version: 1,\n source: \"/observability\"\n }\n })\n\n/**\n * Installs a bounded, drop-on-overflow logger forwarder for one explicit run.\n *\n * Configuration is decoded before a worker starts. The callback reads the\n * queue's remaining room first, snapshots and redacts a bounded DTO\n * synchronously only when a slot is free, then performs only non-blocking\n * queue admission. A record a saturated queue cannot take is counted and\n * discarded without being snapshotted. Queue overflow, journal `Dropped` receipts, delivery failures,\n * and journal defects each advance `Metric.droppedLogRecords`. The two failure\n * paths also warn through the ambient loggers with a fixed code and run id,\n * and the worker keeps draining. `Accepted` and `Duplicate` do not advance the\n * counter. Admission receipts cannot identify later drop-oldest evictions of\n * these records or report asynchronous persistence failures or shutdown losses.\n * Closing the scope interrupts the worker and may drop records still queued\n * behind an in-flight write without advancing the counter.\n *\n * The layer replaces the ambient logger set unless `mergeWithExisting` is\n * `true`, and provides `MinimumLogLevel` only when `minimumLogLevel` is given,\n * so an application that set that reference elsewhere keeps it.\n *\n * @category layers\n * @since 1.0.0-rc.0\n */\nexport const layerJournalForwarding = (\n options: Options\n): Layer.Layer<never, InvalidJournalLoggerOptions, Journal.Journal> =>\n Layer.unwrap(\n Effect.map(validateOptions(options), (configured) =>\n Layer.merge(\n Layer.effect(\n Logger.CurrentLoggers,\n Effect.gen(function*() {\n const journal = yield* Journal.Journal\n const queue = yield* Queue.bounded<JournalEvent.Input>(configured.capacity ?? 256)\n const dropped = EffectMetric.update(droppedLogRecords, 1)\n // This worker is forked before the logger it feeds is installed, so\n // its ambient logger set cannot contain that logger and a warning\n // here cannot enqueue itself. Delivery stays lossy; the loss is\n // reported and counted instead of vanishing. Warning annotations\n // use fixed codes so ambient sinks never receive raw failures.\n const forward = Effect.fn(\"JournalLogger.forward\")((input: JournalEvent.Input) =>\n journal.emitLossy(input).pipe(\n Effect.tap((receipt) => receipt._tag === \"Dropped\" ? dropped : Effect.void),\n Effect.catch(() =>\n dropped.pipe(\n Effect.andThen(\n Effect.annotateLogs(Effect.logWarning(\"A telemetry log record could not be forwarded\"), {\n runId: configured.runId,\n code: \"journal_forwarding_failed\"\n })\n )\n )\n )\n )\n )\n yield* Effect.forever(\n Queue.take(queue).pipe(\n Effect.flatMap(forward),\n // A defect from a journal implementation would otherwise end\n // this fiber for the rest of the run, silently, while the layer\n // still looks installed. Interruption stays fatal.\n Effect.catchCause((cause) =>\n Cause.hasInterruptsOnly(cause)\n ? Effect.failCause(cause)\n : dropped.pipe(\n Effect.andThen(\n Effect.annotateLogs(\n Effect.logWarning(\"The telemetry forwarding worker recovered from a defect\"),\n { runId: configured.runId, code: \"journal_forwarding_defect\" }\n )\n )\n )\n )\n )\n ).pipe(Effect.forkScoped)\n\n const logger = Logger.make<unknown, void>((logOptions) => {\n // Snapshotting and redacting the record is the expensive half of\n // admission, and saturation is exactly when that work is thrown\n // away, so a queue with no room refuses before the record is\n // built. Nothing else runs between this read and the offer, so\n // the check cannot refuse a record the queue would have taken,\n // and the offer still reports a queue that closed underneath it.\n const accepted = !Queue.isFullUnsafe(queue)\n && Queue.offerUnsafe(queue, makeLog(logOptions, configured.runId))\n if (!accepted) droppedLogRecords.updateUnsafe(1, logOptions.fiber.context)\n })\n const current = yield* Effect.withFiber((fiber) => Effect.sync(() => fiber.getRef(Logger.CurrentLoggers)))\n return new Set(configured.mergeWithExisting === true ? current : []).add(logger)\n })\n ),\n configured.minimumLogLevel === undefined\n ? Layer.empty\n : Layer.succeed(References.MinimumLogLevel, configured.minimumLogLevel)\n ))\n )\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,cAAyB;AACzB,mBAA8B;AAC9B,gBAA2B;AAC3B,YAAuB;AACvB,cAAyB;AACzB,aAAwB;AACxB,YAAuB;AACvB,aAAwB;AAExB,mBAA8B;AAC9B,aAAwB;AACxB,YAAuB;AACvB,iBAA4B;AAC5B,aAAwB;AACxB,aAAwB;AACxB,6BAAgC;AAChC,oBAAkC;AAQ3B,MAAM,kBAAkB;AAQxB,MAAM,uBAAuB,OAAO;AAQpC,MAAM,yBAAyB;AAQ/B,MAAM,uBAAuB;AAQ7B,MAAM,qBAAqB;AAQ3B,MAAM,kBAAkB;AA+BxB,MAAM,oCAAoC,OAAO,YAAyC;AAAA,EAC/F;AAAA,EACA;AAAA,IACE,MAAM,OAAO,QAAQ,gCAAgC;AAAA,IACrD,MAAM,OAAO;AAAA,IACb,SAAS,OAAO;AAAA,EAClB;AACF,EAAE;AAAC;AAQI,MAAM,gBAAgB,OAAO,OAAO;AA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AAiB,OAAO;AAAA,IACtB,OAAO,SAAS,CAAC,OAAO,SAAS,SAAS,QAAQ,QAAQ,SAAS,SAAS,MAAM,CAAC;AAAA,EACrF;AAAA,EACA,mBAAmB,OAAO,SAAS,OAAO,OAAO;AACnD,CAAC;AAED,MAAM,kBAAkB,CAAC,YACvB,OAAO,oBAAoB,aAAa,EAAE,OAAO,EAAE;AAAA,EACjD,OAAO,SAAS,CAAC,UAAU;AACzB,UAAM,WAAO,wCAAgB,OAAO,SAAS;AAC7C,WAAO,IAAI,4BAA4B;AAAA,MACrC,MAAM;AAAA,MACN;AAAA,MACA,SAAS,kBAAkB,IAAI;AAAA,IACjC,CAAC;AAAA,EACH,CAAC;AACH;AAOF,MAAM,UAAU,CAAC,QAAwB,UAA2B;AAClE,MAAI,QAAQ,OAAO,MAAO,QAAO;AACjC,SAAO,SAAS;AAChB,SAAO;AACT;AAEA,MAAM,YAAY,CAAC,UAA0B,QAAQ,OAAO,KAAK,UAAU,KAAK,CAAC,EAAE;AAEnF,MAAM,aAAa;AACnB,MAAM,eAAe,oBAAI,IAAI,CAAC,GAAM,GAAM,IAAM,IAAM,EAAI,CAAC;AAG3D,MAAM,YAAY,CAAC,SAAyB;AAC1C,MAAI,SAAS,MAAQ,SAAS,GAAM,QAAO;AAC3C,MAAI,OAAO,GAAM,QAAO,aAAa,IAAI,IAAI,IAAI,IAAI;AACrD,MAAI,OAAO,IAAM,QAAO;AACxB,MAAI,OAAO,KAAO,QAAO;AACzB,SAAO;AACT;AAEA,MAAM,iBAAiB,CAAC,SAA0B,QAAQ,SAAU,QAAQ;
|
|
4
|
+
"sourcesContent": ["/**\n * Non-blocking forwarding of bounded operational logs to the durable journal.\n *\n * @since 0.1.0\n */\n\nimport * as Journal from \"@smthrs/journal/Journal\"\nimport * as JournalEvent from \"@smthrs/journal/JournalEvent\"\nimport * as Redaction from \"@smthrs/journal/Redaction\"\nimport * as Cause from \"effect/Cause\"\nimport * as Context from \"effect/Context\"\nimport * as Effect from \"effect/Effect\"\nimport * as Layer from \"effect/Layer\"\nimport * as Logger from \"effect/Logger\"\nimport type * as LogLevel from \"effect/LogLevel\"\nimport * as EffectMetric from \"effect/Metric\"\nimport * as Option from \"effect/Option\"\nimport * as Queue from \"effect/Queue\"\nimport * as References from \"effect/References\"\nimport * as Schema from \"effect/Schema\"\nimport * as Tracer from \"effect/Tracer\"\nimport { schemaIssuePath } from \"./internal/schemaIssuePath.ts\"\nimport { droppedLogRecords } from \"./Metric.ts\"\n\n/**\n * Largest queue accepted by the forwarding logger.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const maximumCapacity = 65_536\n\n/**\n * Largest detached log payload admitted to the asynchronous queue.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const maximumSnapshotBytes = 1024 * 1024\n\n/**\n * Largest number of container members copied into one detached log payload.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const maximumSnapshotMembers = 4_096\n\n/**\n * Deepest container path copied into one detached log payload.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const maximumSnapshotDepth = 64\n\n/**\n * What a hostile or unreadable logged value becomes.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const unrenderableMarker = \"[Unrenderable]\"\n\n/**\n * What a value beyond a logger resource ceiling becomes.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const truncatedMarker = \"[Truncated]\"\n\n/**\n * Options for the journal forwarding logger.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport interface Options {\n /** The run every forwarded record is attributed to. */\n readonly runId: JournalEvent.RunId\n /** Queue depth, 1 through {@link maximumCapacity}. Defaults to 256. */\n readonly capacity?: number | undefined\n /**\n * Pins `References.MinimumLogLevel` for the whole application. Omitted, the\n * layer leaves that reference alone and Effect's own `Info` default applies.\n */\n readonly minimumLogLevel?: LogLevel.LogLevel | undefined\n /**\n * Keeps the ambient loggers alongside the forwarder. Defaults to `false`,\n * which replaces the ambient logger set.\n */\n readonly mergeWithExisting?: boolean | undefined\n}\n\n/**\n * A stable logger configuration refusal.\n *\n * @category errors\n * @since 1.0.0-rc.0\n */\nexport class InvalidJournalLoggerOptions extends Schema.TaggedError<InvalidJournalLoggerOptions>()(\n \"@smthrs/observability/InvalidJournalLoggerOptions\",\n {\n code: Schema.Literal(\"invalid_journal_logger_options\"),\n path: Schema.String,\n message: Schema.String\n }\n) {}\n\n/**\n * One typed failure retained from an Effect cause.\n *\n * @category schemas\n * @since 1.0.0-rc.0\n */\nexport const TelemetryFail = Schema.Struct({\n _tag: Schema.Literal(\"Fail\"),\n error: Schema.Unknown\n})\n\n/**\n * One unexpected defect retained from an Effect cause.\n *\n * @category schemas\n * @since 1.0.0-rc.0\n */\nexport const TelemetryDie = Schema.Struct({\n _tag: Schema.Literal(\"Die\"),\n defect: Schema.Unknown\n})\n\n/**\n * One interruption retained from an Effect cause.\n *\n * @category schemas\n * @since 1.0.0-rc.0\n */\nexport const TelemetryInterrupt = Schema.Struct({\n _tag: Schema.Literal(\"Interrupt\"),\n fiberId: Schema.NullOr(Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)))\n})\n\n/**\n * One reason in a persisted telemetry cause.\n *\n * @category schemas\n * @since 1.0.0-rc.0\n */\nexport const TelemetryCauseReason = Schema.Union([TelemetryFail, TelemetryDie, TelemetryInterrupt])\n\n/**\n * One reason in a persisted telemetry cause.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport type TelemetryCauseReason = typeof TelemetryCauseReason.Type\n\n/**\n * A versioned structural Effect cause.\n *\n * Effect 4 stores composed failures as an ordered reason list. The projection\n * preserves that order and each fail, defect, or interrupt discriminator.\n *\n * @category schemas\n * @since 1.0.0-rc.0\n */\nexport const TelemetryCause = Schema.Struct({\n version: Schema.Literal(1),\n reasons: Schema.Array(TelemetryCauseReason)\n})\n\n/**\n * A versioned structural Effect cause.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport type TelemetryCause = typeof TelemetryCause.Type\n\n/**\n * Runtime schema for the operational log payload written to the journal.\n *\n * @category schemas\n * @since 1.0.0-rc.0\n */\nexport const TelemetryLog = Schema.Struct({\n version: Schema.Literal(1),\n level: Schema.Literals([\"All\", \"Fatal\", \"Error\", \"Warn\", \"Info\", \"Debug\", \"Trace\", \"None\"]),\n message: Schema.Unknown,\n annotations: Schema.Record(Schema.String, Schema.Unknown),\n cause: TelemetryCause,\n fiberId: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),\n traceId: Schema.optionalKey(Schema.String),\n spanId: Schema.optionalKey(Schema.String),\n timestamp: Schema.String\n})\n\n/**\n * Versioned operational log payload written to the journal.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport type TelemetryLog = typeof TelemetryLog.Type\n\nconst sourceId = \"flows/observability/logger\" as JournalEvent.SourceId\nconst encoder = new TextEncoder()\n\nconst OptionsSchema = Schema.Struct({\n runId: JournalEvent.RunId,\n capacity: Schema.optional(\n Schema.Int.check(\n Schema.isGreaterThanOrEqualTo(1),\n Schema.isLessThanOrEqualTo(maximumCapacity)\n )\n ),\n minimumLogLevel: Schema.optional(\n Schema.Literals([\"All\", \"Fatal\", \"Error\", \"Warn\", \"Info\", \"Debug\", \"Trace\", \"None\"])\n ),\n mergeWithExisting: Schema.optional(Schema.Boolean)\n})\n\nconst validateOptions = (options: Options) =>\n Schema.decodeUnknownEffect(OptionsSchema)(options).pipe(\n Effect.mapError((cause) => {\n const path = schemaIssuePath(cause, \"options\")\n return new InvalidJournalLoggerOptions({\n code: \"invalid_journal_logger_options\",\n path,\n message: `journal logger ${path} is invalid`\n })\n })\n )\n\ninterface SnapshotBudget {\n bytes: number\n members: number\n}\n\nconst reserve = (budget: SnapshotBudget, bytes: number): boolean => {\n if (bytes > budget.bytes) return false\n budget.bytes -= bytes\n return true\n}\n\nconst textBytes = (value: string): number => encoder.encode(JSON.stringify(value)).byteLength\n\nconst quoteBytes = 2\nconst shortEscapes = new Set([0x08, 0x09, 0x0a, 0x0c, 0x0d])\n\n/** Bytes one non-surrogate code unit occupies inside a JSON string body. */\nconst unitBytes = (code: number): number => {\n if (code === 0x22 || code === 0x5c) return 2\n if (code < 0x20) return shortEscapes.has(code) ? 2 : 6\n if (code < 0x80) return 1\n if (code < 0x800) return 2\n return 3\n}\n\nconst isLowSurrogate = (code: number): boolean => code >= 0xdc00 && code <= 0xdfff\n\n/** Code units that occupy exactly one byte inside a JSON string body. */\nconst plainRun = /[\\x20\\x21\\x23-\\x5b\\x5d-\\x7f]*/y\n\n/** One-byte units read one at a time before the rest of their run is matched natively. */\nconst plainStreak = 16\n\n/**\n * The longest prefix whose JSON string body fits `limit` bytes, measured in one\n * forward pass. A surrogate pair is admitted or refused whole, so the retained\n * text is well formed whenever the input is.\n *\n * Plain text is one byte per unit, so once a streak of it starts, the rest of\n * the run is matched natively instead of unit by unit. The match reads a window\n * one unit past the bytes still free, never the tail the cut drops.\n */\nconst boundedPrefix = (value: string, limit: number): { readonly text: string; readonly bytes: number } => {\n let bytes = 0\n let index = 0\n let streak = 0\n while (index < value.length) {\n if (streak >= plainStreak) {\n plainRun.lastIndex = 0\n plainRun.test(value.slice(index, index + limit - bytes + 1))\n const run = plainRun.lastIndex\n const admitted = Math.min(run, limit - bytes)\n bytes += admitted\n index += admitted\n if (admitted < run) break\n streak = 0\n continue\n }\n const code = value.charCodeAt(index)\n let width = 1\n let cost: number\n if (code >= 0xd800 && code <= 0xdbff && isLowSurrogate(value.charCodeAt(index + 1))) {\n width = 2\n cost = 4\n } else if (code >= 0xd800 && code <= 0xdfff) {\n cost = 6\n } else {\n cost = unitBytes(code)\n }\n if (bytes + cost > limit) break\n bytes += cost\n index += width\n streak = cost === 1 ? streak + 1 : 0\n }\n return { text: value.slice(0, index), bytes }\n}\n\nconst boundedText = (value: string, budget: SnapshotBudget): string => {\n if (value.length <= maximumSnapshotBytes && reserve(budget, textBytes(value))) return value\n const markerBytes = textBytes(truncatedMarker)\n const prefix = boundedPrefix(value, Math.max(0, budget.bytes - markerBytes - quoteBytes))\n budget.bytes = Math.max(0, budget.bytes - (prefix.bytes + quoteBytes) - markerBytes)\n return `${prefix.text}${truncatedMarker}`\n}\n\n/**\n * Error fields read through the prototype chain, in the order the snapshot\n * projects them before any own data property the error added.\n */\nconst standardErrorKeys = [\"name\", \"message\", \"stack\", \"cause\"] as const\n\n/** Reads inherited data fields without invoking accessors or walking forever. */\nconst errorField = (value: object, key: string): unknown => {\n let current: object | null = value\n for (let depth = 0; current !== null && depth <= maximumSnapshotDepth; depth++) {\n const descriptor = Object.getOwnPropertyDescriptor(current, key)\n if (descriptor !== undefined) return \"value\" in descriptor ? descriptor.value : unrenderableMarker\n current = Object.getPrototypeOf(current)\n }\n return current === null ? undefined : truncatedMarker\n}\n\nconst snapshotValue = (\n value: unknown,\n budget: SnapshotBudget,\n ancestors: WeakSet<object>,\n depth = 0\n): unknown => {\n if (budget.bytes <= 0) return truncatedMarker\n if (depth > maximumSnapshotDepth) return Redaction.depthMarker\n if (typeof value === \"string\") return boundedText(value, budget)\n if (typeof value === \"number\") {\n const projected = Number.isFinite(value) ? value : String(value)\n reserve(budget, String(projected).length)\n return projected\n }\n if (typeof value === \"boolean\" || value === null) {\n reserve(budget, value === null ? 4 : value ? 4 : 5)\n return value\n }\n if (typeof value === \"bigint\") return boundedText(`${value}n`, budget)\n if (value === undefined) return boundedText(\"[Undefined]\", budget)\n if (typeof value === \"function\") return boundedText(Redaction.functionMarker, budget)\n if (typeof value === \"symbol\") return boundedText(Redaction.symbolMarker, budget)\n try {\n if (ArrayBuffer.isView(value) || value instanceof ArrayBuffer) {\n return boundedText(Redaction.binaryMarker, budget)\n }\n } catch {\n return boundedText(unrenderableMarker, budget)\n }\n if (ancestors.has(value)) return boundedText(\"[Circular]\", budget)\n ancestors.add(value)\n try {\n if (value instanceof Date) {\n try {\n return boundedText(Date.prototype.toISOString.call(value), budget)\n } catch {\n return boundedText(unrenderableMarker, budget)\n }\n }\n if (value instanceof Error) {\n const record: Record<string, unknown> = Object.create(null)\n for (const key of standardErrorKeys.slice(0, budget.members)) {\n budget.members--\n try {\n record[key] = snapshotValue(errorField(value, key), budget, ancestors, depth + 1)\n } catch {\n record[key] = unrenderableMarker\n }\n }\n // Tagged failures (`_tag`, domain fields) and system errors (`code`,\n // `path`, `syscall`) keep their diagnostics as own data properties, so\n // the walk that projects plain records runs over the remaining keys.\n let names: ReadonlyArray<string>\n try {\n names = Object.getOwnPropertyNames(value).filter((key) =>\n !(standardErrorKeys as ReadonlyArray<string>).includes(key)\n )\n } catch {\n return record\n }\n let projected = 0\n let collided = false\n for (; projected < names.length && budget.members > 0; projected++) {\n budget.members--\n const key = names[projected]!\n const boundedKey = boundedText(key, budget)\n if (Object.hasOwn(record, boundedKey)) {\n collided = true\n continue\n }\n const descriptor = Object.getOwnPropertyDescriptor(value, key)\n record[boundedKey] = descriptor !== undefined && \"value\" in descriptor\n ? snapshotValue(descriptor.value, budget, ancestors, depth + 1)\n : unrenderableMarker\n }\n if (collided || projected < names.length) record[truncatedMarker] = truncatedMarker\n return record\n }\n if (Array.isArray(value)) {\n const output: Array<unknown> = []\n const length = value.length\n for (let index = 0; index < length && budget.members > 0; index++) {\n budget.members--\n const descriptor = Object.getOwnPropertyDescriptor(value, String(index))\n output.push(\n descriptor === undefined || !(\"value\" in descriptor)\n ? unrenderableMarker\n : snapshotValue(descriptor.value, budget, ancestors, depth + 1)\n )\n }\n if (output.length < length) output.push(truncatedMarker)\n return output\n }\n const record: Record<string, unknown> = Object.create(null)\n const names = Object.getOwnPropertyNames(value)\n for (let index = 0; index < names.length && budget.members > 0; index++) {\n budget.members--\n const key = names[index]!\n const descriptor = Object.getOwnPropertyDescriptor(value, key)\n const boundedKey = boundedText(key, budget)\n // A key truncated to fit the budget can read exactly like one already\n // copied. The first member keeps its slot; the later one is dropped and\n // the record is marked truncated below rather than silently overwritten.\n if (Object.hasOwn(record, boundedKey)) continue\n record[boundedKey] = descriptor !== undefined && \"value\" in descriptor\n ? snapshotValue(descriptor.value, budget, ancestors, depth + 1)\n : unrenderableMarker\n }\n if (Object.keys(record).length < names.length) record[truncatedMarker] = truncatedMarker\n return record\n } catch {\n return boundedText(unrenderableMarker, budget)\n } finally {\n ancestors.delete(value)\n }\n}\n\nconst snapshotCause = (cause: Cause.Cause<unknown>, budget: SnapshotBudget): TelemetryCause => ({\n version: 1,\n reasons: cause.reasons.slice(0, maximumSnapshotMembers).map((reason): TelemetryCauseReason => {\n switch (reason._tag) {\n case \"Fail\":\n return { _tag: \"Fail\", error: snapshotValue(reason.error, budget, new WeakSet()) }\n case \"Die\":\n return { _tag: \"Die\", defect: snapshotValue(reason.defect, budget, new WeakSet()) }\n case \"Interrupt\":\n return { _tag: \"Interrupt\", fiberId: reason.fiberId ?? null }\n }\n })\n})\n\nconst isTelemetryLog = Schema.is(TelemetryLog)\n\n/**\n * Annotations are a container in the durable schema, so a snapshot that spent\n * the budget names the loss inside a record instead of replacing the record\n * with a scalar the schema refuses.\n */\nconst snapshotAnnotations = (value: unknown, budget: SnapshotBudget): Readonly<Record<string, unknown>> => {\n const snapshot = snapshotValue(value, budget, new WeakSet())\n return typeof snapshot === \"object\" && snapshot !== null && !Array.isArray(snapshot)\n ? snapshot as Readonly<Record<string, unknown>>\n : { [truncatedMarker]: truncatedMarker }\n}\n\nconst snapshotLog = (options: Logger.Options<unknown>): TelemetryLog => {\n const budget: SnapshotBudget = {\n bytes: maximumSnapshotBytes,\n members: maximumSnapshotMembers\n }\n try {\n const span = Option.getOrUndefined(Context.getOption(options.fiber.context, Tracer.ParentSpan))\n const candidate: TelemetryLog = {\n version: 1,\n level: options.logLevel,\n message: snapshotValue(options.message, budget, new WeakSet()),\n annotations: snapshotAnnotations(options.fiber.getRef(References.CurrentLogAnnotations), budget),\n cause: snapshotCause(options.cause, budget),\n fiberId: options.fiber.id,\n ...(span === undefined ? {} : { traceId: span.traceId, spanId: span.spanId }),\n timestamp: options.date.toISOString()\n }\n const redacted = Redaction.redact(candidate, { onTooDeep: \"name\" }) as TelemetryLog\n // The durable row is only useful if the exported schema decodes it, so an\n // oversized or schema-invalid projection degrades to the total record\n // rather than to a payload every consumer throws on.\n return encoder.encode(JSON.stringify(redacted)).byteLength <= maximumSnapshotBytes && isTelemetryLog(redacted)\n ? redacted\n : { ...candidate, message: truncatedMarker, annotations: {}, cause: { version: 1, reasons: [] } }\n } catch {\n return {\n version: 1,\n level: options.logLevel,\n message: unrenderableMarker,\n annotations: {},\n cause: { version: 1, reasons: [] },\n fiberId: options.fiber.id,\n timestamp: options.date.toISOString()\n }\n }\n}\n\nconst makeLog = (options: Logger.Options<unknown>, runId: JournalEvent.RunId): JournalEvent.Input =>\n new JournalEvent.Input({\n runId,\n sourceId,\n // The journal owns the durable per-run/source allocation. A local counter\n // starts over when a layer is rebuilt and makes distinct records collide.\n eventType: \"telemetry.log\",\n payload: snapshotLog(options),\n meta: {\n version: 1,\n source: \"/observability\"\n }\n })\n\n/**\n * Installs a bounded, drop-on-overflow logger forwarder for one explicit run.\n *\n * Configuration is decoded before a worker starts. The callback reads the\n * queue's remaining room first, snapshots and redacts a bounded DTO\n * synchronously only when a slot is free, then performs only non-blocking\n * queue admission. A record a saturated queue cannot take is counted and\n * discarded without being snapshotted. Queue overflow, journal `Dropped` receipts, delivery failures,\n * and journal defects each advance `Metric.droppedLogRecords`. The two failure\n * paths also warn through the ambient loggers with a fixed code and run id,\n * and the worker keeps draining. `Accepted` and `Duplicate` do not advance the\n * counter. Admission receipts cannot identify later drop-oldest evictions of\n * these records or report asynchronous persistence failures or shutdown losses.\n * Closing the scope interrupts the worker and may drop records still queued\n * behind an in-flight write without advancing the counter.\n *\n * The layer replaces the ambient logger set unless `mergeWithExisting` is\n * `true`, and provides `MinimumLogLevel` only when `minimumLogLevel` is given,\n * so an application that set that reference elsewhere keeps it.\n *\n * @category layers\n * @since 1.0.0-rc.0\n */\nexport const layerJournalForwarding = (\n options: Options\n): Layer.Layer<never, InvalidJournalLoggerOptions, Journal.Journal> =>\n Layer.unwrap(\n Effect.map(validateOptions(options), (configured) =>\n Layer.merge(\n Layer.effect(\n Logger.CurrentLoggers,\n Effect.gen(function*() {\n const journal = yield* Journal.Journal\n const queue = yield* Queue.bounded<JournalEvent.Input>(configured.capacity ?? 256)\n const dropped = EffectMetric.update(droppedLogRecords, 1)\n // This worker is forked before the logger it feeds is installed, so\n // its ambient logger set cannot contain that logger and a warning\n // here cannot enqueue itself. Delivery stays lossy; the loss is\n // reported and counted instead of vanishing. Warning annotations\n // use fixed codes so ambient sinks never receive raw failures.\n const forward = Effect.fn(\"JournalLogger.forward\")((input: JournalEvent.Input) =>\n journal.emitLossy(input).pipe(\n Effect.tap((receipt) => receipt._tag === \"Dropped\" ? dropped : Effect.void),\n Effect.catch(() =>\n dropped.pipe(\n Effect.andThen(\n Effect.annotateLogs(Effect.logWarning(\"A telemetry log record could not be forwarded\"), {\n runId: configured.runId,\n code: \"journal_forwarding_failed\"\n })\n )\n )\n )\n )\n )\n yield* Effect.forever(\n Queue.take(queue).pipe(\n Effect.flatMap(forward),\n // A defect from a journal implementation would otherwise end\n // this fiber for the rest of the run, silently, while the layer\n // still looks installed. Interruption stays fatal.\n Effect.catchCause((cause) =>\n Cause.hasInterruptsOnly(cause)\n ? Effect.failCause(cause)\n : dropped.pipe(\n Effect.andThen(\n Effect.annotateLogs(\n Effect.logWarning(\"The telemetry forwarding worker recovered from a defect\"),\n { runId: configured.runId, code: \"journal_forwarding_defect\" }\n )\n )\n )\n )\n )\n ).pipe(Effect.forkScoped)\n\n const logger = Logger.make<unknown, void>((logOptions) => {\n // Snapshotting and redacting the record is the expensive half of\n // admission, and saturation is exactly when that work is thrown\n // away, so a queue with no room refuses before the record is\n // built. Nothing else runs between this read and the offer, so\n // the check cannot refuse a record the queue would have taken,\n // and the offer still reports a queue that closed underneath it.\n const accepted = !Queue.isFullUnsafe(queue)\n && Queue.offerUnsafe(queue, makeLog(logOptions, configured.runId))\n if (!accepted) droppedLogRecords.updateUnsafe(1, logOptions.fiber.context)\n })\n const current = yield* Effect.withFiber((fiber) => Effect.sync(() => fiber.getRef(Logger.CurrentLoggers)))\n return new Set(configured.mergeWithExisting === true ? current : []).add(logger)\n })\n ),\n configured.minimumLogLevel === undefined\n ? Layer.empty\n : Layer.succeed(References.MinimumLogLevel, configured.minimumLogLevel)\n ))\n )\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,cAAyB;AACzB,mBAA8B;AAC9B,gBAA2B;AAC3B,YAAuB;AACvB,cAAyB;AACzB,aAAwB;AACxB,YAAuB;AACvB,aAAwB;AAExB,mBAA8B;AAC9B,aAAwB;AACxB,YAAuB;AACvB,iBAA4B;AAC5B,aAAwB;AACxB,aAAwB;AACxB,6BAAgC;AAChC,oBAAkC;AAQ3B,MAAM,kBAAkB;AAQxB,MAAM,uBAAuB,OAAO;AAQpC,MAAM,yBAAyB;AAQ/B,MAAM,uBAAuB;AAQ7B,MAAM,qBAAqB;AAQ3B,MAAM,kBAAkB;AA+BxB,MAAM,oCAAoC,OAAO,YAAyC;AAAA,EAC/F;AAAA,EACA;AAAA,IACE,MAAM,OAAO,QAAQ,gCAAgC;AAAA,IACrD,MAAM,OAAO;AAAA,IACb,SAAS,OAAO;AAAA,EAClB;AACF,EAAE;AAAC;AAQI,MAAM,gBAAgB,OAAO,OAAO;AAAA,EACzC,MAAM,OAAO,QAAQ,MAAM;AAAA,EAC3B,OAAO,OAAO;AAChB,CAAC;AAQM,MAAM,eAAe,OAAO,OAAO;AAAA,EACxC,MAAM,OAAO,QAAQ,KAAK;AAAA,EAC1B,QAAQ,OAAO;AACjB,CAAC;AAQM,MAAM,qBAAqB,OAAO,OAAO;AAAA,EAC9C,MAAM,OAAO,QAAQ,WAAW;AAAA,EAChC,SAAS,OAAO,OAAO,OAAO,IAAI,MAAM,OAAO,uBAAuB,CAAC,CA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gBAAM,WAAW,CAAC,MAAM,aAAa,KAAK,KACrC,MAAM,YAAY,OAAO,QAAQ,YAAY,WAAW,KAAK,CAAC;AACnE,cAAI,CAAC,SAAU,iCAAkB,aAAa,GAAG,WAAW,MAAM,OAAO;AAAA,QAC3E,CAAC;AACD,cAAM,UAAU,OAAO,OAAO,UAAU,CAAC,UAAU,OAAO,KAAK,MAAM,MAAM,OAAO,OAAO,cAAc,CAAC,CAAC;AACzG,eAAO,IAAI,IAAI,WAAW,sBAAsB,OAAO,UAAU,CAAC,CAAC,EAAE,IAAI,MAAM;AAAA,MACjF,CAAC;AAAA,IACH;AAAA,IACA,WAAW,oBAAoB,SAC3B,MAAM,QACN,MAAM,QAAQ,WAAW,iBAAiB,WAAW,eAAe;AAAA,EAC1E,CAAC;AACL;",
|
|
6
6
|
"names": ["record", "names"]
|
|
7
7
|
}
|
package/dist/cjs/Otlp.d.ts
CHANGED
|
@@ -45,7 +45,7 @@ export declare const defaultServiceName = "flows";
|
|
|
45
45
|
* @category resource
|
|
46
46
|
* @since 0.1.0
|
|
47
47
|
*/
|
|
48
|
-
export declare const defaultServiceVersion = "1.0.0-rc.
|
|
48
|
+
export declare const defaultServiceVersion = "1.0.0-rc.9";
|
|
49
49
|
/**
|
|
50
50
|
* Maximum encoded export request size, in bytes.
|
|
51
51
|
* @category transport
|
package/dist/cjs/Otlp.js
CHANGED
|
@@ -62,7 +62,7 @@ var Tracer = __toESM(require("effect/Tracer"), 1);
|
|
|
62
62
|
var Endpoint = __toESM(require("./Endpoint.js"), 1);
|
|
63
63
|
var Resource = __toESM(require("./Resource.js"), 1);
|
|
64
64
|
const defaultServiceName = "flows";
|
|
65
|
-
const defaultServiceVersion = "1.0.0-rc.
|
|
65
|
+
const defaultServiceVersion = "1.0.0-rc.9";
|
|
66
66
|
const maxBatchSize = 1e3;
|
|
67
67
|
const maxInFlight = 4;
|
|
68
68
|
const maxRequestBytes = 1024 * 1024;
|
package/dist/cjs/Otlp.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Otlp.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Default OTLP export wiring for flows telemetry.\n *\n * The store packages already open spans through Effect's tracer and update\n * `Metric` counters on their hot paths; what they deliberately do not do is\n * ship an exporter. This module is that exporter: one layer that installs\n * Effect's own OTLP logger, metrics exporter, and tracer\n * (`effect/observability/Otlp`) against a collector endpoint, with\n * the flows service identity filled in. Nothing beyond `effect` is involved;\n * no OpenTelemetry SDK dependency.\n *\n * Browser support is met by construction rather than by a no-op variant:\n * export happens over Effect's `HttpClient`, and {@link layerFetch} binds the\n * `fetch` implementation the host already has, so no entry point here ever\n * resolves a `node:` built-in. See the\n * {@link https://smithers.sh/docs/reference/api/observability | observability API contract}.\n *\n * @since 0.1.0\n */\n\nimport * as Redaction from \"@smthrs/journal/Redaction\"\nimport * as Cause from \"effect/Cause\"\nimport { Clock } from \"effect/Clock\"\nimport * as ConfigProvider from \"effect/ConfigProvider\"\nimport type * as Duration from \"effect/Duration\"\nimport * as Effect from \"effect/Effect\"\nimport * as Exit from \"effect/Exit\"\nimport * as FetchHttpClient from \"effect/http/FetchHttpClient\"\nimport * as Headers from \"effect/http/Headers\"\nimport type * as HttpBody from \"effect/http/HttpBody\"\nimport * as HttpClient from \"effect/http/HttpClient\"\nimport type * as HttpClientRequest from \"effect/http/HttpClientRequest\"\nimport * as HttpClientResponse from \"effect/http/HttpClientResponse\"\nimport * as Layer from \"effect/Layer\"\nimport * as Logger from \"effect/Logger\"\nimport * as Metric from \"effect/Metric\"\nimport * as Otlp from \"effect/observability/Otlp\"\nimport * as Option from \"effect/Option\"\nimport * as References from \"effect/References\"\nimport * as Schema from \"effect/Schema\"\nimport * as Semaphore from \"effect/Semaphore\"\nimport * as Tracer from \"effect/Tracer\"\nimport * as Endpoint from \"./Endpoint.ts\"\nimport * as Resource from \"./Resource.ts\"\n\n/**\n * The `service.name` resource attribute installed when the caller supplies\n * none: the flows distribution itself. Override it per application with\n * {@link Options.serviceName}.\n *\n * @category resource\n * @since 0.1.0\n */\nexport const defaultServiceName = \"flows\"\n\n/**\n * The `service.version` resource attribute installed when the caller supplies\n * none. Mirrors the release version in this package's `package.json`.\n *\n * A published package cannot read its own manifest on every runtime it\n * supports, so the version lives here as a literal.\n * `scripts/set-release-version.mjs` rewrites this declaration with the\n * manifests, and its `--check` mode reports drift, so a release bump cannot\n * leave it behind.\n *\n * @category resource\n * @since 0.1.0\n */\nexport const defaultServiceVersion = \"1.0.0-rc.8\"\n\n// The upstream logger and tracer each buffer at most one 1,000-record batch.\n// Do not queue at the transport: upstream forks every full batch independently.\nconst maxBatchSize = 1000\nconst maxInFlight = 4\n/**\n * Maximum encoded export request size, in bytes.\n * @category transport\n * @since 1.0.0-rc.0\n */\nexport const maxRequestBytes = 1024 * 1024\nconst requestTimeout = \"10 seconds\"\nconst diagnosticIntervalMillis = 60_000\n// The envelope around the resource in a metrics request repeats `service.name`\n// as the instrumentation scope name: at most 1,024 code units, at most six\n// bytes each once JSON-escaped, so under 8 KiB together with the envelope's own\n// keys. Log and trace requests name their scope `effect` with the Effect\n// version instead, which is smaller.\n/**\n * Reserved bytes for request wrappers and the escaped instrumentation scope.\n * @category transport\n * @since 1.0.0-rc.0\n */\nexport const maximumEnvelopeBytes = 8 * 1024\n\n/**\n * Bytes of every export request kept free for the signal batch itself.\n *\n * The transport discards a request over 1 MiB, and the resource rides in every\n * request, so the largest resource `Resource.decode` admits\n * (`Resource.maximumResourceBytes`, 128 KiB) and the envelope, which in a\n * metrics request repeats the service name (under 8 KiB), come off the top.\n * The 888 KiB left gives each\n * record of a full 1,000-record logger or tracer batch about 900 bytes, three\n * to four times a bare log record or span, and gives the metrics snapshot room\n * for several thousand series. Every resource the decoder accepts therefore\n * leaves an ordinary batch of any signal exportable; what this reserve does\n * not bound is a single application record or a registry large enough to\n * exceed it on its own.\n *\n * @category transport\n * @since 1.0.0-rc.0\n */\nexport const reservedBatchBytes = maxRequestBytes - Resource.maximumResourceBytes - maximumEnvelopeBytes\n\ntype DiscardReason = \"oversized\" | \"stalled\" | \"saturated\"\n\n/**\n * A collector's answer reduced to what the exporter acts on: its status and\n * its `retry-after` delay, with no body.\n *\n * `Response` refuses a status outside 200 to 599 and a malformed header value.\n * Neither is a collector's answer, so `Response.error()` reports it as status\n * 0, which the exporter fails without retrying. A browser already reports a\n * refused redirect that way.\n */\nconst withoutBody = (response: HttpClientResponse.HttpClientResponse): HttpClientResponse.HttpClientResponse => {\n const retryAfter = response.headers[\"retry-after\"]\n let answer: Response\n try {\n answer = new Response(null, {\n status: response.status,\n headers: retryAfter === undefined ? {} : { \"retry-after\": retryAfter }\n })\n } catch {\n answer = Response.error()\n }\n return HttpClientResponse.fromWeb(response.request, answer)\n}\n\nconst boundedClient = Layer.effect(\n HttpClient.HttpClient,\n Effect.gen(function*() {\n // The exporter reads every response body to its end, after the deadline\n // and the in-flight limit below have let the request go. A collector that\n // never ended its answer would stall that signal and grow the buffered\n // body without bound. So the exchange ends here: the exporter receives the\n // status and retry delay, and closing the scope aborts the transport with\n // the body unread.\n const client = HttpClient.transformResponse(\n HttpClient.withScope(yield* HttpClient.HttpClient),\n (exchange) => exchange.pipe(Effect.map(withoutBody), Effect.scoped)\n )\n const clock = yield* Clock\n // The loggers installed when this transport is acquired. The OTLP logger\n // the same acquisition installs does not exist yet, so a diagnostic pinned\n // to this set cannot enter the exporter it describes, whichever fiber runs\n // the export: the interval and shutdown fibers inherit this set anyway,\n // but a flush requested from application code runs with the application's\n // loggers, which by then include this exporter.\n const ambientLoggers = yield* Effect.withFiber((fiber) => Effect.succeed(fiber.getRef(Logger.CurrentLoggers)))\n const permits = Semaphore.makeUnsafe(maxInFlight)\n // The counter lives with the transport it describes.\n const droppedExports = Metric.counter(\"flows_observability_otlp_dropped\")\n let nextDiagnosticAt = -Infinity\n // A local discard is terminal, so the upstream retry loop must not retain\n // or retry its payload, and the counter records batches, not records. The\n // warning is the diagnostic the counter cannot be: the counter is exported\n // through this same transport and shares every outage with it. One\n // warning per minute keeps a sustained outage from flooding the ambient\n // loggers; the running total in its annotations carries the volume.\n // Replace ambient annotations and log spans to bound the diagnostic itself.\n const discard = (reason: DiscardReason, request: HttpClientRequest.HttpClientRequest, bytes: number) =>\n Metric.update(droppedExports, 1).pipe(\n Effect.andThen(Effect.suspend(() => {\n const now = clock.currentTimeMillisUnsafe()\n if (now < nextDiagnosticAt) return Effect.void\n nextDiagnosticAt = now + diagnosticIntervalMillis\n return Metric.value(droppedExports).pipe(\n Effect.flatMap((dropped) =>\n Effect.logWarning(\"An OTLP export batch was discarded\").pipe(\n Effect.provideService(References.CurrentLogSpans, []),\n Effect.provideService(References.CurrentLogAnnotations, {\n code: \"otlp_export_discarded\",\n reason,\n bytes,\n limit: maxRequestBytes,\n dropped: dropped.count\n })\n )\n ),\n Effect.provideService(Logger.CurrentLoggers, ambientLoggers)\n )\n })),\n Effect.as(HttpClientResponse.fromWeb(request, new Response(null, { status: 204 })))\n )\n return HttpClient.transform(client, (requestEffect, request) =>\n Effect.suspend(() => {\n // layerJson always supplies a Uint8Array body with a byte length.\n const bytes = (request.body as HttpBody.Uint8Array).contentLength\n if (bytes > maxRequestBytes) return discard(\"oversized\", request, bytes)\n // Fetch must expose redirects before any credential or signal body\n // leaves the configured endpoint, even when the caller enables follow.\n const confinedRequest = Effect.flatMap(Effect.serviceOption(FetchHttpClient.RequestInit), (init) =>\n requestEffect.pipe(\n Effect.provideService(FetchHttpClient.RequestInit, {\n ...Option.getOrUndefined(init),\n redirect: \"manual\"\n })\n ))\n return confinedRequest.pipe(\n Effect.timeoutOrElse({\n duration: requestTimeout,\n orElse: () =>\n discard(\"stalled\", request, bytes)\n }),\n permits.withPermitsIfAvailable(1),\n Effect.flatMap(Option.match({\n onNone: () =>\n discard(\"saturated\", request, bytes),\n onSome: Effect.succeed\n }))\n )\n }))\n })\n)\n\nconst loopbackIpv4 = /^127\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$/\n\n/** Whether a decoded endpoint's host never leaves this machine. */\nconst isLoopback = (endpoint: string): boolean => {\n const hostname = new URL(endpoint).hostname\n return hostname === \"localhost\" || hostname === \"[::1]\" || loopbackIpv4.test(hostname)\n}\n\n/**\n * Refuses a credential header bound for a plaintext collector off this\n * machine. Anyone on the network path could read the token from every export\n * request, and the exporter would never report it. Loopback `http://` stays\n * allowed for a local collector or sidecar; non-credential headers such as a\n * tenant id stay allowed on any endpoint.\n */\n/**\n * Vendor credential headers whose names `Redaction.isSensitiveKey` does not\n * recognize. Honeycomb sends its ingest key as `x-honeycomb-team`.\n */\nconst vendorCredentialHeaders: ReadonlySet<string> = new Set([\"x-honeycomb-team\"])\n\nconst isCredentialHeader = (name: string): boolean =>\n Redaction.isSensitiveKey(name) || vendorCredentialHeaders.has(name.toLowerCase())\n\nconst refusePlaintextCredentials = (\n baseUrl: string,\n headers: Headers.Input | undefined\n): Effect.Effect<void, Endpoint.InvalidExporterEndpoint> => {\n if (!baseUrl.toLowerCase().startsWith(\"http:\") || isLoopback(baseUrl)) return Effect.void\n const credential = Object.keys(Headers.fromInput(headers)).some(isCredentialHeader)\n return credential\n ? Effect.fail(\n new Endpoint.InvalidExporterEndpoint({\n code: \"invalid_exporter_endpoint\",\n path: \"baseUrl\",\n message:\n \"OTLP collector baseUrl must use https:// when headers carry credentials, unless it is a loopback address\"\n })\n )\n : Effect.void\n}\n\nconst redactText = (text: string): string => String(Redaction.redact(text))\n\n/**\n * A failed span's error rebuilt with its text redacted. It keeps the original\n * error's `name` and `stack` (redacted) so the collector's exception type and\n * trace stay readable; it is exported to the collector and never thrown.\n */\nclass RedactedSpanError extends Schema.TaggedError<RedactedSpanError>()(\"@smthrs/observability/RedactedSpanError\", {\n message: Schema.String\n}) {}\n\n/**\n * A span failure rendered with credentials removed. The exporter serializes a\n * failed span's cause into its status message and `exception` events, which\n * would otherwise carry any token an error message quoted to the collector.\n */\nconst redactedExit = (exit: Exit.Exit<unknown, unknown>): Exit.Exit<unknown, unknown> => {\n if (exit._tag === \"Success\" || Cause.hasInterruptsOnly(exit.cause)) return exit\n const errors = Cause.prettyErrors(exit.cause, { includeCauseInStack: true }).map((error) => {\n const redacted = new RedactedSpanError({ message: redactText(error.message) })\n Object.defineProperty(redacted, \"name\", { value: redactText(error.name), configurable: true, writable: true })\n // `prettyErrors` always renders a stack.\n redacted.stack = redactText(String(error.stack))\n return redacted\n })\n return Exit.failCause(errors.map(Cause.fail).reduce(Cause.combine, Cause.empty as Cause.Cause<unknown>))\n}\n\n/**\n * Wraps the installed tracer so every exported span's failure and string\n * attributes pass through the journal redaction rules first.\n */\nconst redactedSpans = Layer.effect(Tracer.Tracer)(\n Effect.map(Effect.tracer, (tracer) =>\n Tracer.make({\n ...tracer,\n span(options) {\n const span = tracer.span(options)\n const end = span.end.bind(span)\n const attribute = span.attribute.bind(span)\n span.end = (endTime, exit) => end(endTime, redactedExit(exit))\n span.attribute = (key, value) => attribute(key, typeof value === \"string\" ? redactText(value) : value)\n return span\n }\n }))\n)\n\n/**\n * Configuration for the default OTLP wiring.\n *\n * @category models\n * @since 0.1.0\n */\nexport interface Options {\n /**\n * The collector base URL, for example `http://localhost:4318`. Signals are\n * posted below it at `/v1/logs`, `/v1/metrics`, and `/v1/traces`. It must be\n * an absolute `http://` or `https://` URL without credentials, a query,\n * fragment, backslashes, spaces, or controls. A base path is allowed. Invalid\n * values fail acquisition with {@link Endpoint.InvalidExporterEndpoint}.\n * Use {@link Options.headers} for authentication.\n */\n readonly baseUrl: string\n /** Overrides {@link defaultServiceName} as the `service.name` attribute. */\n readonly serviceName?: string | undefined\n /** Overrides {@link defaultServiceVersion} as the `service.version` attribute. */\n readonly serviceVersion?: string | undefined\n /**\n * Additional resource attributes attached to every exported signal, decoded\n * by `Resource.Attributes`. The whole resource must encode to at most\n * `Resource.maximumResourceBytes`; a larger one fails acquisition with\n * {@link Resource.InvalidResourceConfiguration} rather than making every\n * request oversized.\n */\n readonly attributes?: Record<string, unknown> | undefined\n /**\n * Headers sent with every export request, for example vendor auth. A header\n * whose name names a credential (`authorization`, `x-api-key`, anything\n * `Redaction.isSensitiveKey` recognizes, plus `x-honeycomb-team`) requires\n * an `https://` baseUrl unless the host is loopback; otherwise acquisition\n * fails with\n * {@link Endpoint.InvalidExporterEndpoint}.\n */\n readonly headers?: Headers.Input | undefined\n /** Export cadence for all three signals; each signal's Effect default applies when omitted. */\n readonly exportInterval?: Duration.Input | undefined\n /** Upper bound on the shutdown flush when the layer's scope closes. */\n readonly shutdownTimeout?: Duration.Input | undefined\n}\n\n/**\n * Creates the OTLP logs, metrics, and traces layer with flows resource\n * defaults, JSON-serialized. Exports share a four-request limit with no waiting\n * queue. Requests larger than 1 MiB or stalled for ten seconds are discarded;\n * `flows_observability_otlp_dropped` counts discarded batches, and at most\n * once a minute a `Warn` record with code `otlp_export_discarded` names the\n * reason, the request size, and the running total through the loggers that\n * were installed when the layer was acquired, never through this exporter.\n * A collector's response body is never read: the exporter acts on the status\n * and the `retry-after` header, and the exchange ends when they arrive.\n *\n * **Details**\n *\n * The layer still requires an `HttpClient`, which is how it stays\n * platform-neutral: a Node host may hand it `@effect/platform-node`'s Undici\n * client (re-exported by `@smthrs/platform-node`), a browser or test\n * hands it something else. Use {@link layerFetch} when the host's global\n * `fetch` is good enough. On Node 26 and every browser it is.\n * Fetch redirects are refused. Supply `FetchHttpClient.RequestInit` around\n * the whole exporting effect to retain other fetch options; options scoped\n * only to the supplied client's layer are replaced by the redirect policy.\n * Other HTTP transports must independently refuse automatic redirects.\n *\n * @category layers\n * @since 0.1.0\n */\nexport const layer = (\n options: Options\n): Layer.Layer<\n never,\n Resource.InvalidResourceConfiguration | Endpoint.InvalidExporterEndpoint,\n HttpClient.HttpClient\n> =>\n Layer.unwrap(\n Effect.map(\n Effect.all([\n Resource.decode({\n serviceName: options.serviceName ?? defaultServiceName,\n serviceVersion: options.serviceVersion ?? defaultServiceVersion,\n ...(options.attributes === undefined ? {} : { attributes: options.attributes })\n }),\n Endpoint.decode(options.baseUrl, \"baseUrl\").pipe(\n Effect.tap((baseUrl) => refusePlaintextCredentials(baseUrl, options.headers))\n )\n ]),\n ([decoded, baseUrl]) => {\n const resource = Resource.toOpenTelemetryConfiguration(decoded)\n return (\n Otlp.layerJson({\n baseUrl,\n resource: {\n serviceName: resource.serviceName,\n // `serviceVersion` is supplied above before Resource decoding.\n serviceVersion: resource.serviceVersion!,\n ...(resource.attributes === undefined ? {} : { attributes: resource.attributes })\n },\n headers: options.headers,\n maxBatchSize,\n loggerExportInterval: options.exportInterval,\n metricsExportInterval: options.exportInterval,\n tracerExportInterval: options.exportInterval,\n shutdownTimeout: options.shutdownTimeout\n }).pipe(\n Layer.provide(boundedClient),\n // Upstream merges OTEL_RESOURCE_ATTRIBUTES even with explicit\n // options. Keep unvalidated ambient metadata out of every request.\n Layer.provide(ConfigProvider.layer(ConfigProvider.fromUnknown({}))),\n (exporter) => Layer.provideMerge(redactedSpans, exporter)\n )\n )\n }\n )\n )\n\n/**\n * Provides {@link layer} over the host's global `fetch`, the default wiring\n * for a Node host, and browser-safe by construction because it never touches\n * a `node:` built-in.\n *\n * **Example**\n *\n * ```ts\n * import * as Otlp from \"@smthrs/observability/Otlp\"\n *\n * const Telemetry = Otlp.layerFetch({ baseUrl: \"http://localhost:4318\" })\n * ```\n *\n * @category layers\n * @since 0.1.0\n */\nexport const layerFetch = (\n options: Options\n): Layer.Layer<never, Resource.InvalidResourceConfiguration | Endpoint.InvalidExporterEndpoint> =>\n layer(options).pipe(Layer.provide(FetchHttpClient.layer))\n\n/**\n * Why an OTLP layer refused to start.\n *\n * @category errors\n * @since 1.0.0\n */\nexport type LayerError = Resource.InvalidResourceConfiguration | Endpoint.InvalidExporterEndpoint\n\n/**\n * Parses `OTEL_EXPORTER_OTLP_HEADERS`: comma-separated `key=value` pairs whose\n * values are percent-decoded, as the OpenTelemetry exporter specification\n * defines. A pair without `=` or with an empty key is skipped.\n *\n * @category environment\n * @since 1.0.0\n */\nexport const parseHeaders = (value: string | undefined): Record<string, string> => {\n const headers: Record<string, string> = {}\n for (const pair of (value ?? \"\").split(\",\")) {\n const separator = pair.indexOf(\"=\")\n const key = pair.slice(0, separator).trim()\n if (separator < 0 || key === \"\") continue\n const raw = pair.slice(separator + 1).trim()\n let decoded = raw\n try {\n decoded = decodeURIComponent(raw)\n } catch { /* A malformed escape is kept verbatim. */ }\n headers[key] = decoded\n }\n return headers\n}\n\n/**\n * {@link layerFetch} when the environment names a collector, otherwise\n * {@link layerNoop}.\n *\n * `OTEL_EXPORTER_OTLP_ENDPOINT` is the collector base URL and\n * `OTEL_EXPORTER_OTLP_HEADERS` the headers sent with every export. An unset or\n * empty endpoint installs no exporter at all.\n *\n * @category layers\n * @since 1.0.0\n */\nexport const layerEnvironment = (\n environment: Readonly<Record<string, string | undefined>>,\n options: Omit<Options, \"baseUrl\" | \"headers\"> = {}\n): Layer.Layer<never, LayerError> => {\n const endpoint = environment[\"OTEL_EXPORTER_OTLP_ENDPOINT\"]?.trim()\n if (endpoint === undefined || endpoint === \"\") return layerNoop\n return layerFetch({ ...options, baseUrl: endpoint, headers: parseHeaders(environment[\"OTEL_EXPORTER_OTLP_HEADERS\"]) })\n}\n\n/**\n * Exports nothing. The explicit stand-in for hosts with no collector, such as\n * a development shell, a test, or a browser deployment that has not opted in, so\n * wiring code can switch layers rather than branch.\n *\n * @category layers\n * @since 0.1.0\n */\nexport const layerNoop: Layer.Layer<never> = Layer.empty\n"],
|
|
4
|
+
"sourcesContent": ["/**\n * Default OTLP export wiring for flows telemetry.\n *\n * The store packages already open spans through Effect's tracer and update\n * `Metric` counters on their hot paths; what they deliberately do not do is\n * ship an exporter. This module is that exporter: one layer that installs\n * Effect's own OTLP logger, metrics exporter, and tracer\n * (`effect/observability/Otlp`) against a collector endpoint, with\n * the flows service identity filled in. Nothing beyond `effect` is involved;\n * no OpenTelemetry SDK dependency.\n *\n * Browser support is met by construction rather than by a no-op variant:\n * export happens over Effect's `HttpClient`, and {@link layerFetch} binds the\n * `fetch` implementation the host already has, so no entry point here ever\n * resolves a `node:` built-in. See the\n * {@link https://smithers.sh/docs/reference/api/observability | observability API contract}.\n *\n * @since 0.1.0\n */\n\nimport * as Redaction from \"@smthrs/journal/Redaction\"\nimport * as Cause from \"effect/Cause\"\nimport { Clock } from \"effect/Clock\"\nimport * as ConfigProvider from \"effect/ConfigProvider\"\nimport type * as Duration from \"effect/Duration\"\nimport * as Effect from \"effect/Effect\"\nimport * as Exit from \"effect/Exit\"\nimport * as FetchHttpClient from \"effect/http/FetchHttpClient\"\nimport * as Headers from \"effect/http/Headers\"\nimport type * as HttpBody from \"effect/http/HttpBody\"\nimport * as HttpClient from \"effect/http/HttpClient\"\nimport type * as HttpClientRequest from \"effect/http/HttpClientRequest\"\nimport * as HttpClientResponse from \"effect/http/HttpClientResponse\"\nimport * as Layer from \"effect/Layer\"\nimport * as Logger from \"effect/Logger\"\nimport * as Metric from \"effect/Metric\"\nimport * as Otlp from \"effect/observability/Otlp\"\nimport * as Option from \"effect/Option\"\nimport * as References from \"effect/References\"\nimport * as Schema from \"effect/Schema\"\nimport * as Semaphore from \"effect/Semaphore\"\nimport * as Tracer from \"effect/Tracer\"\nimport * as Endpoint from \"./Endpoint.ts\"\nimport * as Resource from \"./Resource.ts\"\n\n/**\n * The `service.name` resource attribute installed when the caller supplies\n * none: the flows distribution itself. Override it per application with\n * {@link Options.serviceName}.\n *\n * @category resource\n * @since 0.1.0\n */\nexport const defaultServiceName = \"flows\"\n\n/**\n * The `service.version` resource attribute installed when the caller supplies\n * none. Mirrors the release version in this package's `package.json`.\n *\n * A published package cannot read its own manifest on every runtime it\n * supports, so the version lives here as a literal.\n * `scripts/set-release-version.mjs` rewrites this declaration with the\n * manifests, and its `--check` mode reports drift, so a release bump cannot\n * leave it behind.\n *\n * @category resource\n * @since 0.1.0\n */\nexport const defaultServiceVersion = \"1.0.0-rc.9\"\n\n// The upstream logger and tracer each buffer at most one 1,000-record batch.\n// Do not queue at the transport: upstream forks every full batch independently.\nconst maxBatchSize = 1000\nconst maxInFlight = 4\n/**\n * Maximum encoded export request size, in bytes.\n * @category transport\n * @since 1.0.0-rc.0\n */\nexport const maxRequestBytes = 1024 * 1024\nconst requestTimeout = \"10 seconds\"\nconst diagnosticIntervalMillis = 60_000\n// The envelope around the resource in a metrics request repeats `service.name`\n// as the instrumentation scope name: at most 1,024 code units, at most six\n// bytes each once JSON-escaped, so under 8 KiB together with the envelope's own\n// keys. Log and trace requests name their scope `effect` with the Effect\n// version instead, which is smaller.\n/**\n * Reserved bytes for request wrappers and the escaped instrumentation scope.\n * @category transport\n * @since 1.0.0-rc.0\n */\nexport const maximumEnvelopeBytes = 8 * 1024\n\n/**\n * Bytes of every export request kept free for the signal batch itself.\n *\n * The transport discards a request over 1 MiB, and the resource rides in every\n * request, so the largest resource `Resource.decode` admits\n * (`Resource.maximumResourceBytes`, 128 KiB) and the envelope, which in a\n * metrics request repeats the service name (under 8 KiB), come off the top.\n * The 888 KiB left gives each\n * record of a full 1,000-record logger or tracer batch about 900 bytes, three\n * to four times a bare log record or span, and gives the metrics snapshot room\n * for several thousand series. Every resource the decoder accepts therefore\n * leaves an ordinary batch of any signal exportable; what this reserve does\n * not bound is a single application record or a registry large enough to\n * exceed it on its own.\n *\n * @category transport\n * @since 1.0.0-rc.0\n */\nexport const reservedBatchBytes = maxRequestBytes - Resource.maximumResourceBytes - maximumEnvelopeBytes\n\ntype DiscardReason = \"oversized\" | \"stalled\" | \"saturated\"\n\n/**\n * A collector's answer reduced to what the exporter acts on: its status and\n * its `retry-after` delay, with no body.\n *\n * `Response` refuses a status outside 200 to 599 and a malformed header value.\n * Neither is a collector's answer, so `Response.error()` reports it as status\n * 0, which the exporter fails without retrying. A browser already reports a\n * refused redirect that way.\n */\nconst withoutBody = (response: HttpClientResponse.HttpClientResponse): HttpClientResponse.HttpClientResponse => {\n const retryAfter = response.headers[\"retry-after\"]\n let answer: Response\n try {\n answer = new Response(null, {\n status: response.status,\n headers: retryAfter === undefined ? {} : { \"retry-after\": retryAfter }\n })\n } catch {\n answer = Response.error()\n }\n return HttpClientResponse.fromWeb(response.request, answer)\n}\n\nconst boundedClient = Layer.effect(\n HttpClient.HttpClient,\n Effect.gen(function*() {\n // The exporter reads every response body to its end, after the deadline\n // and the in-flight limit below have let the request go. A collector that\n // never ended its answer would stall that signal and grow the buffered\n // body without bound. So the exchange ends here: the exporter receives the\n // status and retry delay, and closing the scope aborts the transport with\n // the body unread.\n const client = HttpClient.transformResponse(\n HttpClient.withScope(yield* HttpClient.HttpClient),\n (exchange) => exchange.pipe(Effect.map(withoutBody), Effect.scoped)\n )\n const clock = yield* Clock\n // The loggers installed when this transport is acquired. The OTLP logger\n // the same acquisition installs does not exist yet, so a diagnostic pinned\n // to this set cannot enter the exporter it describes, whichever fiber runs\n // the export: the interval and shutdown fibers inherit this set anyway,\n // but a flush requested from application code runs with the application's\n // loggers, which by then include this exporter.\n const ambientLoggers = yield* Effect.withFiber((fiber) => Effect.succeed(fiber.getRef(Logger.CurrentLoggers)))\n const permits = Semaphore.makeUnsafe(maxInFlight)\n // The counter lives with the transport it describes.\n const droppedExports = Metric.counter(\"flows_observability_otlp_dropped\")\n let nextDiagnosticAt = -Infinity\n // A local discard is terminal, so the upstream retry loop must not retain\n // or retry its payload, and the counter records batches, not records. The\n // warning is the diagnostic the counter cannot be: the counter is exported\n // through this same transport and shares every outage with it. One\n // warning per minute keeps a sustained outage from flooding the ambient\n // loggers; the running total in its annotations carries the volume.\n // Replace ambient annotations and log spans to bound the diagnostic itself.\n const discard = (reason: DiscardReason, request: HttpClientRequest.HttpClientRequest, bytes: number) =>\n Metric.update(droppedExports, 1).pipe(\n Effect.andThen(Effect.suspend(() => {\n const now = clock.currentTimeMillisUnsafe()\n if (now < nextDiagnosticAt) return Effect.void\n nextDiagnosticAt = now + diagnosticIntervalMillis\n return Metric.value(droppedExports).pipe(\n Effect.flatMap((dropped) =>\n Effect.logWarning(\"An OTLP export batch was discarded\").pipe(\n Effect.provideService(References.CurrentLogSpans, []),\n Effect.provideService(References.CurrentLogAnnotations, {\n code: \"otlp_export_discarded\",\n reason,\n bytes,\n limit: maxRequestBytes,\n dropped: dropped.count\n })\n )\n ),\n Effect.provideService(Logger.CurrentLoggers, ambientLoggers)\n )\n })),\n Effect.as(HttpClientResponse.fromWeb(request, new Response(null, { status: 204 })))\n )\n return HttpClient.transform(client, (requestEffect, request) =>\n Effect.suspend(() => {\n // layerJson always supplies a Uint8Array body with a byte length.\n const bytes = (request.body as HttpBody.Uint8Array).contentLength\n if (bytes > maxRequestBytes) return discard(\"oversized\", request, bytes)\n // Fetch must expose redirects before any credential or signal body\n // leaves the configured endpoint, even when the caller enables follow.\n const confinedRequest = Effect.flatMap(Effect.serviceOption(FetchHttpClient.RequestInit), (init) =>\n requestEffect.pipe(\n Effect.provideService(FetchHttpClient.RequestInit, {\n ...Option.getOrUndefined(init),\n redirect: \"manual\"\n })\n ))\n return confinedRequest.pipe(\n Effect.timeoutOrElse({\n duration: requestTimeout,\n orElse: () =>\n discard(\"stalled\", request, bytes)\n }),\n permits.withPermitsIfAvailable(1),\n Effect.flatMap(Option.match({\n onNone: () =>\n discard(\"saturated\", request, bytes),\n onSome: Effect.succeed\n }))\n )\n }))\n })\n)\n\nconst loopbackIpv4 = /^127\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$/\n\n/** Whether a decoded endpoint's host never leaves this machine. */\nconst isLoopback = (endpoint: string): boolean => {\n const hostname = new URL(endpoint).hostname\n return hostname === \"localhost\" || hostname === \"[::1]\" || loopbackIpv4.test(hostname)\n}\n\n/**\n * Refuses a credential header bound for a plaintext collector off this\n * machine. Anyone on the network path could read the token from every export\n * request, and the exporter would never report it. Loopback `http://` stays\n * allowed for a local collector or sidecar; non-credential headers such as a\n * tenant id stay allowed on any endpoint.\n */\n/**\n * Vendor credential headers whose names `Redaction.isSensitiveKey` does not\n * recognize. Honeycomb sends its ingest key as `x-honeycomb-team`.\n */\nconst vendorCredentialHeaders: ReadonlySet<string> = new Set([\"x-honeycomb-team\"])\n\nconst isCredentialHeader = (name: string): boolean =>\n Redaction.isSensitiveKey(name) || vendorCredentialHeaders.has(name.toLowerCase())\n\nconst refusePlaintextCredentials = (\n baseUrl: string,\n headers: Headers.Input | undefined\n): Effect.Effect<void, Endpoint.InvalidExporterEndpoint> => {\n if (!baseUrl.toLowerCase().startsWith(\"http:\") || isLoopback(baseUrl)) return Effect.void\n const credential = Object.keys(Headers.fromInput(headers)).some(isCredentialHeader)\n return credential\n ? Effect.fail(\n new Endpoint.InvalidExporterEndpoint({\n code: \"invalid_exporter_endpoint\",\n path: \"baseUrl\",\n message:\n \"OTLP collector baseUrl must use https:// when headers carry credentials, unless it is a loopback address\"\n })\n )\n : Effect.void\n}\n\nconst redactText = (text: string): string => String(Redaction.redact(text))\n\n/**\n * A failed span's error rebuilt with its text redacted. It keeps the original\n * error's `name` and `stack` (redacted) so the collector's exception type and\n * trace stay readable; it is exported to the collector and never thrown.\n */\nclass RedactedSpanError extends Schema.TaggedError<RedactedSpanError>()(\"@smthrs/observability/RedactedSpanError\", {\n message: Schema.String\n}) {}\n\n/**\n * A span failure rendered with credentials removed. The exporter serializes a\n * failed span's cause into its status message and `exception` events, which\n * would otherwise carry any token an error message quoted to the collector.\n */\nconst redactedExit = (exit: Exit.Exit<unknown, unknown>): Exit.Exit<unknown, unknown> => {\n if (exit._tag === \"Success\" || Cause.hasInterruptsOnly(exit.cause)) return exit\n const errors = Cause.prettyErrors(exit.cause, { includeCauseInStack: true }).map((error) => {\n const redacted = new RedactedSpanError({ message: redactText(error.message) })\n Object.defineProperty(redacted, \"name\", { value: redactText(error.name), configurable: true, writable: true })\n // `prettyErrors` always renders a stack.\n redacted.stack = redactText(String(error.stack))\n return redacted\n })\n return Exit.failCause(errors.map(Cause.fail).reduce(Cause.combine, Cause.empty as Cause.Cause<unknown>))\n}\n\n/**\n * Wraps the installed tracer so every exported span's failure and string\n * attributes pass through the journal redaction rules first.\n */\nconst redactedSpans = Layer.effect(Tracer.Tracer)(\n Effect.map(Effect.tracer, (tracer) =>\n Tracer.make({\n ...tracer,\n span(options) {\n const span = tracer.span(options)\n const end = span.end.bind(span)\n const attribute = span.attribute.bind(span)\n span.end = (endTime, exit) => end(endTime, redactedExit(exit))\n span.attribute = (key, value) => attribute(key, typeof value === \"string\" ? redactText(value) : value)\n return span\n }\n }))\n)\n\n/**\n * Configuration for the default OTLP wiring.\n *\n * @category models\n * @since 0.1.0\n */\nexport interface Options {\n /**\n * The collector base URL, for example `http://localhost:4318`. Signals are\n * posted below it at `/v1/logs`, `/v1/metrics`, and `/v1/traces`. It must be\n * an absolute `http://` or `https://` URL without credentials, a query,\n * fragment, backslashes, spaces, or controls. A base path is allowed. Invalid\n * values fail acquisition with {@link Endpoint.InvalidExporterEndpoint}.\n * Use {@link Options.headers} for authentication.\n */\n readonly baseUrl: string\n /** Overrides {@link defaultServiceName} as the `service.name` attribute. */\n readonly serviceName?: string | undefined\n /** Overrides {@link defaultServiceVersion} as the `service.version` attribute. */\n readonly serviceVersion?: string | undefined\n /**\n * Additional resource attributes attached to every exported signal, decoded\n * by `Resource.Attributes`. The whole resource must encode to at most\n * `Resource.maximumResourceBytes`; a larger one fails acquisition with\n * {@link Resource.InvalidResourceConfiguration} rather than making every\n * request oversized.\n */\n readonly attributes?: Record<string, unknown> | undefined\n /**\n * Headers sent with every export request, for example vendor auth. A header\n * whose name names a credential (`authorization`, `x-api-key`, anything\n * `Redaction.isSensitiveKey` recognizes, plus `x-honeycomb-team`) requires\n * an `https://` baseUrl unless the host is loopback; otherwise acquisition\n * fails with\n * {@link Endpoint.InvalidExporterEndpoint}.\n */\n readonly headers?: Headers.Input | undefined\n /** Export cadence for all three signals; each signal's Effect default applies when omitted. */\n readonly exportInterval?: Duration.Input | undefined\n /** Upper bound on the shutdown flush when the layer's scope closes. */\n readonly shutdownTimeout?: Duration.Input | undefined\n}\n\n/**\n * Creates the OTLP logs, metrics, and traces layer with flows resource\n * defaults, JSON-serialized. Exports share a four-request limit with no waiting\n * queue. Requests larger than 1 MiB or stalled for ten seconds are discarded;\n * `flows_observability_otlp_dropped` counts discarded batches, and at most\n * once a minute a `Warn` record with code `otlp_export_discarded` names the\n * reason, the request size, and the running total through the loggers that\n * were installed when the layer was acquired, never through this exporter.\n * A collector's response body is never read: the exporter acts on the status\n * and the `retry-after` header, and the exchange ends when they arrive.\n *\n * **Details**\n *\n * The layer still requires an `HttpClient`, which is how it stays\n * platform-neutral: a Node host may hand it `@effect/platform-node`'s Undici\n * client (re-exported by `@smthrs/platform-node`), a browser or test\n * hands it something else. Use {@link layerFetch} when the host's global\n * `fetch` is good enough. On Node 26 and every browser it is.\n * Fetch redirects are refused. Supply `FetchHttpClient.RequestInit` around\n * the whole exporting effect to retain other fetch options; options scoped\n * only to the supplied client's layer are replaced by the redirect policy.\n * Other HTTP transports must independently refuse automatic redirects.\n *\n * @category layers\n * @since 0.1.0\n */\nexport const layer = (\n options: Options\n): Layer.Layer<\n never,\n Resource.InvalidResourceConfiguration | Endpoint.InvalidExporterEndpoint,\n HttpClient.HttpClient\n> =>\n Layer.unwrap(\n Effect.map(\n Effect.all([\n Resource.decode({\n serviceName: options.serviceName ?? defaultServiceName,\n serviceVersion: options.serviceVersion ?? defaultServiceVersion,\n ...(options.attributes === undefined ? {} : { attributes: options.attributes })\n }),\n Endpoint.decode(options.baseUrl, \"baseUrl\").pipe(\n Effect.tap((baseUrl) => refusePlaintextCredentials(baseUrl, options.headers))\n )\n ]),\n ([decoded, baseUrl]) => {\n const resource = Resource.toOpenTelemetryConfiguration(decoded)\n return (\n Otlp.layerJson({\n baseUrl,\n resource: {\n serviceName: resource.serviceName,\n // `serviceVersion` is supplied above before Resource decoding.\n serviceVersion: resource.serviceVersion!,\n ...(resource.attributes === undefined ? {} : { attributes: resource.attributes })\n },\n headers: options.headers,\n maxBatchSize,\n loggerExportInterval: options.exportInterval,\n metricsExportInterval: options.exportInterval,\n tracerExportInterval: options.exportInterval,\n shutdownTimeout: options.shutdownTimeout\n }).pipe(\n Layer.provide(boundedClient),\n // Upstream merges OTEL_RESOURCE_ATTRIBUTES even with explicit\n // options. Keep unvalidated ambient metadata out of every request.\n Layer.provide(ConfigProvider.layer(ConfigProvider.fromUnknown({}))),\n (exporter) => Layer.provideMerge(redactedSpans, exporter)\n )\n )\n }\n )\n )\n\n/**\n * Provides {@link layer} over the host's global `fetch`, the default wiring\n * for a Node host, and browser-safe by construction because it never touches\n * a `node:` built-in.\n *\n * **Example**\n *\n * ```ts\n * import * as Otlp from \"@smthrs/observability/Otlp\"\n *\n * const Telemetry = Otlp.layerFetch({ baseUrl: \"http://localhost:4318\" })\n * ```\n *\n * @category layers\n * @since 0.1.0\n */\nexport const layerFetch = (\n options: Options\n): Layer.Layer<never, Resource.InvalidResourceConfiguration | Endpoint.InvalidExporterEndpoint> =>\n layer(options).pipe(Layer.provide(FetchHttpClient.layer))\n\n/**\n * Why an OTLP layer refused to start.\n *\n * @category errors\n * @since 1.0.0\n */\nexport type LayerError = Resource.InvalidResourceConfiguration | Endpoint.InvalidExporterEndpoint\n\n/**\n * Parses `OTEL_EXPORTER_OTLP_HEADERS`: comma-separated `key=value` pairs whose\n * values are percent-decoded, as the OpenTelemetry exporter specification\n * defines. A pair without `=` or with an empty key is skipped.\n *\n * @category environment\n * @since 1.0.0\n */\nexport const parseHeaders = (value: string | undefined): Record<string, string> => {\n const headers: Record<string, string> = {}\n for (const pair of (value ?? \"\").split(\",\")) {\n const separator = pair.indexOf(\"=\")\n const key = pair.slice(0, separator).trim()\n if (separator < 0 || key === \"\") continue\n const raw = pair.slice(separator + 1).trim()\n let decoded = raw\n try {\n decoded = decodeURIComponent(raw)\n } catch { /* A malformed escape is kept verbatim. */ }\n headers[key] = decoded\n }\n return headers\n}\n\n/**\n * {@link layerFetch} when the environment names a collector, otherwise\n * {@link layerNoop}.\n *\n * `OTEL_EXPORTER_OTLP_ENDPOINT` is the collector base URL and\n * `OTEL_EXPORTER_OTLP_HEADERS` the headers sent with every export. An unset or\n * empty endpoint installs no exporter at all.\n *\n * @category layers\n * @since 1.0.0\n */\nexport const layerEnvironment = (\n environment: Readonly<Record<string, string | undefined>>,\n options: Omit<Options, \"baseUrl\" | \"headers\"> = {}\n): Layer.Layer<never, LayerError> => {\n const endpoint = environment[\"OTEL_EXPORTER_OTLP_ENDPOINT\"]?.trim()\n if (endpoint === undefined || endpoint === \"\") return layerNoop\n return layerFetch({ ...options, baseUrl: endpoint, headers: parseHeaders(environment[\"OTEL_EXPORTER_OTLP_HEADERS\"]) })\n}\n\n/**\n * Exports nothing. The explicit stand-in for hosts with no collector, such as\n * a development shell, a test, or a browser deployment that has not opted in, so\n * wiring code can switch layers rather than branch.\n *\n * @category layers\n * @since 0.1.0\n */\nexport const layerNoop: Layer.Layer<never> = Layer.empty\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAoBA,gBAA2B;AAC3B,YAAuB;AACvB,mBAAsB;AACtB,qBAAgC;AAEhC,aAAwB;AACxB,WAAsB;AACtB,sBAAiC;AACjC,cAAyB;AAEzB,iBAA4B;AAE5B,yBAAoC;AACpC,YAAuB;AACvB,aAAwB;AACxB,aAAwB;AACxB,WAAsB;AACtB,aAAwB;AACxB,iBAA4B;AAC5B,aAAwB;AACxB,gBAA2B;AAC3B,aAAwB;AACxB,eAA0B;AAC1B,eAA0B;AAUnB,MAAM,qBAAqB;AAe3B,MAAM,wBAAwB;AAIrC,MAAM,eAAe;AACrB,MAAM,cAAc;AAMb,MAAM,kBAAkB,OAAO;AACtC,MAAM,iBAAiB;AACvB,MAAM,2BAA2B;AAW1B,MAAM,uBAAuB,IAAI;AAoBjC,MAAM,qBAAqB,kBAAkB,SAAS,uBAAuB;AAapF,MAAM,cAAc,CAAC,aAA2F;AAC9G,QAAM,a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,QAAQ,CAAC,QAAQ,GAAG,SAAS,CAAA;IACxD;;;OAGG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CACjD;;;;;;AAED;;;;;GAKG;AACH,qBAAa,2BAA4B,SAAQ,gCAOhD;CAAG;AAEJ;;;;;GAKG;AACH,eAAO,MAAM,aAAa;;;EAGxB,CAAA;AAEF;;;;;GAKG;AACH,eAAO,MAAM,YAAY;;;EAGvB,CAAA;AAEF;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB;;;EAG7B,CAAA;AAEF;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;IAAkE,CAAA;AAEnG;;;;;GAKG;AACH,MAAM,MAAM,oBAAoB,GAAG,OAAO,oBAAoB,CAAC,IAAI,CAAA;AAEnE;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;EAGzB,CAAA;AAEF;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GAAG,OAAO,cAAc,CAAC,IAAI,CAAA;AAEvD;;;;;GAKG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;EAUvB,CAAA;AAEF;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG,OAAO,YAAY,CAAC,IAAI,CAAA;AAyUnD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,sBAAsB,GACjC,SAAS,OAAO,KACf,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,2BAA2B,EAAE,OAAO,CAAC,OAAO,CAsE/D,CAAA"}
|
|
@@ -178,15 +178,36 @@ const unitBytes = (code) => {
|
|
|
178
178
|
return 3;
|
|
179
179
|
};
|
|
180
180
|
const isLowSurrogate = (code) => code >= 0xdc00 && code <= 0xdfff;
|
|
181
|
+
/** Code units that occupy exactly one byte inside a JSON string body. */
|
|
182
|
+
const plainRun = /[\x20\x21\x23-\x5b\x5d-\x7f]*/y;
|
|
183
|
+
/** One-byte units read one at a time before the rest of their run is matched natively. */
|
|
184
|
+
const plainStreak = 16;
|
|
181
185
|
/**
|
|
182
186
|
* The longest prefix whose JSON string body fits `limit` bytes, measured in one
|
|
183
187
|
* forward pass. A surrogate pair is admitted or refused whole, so the retained
|
|
184
188
|
* text is well formed whenever the input is.
|
|
189
|
+
*
|
|
190
|
+
* Plain text is one byte per unit, so once a streak of it starts, the rest of
|
|
191
|
+
* the run is matched natively instead of unit by unit. The match reads a window
|
|
192
|
+
* one unit past the bytes still free, never the tail the cut drops.
|
|
185
193
|
*/
|
|
186
194
|
const boundedPrefix = (value, limit) => {
|
|
187
195
|
let bytes = 0;
|
|
188
196
|
let index = 0;
|
|
197
|
+
let streak = 0;
|
|
189
198
|
while (index < value.length) {
|
|
199
|
+
if (streak >= plainStreak) {
|
|
200
|
+
plainRun.lastIndex = 0;
|
|
201
|
+
plainRun.test(value.slice(index, index + limit - bytes + 1));
|
|
202
|
+
const run = plainRun.lastIndex;
|
|
203
|
+
const admitted = Math.min(run, limit - bytes);
|
|
204
|
+
bytes += admitted;
|
|
205
|
+
index += admitted;
|
|
206
|
+
if (admitted < run)
|
|
207
|
+
break;
|
|
208
|
+
streak = 0;
|
|
209
|
+
continue;
|
|
210
|
+
}
|
|
190
211
|
const code = value.charCodeAt(index);
|
|
191
212
|
let width = 1;
|
|
192
213
|
let cost;
|
|
@@ -204,6 +225,7 @@ const boundedPrefix = (value, limit) => {
|
|
|
204
225
|
break;
|
|
205
226
|
bytes += cost;
|
|
206
227
|
index += width;
|
|
228
|
+
streak = cost === 1 ? streak + 1 : 0;
|
|
207
229
|
}
|
|
208
230
|
return { text: value.slice(0, index), bytes };
|
|
209
231
|
};
|
|
@@ -269,7 +291,7 @@ const snapshotValue = (value, budget, ancestors, depth = 0) => {
|
|
|
269
291
|
try {
|
|
270
292
|
if (value instanceof Date) {
|
|
271
293
|
try {
|
|
272
|
-
return boundedText(
|
|
294
|
+
return boundedText(Date.prototype.toISOString.call(value), budget);
|
|
273
295
|
}
|
|
274
296
|
catch {
|
|
275
297
|
return boundedText(unrenderableMarker, budget);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JournalLogger.js","sourceRoot":"","sources":["../../src/JournalLogger.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,OAAO,MAAM,yBAAyB,CAAA;AAClD,OAAO,KAAK,YAAY,MAAM,8BAA8B,CAAA;AAC5D,OAAO,KAAK,SAAS,MAAM,2BAA2B,CAAA;AACtD,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,OAAO,KAAK,YAAY,MAAM,eAAe,CAAA;AAC7C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAA;AAC/C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAE/C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAA;AAErC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,GAAG,IAAI,CAAA;AAE/C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,CAAA;AAE3C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,CAAA;AAEtC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,gBAAgB,CAAA;A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KAAK,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;AAClF,CAAC,CAAC,CACH,EACD,UAAU,CAAC,eAAe,KAAK,SAAS;IACtC,CAAC,CAAC,KAAK,CAAC,KAAK;IACb,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,eAAe,EAAE,UAAU,CAAC,eAAe,CAAC,CAC1E,CAAC,CACL,CAAA"}
|
package/dist/esm/Otlp.d.ts
CHANGED
|
@@ -45,7 +45,7 @@ export declare const defaultServiceName = "flows";
|
|
|
45
45
|
* @category resource
|
|
46
46
|
* @since 0.1.0
|
|
47
47
|
*/
|
|
48
|
-
export declare const defaultServiceVersion = "1.0.0-rc.
|
|
48
|
+
export declare const defaultServiceVersion = "1.0.0-rc.9";
|
|
49
49
|
/**
|
|
50
50
|
* Maximum encoded export request size, in bytes.
|
|
51
51
|
* @category transport
|
package/dist/esm/Otlp.js
CHANGED
|
@@ -60,7 +60,7 @@ export const defaultServiceName = "flows";
|
|
|
60
60
|
* @category resource
|
|
61
61
|
* @since 0.1.0
|
|
62
62
|
*/
|
|
63
|
-
export const defaultServiceVersion = "1.0.0-rc.
|
|
63
|
+
export const defaultServiceVersion = "1.0.0-rc.9";
|
|
64
64
|
// The upstream logger and tracer each buffer at most one 1,000-record batch.
|
|
65
65
|
// Do not queue at the transport: upstream forks every full batch independently.
|
|
66
66
|
const maxBatchSize = 1000;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smthrs/observability",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.0-rc.
|
|
4
|
+
"version": "1.0.0-rc.9",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"smthrs": {
|
|
7
7
|
"group": "engine"
|
|
@@ -165,7 +165,7 @@
|
|
|
165
165
|
"dependencies": {
|
|
166
166
|
"@opentelemetry/sdk-logs": "0.222.0",
|
|
167
167
|
"@opentelemetry/sdk-metrics": "2.11.0",
|
|
168
|
-
"@smthrs/journal": "1.0.0-rc.
|
|
168
|
+
"@smthrs/journal": "1.0.0-rc.9",
|
|
169
169
|
"@effect/opentelemetry": "4.0.4"
|
|
170
170
|
},
|
|
171
171
|
"devDependencies": {
|
package/src/JournalLogger.ts
CHANGED
|
@@ -261,15 +261,37 @@ const unitBytes = (code: number): number => {
|
|
|
261
261
|
|
|
262
262
|
const isLowSurrogate = (code: number): boolean => code >= 0xdc00 && code <= 0xdfff
|
|
263
263
|
|
|
264
|
+
/** Code units that occupy exactly one byte inside a JSON string body. */
|
|
265
|
+
const plainRun = /[\x20\x21\x23-\x5b\x5d-\x7f]*/y
|
|
266
|
+
|
|
267
|
+
/** One-byte units read one at a time before the rest of their run is matched natively. */
|
|
268
|
+
const plainStreak = 16
|
|
269
|
+
|
|
264
270
|
/**
|
|
265
271
|
* The longest prefix whose JSON string body fits `limit` bytes, measured in one
|
|
266
272
|
* forward pass. A surrogate pair is admitted or refused whole, so the retained
|
|
267
273
|
* text is well formed whenever the input is.
|
|
274
|
+
*
|
|
275
|
+
* Plain text is one byte per unit, so once a streak of it starts, the rest of
|
|
276
|
+
* the run is matched natively instead of unit by unit. The match reads a window
|
|
277
|
+
* one unit past the bytes still free, never the tail the cut drops.
|
|
268
278
|
*/
|
|
269
279
|
const boundedPrefix = (value: string, limit: number): { readonly text: string; readonly bytes: number } => {
|
|
270
280
|
let bytes = 0
|
|
271
281
|
let index = 0
|
|
282
|
+
let streak = 0
|
|
272
283
|
while (index < value.length) {
|
|
284
|
+
if (streak >= plainStreak) {
|
|
285
|
+
plainRun.lastIndex = 0
|
|
286
|
+
plainRun.test(value.slice(index, index + limit - bytes + 1))
|
|
287
|
+
const run = plainRun.lastIndex
|
|
288
|
+
const admitted = Math.min(run, limit - bytes)
|
|
289
|
+
bytes += admitted
|
|
290
|
+
index += admitted
|
|
291
|
+
if (admitted < run) break
|
|
292
|
+
streak = 0
|
|
293
|
+
continue
|
|
294
|
+
}
|
|
273
295
|
const code = value.charCodeAt(index)
|
|
274
296
|
let width = 1
|
|
275
297
|
let cost: number
|
|
@@ -284,6 +306,7 @@ const boundedPrefix = (value: string, limit: number): { readonly text: string; r
|
|
|
284
306
|
if (bytes + cost > limit) break
|
|
285
307
|
bytes += cost
|
|
286
308
|
index += width
|
|
309
|
+
streak = cost === 1 ? streak + 1 : 0
|
|
287
310
|
}
|
|
288
311
|
return { text: value.slice(0, index), bytes }
|
|
289
312
|
}
|
|
@@ -347,7 +370,7 @@ const snapshotValue = (
|
|
|
347
370
|
try {
|
|
348
371
|
if (value instanceof Date) {
|
|
349
372
|
try {
|
|
350
|
-
return boundedText(
|
|
373
|
+
return boundedText(Date.prototype.toISOString.call(value), budget)
|
|
351
374
|
} catch {
|
|
352
375
|
return boundedText(unrenderableMarker, budget)
|
|
353
376
|
}
|
package/src/Otlp.ts
CHANGED
|
@@ -66,7 +66,7 @@ export const defaultServiceName = "flows"
|
|
|
66
66
|
* @category resource
|
|
67
67
|
* @since 0.1.0
|
|
68
68
|
*/
|
|
69
|
-
export const defaultServiceVersion = "1.0.0-rc.
|
|
69
|
+
export const defaultServiceVersion = "1.0.0-rc.9"
|
|
70
70
|
|
|
71
71
|
// The upstream logger and tracer each buffer at most one 1,000-record batch.
|
|
72
72
|
// Do not queue at the transport: upstream forks every full batch independently.
|