@ooopsstudio/performance 0.9.0

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.
Files changed (52) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +50 -0
  3. package/dist/budget-engine-KDA4FRYU.js +160 -0
  4. package/dist/budget-engine-KDA4FRYU.js.map +1 -0
  5. package/dist/chunk-2XXIOHOO.js +58 -0
  6. package/dist/chunk-2XXIOHOO.js.map +1 -0
  7. package/dist/chunk-3GMKPRQP.js +197 -0
  8. package/dist/chunk-3GMKPRQP.js.map +1 -0
  9. package/dist/chunk-J6KBSLYO.js +118 -0
  10. package/dist/chunk-J6KBSLYO.js.map +1 -0
  11. package/dist/chunk-MMO5UEUU.js +20 -0
  12. package/dist/chunk-MMO5UEUU.js.map +1 -0
  13. package/dist/chunk-RL2752FW.js +31 -0
  14. package/dist/chunk-RL2752FW.js.map +1 -0
  15. package/dist/chunk-RY65GERM.js +159 -0
  16. package/dist/chunk-RY65GERM.js.map +1 -0
  17. package/dist/chunk-W72QW2AD.js +29 -0
  18. package/dist/chunk-W72QW2AD.js.map +1 -0
  19. package/dist/chunk-ZAXGEDZW.js +1184 -0
  20. package/dist/chunk-ZAXGEDZW.js.map +1 -0
  21. package/dist/custom/exporters/http.d.ts +11 -0
  22. package/dist/custom/exporters/http.js +364 -0
  23. package/dist/custom/exporters/http.js.map +1 -0
  24. package/dist/custom/exporters/raw.d.ts +8 -0
  25. package/dist/custom/exporters/raw.js +6 -0
  26. package/dist/custom/exporters/raw.js.map +1 -0
  27. package/dist/custom.d.ts +58 -0
  28. package/dist/custom.js +299 -0
  29. package/dist/custom.js.map +1 -0
  30. package/dist/development.d.ts +19 -0
  31. package/dist/development.js +55 -0
  32. package/dist/development.js.map +1 -0
  33. package/dist/event-export-manager-DEB64LWZ.js +632 -0
  34. package/dist/event-export-manager-DEB64LWZ.js.map +1 -0
  35. package/dist/index.d.ts +26 -0
  36. package/dist/index.js +205 -0
  37. package/dist/index.js.map +1 -0
  38. package/dist/monitors-VNNUIKAK.js +753 -0
  39. package/dist/monitors-VNNUIKAK.js.map +1 -0
  40. package/dist/n1-detector-6IQ2DINP.js +247 -0
  41. package/dist/n1-detector-6IQ2DINP.js.map +1 -0
  42. package/dist/observability.d.ts +32 -0
  43. package/dist/observability.js +76 -0
  44. package/dist/observability.js.map +1 -0
  45. package/dist/ports-DwUYdKj-.d.ts +23 -0
  46. package/dist/production.d.ts +19 -0
  47. package/dist/production.js +42 -0
  48. package/dist/production.js.map +1 -0
  49. package/dist/public/types.d.ts +11 -0
  50. package/dist/public/types.js +3 -0
  51. package/dist/public/types.js.map +1 -0
  52. package/package.json +74 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/performance/features/exporters/http-ndjson-exporter.ts"],"names":[],"mappings":";;;;AAwBA,IAAM,mCAAmB,IAAI,GAAA,CAAI,CAAC,gBAAA,EAAkB,MAAA,EAAQ,mBAAmB,CAAC,CAAA;AAChF,IAAM,gBAAA,GAAmB,GAAA;AACzB,IAAM,sBAAA,GAAyB,IAAA;AAC/B,IAAM,cAAA,GAAiB,IAAA;AACvB,IAAM,mBAAA,GAAsB,GAAA;AAErB,SAAS,yCACf,OAAA,EAC+B;AAC/B,EAAA,MAAM,UAAA,GAAa,kBAAA;AAAA,IAClB,OAAA;AAAA,wBACI,GAAA,CAAI,CAAC,OAAO,SAAA,EAAW,WAAA,EAAa,WAAW,CAAC,CAAA;AAAA,IACpD;AAAA,GACD;AACA,EAAA,MAAM,EAAC,GAAA,EAAK,MAAA,EAAQ,OAAA,EAAS,UAAA,GAAa,EAAC,EAAG,SAAA,EAAW,QAAA,EAAU,SAAA,EAAW,UAAA,EAAU,GAAI,UAAA;AAC5F,EAAA,IAAI,OAAO,WAAW,QAAA,IAAY,MAAA,CAAO,WAAW,CAAA,IAAK,MAAA,CAAO,SAAS,cAAA,EAAgB;AACxF,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,sEAAA,EAAyE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AO,MAAA,CAAO,IAAI,CAAA;AAC5D,IAAA,IAAI,SAAA,GAAY,CAAA;AAChB,IAAA,MAAM,OAAA,GAAU,SAAS,IAAA,IAAQ,gBAAA;AACjC,IAAA,KAAA,MAAW,OAAO,KAAA,EAAO;AACxB,MAAA,IAAI,SAAA,IAAa,OAAA,EAAS,MAAM,IAAI,SAAA,EAAU;AAC9C,MAAA,MAAM,UAAA,GAAa,MAAA,CAAO,wBAAA,CAAyB,KAAA,EAAO,GAAG,CAAA;AAC7D,MAAA,IAAI,IAAI,MAAA,IAAU,OAAA,GAAU,KAAK,GAAA,CAAA,IAAQ,CAAC,YAAY,UAAA,IAAc,EAAE,WAAW,UAAA,CAAA,IAC5E,OAAA,IAAW,CAAC,OAAA,CAAQ,GAAA,CAAI,GAAG,CAAA,EAAI,MAAM,IAAI,SAAA,EAAU;AACxD,MAAA,SAAA,IAAa,CAAA;AACb,MAAA,QAAA,CAAS,GAAG,IAAI,UAAA,CAAW,KAAA;AAAA,IAC5B;AACA,IAAA,OAAO,MAAA,CAAO,OAAO,QAAQ,CAAA;AAAA,EAC9B,CAAA,CAAA,MAAQ;AAAE,IAAA,MAAM,IAAI,SAAA,CAAU,CAAA,EAAG,KAAK,CAAA,mCAAA,CAAqC,CAAA;AAAA,EAAE;AAC9E","file":"http.js","sourcesContent":["import type {PerformanceEventRecord} from '@ooopsstudio/core/contracts/performance'\nimport type {PerformanceEventExporterPort} from '@ooopsstudio/core/ports/performance'\nimport {byteSize} from '@ooopsstudio/core/utils/byte-size'\n\nimport {\n\tMAX_PERFORMANCE_EXPORT_BATCH_BYTES,\n\tMAX_PERFORMANCE_EXPORT_BATCH_COUNT,\n\tserializePerformanceEventRecord\n} from '../../core/event-export-utils'\nimport {classifyFetchFailure, classifyHttpStatus, createPerformanceExportError} from '../../core/export-errors'\nimport {\n\thasSafeRuntimePrototype,\n\tignoreRuntimePromiseRejection,\n\tisRuntimePromise,\n\tisRuntimeProxy\n} from '../../utils/safe-object'\n\nexport interface HttpNdjsonPerformanceEventExporterOptions {\n\turl: string\n\theaders?: Record<string, string>\n\tfetchImpl?: typeof fetch\n\ttimeoutMs?: number\n}\n\nconst RESERVED_HEADERS = new Set(['content-length', 'host', 'transfer-encoding'])\nconst MAX_HEADER_COUNT = 100\nconst MAX_HEADER_VALUE_BYTES = 8_192\nconst MAX_URL_LENGTH = 4_096\nconst MAX_HTTP_TIMEOUT_MS = 30_000\n\nexport function createHttpNdjsonPerformanceEventExporter(\n\toptions: HttpNdjsonPerformanceEventExporterOptions\n): PerformanceEventExporterPort {\n\tconst configured = snapshotDataObject(\n\t\toptions,\n\t\tnew Set(['url', 'headers', 'fetchImpl', 'timeoutMs']),\n\t\t'Performance NDJSON exporter options'\n\t)\n\tconst {url: rawUrl, headers: rawHeaders = {}, fetchImpl: rawFetch, timeoutMs: rawTimeout} = configured\n\tif (typeof rawUrl !== 'string' || rawUrl.length === 0 || rawUrl.length > MAX_URL_LENGTH) {\n\t\tthrow new Error(`Performance NDJSON exporter URL must be a non-empty string of at most ${MAX_URL_LENGTH} characters`)\n\t}\n\tlet parsedUrl: URL\n\ttry { parsedUrl = new URL(rawUrl) } catch { throw new Error('Performance NDJSON exporter URL must be a valid URL') }\n\tif (parsedUrl.protocol !== 'http:' && parsedUrl.protocol !== 'https:') {\n\t\tthrow new Error('Performance NDJSON exporter URL must use HTTP or HTTPS')\n\t}\n\tconst hostname = parsedUrl.hostname.toLowerCase().replace(/^\\[|\\]$/gu, '').replace(/\\.+$/u, '')\n\tconst loopback = hostname === 'localhost' || hostname.endsWith('.localhost') || hostname === '::1'\n\t\t|| /^127(?:\\.\\d{1,3}){3}$/u.test(hostname)\n\tif (parsedUrl.protocol === 'http:' && !loopback) {\n\t\tthrow new Error('Performance NDJSON exporter remote URLs must use HTTPS')\n\t}\n\tif (parsedUrl.username || parsedUrl.password) {\n\t\tthrow new Error('Performance NDJSON exporter URL must not contain credentials; use headers instead')\n\t}\n\tif (parsedUrl.search || parsedUrl.hash) {\n\t\tthrow new Error('Performance NDJSON exporter URL must not contain query parameters or fragments')\n\t}\n\tconst timeoutMs = rawTimeout ?? 5_000\n\tif (typeof timeoutMs !== 'number' || !Number.isSafeInteger(timeoutMs)\n\t\t|| timeoutMs <= 0 || timeoutMs > MAX_HTTP_TIMEOUT_MS) {\n\t\tthrow new Error(`Performance NDJSON exporter timeoutMs must be between 1 and ${MAX_HTTP_TIMEOUT_MS}`)\n\t}\n\n\tconst configuredFetch = rawFetch ?? globalThis.fetch\n\tif (typeof configuredFetch !== 'function') {\n\t\tthrow new Error('Performance NDJSON exporter requires a fetch implementation')\n\t}\n\tconst fetchImpl = configuredFetch as typeof fetch\n\tconst url = parsedUrl.toString()\n\tconst headers = Object.fromEntries(Object.entries(snapshotHeaders(rawHeaders))\n\t\t.filter(([name]) => name.toLowerCase() !== 'content-type'))\n\ttype ActiveRequest = {\n\t\tbody: string\n\t\tcontroller: AbortController\n\t\tpromise: Promise<Response>\n\t\tinvocation?: Promise<void>\n\t\tsettled: 0 | 1 | 2 // pending | reusable success | failure\n\t\ttimedOut: boolean\n\t}\n\tlet activeRequest: ActiveRequest | undefined\n\tlet pendingBodyDisposal: Promise<unknown> | undefined\n\tlet bodyDisposalDisabled = false\n\tconst disposeResponse = (response: Response | undefined): void => {\n\t\tif (pendingBodyDisposal || bodyDisposalDisabled) return\n\t\tconst disposal = disposeResponseBody(response)\n\t\tif (!disposal) return\n\t\tpendingBodyDisposal = disposal\n\t\tlet cleanupTimeout: ReturnType<typeof setTimeout> | undefined\n\t\tconst release = () => {\n\t\t\tif (pendingBodyDisposal !== disposal) return\n\t\t\tpendingBodyDisposal = undefined\n\t\t\tif (cleanupTimeout !== undefined) {\n\t\t\t\ttry { clearTimeout(cleanupTimeout) } catch { /* cleanup settlement remains authoritative */ }\n\t\t\t\tcleanupTimeout = undefined\n\t\t\t}\n\t\t}\n\t\ttry {\n\t\t\tcleanupTimeout = setTimeout(() => {\n\t\t\t\tif (pendingBodyDisposal !== disposal) return\n\t\t\t\tbodyDisposalDisabled = true\n\t\t\t\trelease()\n\t\t\t}, timeoutMs)\n\t\t\ttry { cleanupTimeout.unref?.() } catch { /* optional process-lifetime optimization */ }\n\t\t} catch {\n\t\t\tbodyDisposalDisabled = true\n\t\t\trelease()\n\t\t}\n\t\ttry { void Reflect.apply(Promise.prototype.then, disposal, [release, release]) } catch { release() }\n\t}\n\tlet exportInvocationActive = false\n\n\tconst exportBatch = async(batch: ReadonlyArray<PerformanceEventRecord>): Promise<void> => {\n\t\tif (pendingBodyDisposal) {\n\t\t\tthrow createPerformanceExportError('A performance response cleanup is still active', {\n\t\t\t\tretryable: true,\n\t\t\t\tcode: 'fetch_aborted'\n\t\t\t})\n\t\t}\n\t\tlet body: string\n\t\ttry {\n\t\t\tif (!Array.isArray(batch)) throw new TypeError()\n\t\t\tconst lengthDescriptor = Object.getOwnPropertyDescriptor(batch, 'length')\n\t\t\tconst batchLength = lengthDescriptor && 'value' in lengthDescriptor ? lengthDescriptor.value : undefined\n\t\t\tif (!Number.isSafeInteger(batchLength) || batchLength < 0 ||\n\t\t\t\t\tbatchLength > MAX_PERFORMANCE_EXPORT_BATCH_COUNT) throw new TypeError()\n\t\t\tif (batchLength === 0) return\n\t\t\tconst lines: string[] = []\n\t\t\tlet serializedBytes = 0\n\t\t\tfor (let index = 0; index < batchLength; index += 1) {\n\t\t\t\tconst descriptor = Object.getOwnPropertyDescriptor(batch, String(index))\n\t\t\t\tif (!descriptor?.enumerable || !('value' in descriptor)) throw new TypeError()\n\t\t\t\tconst snapshot = serializePerformanceEventRecord(descriptor.value as PerformanceEventRecord)\n\t\t\t\tif (!snapshot) throw new TypeError('Invalid performance event record')\n\t\t\t\tserializedBytes += snapshot.bytes + 1\n\t\t\t\tif (serializedBytes > MAX_PERFORMANCE_EXPORT_BATCH_BYTES) throw new TypeError()\n\t\t\t\tlines.push(snapshot.serialized)\n\t\t\t}\n\t\t\tbody = `${lines.join('\\n')}\\n`\n\t\t} catch(error) {\n\t\t\tthrow createPerformanceExportError('Performance event serialization failed', {\n\t\t\t\tretryable: false,\n\t\t\t\tcode: 'event_serialization_failed',\n\t\t\t\tcause: error\n\t\t\t})\n\t\t}\n\t\tlet slot = activeRequest\n\t\t// A transport may acknowledge AbortController asynchronously, after the\n\t\t// invocation timeout has already returned. Keep late successes reusable to\n\t\t// avoid duplicate delivery, but never spend a retry on a settled rejection.\n\t\tif (slot?.settled === 2) activeRequest = slot = undefined\n\t\tif (slot && slot.body !== body) {\n\t\t\tif (slot.settled) activeRequest = slot = undefined\n\t\t\telse {\n\t\t\t\tthrow createPerformanceExportError('A previous performance export is still active', {\n\t\t\t\t\tretryable: true,\n\t\t\t\t\tcode: 'fetch_aborted'\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\tif (!slot) {\n\t\t\tconst controller = new AbortController()\n\t\t\tconst pending: ActiveRequest = {\n\t\t\t\tbody,\n\t\t\t\tcontroller,\n\t\t\t\tpromise: undefined as unknown as Promise<Response>,\n\t\t\t\tsettled: 0,\n\t\t\t\ttimedOut: false\n\t\t\t}\n\t\t\tconst request = Promise.resolve().then(() => {\n\t\t\t\tconst result = fetchImpl(url, {\n\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\theaders: {\n\t\t\t\t\t\t...headers,\n\t\t\t\t\t\t'content-type': 'application/x-ndjson'\n\t\t\t\t\t},\n\t\t\t\t\tbody,\n\t\t\t\t\tsignal: controller.signal,\n\t\t\t\t\t// Collector headers can contain credentials. Never forward them to\n\t\t\t\t\t// a redirected destination chosen by the remote endpoint.\n\t\t\t\t\tredirect: 'error'\n\t\t\t\t})\n\t\t\t\tif (!isRuntimePromise(result)) {\n\t\t\t\t\tthrow createPerformanceExportError('', {\n\t\t\t\t\t\tretryable: false, code: 'invalid_fetch_response'\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\treturn result\n\t\t\t})\n\t\t\tpending.promise = request\n\t\t\tslot = pending\n\t\t\tactiveRequest = pending\n\t\t\tvoid request.then(\n\t\t\t\t(lateResponse) => {\n\t\t\t\t\tpending.settled = pending.timedOut && !snapshotValidResponse(lateResponse)?.ok ? 2 : 1\n\t\t\t\t\tif (pending.timedOut) {\n\t\t\t\t\t\tdisposeResponse(lateResponse)\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t() => {\n\t\t\t\t\tpending.settled = 2\n\t\t\t\t}\n\t\t\t)\n\t\t}\n\t\tconst ownedSlot = slot\n\t\tif (ownedSlot.invocation) {\n\t\t\tthrow createPerformanceExportError('A performance export invocation is already active', {\n\t\t\t\tretryable: true,\n\t\t\t\tcode: 'fetch_aborted'\n\t\t\t})\n\t\t}\n\t\tconst invocation = (async() => {\n\t\t\tlet rejectTimeout!: (error: unknown) => void\n\t\t\tconst timeoutFailure = new Promise<never>((_resolve, reject) => { rejectTimeout = reject })\n\t\t\tconst timeout = setTimeout(() => {\n\t\t\t\tif (!ownedSlot.timedOut) {\n\t\t\t\t\townedSlot.timedOut = true\n\t\t\t\t\ttry { ignoreRuntimePromiseRejection(ownedSlot.controller.abort()) } catch { /* timeout remains authoritative */ }\n\t\t\t\t}\n\t\t\t\trejectTimeout(createPerformanceExportError('Performance NDJSON export timed out', {\n\t\t\t\t\tretryable: true,\n\t\t\t\t\tcode: 'fetch_aborted'\n\t\t\t\t}))\n\t\t\t}, timeoutMs)\n\t\t\tlet response: Response | undefined\n\t\t\ttry {\n\t\t\t\tconst fetchedResponse = await Promise.race([ownedSlot.promise, timeoutFailure])\n\t\t\t\tif (activeRequest === ownedSlot) activeRequest = undefined\n\t\t\t\tresponse = fetchedResponse\n\t\t\t\tconst responseSnapshot = snapshotValidResponse(fetchedResponse)\n\t\t\t\tif (!responseSnapshot) {\n\t\t\t\t\tthrow createPerformanceExportError('Performance NDJSON exporter received an invalid response', {\n\t\t\t\t\t\tretryable: false, code: 'invalid_fetch_response'\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\tconst {ok, status} = responseSnapshot\n\t\t\t\tif (!ok) {\n\t\t\t\t\tconst statusCode = status as number\n\t\t\t\t\tconst classification = classifyHttpStatus(statusCode)\n\t\t\t\t\tthrow createPerformanceExportError(\n\t\t\t\t\t\t`NDJSON performance export failed with status ${statusCode}`,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tstatusCode,\n\t\t\t\t\t\t\t...classification\n\t\t\t\t\t\t}\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t} catch(error) {\n\t\t\t\tif (ownedSlot.settled && activeRequest === ownedSlot) activeRequest = undefined\n\t\t\t\tthrow classifyFetchFailure(error)\n\t\t\t} finally {\n\t\t\t\ttry { clearTimeout(timeout) } catch { /* response disposal remains authoritative */ }\n\t\t\t\tdisposeResponse(response)\n\t\t\t}\n\t\t})()\n\t\townedSlot.invocation = invocation\n\t\ttry {\n\t\t\tawait invocation\n\t\t} finally {\n\t\t\tif (ownedSlot.invocation === invocation) ownedSlot.invocation = undefined\n\t\t}\n\t}\n\treturn {\n\t\texport(batch) {\n\t\t\tif (exportInvocationActive) {\n\t\t\t\treturn Promise.reject(createPerformanceExportError('A performance export invocation is already active', {\n\t\t\t\t\tretryable: true,\n\t\t\t\t\tcode: 'fetch_aborted'\n\t\t\t\t}))\n\t\t\t}\n\t\t\texportInvocationActive = true\n\t\t\tconst operation = exportBatch(batch)\n\t\t\tconst release = () => { exportInvocationActive = false }\n\t\t\ttry { void Reflect.apply(Promise.prototype.then, operation, [release, release]) } catch { release() }\n\t\t\treturn operation\n\t\t}\n\t}\n}\n\nfunction disposeResponseBody(response: Response | undefined): Promise<unknown> | undefined {\n\ttry {\n\t\tif (!response || isRuntimeProxy(response)) return\n\t\tconst body = readResponseProperty(response, 'body')\n\t\tif (!body || (typeof body !== 'object' && typeof body !== 'function') || isRuntimeProxy(body)) return\n\t\tlet owner: object | null = body\n\t\tlet cancel: ((...args: never[]) => unknown) | undefined\n\t\tfor (let depth = 0; owner && depth < 8; depth += 1) {\n\t\t\tif (isRuntimeProxy(owner)) return\n\t\t\tconst descriptor = Object.getOwnPropertyDescriptor(owner, 'cancel')\n\t\t\tif (descriptor) {\n\t\t\t\tif ('value' in descriptor && typeof descriptor.value === 'function') cancel = descriptor.value\n\t\t\t\tbreak\n\t\t\t}\n\t\t\towner = Object.getPrototypeOf(owner) as object | null\n\t\t}\n\t\tconst disposal = cancel ? Reflect.apply(cancel, body, []) : undefined\n\t\treturn isRuntimePromise(disposal) ? disposal as Promise<unknown> : undefined\n\t} catch { /* response disposal is best-effort */ }\n}\n\nfunction readResponseProperty(response: object, key: 'ok' | 'status' | 'body'): unknown {\n\tconst descriptor = Object.getOwnPropertyDescriptor(response, key)\n\tif (descriptor) return 'value' in descriptor ? descriptor.value : undefined\n\tif (typeof Response === 'undefined' || !hasSafeRuntimePrototype(response, Response.prototype)) return undefined\n\tconst getter = Object.getOwnPropertyDescriptor(Response.prototype, key)?.get\n\treturn typeof getter === 'function' ? Reflect.apply(getter, response, []) : undefined\n}\n\nfunction snapshotValidResponse(value: unknown): {ok: boolean; status: number} | undefined {\n\tif (!value || typeof value !== 'object' || isRuntimeProxy(value)) return undefined\n\ttry {\n\t\tconst ok = readResponseProperty(value, 'ok')\n\t\tconst status = readResponseProperty(value, 'status')\n\t\tif (typeof ok !== 'boolean' || !Number.isInteger(status)\n\t\t\t|| (status as number) < 100 || (status as number) > 599) return undefined\n\t\tconst validStatus = status as number\n\t\treturn ok === (validStatus >= 200 && validStatus < 300) ? {ok, status: validStatus} : undefined\n\t} catch { return undefined }\n}\n\nfunction snapshotHeaders(value: unknown): Readonly<Record<string, string>> {\n\tconst headers = snapshotDataObject(value, undefined, 'Performance NDJSON exporter headers')\n\tif (Object.keys(headers).length > MAX_HEADER_COUNT) {\n\t\tthrow new Error(`Performance NDJSON exporter headers must contain at most ${MAX_HEADER_COUNT} values`)\n\t}\n\tconst snapshot: Record<string, string> = Object.create(null) as Record<string, string>\n\tconst normalizedNames = new Set<string>()\n\tfor (const [name, headerValue] of Object.entries(headers)) {\n\t\tif (!/^[!#$%&'*+\\-.^_`|~0-9A-Za-z]{1,256}$/u.test(name)) {\n\t\t\tthrow new Error('Performance NDJSON exporter header names must be valid HTTP tokens')\n\t\t}\n\t\tif (typeof headerValue !== 'string') {\n\t\t\tthrow new Error(`Header value for \"${name}\" must be a string`)\n\t\t}\n\t\tif (headerValue.length > MAX_HEADER_VALUE_BYTES || byteSize(headerValue) > MAX_HEADER_VALUE_BYTES || /[\\0\\r\\n]/u.test(headerValue)) {\n\t\t\tthrow new Error(`Performance NDJSON exporter header value for \"${name}\" is invalid`)\n\t\t}\n\t\tif (RESERVED_HEADERS.has(name.toLowerCase())) {\n\t\t\tthrow new Error(`Performance NDJSON exporter header \"${name}\" is managed by the HTTP transport`)\n\t\t}\n\t\tconst normalizedName = name.toLowerCase()\n\t\tif (normalizedNames.has(normalizedName)) {\n\t\t\tthrow new Error(`Performance NDJSON exporter header \"${name}\" is duplicated case-insensitively`)\n\t\t}\n\t\tnormalizedNames.add(normalizedName)\n\t\tsnapshot[name] = headerValue\n\t}\n\treturn Object.freeze(snapshot)\n}\n\nfunction snapshotDataObject(\n\tvalue: unknown,\n\tallowed: ReadonlySet<string> | undefined,\n\tlabel: string\n): Readonly<Record<string, unknown>> {\n\ttry {\n\t\tif (!value || typeof value !== 'object' || isRuntimeProxy(value) || Array.isArray(value)) throw new TypeError()\n\t\tconst prototype = Object.getPrototypeOf(value)\n\t\tif (prototype !== Object.prototype && prototype !== null) throw new TypeError()\n\t\tif (Object.getOwnPropertySymbols(value).length > 0) throw new TypeError()\n\t\tconst snapshot: Record<string, unknown> = Object.create(null) as Record<string, unknown>\n\t\tlet inspected = 0\n\t\tconst maximum = allowed?.size ?? MAX_HEADER_COUNT\n\t\tfor (const key in value) {\n\t\t\tif (inspected >= maximum) throw new TypeError()\n\t\t\tconst descriptor = Object.getOwnPropertyDescriptor(value, key)\n\t\t\tif (key.length > (allowed ? 64 : 256) || !descriptor?.enumerable || !('value' in descriptor)\n\t\t\t\t|| (allowed && !allowed.has(key))) throw new TypeError()\n\t\t\tinspected += 1\n\t\t\tsnapshot[key] = descriptor.value\n\t\t}\n\t\treturn Object.freeze(snapshot)\n\t} catch { throw new TypeError(`${label} must be a closed plain data object`) }\n}\n"]}
@@ -0,0 +1,8 @@
1
+ import { PerformanceEventExporterPort } from '@ooopsstudio/core/ports/performance';
2
+ export { PerformanceEventExporterPort } from '@ooopsstudio/core/ports/performance';
3
+ export { PerformanceEventRecord } from '@ooopsstudio/core/contracts/performance';
4
+
5
+ /** Type-safe identity helper for custom raw performance exporters. */
6
+ declare const definePerformanceEventExporter: <T extends PerformanceEventExporterPort>(exporter: T) => T;
7
+
8
+ export { definePerformanceEventExporter };
@@ -0,0 +1,6 @@
1
+ // src/performance/public/custom-exporters-raw.ts
2
+ var definePerformanceEventExporter = (exporter) => exporter;
3
+
4
+ export { definePerformanceEventExporter };
5
+ //# sourceMappingURL=raw.js.map
6
+ //# sourceMappingURL=raw.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/performance/public/custom-exporters-raw.ts"],"names":[],"mappings":";AAMO,IAAM,8BAAA,GAAiC,CAAyC,QAAA,KAAmB","file":"raw.js","sourcesContent":["export type {PerformanceEventExporterPort} from '@ooopsstudio/core/ports/performance'\nexport type {PerformanceEventRecord} from '@ooopsstudio/core/contracts/performance'\n\nimport type {PerformanceEventExporterPort} from '@ooopsstudio/core/ports/performance'\n\n/** Type-safe identity helper for custom raw performance exporters. */\nexport const definePerformanceEventExporter = <T extends PerformanceEventExporterPort>(exporter: T): T => exporter\n"]}
@@ -0,0 +1,58 @@
1
+ import { Clock } from '@ooopsstudio/core/contracts/clock';
2
+ import { ObservabilityResource } from '@ooopsstudio/core/contracts/observability-shared';
3
+ import { Errors } from '@ooopsstudio/core/ports/errors';
4
+ import { LifecyclePort } from '@ooopsstudio/core/ports/lifecycle';
5
+ import { PerformanceEventExporterPort } from '@ooopsstudio/core/ports/performance';
6
+ import { Tracing } from '@ooopsstudio/core/ports/tracing';
7
+ import { M as ManagedPerformance } from './ports-DwUYdKj-.js';
8
+ import '@ooopsstudio/core/contracts/performance';
9
+
10
+ interface BudgetConfig {
11
+ name: string;
12
+ pattern?: string;
13
+ percentile?: number;
14
+ target: number;
15
+ window: number;
16
+ }
17
+
18
+ interface N1DetectorOptions {
19
+ timeWindowMs?: number;
20
+ minDuplicates?: number;
21
+ maxTrackedTraces?: number;
22
+ maxEventsPerTrace?: number;
23
+ enabled: true;
24
+ }
25
+
26
+ type PerformanceBudgetDefinition = BudgetConfig;
27
+ type PerformanceEventExporter = PerformanceEventExporterPort;
28
+ interface CustomPerformanceOptions {
29
+ clock?: Clock;
30
+ resource?: ObservabilityResource;
31
+ errors?: Errors;
32
+ tracer?: Tracing;
33
+ lifecycle?: LifecyclePort;
34
+ budgets?: readonly PerformanceBudgetDefinition[];
35
+ n1Detection?: N1DetectorOptions;
36
+ runtimeMonitoring?: {
37
+ eventLoop?: boolean;
38
+ gc?: boolean;
39
+ resources?: boolean;
40
+ };
41
+ destinations?: ReadonlyArray<{
42
+ name: string;
43
+ exporter: PerformanceEventExporter;
44
+ }>;
45
+ delivery?: {
46
+ maxQueueRecords?: number;
47
+ maxQueueBytes?: number;
48
+ flushIntervalMs?: number;
49
+ retry?: {
50
+ attempts?: number;
51
+ baseDelayMs?: number;
52
+ };
53
+ operationTimeoutMs?: number;
54
+ };
55
+ }
56
+ declare function createCustomPerformance(options: CustomPerformanceOptions): Promise<ManagedPerformance>;
57
+
58
+ export { type CustomPerformanceOptions, type PerformanceBudgetDefinition, type PerformanceEventExporter, createCustomPerformance };
package/dist/custom.js ADDED
@@ -0,0 +1,299 @@
1
+ import { createBasePerformanceHandler, toPerformanceEventRecord, registerPerformanceLifecycleCleanup, failPerformanceSetup } from './chunk-ZAXGEDZW.js';
2
+ import './chunk-RY65GERM.js';
3
+ import { isSensitivePerformanceKey, sanitizePerformanceLabelValue } from './chunk-2XXIOHOO.js';
4
+ import { isResourceSnapshotEvent } from './chunk-J6KBSLYO.js';
5
+ import './chunk-MMO5UEUU.js';
6
+ import { isRuntimeProxy } from './chunk-RL2752FW.js';
7
+ import { createSystemClock } from '@ooopsstudio/core/runtime/time/system-clock';
8
+
9
+ var CUSTOM_FIELDS = /* @__PURE__ */ new Set([
10
+ "clock",
11
+ "resource",
12
+ "errors",
13
+ "tracer",
14
+ "lifecycle",
15
+ "budgets",
16
+ "n1Detection",
17
+ "runtimeMonitoring",
18
+ "destinations",
19
+ "delivery"
20
+ ]);
21
+ var BUDGET_FIELDS = /* @__PURE__ */ new Set(["name", "pattern", "percentile", "target", "window"]);
22
+ var N1_FIELDS = /* @__PURE__ */ new Set(["enabled", "timeWindowMs", "minDuplicates", "maxTrackedTraces", "maxEventsPerTrace"]);
23
+ var MONITOR_FIELDS = /* @__PURE__ */ new Set(["eventLoop", "gc", "resources"]);
24
+ var DELIVERY_FIELDS = /* @__PURE__ */ new Set(["maxQueueRecords", "maxQueueBytes", "flushIntervalMs", "retry", "operationTimeoutMs"]);
25
+ var RETRY_FIELDS = /* @__PURE__ */ new Set(["attempts", "baseDelayMs"]);
26
+ var DESTINATION_FIELDS = /* @__PURE__ */ new Set(["name", "exporter"]);
27
+ var snapshotClosed = (value, allowed, label) => {
28
+ try {
29
+ if (!value || typeof value !== "object" || isRuntimeProxy(value) || Array.isArray(value)) throw new TypeError();
30
+ const prototype = Object.getPrototypeOf(value);
31
+ if (prototype !== Object.prototype && prototype !== null) throw new TypeError();
32
+ if (Object.getOwnPropertySymbols(value).length > 0) throw new TypeError();
33
+ const result = /* @__PURE__ */ Object.create(null);
34
+ let inspected = 0;
35
+ for (const key in value) {
36
+ if (inspected >= allowed.size) throw new TypeError();
37
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
38
+ if (key.length > 64 || !descriptor?.enumerable || !("value" in descriptor) || !allowed.has(key)) {
39
+ throw new TypeError();
40
+ }
41
+ inspected += 1;
42
+ result[key] = descriptor.value;
43
+ }
44
+ return Object.freeze(result);
45
+ } catch {
46
+ throw new TypeError(`${label} must be a closed plain data object`);
47
+ }
48
+ };
49
+ var snapshotArray = (value, maximum, label) => {
50
+ if (isRuntimeProxy(value) || !Array.isArray(value)) throw new TypeError(`${label} must be an array`);
51
+ let lengthDescriptor;
52
+ try {
53
+ lengthDescriptor = Object.getOwnPropertyDescriptor(value, "length");
54
+ } catch {
55
+ throw new TypeError(`${label} must contain stable data items`);
56
+ }
57
+ const length = lengthDescriptor && "value" in lengthDescriptor ? lengthDescriptor.value : void 0;
58
+ if (!Number.isSafeInteger(length) || length < 0 || length > maximum) {
59
+ throw new Error(`${label} supports at most ${maximum === 2 ? "two" : maximum} items`);
60
+ }
61
+ const result = [];
62
+ for (let index = 0; index < length; index += 1) {
63
+ let descriptor;
64
+ try {
65
+ descriptor = Object.getOwnPropertyDescriptor(value, String(index));
66
+ } catch {
67
+ throw new TypeError(`${label} must contain stable data items`);
68
+ }
69
+ if (!descriptor?.enumerable || !("value" in descriptor)) {
70
+ throw new TypeError(`${label} must contain stable data items`);
71
+ }
72
+ result.push(descriptor.value);
73
+ }
74
+ return Object.freeze(result);
75
+ };
76
+ var captureExporterMethod = (exporter, key) => {
77
+ if (isRuntimeProxy(exporter) || (!exporter || typeof exporter !== "object") && typeof exporter !== "function") return void 0;
78
+ try {
79
+ let owner = exporter;
80
+ for (let depth = 0; owner && depth < 16; depth += 1) {
81
+ if (isRuntimeProxy(owner)) return void 0;
82
+ const descriptor = Object.getOwnPropertyDescriptor(owner, key);
83
+ if (descriptor) {
84
+ if (!("value" in descriptor) || typeof descriptor.value !== "function") return void 0;
85
+ const method = descriptor.value;
86
+ return (...args) => Reflect.apply(method, exporter, args);
87
+ }
88
+ owner = Object.getPrototypeOf(owner);
89
+ }
90
+ } catch {
91
+ return void 0;
92
+ }
93
+ return void 0;
94
+ };
95
+ var hasExporterMethodField = (exporter, key) => {
96
+ if (isRuntimeProxy(exporter) || (!exporter || typeof exporter !== "object") && typeof exporter !== "function") return false;
97
+ try {
98
+ let owner = exporter;
99
+ for (let depth = 0; owner && depth < 16; depth += 1) {
100
+ if (isRuntimeProxy(owner)) return true;
101
+ if (Object.getOwnPropertyDescriptor(owner, key)) return true;
102
+ owner = Object.getPrototypeOf(owner);
103
+ }
104
+ } catch {
105
+ return true;
106
+ }
107
+ return false;
108
+ };
109
+ var snapshotDestination = (value) => {
110
+ const destination = snapshotClosed(value, DESTINATION_FIELDS, "Custom performance destination");
111
+ const exportBatch = captureExporterMethod(destination.exporter, "export");
112
+ const flush = captureExporterMethod(destination.exporter, "flush");
113
+ const shutdown = captureExporterMethod(destination.exporter, "shutdown");
114
+ if (!exportBatch) throw new TypeError("Custom performance destination exporter must provide export()");
115
+ if (hasExporterMethodField(destination.exporter, "flush") && !flush || hasExporterMethodField(destination.exporter, "shutdown") && !shutdown) {
116
+ throw new TypeError("Custom performance destination lifecycle hooks must be data-method functions");
117
+ }
118
+ return Object.freeze({
119
+ name: destination.name,
120
+ exporter: Object.freeze({
121
+ export: exportBatch,
122
+ ...flush ? { flush } : {},
123
+ ...shutdown ? { shutdown } : {}
124
+ })
125
+ });
126
+ };
127
+ var snapshotResource = (value) => {
128
+ if (value === void 0) return void 0;
129
+ const resource = snapshotClosed(
130
+ value,
131
+ /* @__PURE__ */ new Set(["serviceName", "serviceVersion", "deploymentEnvironment", "hostKind", "runtime", "attributes"]),
132
+ "Performance resource"
133
+ );
134
+ if (typeof resource.serviceName !== "string" || resource.serviceName.length > 128 || !resource.serviceName.trim()) {
135
+ throw new TypeError("Performance resource serviceName must be a non-empty string of at most 128 characters");
136
+ }
137
+ const result = { serviceName: resource.serviceName };
138
+ for (const key of ["serviceVersion", "deploymentEnvironment", "hostKind", "runtime"]) {
139
+ const field = resource[key];
140
+ if (field !== void 0) {
141
+ if (typeof field !== "string" || field.length > 256) throw new TypeError(`Performance resource ${key} is invalid`);
142
+ Object.assign(result, { [key]: field });
143
+ }
144
+ }
145
+ if (resource.attributes !== void 0) {
146
+ let remainingNodes = 128;
147
+ let remainingCharacters = 8192;
148
+ const capture = (current, key, depth) => {
149
+ if (key.length > 128) throw new TypeError("Performance resource attribute keys must be at most 128 characters");
150
+ if (isSensitivePerformanceKey(key)) return "[redacted]";
151
+ if (typeof current === "string") {
152
+ const bounded = current.slice(0, Math.min(256, remainingCharacters));
153
+ remainingCharacters -= bounded.length;
154
+ return sanitizePerformanceLabelValue(bounded);
155
+ }
156
+ if (typeof current === "number") return Number.isFinite(current) ? current : void 0;
157
+ if (typeof current === "boolean" || current === null) return current;
158
+ if (!current || typeof current !== "object" || isRuntimeProxy(current) || depth >= 8 || remainingNodes-- <= 0) return void 0;
159
+ if (Array.isArray(current)) {
160
+ const values = [];
161
+ let lengthDescriptor;
162
+ try {
163
+ lengthDescriptor = Object.getOwnPropertyDescriptor(current, "length");
164
+ } catch {
165
+ return void 0;
166
+ }
167
+ const length = lengthDescriptor && "value" in lengthDescriptor && Number.isSafeInteger(lengthDescriptor.value) ? Math.min(32, lengthDescriptor.value) : 0;
168
+ for (let index = 0; index < length; index += 1) {
169
+ let descriptor;
170
+ try {
171
+ descriptor = Object.getOwnPropertyDescriptor(current, String(index));
172
+ } catch {
173
+ return void 0;
174
+ }
175
+ if (descriptor && "value" in descriptor) values.push(capture(descriptor.value, key, depth + 1));
176
+ }
177
+ return Object.freeze(values);
178
+ }
179
+ let prototype;
180
+ try {
181
+ prototype = Object.getPrototypeOf(current);
182
+ } catch {
183
+ return void 0;
184
+ }
185
+ if (prototype !== Object.prototype && prototype !== null) return void 0;
186
+ const result2 = /* @__PURE__ */ Object.create(null);
187
+ let inspected = 0;
188
+ for (const childKey in current) {
189
+ if (inspected >= 64) break;
190
+ let descriptor;
191
+ try {
192
+ descriptor = Object.getOwnPropertyDescriptor(current, childKey);
193
+ } catch {
194
+ return void 0;
195
+ }
196
+ if (!descriptor?.enumerable || !("value" in descriptor)) continue;
197
+ inspected += 1;
198
+ const captured = capture(descriptor.value, childKey, depth + 1);
199
+ if (captured !== void 0) result2[childKey] = captured;
200
+ }
201
+ return Object.freeze(result2);
202
+ };
203
+ const attributes = capture(resource.attributes, "attributes", 0);
204
+ if (!attributes || typeof attributes !== "object" || Array.isArray(attributes)) {
205
+ throw new TypeError("Performance resource attributes must be bounded plain data");
206
+ }
207
+ Object.assign(result, { attributes });
208
+ }
209
+ return Object.freeze(result);
210
+ };
211
+ async function createCustomPerformance(options) {
212
+ const configured = snapshotClosed(options, CUSTOM_FIELDS, "Custom performance options");
213
+ const rawBudgets = snapshotArray(configured.budgets ?? [], 100, "Custom performance budgets");
214
+ const budgets = rawBudgets.map((budget) => snapshotClosed(budget, BUDGET_FIELDS, "Custom performance budget"));
215
+ const names = /* @__PURE__ */ new Set();
216
+ for (const budget of budgets) {
217
+ if (typeof budget.name !== "string" || budget.name.length > 128 || names.has(budget.name)) {
218
+ throw new Error("Performance budget names must be unique safe identifiers of at most 128 characters");
219
+ }
220
+ names.add(budget.name);
221
+ }
222
+ const n1Detection = configured.n1Detection === void 0 ? void 0 : snapshotClosed(configured.n1Detection, N1_FIELDS, "Custom performance N+1 options");
223
+ if (n1Detection && n1Detection.enabled !== true) throw new Error("N+1 detection must use enabled: true when configured");
224
+ const monitoring = configured.runtimeMonitoring === void 0 ? {} : snapshotClosed(configured.runtimeMonitoring, MONITOR_FIELDS, "Custom performance runtime monitoring");
225
+ for (const value of Object.values(monitoring)) if (typeof value !== "boolean") throw new TypeError("Runtime monitoring switches must be booleans");
226
+ const destinations = snapshotArray(configured.destinations ?? [], 2, "Custom performance destinations").map(snapshotDestination);
227
+ const delivery = configured.delivery === void 0 ? void 0 : snapshotClosed(configured.delivery, DELIVERY_FIELDS, "Custom performance delivery");
228
+ if (delivery && destinations.length === 0) throw new Error("Performance delivery requires at least one destination");
229
+ const retry = delivery?.retry === void 0 ? void 0 : snapshotClosed(delivery.retry, RETRY_FIELDS, "Custom performance retry");
230
+ const resource = snapshotResource(configured.resource);
231
+ const monitoringEnabled = monitoring.eventLoop === true || monitoring.gc === true || monitoring.resources === true;
232
+ const [budgetModule, n1Module, exportModule, monitorModule] = await Promise.all([
233
+ budgets.length > 0 ? import('./budget-engine-KDA4FRYU.js') : void 0,
234
+ n1Detection ? import('./n1-detector-6IQ2DINP.js') : void 0,
235
+ destinations.length > 0 ? import('./event-export-manager-DEB64LWZ.js') : void 0,
236
+ monitoringEnabled ? import('./monitors-VNNUIKAK.js') : void 0
237
+ ]);
238
+ const handler = createBasePerformanceHandler({
239
+ clock: configured.clock === void 0 ? createSystemClock() : configured.clock,
240
+ cardinalityLimit: 100,
241
+ cardinalityMode: "drop",
242
+ enableEventLoopMonitor: monitoring.eventLoop === true,
243
+ enableGCMonitor: monitoring.gc === true,
244
+ enableResourceMonitor: monitoring.resources === true,
245
+ ...monitorModule ? { createRuntimeMonitoring: (monitorOptions) => {
246
+ const monitors = monitorModule.createMonitors(monitorOptions);
247
+ return { stop: () => monitorModule.stopAllMonitors(monitors) };
248
+ } } : {},
249
+ ...configured.errors ? { errors: configured.errors } : {},
250
+ ...configured.tracer ? { tracer: configured.tracer } : {},
251
+ ...budgetModule || n1Module || exportModule ? { createExtensions(dispatcher, clock) {
252
+ const budgetEngine = budgetModule?.createBudgetEngine({
253
+ now: clock.now,
254
+ onViolation: (violation) => dispatcher.emit("onBudgetViolation", violation)
255
+ });
256
+ for (const budget of budgets) budgetEngine?.registerBudget(budget);
257
+ const n1Detector = n1Module && n1Detection ? n1Module.createN1Detector(n1Detection) : void 0;
258
+ const exportManager = exportModule ? exportModule.createEventExportManager({
259
+ exporters: destinations,
260
+ maxBufferCount: delivery?.maxQueueRecords ?? 1e3,
261
+ maxBufferBytes: delivery?.maxQueueBytes ?? 1048576,
262
+ flushIntervalMs: delivery?.flushIntervalMs ?? 1e3,
263
+ retryAttempts: retry?.attempts ?? 2,
264
+ retryBaseDelayMs: retry?.baseDelayMs ?? 100,
265
+ operationTimeoutMs: delivery?.operationTimeoutMs ?? 5e3,
266
+ observe: (name, value, labels) => dispatcher.emit("onSelfMetric", name, value, labels),
267
+ ...configured.errors ? { errors: configured.errors } : {}
268
+ }) : void 0;
269
+ return {
270
+ onAcceptedEvent(event) {
271
+ budgetEngine?.checkEvent(event);
272
+ for (const pattern of n1Detector?.check(event) ?? []) dispatcher.emit("onN1Pattern", pattern);
273
+ if (!isResourceSnapshotEvent(event.source, event.name)) {
274
+ exportManager?.enqueue(toPerformanceEventRecord(event, resource));
275
+ }
276
+ },
277
+ getBudgetStatus: (name) => budgetEngine?.getStatus(name),
278
+ flush: async () => exportManager?.flush(),
279
+ shutdown: async () => exportManager?.shutdown(),
280
+ getExportStatus: () => exportManager?.getStatus() ?? {
281
+ queueSize: 0,
282
+ droppedTotal: 0,
283
+ retriedTotal: 0,
284
+ sinkState: "healthy"
285
+ }
286
+ };
287
+ } } : {}
288
+ });
289
+ try {
290
+ registerPerformanceLifecycleCleanup(configured.lifecycle, handler);
291
+ } catch (error) {
292
+ return await failPerformanceSetup(handler, error);
293
+ }
294
+ return handler;
295
+ }
296
+
297
+ export { createCustomPerformance };
298
+ //# sourceMappingURL=custom.js.map
299
+ //# sourceMappingURL=custom.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/performance/public/custom.ts"],"names":["result"],"mappings":";;;;;;;;AAwCA,IAAM,aAAA,uBAAoB,GAAA,CAAI;AAAA,EAC7B,OAAA;AAAA,EAAS,UAAA;AAAA,EAAY,QAAA;AAAA,EAAU,QAAA;AAAA,EAAU,WAAA;AAAA,EAAa,SAAA;AAAA,EAAW,aAAA;AAAA,EACjE,mBAAA;AAAA,EAAqB,cAAA;AAAA,EAAgB;AACtC,CAAC,CAAA;AACD,IAAM,aAAA,uBAAoB,GAAA,CAAI,CAAC,QAAQ,SAAA,EAAW,YAAA,EAAc,QAAA,EAAU,QAAQ,CAAC,CAAA;AACnF,IAAM,SAAA,uBAAgB,GAAA,CAAI,CAAC,WAAW,cAAA,EAAgB,eAAA,EAAiB,kBAAA,EAAoB,mBAAmB,CAAC,CAAA;AAC/G,IAAM,iCAAiB,IAAI,GAAA,CAAI,CAAC,WAAA,EAAa,IAAA,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AAA,EAAe,SAAA,EAAU,IAAK;AAAA,UACpD,SAAA,EAAW,CAAA;AAAA,UAAG,YAAA,EAAc,CAAA;AAAA,UAAG,YAAA,EAAc,CAAA;AAAA,UAAG,SAAA,EAAW;AAAA;AAC5D,OACD;AAAA,IACD,CAAA,KAAK;AAAC,GACN,CAAA;AACD,EAAA,IAAI;AAAE,IAAA,mCAAA,CAAoC,UAAA,CAAW,WAAwC,OAAO,CAAA;AAAA,EAAE,SAChG,KAAA,EAAO;AAAE,IAAA,OAAO,MAAM,oBAAA,CAAqB,OAAA,EAAS,KAAK,CAAA;AAAA,EAAE;AACjE,EAAA,OAAO,OAAA;AACR","file":"custom.js","sourcesContent":["import type {Clock} from '@ooopsstudio/core/contracts/clock'\nimport type {ObservabilityResource} from '@ooopsstudio/core/contracts/observability-shared'\nimport type {Errors} from '@ooopsstudio/core/ports/errors'\nimport type {LifecyclePort} from '@ooopsstudio/core/ports/lifecycle'\nimport type {PerformanceEventExporterPort} from '@ooopsstudio/core/ports/performance'\nimport type {Tracing} from '@ooopsstudio/core/ports/tracing'\nimport {createSystemClock} from '@ooopsstudio/core/runtime/time/system-clock'\n\nimport {createBasePerformanceHandler} from '../core/base-handler'\nimport {isResourceSnapshotEvent} from '../core/utils/event-helpers'\nimport {toPerformanceEventRecord} from '../core/utils/request-helpers'\nimport type {BudgetConfig} from '../features/core/budget-engine'\nimport type {N1DetectorOptions} from '../features/db/n1-detector'\nimport type {ManagedPerformance} from '../types/ports'\nimport {failPerformanceSetup, registerPerformanceLifecycleCleanup} from '../utils/lifecycle-cleanup'\nimport {isSensitivePerformanceKey, sanitizePerformanceLabelValue} from '../utils/safe-identifiers'\nimport {isRuntimeProxy} from '../utils/safe-object'\n\nexport type PerformanceBudgetDefinition = BudgetConfig\nexport type PerformanceEventExporter = PerformanceEventExporterPort\n\nexport interface CustomPerformanceOptions {\n\tclock?: Clock\n\tresource?: ObservabilityResource\n\terrors?: Errors\n\ttracer?: Tracing\n\tlifecycle?: LifecyclePort\n\tbudgets?: readonly PerformanceBudgetDefinition[]\n\tn1Detection?: N1DetectorOptions\n\truntimeMonitoring?: {eventLoop?: boolean; gc?: boolean; resources?: boolean}\n\tdestinations?: ReadonlyArray<{name: string; exporter: PerformanceEventExporter}>\n\tdelivery?: {\n\t\tmaxQueueRecords?: number\n\t\tmaxQueueBytes?: number\n\t\tflushIntervalMs?: number\n\t\tretry?: {attempts?: number; baseDelayMs?: number}\n\t\toperationTimeoutMs?: number\n\t}\n}\n\nconst CUSTOM_FIELDS = new Set([\n\t'clock', 'resource', 'errors', 'tracer', 'lifecycle', 'budgets', 'n1Detection',\n\t'runtimeMonitoring', 'destinations', 'delivery'\n])\nconst BUDGET_FIELDS = new Set(['name', 'pattern', 'percentile', 'target', 'window'])\nconst N1_FIELDS = new Set(['enabled', 'timeWindowMs', 'minDuplicates', 'maxTrackedTraces', 'maxEventsPerTrace'])\nconst MONITOR_FIELDS = new Set(['eventLoop', 'gc', 'resources'])\nconst DELIVERY_FIELDS = new Set(['maxQueueRecords', 'maxQueueBytes', 'flushIntervalMs', 'retry', 'operationTimeoutMs'])\nconst RETRY_FIELDS = new Set(['attempts', 'baseDelayMs'])\nconst DESTINATION_FIELDS = new Set(['name', 'exporter'])\nconst snapshotClosed = (\n\tvalue: unknown,\n\tallowed: ReadonlySet<string>,\n\tlabel: string\n): Record<string, unknown> => {\n\ttry {\n\t\tif (!value || typeof value !== 'object' || isRuntimeProxy(value) || Array.isArray(value)) throw new TypeError()\n\t\tconst prototype = Object.getPrototypeOf(value)\n\t\tif (prototype !== Object.prototype && prototype !== null) throw new TypeError()\n\t\tif (Object.getOwnPropertySymbols(value).length > 0) throw new TypeError()\n\t\tconst result: Record<string, unknown> = Object.create(null) as Record<string, unknown>\n\t\tlet inspected = 0\n\t\tfor (const key in value) {\n\t\t\tif (inspected >= allowed.size) throw new TypeError()\n\t\t\tconst descriptor = Object.getOwnPropertyDescriptor(value, key)\n\t\t\tif (key.length > 64 || !descriptor?.enumerable || !('value' in descriptor) || !allowed.has(key)) {\n\t\t\t\tthrow new TypeError()\n\t\t\t}\n\t\t\tinspected += 1\n\t\t\tresult[key] = descriptor.value\n\t\t}\n\t\treturn Object.freeze(result)\n\t} catch { throw new TypeError(`${label} must be a closed plain data object`) }\n}\n\nconst snapshotArray = (value: unknown, maximum: number, label: string): readonly unknown[] => {\n\tif (isRuntimeProxy(value) || !Array.isArray(value)) throw new TypeError(`${label} must be an array`)\n\tlet lengthDescriptor: PropertyDescriptor | undefined\n\ttry { lengthDescriptor = Object.getOwnPropertyDescriptor(value, 'length') } catch {\n\t\tthrow new TypeError(`${label} must contain stable data items`)\n\t}\n\tconst length = lengthDescriptor && 'value' in lengthDescriptor ? lengthDescriptor.value : undefined\n\tif (!Number.isSafeInteger(length) || length < 0 || length > maximum) {\n\t\tthrow new Error(`${label} supports at most ${maximum === 2 ? 'two' : maximum} items`)\n\t}\n\tconst result: unknown[] = []\n\tfor (let index = 0; index < length; index += 1) {\n\t\tlet descriptor: PropertyDescriptor | undefined\n\t\ttry { descriptor = Object.getOwnPropertyDescriptor(value, String(index)) } catch {\n\t\t\tthrow new TypeError(`${label} must contain stable data items`)\n\t\t}\n\t\tif (!descriptor?.enumerable || !('value' in descriptor)) {\n\t\t\tthrow new TypeError(`${label} must contain stable data items`)\n\t\t}\n\t\tresult.push(descriptor.value)\n\t}\n\treturn Object.freeze(result)\n}\n\nconst captureExporterMethod = (\n\texporter: unknown,\n\tkey: 'export' | 'flush' | 'shutdown'\n): ((...args: never[]) => unknown) | undefined => {\n\tif (isRuntimeProxy(exporter) || ((!exporter || typeof exporter !== 'object') && typeof exporter !== 'function')) return undefined\n\ttry {\n\t\tlet owner: object | null = exporter as object\n\t\tfor (let depth = 0; owner && depth < 16; depth += 1) {\n\t\t\tif (isRuntimeProxy(owner)) return undefined\n\t\t\tconst descriptor = Object.getOwnPropertyDescriptor(owner, key)\n\t\t\tif (descriptor) {\n\t\t\t\tif (!('value' in descriptor) || typeof descriptor.value !== 'function') return undefined\n\t\t\t\tconst method = descriptor.value as (...args: never[]) => unknown\n\t\t\t\treturn (...args: never[]) => Reflect.apply(method, exporter, args)\n\t\t\t}\n\t\t\towner = Object.getPrototypeOf(owner) as object | null\n\t\t}\n\t} catch { return undefined }\n\treturn undefined\n}\n\nconst hasExporterMethodField = (exporter: unknown, key: 'flush' | 'shutdown'): boolean => {\n\tif (isRuntimeProxy(exporter) || ((!exporter || typeof exporter !== 'object') && typeof exporter !== 'function')) return false\n\ttry {\n\t\tlet owner: object | null = exporter as object\n\t\tfor (let depth = 0; owner && depth < 16; depth += 1) {\n\t\t\tif (isRuntimeProxy(owner)) return true\n\t\t\tif (Object.getOwnPropertyDescriptor(owner, key)) return true\n\t\t\towner = Object.getPrototypeOf(owner) as object | null\n\t\t}\n\t} catch { return true }\n\treturn false\n}\n\nconst snapshotDestination = (value: unknown): {name: string; exporter: PerformanceEventExporter} => {\n\tconst destination = snapshotClosed(value, DESTINATION_FIELDS, 'Custom performance destination')\n\tconst exportBatch = captureExporterMethod(destination.exporter, 'export')\n\tconst flush = captureExporterMethod(destination.exporter, 'flush')\n\tconst shutdown = captureExporterMethod(destination.exporter, 'shutdown')\n\tif (!exportBatch) throw new TypeError('Custom performance destination exporter must provide export()')\n\tif ((hasExporterMethodField(destination.exporter, 'flush') && !flush) ||\n\t\t(hasExporterMethodField(destination.exporter, 'shutdown') && !shutdown)) {\n\t\tthrow new TypeError('Custom performance destination lifecycle hooks must be data-method functions')\n\t}\n\treturn Object.freeze({\n\t\tname: destination.name as string,\n\t\texporter: Object.freeze({\n\t\t\texport: exportBatch as PerformanceEventExporter['export'],\n\t\t\t...(flush ? {flush: flush as NonNullable<PerformanceEventExporter['flush']>} : {}),\n\t\t\t...(shutdown ? {shutdown: shutdown as NonNullable<PerformanceEventExporter['shutdown']>} : {})\n\t\t})\n\t})\n}\n\nconst snapshotResource = (value: unknown): ObservabilityResource | undefined => {\n\tif (value === undefined) return undefined\n\tconst resource = snapshotClosed(\n\t\tvalue,\n\t\tnew Set(['serviceName', 'serviceVersion', 'deploymentEnvironment', 'hostKind', 'runtime', 'attributes']),\n\t\t'Performance resource'\n\t)\n\tif (typeof resource.serviceName !== 'string' || resource.serviceName.length > 128 || !resource.serviceName.trim()) {\n\t\tthrow new TypeError('Performance resource serviceName must be a non-empty string of at most 128 characters')\n\t}\n\tconst result: ObservabilityResource = {serviceName: resource.serviceName}\n\tfor (const key of ['serviceVersion', 'deploymentEnvironment', 'hostKind', 'runtime'] as const) {\n\t\tconst field = resource[key]\n\t\tif (field !== undefined) {\n\t\t\tif (typeof field !== 'string' || field.length > 256) throw new TypeError(`Performance resource ${key} is invalid`)\n\t\t\tObject.assign(result, {[key]: field})\n\t\t}\n\t}\n\tif (resource.attributes !== undefined) {\n\t\tlet remainingNodes = 128\n\t\tlet remainingCharacters = 8_192\n\t\tconst capture = (current: unknown, key: string, depth: number): unknown => {\n\t\t\tif (key.length > 128) throw new TypeError('Performance resource attribute keys must be at most 128 characters')\n\t\t\tif (isSensitivePerformanceKey(key)) return '[redacted]'\n\t\t\tif (typeof current === 'string') {\n\t\t\t\tconst bounded = current.slice(0, Math.min(256, remainingCharacters))\n\t\t\t\tremainingCharacters -= bounded.length\n\t\t\t\treturn sanitizePerformanceLabelValue(bounded)\n\t\t\t}\n\t\t\tif (typeof current === 'number') return Number.isFinite(current) ? current : undefined\n\t\t\tif (typeof current === 'boolean' || current === null) return current\n\t\t\tif (!current || typeof current !== 'object' || isRuntimeProxy(current) || depth >= 8 || remainingNodes-- <= 0) return undefined\n\t\t\tif (Array.isArray(current)) {\n\t\t\t\tconst values: unknown[] = []\n\t\t\t\tlet lengthDescriptor: PropertyDescriptor | undefined\n\t\t\t\ttry { lengthDescriptor = Object.getOwnPropertyDescriptor(current, 'length') } catch { return undefined }\n\t\t\t\tconst length = lengthDescriptor && 'value' in lengthDescriptor && Number.isSafeInteger(lengthDescriptor.value)\n\t\t\t\t\t? Math.min(32, lengthDescriptor.value as number) : 0\n\t\t\t\tfor (let index = 0; index < length; index += 1) {\n\t\t\t\t\tlet descriptor: PropertyDescriptor | undefined\n\t\t\t\t\ttry { descriptor = Object.getOwnPropertyDescriptor(current, String(index)) } catch { return undefined }\n\t\t\t\t\tif (descriptor && 'value' in descriptor) values.push(capture(descriptor.value, key, depth + 1))\n\t\t\t\t}\n\t\t\t\treturn Object.freeze(values)\n\t\t\t}\n\t\t\tlet prototype: object | null\n\t\t\ttry { prototype = Object.getPrototypeOf(current) as object | null } catch { return undefined }\n\t\t\tif (prototype !== Object.prototype && prototype !== null) return undefined\n\t\t\tconst result: Record<string, unknown> = Object.create(null) as Record<string, unknown>\n\t\t\tlet inspected = 0\n\t\t\tfor (const childKey in current) {\n\t\t\t\tif (inspected >= 64) break\n\t\t\t\tlet descriptor: PropertyDescriptor | undefined\n\t\t\t\ttry { descriptor = Object.getOwnPropertyDescriptor(current, childKey) } catch { return undefined }\n\t\t\t\tif (!descriptor?.enumerable || !('value' in descriptor)) continue\n\t\t\t\tinspected += 1\n\t\t\t\tconst captured = capture(descriptor.value, childKey, depth + 1)\n\t\t\t\tif (captured !== undefined) result[childKey] = captured\n\t\t\t}\n\t\t\treturn Object.freeze(result)\n\t\t}\n\t\tconst attributes = capture(resource.attributes, 'attributes', 0)\n\t\tif (!attributes || typeof attributes !== 'object' || Array.isArray(attributes)) {\n\t\t\tthrow new TypeError('Performance resource attributes must be bounded plain data')\n\t\t}\n\t\tObject.assign(result, {attributes})\n\t}\n\treturn Object.freeze(result)\n}\n\nexport async function createCustomPerformance(options: CustomPerformanceOptions): Promise<ManagedPerformance> {\n\tconst configured = snapshotClosed(options, CUSTOM_FIELDS, 'Custom performance options')\n\tconst rawBudgets = snapshotArray(configured.budgets ?? [], 100, 'Custom performance budgets')\n\tconst budgets = rawBudgets.map((budget) =>\n\t\tsnapshotClosed(budget, BUDGET_FIELDS, 'Custom performance budget') as unknown as BudgetConfig)\n\tconst names = new Set<string>()\n\tfor (const budget of budgets) {\n\t\tif (typeof budget.name !== 'string' || budget.name.length > 128 || names.has(budget.name)) {\n\t\t\tthrow new Error('Performance budget names must be unique safe identifiers of at most 128 characters')\n\t\t}\n\t\tnames.add(budget.name)\n\t}\n\n\tconst n1Detection = configured.n1Detection === undefined ? undefined\n\t\t: snapshotClosed(configured.n1Detection, N1_FIELDS, 'Custom performance N+1 options') as unknown as N1DetectorOptions\n\tif (n1Detection && n1Detection.enabled !== true) throw new Error('N+1 detection must use enabled: true when configured')\n\tconst monitoring = configured.runtimeMonitoring === undefined ? {}\n\t\t: snapshotClosed(configured.runtimeMonitoring, MONITOR_FIELDS, 'Custom performance runtime monitoring')\n\tfor (const value of Object.values(monitoring)) if (typeof value !== 'boolean') throw new TypeError('Runtime monitoring switches must be booleans')\n\n\tconst destinations = snapshotArray(configured.destinations ?? [], 2, 'Custom performance destinations')\n\t\t.map(snapshotDestination)\n\tconst delivery = configured.delivery === undefined ? undefined\n\t\t: snapshotClosed(configured.delivery, DELIVERY_FIELDS, 'Custom performance delivery')\n\tif (delivery && destinations.length === 0) throw new Error('Performance delivery requires at least one destination')\n\tconst retry = delivery?.retry === undefined ? undefined\n\t\t: snapshotClosed(delivery.retry, RETRY_FIELDS, 'Custom performance retry')\n\n\tconst resource = snapshotResource(configured.resource)\n\tconst monitoringEnabled = monitoring.eventLoop === true || monitoring.gc === true || monitoring.resources === true\n\tconst [budgetModule, n1Module, exportModule, monitorModule] = await Promise.all([\n\t\tbudgets.length > 0 ? import('../features/core/budget-engine') : undefined,\n\t\tn1Detection ? import('../features/db/n1-detector') : undefined,\n\t\tdestinations.length > 0 ? import('../core/event-export-manager') : undefined,\n\t\tmonitoringEnabled ? import('../core/runtime/monitors') : undefined\n\t])\n\tconst handler = createBasePerformanceHandler({\n\t\tclock: configured.clock === undefined ? createSystemClock() : configured.clock as Clock,\n\t\tcardinalityLimit: 100,\n\t\tcardinalityMode: 'drop',\n\t\tenableEventLoopMonitor: monitoring.eventLoop === true,\n\t\tenableGCMonitor: monitoring.gc === true,\n\t\tenableResourceMonitor: monitoring.resources === true,\n\t\t...(monitorModule ? {createRuntimeMonitoring: (monitorOptions: Parameters<typeof monitorModule.createMonitors>[0]) => {\n\t\t\tconst monitors = monitorModule.createMonitors(monitorOptions)\n\t\t\treturn {stop: () => monitorModule.stopAllMonitors(monitors)}\n\t\t}} : {}),\n\t\t...(configured.errors ? {errors: configured.errors as Errors} : {}),\n\t\t...(configured.tracer ? {tracer: configured.tracer as Tracing} : {}),\n\t\t...((budgetModule || n1Module || exportModule) ? {createExtensions(dispatcher, clock) {\n\t\t\tconst budgetEngine = budgetModule?.createBudgetEngine({\n\t\t\t\tnow: clock.now,\n\t\t\t\tonViolation: (violation) => dispatcher.emit('onBudgetViolation', violation)\n\t\t\t})\n\t\t\tfor (const budget of budgets) budgetEngine?.registerBudget(budget)\n\t\t\tconst n1Detector = n1Module && n1Detection ? n1Module.createN1Detector(n1Detection) : undefined\n\t\t\tconst exportManager = exportModule ? exportModule.createEventExportManager({\n\t\t\t\texporters: destinations as Array<{name: string; exporter: PerformanceEventExporter}>,\n\t\t\t\tmaxBufferCount: (delivery?.maxQueueRecords as number | undefined) ?? 1_000,\n\t\t\t\tmaxBufferBytes: (delivery?.maxQueueBytes as number | undefined) ?? 1_048_576,\n\t\t\t\tflushIntervalMs: (delivery?.flushIntervalMs as number | undefined) ?? 1_000,\n\t\t\t\tretryAttempts: (retry?.attempts as number | undefined) ?? 2,\n\t\t\t\tretryBaseDelayMs: (retry?.baseDelayMs as number | undefined) ?? 100,\n\t\t\t\toperationTimeoutMs: (delivery?.operationTimeoutMs as number | undefined) ?? 5_000,\n\t\t\t\tobserve: (name, value, labels) => dispatcher.emit('onSelfMetric', name, value, labels),\n\t\t\t\t...(configured.errors ? {errors: configured.errors as Errors} : {})\n\t\t\t}) : undefined\n\t\t\treturn {\n\t\t\t\tonAcceptedEvent(event) {\n\t\t\t\t\tbudgetEngine?.checkEvent(event)\n\t\t\t\t\tfor (const pattern of n1Detector?.check(event) ?? []) dispatcher.emit('onN1Pattern', pattern)\n\t\t\t\t\t// Resource snapshots are emitted as gauges by the metrics bridge. Their\n\t\t\t\t\t// changing values must never become exported label dimensions.\n\t\t\t\t\tif (!isResourceSnapshotEvent(event.source, event.name)) {\n\t\t\t\t\t\texportManager?.enqueue(toPerformanceEventRecord(event, resource))\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tgetBudgetStatus: (name) => budgetEngine?.getStatus(name),\n\t\t\t\tflush: async() => exportManager?.flush(),\n\t\t\t\tshutdown: async() => exportManager?.shutdown(),\n\t\t\t\tgetExportStatus: () => exportManager?.getStatus() ?? {\n\t\t\t\t\tqueueSize: 0, droppedTotal: 0, retriedTotal: 0, sinkState: 'healthy' as const\n\t\t\t\t}\n\t\t\t}\n\t\t}} : {})\n\t})\n\ttry { registerPerformanceLifecycleCleanup(configured.lifecycle as LifecyclePort | undefined, handler) }\n\tcatch(error) { return await failPerformanceSetup(handler, error) }\n\treturn handler\n}\n"]}
@@ -0,0 +1,19 @@
1
+ import { Clock } from '@ooopsstudio/core/contracts/clock';
2
+ import { ObservabilityResource } from '@ooopsstudio/core/contracts/observability-shared';
3
+ import { Errors } from '@ooopsstudio/core/ports/errors';
4
+ import { LifecyclePort } from '@ooopsstudio/core/ports/lifecycle';
5
+ import { Tracing } from '@ooopsstudio/core/ports/tracing';
6
+ import { M as ManagedPerformance } from './ports-DwUYdKj-.js';
7
+ import '@ooopsstudio/core/contracts/performance';
8
+ import '@ooopsstudio/core/ports/performance';
9
+
10
+ interface DevelopmentPerformanceOptions {
11
+ clock?: Clock;
12
+ resource?: ObservabilityResource;
13
+ errors?: Errors;
14
+ tracer?: Tracing;
15
+ lifecycle?: LifecyclePort;
16
+ }
17
+ declare function createDevelopmentPerformance(options?: DevelopmentPerformanceOptions): Promise<ManagedPerformance>;
18
+
19
+ export { type DevelopmentPerformanceOptions, createDevelopmentPerformance };
@@ -0,0 +1,55 @@
1
+ import { snapshotPerformancePresetOptions } from './chunk-W72QW2AD.js';
2
+ import { createBasePerformanceHandler, registerPerformanceLifecycleCleanup, failPerformanceSetup } from './chunk-ZAXGEDZW.js';
3
+ import './chunk-RY65GERM.js';
4
+ import './chunk-2XXIOHOO.js';
5
+ import './chunk-J6KBSLYO.js';
6
+ import './chunk-MMO5UEUU.js';
7
+ import './chunk-RL2752FW.js';
8
+ import { createSystemClock } from '@ooopsstudio/core/runtime/time/system-clock';
9
+
10
+ var DEVELOPMENT_OPTION_FIELDS = /* @__PURE__ */ new Set(["clock", "resource", "errors", "tracer", "lifecycle"]);
11
+ async function createDevelopmentPerformance(options = {}) {
12
+ const configured = snapshotPerformancePresetOptions(
13
+ options,
14
+ DEVELOPMENT_OPTION_FIELDS,
15
+ "Development performance options"
16
+ );
17
+ const { createMonitors, stopAllMonitors } = await import('./monitors-VNNUIKAK.js');
18
+ const handler = createBasePerformanceHandler({
19
+ clock: configured.clock === void 0 ? createSystemClock() : configured.clock,
20
+ cardinalityLimit: 200,
21
+ cardinalityMode: "warn",
22
+ enableEventLoopMonitor: true,
23
+ enableGCMonitor: true,
24
+ enableResourceMonitor: true,
25
+ createRuntimeMonitoring: (monitorOptions) => {
26
+ const monitors = createMonitors(monitorOptions);
27
+ return { stop: () => stopAllMonitors(monitors) };
28
+ },
29
+ ...configured.errors ? { errors: configured.errors } : {},
30
+ ...configured.tracer ? { tracer: configured.tracer } : {},
31
+ callbacks: {
32
+ onSaturationAlert(alert) {
33
+ try {
34
+ console.warn("performance.alert", {
35
+ reason: alert.reason,
36
+ severity: alert.severity,
37
+ value: alert.value,
38
+ threshold: alert.threshold
39
+ });
40
+ } catch {
41
+ }
42
+ }
43
+ }
44
+ });
45
+ try {
46
+ registerPerformanceLifecycleCleanup(configured.lifecycle, handler);
47
+ } catch (error) {
48
+ return await failPerformanceSetup(handler, error);
49
+ }
50
+ return handler;
51
+ }
52
+
53
+ export { createDevelopmentPerformance };
54
+ //# sourceMappingURL=development.js.map
55
+ //# sourceMappingURL=development.js.map
@@ -0,0 +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A;AAAA,YAChB,OAAO,KAAA,CAAM,KAAA;AAAA,YACb,WAAW,KAAA,CAAM;AAAA,WACjB,CAAA;AAAA,QACF,CAAA,CAAA,MAAQ;AAAA,QAER;AAAA,MACD;AAAA;AACD,GACA,CAAA;AACD,EAAA,IAAI;AACH,IAAA,mCAAA,CAAoC,UAAA,CAAW,WAAwC,OAAO,CAAA;AAAA,EAC/F,SAAQ,KAAA,EAAO;AACd,IAAA,OAAO,MAAM,oBAAA,CAAqB,OAAA,EAAS,KAAK,CAAA;AAAA,EACjD;AACA,EAAA,OAAO,OAAA;AACR","file":"development.js","sourcesContent":["import type {Clock} from '@ooopsstudio/core/contracts/clock'\nimport type {ObservabilityResource} from '@ooopsstudio/core/contracts/observability-shared'\nimport type {Errors} from '@ooopsstudio/core/ports/errors'\nimport type {LifecyclePort} from '@ooopsstudio/core/ports/lifecycle'\nimport type {Tracing} from '@ooopsstudio/core/ports/tracing'\nimport {createSystemClock} from '@ooopsstudio/core/runtime/time/system-clock'\n\nimport {createBasePerformanceHandler} from '../core/base-handler'\nimport type {ManagedPerformance} from '../types/ports'\nimport {failPerformanceSetup, registerPerformanceLifecycleCleanup} from '../utils/lifecycle-cleanup'\nimport {snapshotPerformancePresetOptions} from '../utils/preset-options'\n\nexport interface DevelopmentPerformanceOptions {\n\tclock?: Clock\n\tresource?: ObservabilityResource\n\terrors?: Errors\n\ttracer?: Tracing\n\tlifecycle?: LifecyclePort\n}\n\nconst DEVELOPMENT_OPTION_FIELDS = new Set(['clock', 'resource', 'errors', 'tracer', 'lifecycle'])\n\nexport async function createDevelopmentPerformance(options: DevelopmentPerformanceOptions = {}): Promise<ManagedPerformance> {\n\tconst configured = snapshotPerformancePresetOptions(\n\t\toptions, DEVELOPMENT_OPTION_FIELDS, 'Development performance options'\n\t)\n\tconst {createMonitors, stopAllMonitors} = await import('../core/runtime/monitors')\n\tconst handler = createBasePerformanceHandler({\n\t\tclock: configured.clock === undefined ? createSystemClock() : configured.clock as Clock,\n\t\tcardinalityLimit: 200,\n\t\tcardinalityMode: 'warn',\n\t\tenableEventLoopMonitor: true,\n\t\tenableGCMonitor: true,\n\t\tenableResourceMonitor: true,\n\t\tcreateRuntimeMonitoring: (monitorOptions) => {\n\t\t\tconst monitors = createMonitors(monitorOptions)\n\t\t\treturn {stop: () => stopAllMonitors(monitors)}\n\t\t},\n\t\t...(configured.errors ? {errors: configured.errors as Errors} : {}),\n\t\t...(configured.tracer ? {tracer: configured.tracer as Tracing} : {}),\n\t\tcallbacks: {\n\t\t\tonSaturationAlert(alert) {\n\t\t\t\ttry {\n\t\t\t\t\tconsole.warn('performance.alert', {\n\t\t\t\t\t\treason: alert.reason,\n\t\t\t\t\t\tseverity: alert.severity,\n\t\t\t\t\t\tvalue: alert.value,\n\t\t\t\t\t\tthreshold: alert.threshold\n\t\t\t\t\t})\n\t\t\t\t} catch {\n\t\t\t\t\t// Development console failures must not affect measurements.\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t})\n\ttry {\n\t\tregisterPerformanceLifecycleCleanup(configured.lifecycle as LifecyclePort | undefined, handler)\n\t} catch(error) {\n\t\treturn await failPerformanceSetup(handler, error)\n\t}\n\treturn handler\n}\n"]}