@entifix/service-shell 0.12.0 → 0.13.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.
@@ -1,4 +1,4 @@
1
- import { NodeSdk } from '@effect/opentelemetry';
1
+ import * as NodeSdk from '@effect/opentelemetry/NodeSdk';
2
2
  import { createLogger, makeOtlpHttpLogSink, makeStdoutJsonSink } from '@entifix/tooling/logging';
3
3
  import { context } from '@opentelemetry/api';
4
4
  import { AsyncLocalStorageContextManager } from '@opentelemetry/context-async-hooks';
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/observability.ts"],"sourcesContent":["import { NodeSdk } from '@effect/opentelemetry';\nimport type { ConfigurationClient, EntifixBuildError } from '@entifix/core';\nimport {\n type Attributes,\n createLogger,\n type Logger as ToolingLogger,\n type LogLevel,\n type LogRecord,\n type LogSink,\n makeOtlpHttpLogSink,\n makeStdoutJsonSink,\n} from '@entifix/tooling/logging';\nimport { context } from '@opentelemetry/api';\nimport { AsyncLocalStorageContextManager } from '@opentelemetry/context-async-hooks';\nimport { OTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-http';\nimport { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';\nimport {\n AggregationTemporality,\n InMemoryMetricExporter,\n type MetricReader,\n PeriodicExportingMetricReader,\n type ResourceMetrics,\n} from '@opentelemetry/sdk-metrics';\nimport {\n BatchSpanProcessor,\n InMemorySpanExporter,\n type ReadableSpan,\n SimpleSpanProcessor,\n type SpanProcessor,\n} from '@opentelemetry/sdk-trace-base';\nimport { Effect, Layer, Logger, References } from 'effect';\nimport type * as EffectLogLevel from 'effect/LogLevel';\n\n/** Resolved observability settings (from config-service `logging.*`/`otel.*`). */\nexport interface ObservabilityConfig {\n readonly serviceName: string;\n readonly level: LogLevel;\n /** `otlp` in dev (ship straight to otel-lgtm), `stdout` in a cluster (filelog). */\n readonly sink: 'stdout' | 'otlp';\n /**\n * OTLP base URL; `/v1/traces`, `/v1/logs` and `/v1/metrics` are appended.\n *\n * **Optional, and that is the boot guarantee**: with no endpoint the service\n * still starts — logs fall back to the stdout sink and neither exporter is\n * built. It used to be a required `getString`, so a fleet whose\n * `otel.endpoint` row was missing failed to boot at all rather than running\n * without telemetry, which is the wrong trade for a signal that is not on the\n * request path.\n */\n readonly otelEndpoint?: string | undefined;\n /**\n * How often the metric reader exports, in milliseconds. Config rather than a\n * constant because it is a real operational dial (a shorter interval buys\n * resolution with cardinality-independent request volume), and optional\n * because a fleet whose seed predates the key should not fail to boot over an\n * export interval. (Optional for that reason alone: config-service reconciles\n * `SEED_ROWS` per row on every boot, so a *new* key does reach an existing\n * Postgres — `ON CONFLICT DO NOTHING` declines to overwrite an operator's\n * changed *value*, which is the case that needs a `dev:reset`.)\n */\n readonly metricIntervalMs?: number | undefined;\n}\n\n/** Export interval used when `otel.metricIntervalMs` is unset. */\nconst DEFAULT_METRIC_INTERVAL_MS = 60_000;\n\n/** The in-memory reader's interval — long enough that only `forceFlush` collects. */\nconst ONE_HOUR_MS = 3_600_000;\n\n/**\n * `@effect/opentelemetry` manages its own span tree but does not register an\n * OpenTelemetry context manager, so `@opentelemetry/api`'s active-span lookup\n * (which the tooling logger uses to stamp `trace_id`) would stay empty. Register\n * the AsyncLocalStorage manager once so the active span propagates and logs\n * correlate to their traces. Idempotent — `setGlobalContextManager` no-ops if a\n * manager is already registered (e.g. across test boots in one process).\n */\nlet contextManagerReady = false;\nconst ensureContextManager = (): void => {\n if (!contextManagerReady) {\n context.setGlobalContextManager(\n new AsyncLocalStorageContextManager().enable(),\n );\n contextManagerReady = true;\n }\n};\n\n/**\n * The OTLP base URL, or `undefined` when there is nowhere to export.\n *\n * A **blank** endpoint counts as absent, not as a base URL. config-service's\n * operator CRUD writes empty strings, so `''` is reachable in practice — and\n * taken literally it builds exporters aimed at the relative `/v1/traces` and\n * `/v1/metrics`, which resolve against nothing, fail every export, and look\n * from the call site exactly like a service that is simply quiet.\n */\nconst resolveEndpoint = (raw: string | undefined): string | undefined => {\n const trimmed = raw?.trim();\n return trimmed === undefined || trimmed === '' ? undefined : trimmed;\n};\n\nconst makeSink = (\n config: ObservabilityConfig,\n endpoint: string | undefined,\n): LogSink =>\n config.sink === 'otlp' && endpoint !== undefined\n ? makeOtlpHttpLogSink({\n endpoint,\n serviceName: config.serviceName,\n // Flush on a short interval too, so a quiet service's logs reach the\n // Collector promptly instead of waiting for a full batch.\n flushIntervalMs: 2000,\n onError: error =>\n process.stderr.write(\n `[otlp-log-sink] export failed: ${String(error)}\\n`,\n ),\n })\n : makeStdoutJsonSink();\n\n/**\n * Effect's `LogLevel` mapped onto the four levels the tooling logger has.\n *\n * ⚠️ **Match the spelling `effect/LogLevel` declares, and let the compiler\n * hold you to it.** Effect 4's level is the string union `\"All\" | \"Fatal\" |\n * \"Error\" | \"Warn\" | \"Info\" | \"Debug\" | \"Trace\" | \"None\"`. Under Effect 3 this\n * switch read the level's `label`, which was upper case (`\"ERROR\"`), against\n * mixed-case spellings (`'Error'`, `'Warning'`) typed as a plain `string` — so\n * **no case could ever match** and every log in the service fell through to\n * `default` and was emitted at `info`. Measured in Loki: an `Effect.logError`\n * arrived as `severity_text: INFO`, `severity_number: 9`, which makes an error\n * invisible to every level-based alert and dashboard while still appearing in\n * the log — the failure mode that reads as \"we have no errors\". Typing the\n * parameter as Effect's own union is what makes a misspelt case a compile\n * error now: `'Warning'` would not compile.\n */\nconst toToolingLevel = (level: EffectLogLevel.LogLevel): LogLevel => {\n switch (level) {\n case 'Trace':\n case 'Debug':\n return 'debug';\n case 'Warn':\n return 'warn';\n case 'Error':\n case 'Fatal':\n return 'error';\n default:\n return 'info';\n }\n};\n\n/**\n * `Effect.annotateLogs`' entries flattened into tooling `Attributes`.\n *\n * The annotations are a record read off the fiber, and the attribute values are\n * a closed scalar set, so anything else is stringified rather than dropped — an\n * annotation that reaches a sink as `[object Object]` is still more use than one\n * that silently is not there.\n */\nconst toAttributes = (\n annotations: Readonly<Record<string, unknown>>,\n): Attributes =>\n Object.fromEntries(\n Object.entries(annotations).map(([key, value]) => [\n key,\n typeof value === 'string' ||\n typeof value === 'number' ||\n typeof value === 'boolean' ||\n value === null\n ? value\n : String(value),\n ]),\n );\n\nconst messageToString = (message: unknown): string =>\n Array.isArray(message)\n ? message.map(part => String(part)).join(' ')\n : String(message);\n\n/**\n * An Effect `Logger` that forwards every Effect log (including the request logs\n * `HttpRouter.serve` writes) to the tooling logger — so the whole service logs\n * through one structured, trace-correlated pipeline.\n *\n * **Annotations are forwarded**, and used not to be: they were destructured\n * away, so every `Effect.annotateLogs` in every service was discarded before it\n * reached a sink. That made the annotated fields the outbox relay and the\n * transaction engine attach — the tenant database, the event id, the\n * transaction id, the rollback's own error — unqueryable, while the comments\n * beside them said they were structured fields in Loki. Measured: the records\n * arrived carrying the message and nothing else. Effect 4 no longer hands them\n * to a logger at all; they live on the fiber, as\n * `References.CurrentLogAnnotations`, and are read from there.\n *\n * `error` is called through its own arm because the tooling `Logger` gives it a\n * different signature — `(message, error?, attributes?)` — so passing the\n * attributes positionally as the second argument would file them as the *cause*\n * and lose them again.\n */\nconst makeEffectLogger = (\n logger: ToolingLogger,\n): Logger.Logger<unknown, void> =>\n Logger.make(({ logLevel, message, fiber }) => {\n const level = toToolingLevel(logLevel);\n const text = messageToString(message);\n const attributes = toAttributes(\n fiber.getRef(References.CurrentLogAnnotations),\n );\n\n if (level === 'error') {\n logger.error(text, undefined, attributes);\n return;\n }\n logger[level](text, attributes);\n });\n\n/** Lower-level inputs to {@link makeObservabilityLayerWith}. */\nexport interface ObservabilityLayerOptions {\n readonly serviceName: string;\n readonly level: LogLevel;\n /** Where log records go (a real sink in prod, an in-memory double in tests). */\n readonly sink: LogSink;\n /**\n * How spans are exported (batch→OTLP in prod, in-memory in tests).\n * Omitted when there is no OTLP endpoint to export to.\n */\n readonly spanProcessor?: SpanProcessor | undefined;\n /**\n * How metrics are exported (periodic→OTLP in prod, in-memory in tests).\n *\n * Injectable for the same reason `spanProcessor` is: a test drives the exact\n * wiring that ships, so — unlike a double that reimplements the composition —\n * it can see `Metrics.layer` failing to register a producer at all.\n */\n readonly metricReader?: MetricReader | undefined;\n}\n\n/**\n * The observability composition over explicit sink + span processor: replace\n * Effect's default logger with the tooling-backed one, and stand up the OTel\n * tracer so requests produce spans. Keeping sink/processor injectable lets a\n * test drive the exact same wiring with in-memory exporters (see\n * {@link makeInMemoryObservabilityLayer}), so the correlation the e2e asserts is\n * the correlation that ships.\n */\nexport const makeObservabilityLayerWith = (\n options: ObservabilityLayerOptions,\n) => {\n ensureContextManager();\n const toolingLogger = createLogger({\n service: options.serviceName,\n level: options.level,\n sink: options.sink,\n });\n // Replace Effect's loggers with the tooling logger. `Logger.layer` sets the\n // fiber's current loggers outright rather than adding to them, and neither\n // the service boot (`runMain`) nor the e2e boot (`Effect.runFork`) installs a\n // logger of its own, so this single layer takes effect in either runtime.\n const effectLogger = makeEffectLogger(toolingLogger);\n const LoggingLayer = Logger.layer([effectLogger]);\n // One `NodeSdk.layer` for both signals: it builds the OTel `Resource` once,\n // so the spans and the metrics carry the same `service.name` rather than two\n // resources that can disagree. `NodeSdk` degrades an absent `spanProcessor`\n // or `metricReader` to `Layer.empty` on its own (its `isNonEmpty` guard), so\n // the no-endpoint case needs no branch here — it simply exports nothing.\n //\n // The metric half needs no producer of its own: `NodeSdk` wires the reader\n // through `Metrics.layer`, whose `MetricProducer` reads **Effect's own metric\n // registry**. So `Metric.counter(…)` at any call site is exported, and a\n // domain counter stays one line where it is incremented.\n const TelemetryLayer = NodeSdk.layer(() => ({\n resource: { serviceName: options.serviceName },\n spanProcessor: options.spanProcessor,\n metricReader: options.metricReader,\n }));\n return Layer.merge(LoggingLayer, TelemetryLayer);\n};\n\n/**\n * The production/dev observability layer: log level + sink and OTLP endpoint\n * come from config-service. Merged into the service `AppLayer`.\n */\nexport const makeObservabilityLayer = (config: ObservabilityConfig) => {\n const endpoint = resolveEndpoint(config.otelEndpoint);\n return makeObservabilityLayerWith({\n serviceName: config.serviceName,\n level: config.level,\n sink: makeSink(config, endpoint),\n spanProcessor:\n endpoint === undefined\n ? undefined\n : new BatchSpanProcessor(\n new OTLPTraceExporter({ url: `${endpoint}/v1/traces` }),\n ),\n metricReader:\n endpoint === undefined\n ? undefined\n : new PeriodicExportingMetricReader({\n exporter: new OTLPMetricExporter({\n url: `${endpoint}/v1/metrics`,\n }),\n exportIntervalMillis:\n config.metricIntervalMs ?? DEFAULT_METRIC_INTERVAL_MS,\n }),\n });\n};\n\n/** Captured telemetry from {@link makeInMemoryObservabilityLayer}. */\nexport interface InMemoryObservability {\n readonly layer: ReturnType<typeof makeObservabilityLayerWith>;\n /** Records the (replaced) logger emitted — the e2e asserts on these. */\n readonly logRecords: readonly LogRecord[];\n /** The spans exported so far (used to confirm requests produced traces). */\n readonly getSpans: () => ReadonlyArray<ReadableSpan>;\n /**\n * Forces a metric collection and returns what the exporter then holds.\n *\n * A push reader only exports on its interval, so a test that merely read the\n * exporter would find it empty and could not tell \"the producer is not\n * registered\" from \"the interval has not elapsed\".\n */\n readonly collectMetrics: () => Promise<ReadonlyArray<ResourceMetrics>>;\n}\n\n/**\n * Test-support: the real observability wiring with in-memory exporters, so an\n * e2e can boot the service and assert that logs are structured and carry the\n * `trace_id` of the request span that produced them.\n */\nexport const makeInMemoryObservabilityLayer = (\n serviceName: string,\n): InMemoryObservability => {\n const logRecords: LogRecord[] = [];\n const spanExporter = new InMemorySpanExporter();\n const metricExporter = new InMemoryMetricExporter(\n AggregationTemporality.CUMULATIVE,\n );\n // A long interval, because the test drives collection explicitly through\n // `collectMetrics`. A short one would export on a timer as well and make the\n // assertions depend on how long the surrounding effect happened to take.\n const metricReader = new PeriodicExportingMetricReader({\n exporter: metricExporter,\n exportIntervalMillis: ONE_HOUR_MS,\n });\n const layer = makeObservabilityLayerWith({\n serviceName,\n level: 'debug',\n sink: { emit: record => logRecords.push(record) },\n spanProcessor: new SimpleSpanProcessor(spanExporter),\n metricReader,\n });\n return {\n layer,\n logRecords,\n getSpans: () => spanExporter.getFinishedSpans(),\n collectMetrics: async () => {\n await metricReader.forceFlush();\n return metricExporter.getMetrics();\n },\n };\n};\n\n/**\n * The observability layer for a service, read from its own configuration.\n *\n * This is the whole per-service wiring: a composition root yields it and merges\n * the result into its `AppLayer`. It exists because the four reads below were\n * byte-identical in every service that had them, sitting directly above a\n * `makeObservabilityLayer` call that mapped them one-for-one — the same\n * duplication the module itself carried, one level up.\n *\n * `logging.level` and `logging.sink` are **required**: the rows are seeded for\n * every service and reach an existing table on config-service's next boot (the\n * seed reconciles per row and only declines to overwrite a value that is already\n * there), so a missing one is a real misconfiguration and should be loud.\n *\n * `otel.endpoint` and `otel.metricIntervalMs` are **optional**, for two\n * different reasons. The endpoint is what makes telemetry a *degradable*\n * dependency — with none, the service boots and serves, logs to stdout and\n * exports nothing, rather than an unreachable telemetry destination taking the\n * service down. The interval is a dial with a sane default, and requiring it\n * would fail the boot on any fleet whose seed predates it.\n *\n * Takes the {@link ConfigurationClient} port rather than a concrete client, so\n * config-service can pass the store it builds from its **own** SQL rows: it is\n * the one service that cannot fetch its configuration over HTTP, because it is\n * the thing being fetched from.\n */\nexport const observabilityFromConfiguration = (\n store: ConfigurationClient,\n serviceName: string,\n): Effect.Effect<\n ReturnType<typeof makeObservabilityLayer>,\n EntifixBuildError\n> =>\n Effect.gen(function* () {\n const level = yield* store.in('logging').getString('level');\n const sink = yield* store.in('logging').getString('sink');\n const otelEndpoint = yield* store.in('otel').getOptionalString('endpoint');\n const metricIntervalMs = yield* store\n .in('otel')\n .getOptionalNumber('metricIntervalMs');\n\n return makeObservabilityLayer({\n serviceName,\n level: level as LogLevel,\n // Anything but the explicit `stdout` is the OTLP sink, which is what makes\n // a mistyped value degrade to shipping rather than to silence.\n sink: sink === 'stdout' ? 'stdout' : 'otlp',\n otelEndpoint,\n metricIntervalMs,\n });\n });\n"],"names":["NodeSdk","createLogger","makeOtlpHttpLogSink","makeStdoutJsonSink","context","AsyncLocalStorageContextManager","OTLPMetricExporter","OTLPTraceExporter","AggregationTemporality","InMemoryMetricExporter","PeriodicExportingMetricReader","BatchSpanProcessor","InMemorySpanExporter","SimpleSpanProcessor","Effect","Layer","Logger","References","DEFAULT_METRIC_INTERVAL_MS","ONE_HOUR_MS","contextManagerReady","ensureContextManager","setGlobalContextManager","enable","resolveEndpoint","raw","trimmed","trim","undefined","makeSink","config","endpoint","sink","serviceName","flushIntervalMs","onError","error","process","stderr","write","String","toToolingLevel","level","toAttributes","annotations","Object","fromEntries","entries","map","key","value","messageToString","message","Array","isArray","part","join","makeEffectLogger","logger","make","logLevel","fiber","text","attributes","getRef","CurrentLogAnnotations","makeObservabilityLayerWith","options","toolingLogger","service","effectLogger","LoggingLayer","layer","TelemetryLayer","resource","spanProcessor","metricReader","merge","makeObservabilityLayer","otelEndpoint","url","exporter","exportIntervalMillis","metricIntervalMs","makeInMemoryObservabilityLayer","logRecords","spanExporter","metricExporter","CUMULATIVE","emit","record","push","getSpans","getFinishedSpans","collectMetrics","forceFlush","getMetrics","observabilityFromConfiguration","store","gen","in","getString","getOptionalString","getOptionalNumber"],"mappings":"AAAA,SAASA,OAAO,QAAQ,wBAAwB;AAEhD,SAEEC,YAAY,EAKZC,mBAAmB,EACnBC,kBAAkB,QACb,2BAA2B;AAClC,SAASC,OAAO,QAAQ,qBAAqB;AAC7C,SAASC,+BAA+B,QAAQ,qCAAqC;AACrF,SAASC,kBAAkB,QAAQ,4CAA4C;AAC/E,SAASC,iBAAiB,QAAQ,0CAA0C;AAC5E,SACEC,sBAAsB,EACtBC,sBAAsB,EAEtBC,6BAA6B,QAExB,6BAA6B;AACpC,SACEC,kBAAkB,EAClBC,oBAAoB,EAEpBC,mBAAmB,QAEd,gCAAgC;AACvC,SAASC,MAAM,EAAEC,KAAK,EAAEC,MAAM,EAAEC,UAAU,QAAQ,SAAS;AAiC3D,gEAAgE,GAChE,MAAMC,6BAA6B;AAEnC,mFAAmF,GACnF,MAAMC,cAAc;AAEpB;;;;;;;CAOC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B,MAAME,EAAE,CAAC,QAAQE,iBAAiB,CAAC;QAC/D,MAAMnB,mBAAmB,OAAOe,MAC7BE,EAAE,CAAC,QACHG,iBAAiB,CAAC;QAErB,OAAOzB,uBAAuB;YAC5B7C;YACAS,OAAOA;YACP,2EAA2E;YAC3E,+DAA+D;YAC/DV,MAAMA,SAAS,WAAW,WAAW;YACrC+C;YACAI;QACF;IACF,GAAG"}
1
+ {"version":3,"sources":["../src/observability.ts"],"sourcesContent":["import * as NodeSdk from '@effect/opentelemetry/NodeSdk';\nimport type { ConfigurationClient, EntifixBuildError } from '@entifix/core';\nimport {\n type Attributes,\n createLogger,\n type Logger as ToolingLogger,\n type LogLevel,\n type LogRecord,\n type LogSink,\n makeOtlpHttpLogSink,\n makeStdoutJsonSink,\n} from '@entifix/tooling/logging';\nimport { context } from '@opentelemetry/api';\nimport { AsyncLocalStorageContextManager } from '@opentelemetry/context-async-hooks';\nimport { OTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-http';\nimport { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';\nimport {\n AggregationTemporality,\n InMemoryMetricExporter,\n type MetricReader,\n PeriodicExportingMetricReader,\n type ResourceMetrics,\n} from '@opentelemetry/sdk-metrics';\nimport {\n BatchSpanProcessor,\n InMemorySpanExporter,\n type ReadableSpan,\n SimpleSpanProcessor,\n type SpanProcessor,\n} from '@opentelemetry/sdk-trace-base';\nimport { Effect, Layer, Logger, References } from 'effect';\nimport type * as EffectLogLevel from 'effect/LogLevel';\n\n/** Resolved observability settings (from config-service `logging.*`/`otel.*`). */\nexport interface ObservabilityConfig {\n readonly serviceName: string;\n readonly level: LogLevel;\n /** `otlp` in dev (ship straight to otel-lgtm), `stdout` in a cluster (filelog). */\n readonly sink: 'stdout' | 'otlp';\n /**\n * OTLP base URL; `/v1/traces`, `/v1/logs` and `/v1/metrics` are appended.\n *\n * **Optional, and that is the boot guarantee**: with no endpoint the service\n * still starts — logs fall back to the stdout sink and neither exporter is\n * built. It used to be a required `getString`, so a fleet whose\n * `otel.endpoint` row was missing failed to boot at all rather than running\n * without telemetry, which is the wrong trade for a signal that is not on the\n * request path.\n */\n readonly otelEndpoint?: string | undefined;\n /**\n * How often the metric reader exports, in milliseconds. Config rather than a\n * constant because it is a real operational dial (a shorter interval buys\n * resolution with cardinality-independent request volume), and optional\n * because a fleet whose seed predates the key should not fail to boot over an\n * export interval. (Optional for that reason alone: config-service reconciles\n * `SEED_ROWS` per row on every boot, so a *new* key does reach an existing\n * Postgres — `ON CONFLICT DO NOTHING` declines to overwrite an operator's\n * changed *value*, which is the case that needs a `dev:reset`.)\n */\n readonly metricIntervalMs?: number | undefined;\n}\n\n/** Export interval used when `otel.metricIntervalMs` is unset. */\nconst DEFAULT_METRIC_INTERVAL_MS = 60_000;\n\n/** The in-memory reader's interval — long enough that only `forceFlush` collects. */\nconst ONE_HOUR_MS = 3_600_000;\n\n/**\n * `@effect/opentelemetry` manages its own span tree but does not register an\n * OpenTelemetry context manager, so `@opentelemetry/api`'s active-span lookup\n * (which the tooling logger uses to stamp `trace_id`) would stay empty. Register\n * the AsyncLocalStorage manager once so the active span propagates and logs\n * correlate to their traces. Idempotent — `setGlobalContextManager` no-ops if a\n * manager is already registered (e.g. across test boots in one process).\n */\nlet contextManagerReady = false;\nconst ensureContextManager = (): void => {\n if (!contextManagerReady) {\n context.setGlobalContextManager(\n new AsyncLocalStorageContextManager().enable(),\n );\n contextManagerReady = true;\n }\n};\n\n/**\n * The OTLP base URL, or `undefined` when there is nowhere to export.\n *\n * A **blank** endpoint counts as absent, not as a base URL. config-service's\n * operator CRUD writes empty strings, so `''` is reachable in practice — and\n * taken literally it builds exporters aimed at the relative `/v1/traces` and\n * `/v1/metrics`, which resolve against nothing, fail every export, and look\n * from the call site exactly like a service that is simply quiet.\n */\nconst resolveEndpoint = (raw: string | undefined): string | undefined => {\n const trimmed = raw?.trim();\n return trimmed === undefined || trimmed === '' ? undefined : trimmed;\n};\n\nconst makeSink = (\n config: ObservabilityConfig,\n endpoint: string | undefined,\n): LogSink =>\n config.sink === 'otlp' && endpoint !== undefined\n ? makeOtlpHttpLogSink({\n endpoint,\n serviceName: config.serviceName,\n // Flush on a short interval too, so a quiet service's logs reach the\n // Collector promptly instead of waiting for a full batch.\n flushIntervalMs: 2000,\n onError: error =>\n process.stderr.write(\n `[otlp-log-sink] export failed: ${String(error)}\\n`,\n ),\n })\n : makeStdoutJsonSink();\n\n/**\n * Effect's `LogLevel` mapped onto the four levels the tooling logger has.\n *\n * ⚠️ **Match the spelling `effect/LogLevel` declares, and let the compiler\n * hold you to it.** Effect 4's level is the string union `\"All\" | \"Fatal\" |\n * \"Error\" | \"Warn\" | \"Info\" | \"Debug\" | \"Trace\" | \"None\"`. Under Effect 3 this\n * switch read the level's `label`, which was upper case (`\"ERROR\"`), against\n * mixed-case spellings (`'Error'`, `'Warning'`) typed as a plain `string` — so\n * **no case could ever match** and every log in the service fell through to\n * `default` and was emitted at `info`. Measured in Loki: an `Effect.logError`\n * arrived as `severity_text: INFO`, `severity_number: 9`, which makes an error\n * invisible to every level-based alert and dashboard while still appearing in\n * the log — the failure mode that reads as \"we have no errors\". Typing the\n * parameter as Effect's own union is what makes a misspelt case a compile\n * error now: `'Warning'` would not compile.\n */\nconst toToolingLevel = (level: EffectLogLevel.LogLevel): LogLevel => {\n switch (level) {\n case 'Trace':\n case 'Debug':\n return 'debug';\n case 'Warn':\n return 'warn';\n case 'Error':\n case 'Fatal':\n return 'error';\n default:\n return 'info';\n }\n};\n\n/**\n * `Effect.annotateLogs`' entries flattened into tooling `Attributes`.\n *\n * The annotations are a record read off the fiber, and the attribute values are\n * a closed scalar set, so anything else is stringified rather than dropped — an\n * annotation that reaches a sink as `[object Object]` is still more use than one\n * that silently is not there.\n */\nconst toAttributes = (\n annotations: Readonly<Record<string, unknown>>,\n): Attributes =>\n Object.fromEntries(\n Object.entries(annotations).map(([key, value]) => [\n key,\n typeof value === 'string' ||\n typeof value === 'number' ||\n typeof value === 'boolean' ||\n value === null\n ? value\n : String(value),\n ]),\n );\n\nconst messageToString = (message: unknown): string =>\n Array.isArray(message)\n ? message.map(part => String(part)).join(' ')\n : String(message);\n\n/**\n * An Effect `Logger` that forwards every Effect log (including the request logs\n * `HttpRouter.serve` writes) to the tooling logger — so the whole service logs\n * through one structured, trace-correlated pipeline.\n *\n * **Annotations are forwarded**, and used not to be: they were destructured\n * away, so every `Effect.annotateLogs` in every service was discarded before it\n * reached a sink. That made the annotated fields the outbox relay and the\n * transaction engine attach — the tenant database, the event id, the\n * transaction id, the rollback's own error — unqueryable, while the comments\n * beside them said they were structured fields in Loki. Measured: the records\n * arrived carrying the message and nothing else. Effect 4 no longer hands them\n * to a logger at all; they live on the fiber, as\n * `References.CurrentLogAnnotations`, and are read from there.\n *\n * `error` is called through its own arm because the tooling `Logger` gives it a\n * different signature — `(message, error?, attributes?)` — so passing the\n * attributes positionally as the second argument would file them as the *cause*\n * and lose them again.\n */\nconst makeEffectLogger = (\n logger: ToolingLogger,\n): Logger.Logger<unknown, void> =>\n Logger.make(({ logLevel, message, fiber }) => {\n const level = toToolingLevel(logLevel);\n const text = messageToString(message);\n const attributes = toAttributes(\n fiber.getRef(References.CurrentLogAnnotations),\n );\n\n if (level === 'error') {\n logger.error(text, undefined, attributes);\n return;\n }\n logger[level](text, attributes);\n });\n\n/** Lower-level inputs to {@link makeObservabilityLayerWith}. */\nexport interface ObservabilityLayerOptions {\n readonly serviceName: string;\n readonly level: LogLevel;\n /** Where log records go (a real sink in prod, an in-memory double in tests). */\n readonly sink: LogSink;\n /**\n * How spans are exported (batch→OTLP in prod, in-memory in tests).\n * Omitted when there is no OTLP endpoint to export to.\n */\n readonly spanProcessor?: SpanProcessor | undefined;\n /**\n * How metrics are exported (periodic→OTLP in prod, in-memory in tests).\n *\n * Injectable for the same reason `spanProcessor` is: a test drives the exact\n * wiring that ships, so — unlike a double that reimplements the composition —\n * it can see `Metrics.layer` failing to register a producer at all.\n */\n readonly metricReader?: MetricReader | undefined;\n}\n\n/**\n * The observability composition over explicit sink + span processor: replace\n * Effect's default logger with the tooling-backed one, and stand up the OTel\n * tracer so requests produce spans. Keeping sink/processor injectable lets a\n * test drive the exact same wiring with in-memory exporters (see\n * {@link makeInMemoryObservabilityLayer}), so the correlation the e2e asserts is\n * the correlation that ships.\n */\nexport const makeObservabilityLayerWith = (\n options: ObservabilityLayerOptions,\n) => {\n ensureContextManager();\n const toolingLogger = createLogger({\n service: options.serviceName,\n level: options.level,\n sink: options.sink,\n });\n // Replace Effect's loggers with the tooling logger. `Logger.layer` sets the\n // fiber's current loggers outright rather than adding to them, and neither\n // the service boot (`runMain`) nor the e2e boot (`Effect.runFork`) installs a\n // logger of its own, so this single layer takes effect in either runtime.\n const effectLogger = makeEffectLogger(toolingLogger);\n const LoggingLayer = Logger.layer([effectLogger]);\n // One `NodeSdk.layer` for both signals: it builds the OTel `Resource` once,\n // so the spans and the metrics carry the same `service.name` rather than two\n // resources that can disagree. `NodeSdk` degrades an absent `spanProcessor`\n // or `metricReader` to `Layer.empty` on its own (its `isNonEmpty` guard), so\n // the no-endpoint case needs no branch here — it simply exports nothing.\n //\n // The metric half needs no producer of its own: `NodeSdk` wires the reader\n // through `Metrics.layer`, whose `MetricProducer` reads **Effect's own metric\n // registry**. So `Metric.counter(…)` at any call site is exported, and a\n // domain counter stays one line where it is incremented.\n const TelemetryLayer = NodeSdk.layer(() => ({\n resource: { serviceName: options.serviceName },\n spanProcessor: options.spanProcessor,\n metricReader: options.metricReader,\n }));\n return Layer.merge(LoggingLayer, TelemetryLayer);\n};\n\n/**\n * The production/dev observability layer: log level + sink and OTLP endpoint\n * come from config-service. Merged into the service `AppLayer`.\n */\nexport const makeObservabilityLayer = (config: ObservabilityConfig) => {\n const endpoint = resolveEndpoint(config.otelEndpoint);\n return makeObservabilityLayerWith({\n serviceName: config.serviceName,\n level: config.level,\n sink: makeSink(config, endpoint),\n spanProcessor:\n endpoint === undefined\n ? undefined\n : new BatchSpanProcessor(\n new OTLPTraceExporter({ url: `${endpoint}/v1/traces` }),\n ),\n metricReader:\n endpoint === undefined\n ? undefined\n : new PeriodicExportingMetricReader({\n exporter: new OTLPMetricExporter({\n url: `${endpoint}/v1/metrics`,\n }),\n exportIntervalMillis:\n config.metricIntervalMs ?? DEFAULT_METRIC_INTERVAL_MS,\n }),\n });\n};\n\n/** Captured telemetry from {@link makeInMemoryObservabilityLayer}. */\nexport interface InMemoryObservability {\n readonly layer: ReturnType<typeof makeObservabilityLayerWith>;\n /** Records the (replaced) logger emitted — the e2e asserts on these. */\n readonly logRecords: readonly LogRecord[];\n /** The spans exported so far (used to confirm requests produced traces). */\n readonly getSpans: () => ReadonlyArray<ReadableSpan>;\n /**\n * Forces a metric collection and returns what the exporter then holds.\n *\n * A push reader only exports on its interval, so a test that merely read the\n * exporter would find it empty and could not tell \"the producer is not\n * registered\" from \"the interval has not elapsed\".\n */\n readonly collectMetrics: () => Promise<ReadonlyArray<ResourceMetrics>>;\n}\n\n/**\n * Test-support: the real observability wiring with in-memory exporters, so an\n * e2e can boot the service and assert that logs are structured and carry the\n * `trace_id` of the request span that produced them.\n */\nexport const makeInMemoryObservabilityLayer = (\n serviceName: string,\n): InMemoryObservability => {\n const logRecords: LogRecord[] = [];\n const spanExporter = new InMemorySpanExporter();\n const metricExporter = new InMemoryMetricExporter(\n AggregationTemporality.CUMULATIVE,\n );\n // A long interval, because the test drives collection explicitly through\n // `collectMetrics`. A short one would export on a timer as well and make the\n // assertions depend on how long the surrounding effect happened to take.\n const metricReader = new PeriodicExportingMetricReader({\n exporter: metricExporter,\n exportIntervalMillis: ONE_HOUR_MS,\n });\n const layer = makeObservabilityLayerWith({\n serviceName,\n level: 'debug',\n sink: { emit: record => logRecords.push(record) },\n spanProcessor: new SimpleSpanProcessor(spanExporter),\n metricReader,\n });\n return {\n layer,\n logRecords,\n getSpans: () => spanExporter.getFinishedSpans(),\n collectMetrics: async () => {\n await metricReader.forceFlush();\n return metricExporter.getMetrics();\n },\n };\n};\n\n/**\n * The observability layer for a service, read from its own configuration.\n *\n * This is the whole per-service wiring: a composition root yields it and merges\n * the result into its `AppLayer`. It exists because the four reads below were\n * byte-identical in every service that had them, sitting directly above a\n * `makeObservabilityLayer` call that mapped them one-for-one — the same\n * duplication the module itself carried, one level up.\n *\n * `logging.level` and `logging.sink` are **required**: the rows are seeded for\n * every service and reach an existing table on config-service's next boot (the\n * seed reconciles per row and only declines to overwrite a value that is already\n * there), so a missing one is a real misconfiguration and should be loud.\n *\n * `otel.endpoint` and `otel.metricIntervalMs` are **optional**, for two\n * different reasons. The endpoint is what makes telemetry a *degradable*\n * dependency — with none, the service boots and serves, logs to stdout and\n * exports nothing, rather than an unreachable telemetry destination taking the\n * service down. The interval is a dial with a sane default, and requiring it\n * would fail the boot on any fleet whose seed predates it.\n *\n * Takes the {@link ConfigurationClient} port rather than a concrete client, so\n * config-service can pass the store it builds from its **own** SQL rows: it is\n * the one service that cannot fetch its configuration over HTTP, because it is\n * the thing being fetched from.\n */\nexport const observabilityFromConfiguration = (\n store: ConfigurationClient,\n serviceName: string,\n): Effect.Effect<\n ReturnType<typeof makeObservabilityLayer>,\n EntifixBuildError\n> =>\n Effect.gen(function* () {\n const level = yield* store.in('logging').getString('level');\n const sink = yield* store.in('logging').getString('sink');\n const otelEndpoint = yield* store.in('otel').getOptionalString('endpoint');\n const metricIntervalMs = yield* store\n .in('otel')\n .getOptionalNumber('metricIntervalMs');\n\n return makeObservabilityLayer({\n serviceName,\n level: level as LogLevel,\n // Anything but the explicit `stdout` is the OTLP sink, which is what makes\n // a mistyped value degrade to shipping rather than to silence.\n sink: sink === 'stdout' ? 'stdout' : 'otlp',\n otelEndpoint,\n metricIntervalMs,\n });\n });\n"],"names":["NodeSdk","createLogger","makeOtlpHttpLogSink","makeStdoutJsonSink","context","AsyncLocalStorageContextManager","OTLPMetricExporter","OTLPTraceExporter","AggregationTemporality","InMemoryMetricExporter","PeriodicExportingMetricReader","BatchSpanProcessor","InMemorySpanExporter","SimpleSpanProcessor","Effect","Layer","Logger","References","DEFAULT_METRIC_INTERVAL_MS","ONE_HOUR_MS","contextManagerReady","ensureContextManager","setGlobalContextManager","enable","resolveEndpoint","raw","trimmed","trim","undefined","makeSink","config","endpoint","sink","serviceName","flushIntervalMs","onError","error","process","stderr","write","String","toToolingLevel","level","toAttributes","annotations","Object","fromEntries","entries","map","key","value","messageToString","message","Array","isArray","part","join","makeEffectLogger","logger","make","logLevel","fiber","text","attributes","getRef","CurrentLogAnnotations","makeObservabilityLayerWith","options","toolingLogger","service","effectLogger","LoggingLayer","layer","TelemetryLayer","resource","spanProcessor","metricReader","merge","makeObservabilityLayer","otelEndpoint","url","exporter","exportIntervalMillis","metricIntervalMs","makeInMemoryObservabilityLayer","logRecords","spanExporter","metricExporter","CUMULATIVE","emit","record","push","getSpans","getFinishedSpans","collectMetrics","forceFlush","getMetrics","observabilityFromConfiguration","store","gen","in","getString","getOptionalString","getOptionalNumber"],"mappings":"AAAA,YAAYA,aAAa,gCAAgC;AAEzD,SAEEC,YAAY,EAKZC,mBAAmB,EACnBC,kBAAkB,QACb,2BAA2B;AAClC,SAASC,OAAO,QAAQ,qBAAqB;AAC7C,SAASC,+BAA+B,QAAQ,qCAAqC;AACrF,SAASC,kBAAkB,QAAQ,4CAA4C;AAC/E,SAASC,iBAAiB,QAAQ,0CAA0C;AAC5E,SACEC,sBAAsB,EACtBC,sBAAsB,EAEtBC,6BAA6B,QAExB,6BAA6B;AACpC,SACEC,kBAAkB,EAClBC,oBAAoB,EAEpBC,mBAAmB,QAEd,gCAAgC;AACvC,SAASC,MAAM,EAAEC,KAAK,EAAEC,MAAM,EAAEC,UAAU,QAAQ,SAAS;AAiC3D,gEAAgE,GAChE,MAAMC,6BAA6B;AAEnC,mFAAmF,GACnF,MAAMC,cAAc;AAEpB;;;;;;;CAOC,GACD,IAAIC,sBAAsB;AAC1B,MAAMC,uBAAuB;IAC3B,IAAI,CAACD,qBAAqB;QACxBhB,QAAQkB,uBAAuB,C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,iBAAiB,CAAC;QAErB,OAAOzB,uBAAuB;YAC5B7C;YACAS,OAAOA;YACP,2EAA2E;YAC3E,+DAA+D;YAC/DV,MAAMA,SAAS,WAAW,WAAW;YACrC+C;YACAI;QACF;IACF,GAAG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@entifix/service-shell",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "description": "Effect HTTP service skeleton: server layer, health and metadata routes, permission guards, remote configuration and OpenTelemetry.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -66,10 +66,10 @@
66
66
  },
67
67
  "dependencies": {
68
68
  "@swc/helpers": "0.5.23",
69
- "@entifix/authz": "0.12.0",
70
- "@entifix/business": "0.12.0",
71
- "@entifix/core": "0.12.0",
72
- "@entifix/tooling": "0.12.0"
69
+ "@entifix/authz": "0.13.0",
70
+ "@entifix/business": "0.13.0",
71
+ "@entifix/core": "0.13.0",
72
+ "@entifix/tooling": "0.13.0"
73
73
  },
74
74
  "devDependencies": {
75
75
  "@effect/opentelemetry": "4.0.6",
@@ -81,8 +81,8 @@
81
81
  "@opentelemetry/sdk-metrics": "2.12.0",
82
82
  "@opentelemetry/sdk-trace-base": "2.12.0",
83
83
  "effect": "4.0.6",
84
- "@entifix/rest": "0.12.0",
85
- "@entifix/testing-unit": "0.12.0"
84
+ "@entifix/rest": "0.13.0",
85
+ "@entifix/testing-unit": "0.13.0"
86
86
  },
87
87
  "peerDependencies": {
88
88
  "@effect/opentelemetry": "^4.0.6",