@safaricom-mxl/effect-sdk 0.0.22 → 0.0.24

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-BMDPjez-.mjs","names":["traceApi","otelContext","stringOrUndefined","make","layer","traceApi","otelContext","Option","headerValue","Tracer","uuidv7","EnvConfig.sdkDisabled","EnvConfig.endpoint","endpoint","EnvConfig.otlpHeaders","EnvConfig.serviceVersion","serviceVersion","EnvConfig.environment","environment","EnvConfig.otelServiceName","EnvConfig.otelResourceAttributes","otelLayer","eventsLayer","traceApi","otelContext","Option"],"sources":["../src/shared/span-options.ts","../src/server/config.ts","../src/shared/try-sync.ts","../src/server/container.ts","../src/shared/dependency-spans.ts","../src/shared/product-event.ts","../src/version.ts","../src/server/events.ts","../src/server/trace-correlation.ts","../src/server/evlog-bridge.ts","../src/server/otel-context-bridge.ts","../src/server/otlp.ts","../src/server/platform.ts","../src/server/resource.ts","../src/server/layer.ts","../src/server/flushable.ts","../src/server/http-middleware.ts","../src/server/logging.ts","../src/server/http-tracing.ts","../src/server/jobs.ts"],"sourcesContent":["// Span filtering + error classification options, shared by every preset\n// (`Mxl.layer`, `MxlFlush.make`, and the Cloudflare `make`) so they accept\n// the same options and classify a given span the same way.\n//\n// BOUNDARY: a span's failure can be any value, so error predicates take `unknown`\n// and `failureIdentifier` narrows it.\n\nimport type { Exit, Tracer } from 'effect';\nimport { Predicate } from 'effect';\n\n/** A finished span, as handed to the `dropSpan` predicate. */\nexport interface FinishedSpan {\n readonly name: string;\n readonly kind: Tracer.SpanKind;\n readonly attributes: ReadonlyMap<string, unknown>;\n readonly exit: Exit.Exit<unknown, unknown>;\n}\n\nexport interface MxlSpanOptions {\n /**\n * Span name prefixes to drop before OTLP export. Only the matching span is\n * dropped: its children still export (with a parent that never arrives). Use\n * `dropSpanSubtrees` to drop the children too.\n */\n readonly dropSpanNames?: ReadonlyArray<string> | undefined;\n /**\n * Span name prefixes whose span AND every descendant are dropped. The span is\n * started unsampled, so children inherit that and nothing under it exports,\n * whatever its name (DB queries, HTTP client calls, ...).\n *\n * Two side effects worth knowing before reaching for it: outgoing HTTP calls\n * under a dropped span send `traceparent` with the sampled flag off, so\n * downstream services that honour it drop their part of the trace too; and\n * errors inside the subtree never reach error tracking. Keep real work (e.g.\n * processing a job a poll found) out of the dropped span.\n */\n readonly dropSpanSubtrees?: ReadonlyArray<string> | undefined;\n /**\n * Called on each finished span; returning `true` drops it (children are not\n * affected). Use when a name prefix isn't enough, e.g. dropping only polls\n * that found nothing: `(span) => span.attributes.get(\"queue.empty\") === true`.\n */\n readonly dropSpan?: ((span: FinishedSpan) => boolean) | undefined;\n /**\n * Stable `_tag` / `Error.name` identifiers of expected failures (validation,\n * not-found, duplicate, ...). A span failing entirely with these exports as\n * status `Ok` with no `exception` event: still visible, never an error. A\n * failure wrapped in an `{ error: … }` envelope is matched on the body's\n * `_tag`. A server span that answered 5xx stays `Error` regardless.\n */\n readonly anticipatedErrorIdentifiers?: ReadonlyArray<string> | undefined;\n /** @deprecated Use `anticipatedErrorIdentifiers`. */\n readonly anticipatedErrorTags?: ReadonlyArray<string> | undefined;\n /**\n * Predicate form of `anticipatedErrorIdentifiers`, for failures a tag can't\n * single out (e.g. a driver error that is only expected for a duplicate key).\n * Either matching makes the failure anticipated.\n */\n readonly isAnticipatedError?: ((error: unknown) => boolean) | undefined;\n}\n\nexport type MapleSpanOptions = MxlSpanOptions;\n\n/** Internal input: sets are accepted wherever the public options take arrays. */\nexport interface SpanFilterInput {\n readonly dropSpanNames?: Iterable<string> | undefined;\n readonly dropSpanSubtrees?: Iterable<string> | undefined;\n readonly dropSpan?: ((span: FinishedSpan) => boolean) | undefined;\n readonly anticipatedErrorIdentifiers?: Iterable<string> | undefined;\n readonly anticipatedErrorTags?: Iterable<string> | undefined;\n readonly isAnticipatedError?: ((error: unknown) => boolean) | undefined;\n /**\n * Append each error's `[cause]` chain to `exception.stacktrace`, as Effect's\n * stock `OtlpTracer` does. Fingerprints hash the top stack frames, so a\n * preset keeps whatever it shipped with to avoid re-splitting error groups.\n */\n readonly includeCauseInStack?: boolean | undefined;\n}\n\nexport interface SpanFilter {\n readonly dropSubtree: ((name: string) => boolean) | undefined;\n readonly drop: ((span: FinishedSpan) => boolean) | undefined;\n readonly isAnticipated: ((error: unknown) => boolean) | undefined;\n readonly includeCauseInStack: boolean;\n}\n\nconst prefixMatcher = (\n prefixes: Iterable<string> | undefined,\n): ((name: string) => boolean) | undefined => {\n const list = prefixes === undefined ? [] : [...prefixes];\n return list.length > 0\n ? (name) => list.some((prefix) => name.startsWith(prefix))\n : undefined;\n};\n\n// A failure's stable identifier: its `_tag`, else its `Error.name`. An error\n// that crossed an HTTP boundary arrives as a decoded *body*, so an API that\n// wraps bodies in `{ error: … }` hands over a plain object with no identifier of\n// its own; unwrap one level, and only for the body's own tag.\nexport const failureIdentifier = (error: unknown): string | undefined => {\n if (Predicate.hasProperty(error, '_tag') && typeof error._tag === 'string')\n return error._tag;\n if (Predicate.hasProperty(error, 'name') && typeof error.name === 'string')\n return error.name;\n const body = Predicate.hasProperty(error, 'error') ? error.error : undefined;\n if (Predicate.hasProperty(body, '_tag') && typeof body._tag === 'string')\n return body._tag;\n return undefined;\n};\n\nexport const resolveSpanFilter = (input: SpanFilterInput = {}): SpanFilter => {\n const dropName = prefixMatcher(input.dropSpanNames);\n const dropPredicate = input.dropSpan;\n const drop =\n dropName !== undefined && dropPredicate !== undefined\n ? (span: FinishedSpan) => dropName(span.name) || dropPredicate(span)\n : dropName !== undefined\n ? (span: FinishedSpan) => dropName(span.name)\n : dropPredicate;\n\n const identifiers = new Set([\n ...(input.anticipatedErrorIdentifiers ?? []),\n ...(input.anticipatedErrorTags ?? []),\n ]);\n const byIdentifier =\n identifiers.size > 0\n ? (error: unknown) => {\n const identifier = failureIdentifier(error);\n return identifier !== undefined && identifiers.has(identifier);\n }\n : undefined;\n const byPredicate = input.isAnticipatedError;\n const isAnticipated =\n byIdentifier !== undefined && byPredicate !== undefined\n ? (error: unknown) => byIdentifier(error) || byPredicate(error)\n : (byIdentifier ?? byPredicate);\n\n return {\n dropSubtree: prefixMatcher(input.dropSpanSubtrees),\n drop,\n isAnticipated,\n includeCauseInStack: input.includeCauseInStack ?? false,\n };\n};\n","import { Config, Effect, Option } from 'effect';\n\nconst DEFAULT_OTLP_ENDPOINT = 'http://127.0.0.1:4318';\n\n/** Resolve the OTLP exporter endpoint from standard env vars. */\nexport const endpoint = Effect.gen(function* () {\n const otlp = yield* Config.option(\n Config.String('OTEL_EXPORTER_OTLP_ENDPOINT'),\n );\n if (Option.isSome(otlp)) return otlp;\n return yield* Config.option(Config.String('OTLP_ENDPOINT'));\n});\n\nexport const defaultOtlpEndpoint = DEFAULT_OTLP_ENDPOINT;\n\nexport const sdkDisabled = Config.Boolean('OTEL_SDK_DISABLED').pipe(\n Config.withDefault(false),\n);\n\n/**\n * Resolve service version / commit SHA from platform-specific env vars.\n *\n * Priority: npm_package_version > COMMIT_SHA > RAILWAY_GIT_COMMIT_SHA >\n * VERCEL_GIT_COMMIT_SHA > CF_PAGES_COMMIT_SHA > RENDER_GIT_COMMIT\n */\nexport const serviceVersion = Config.option(\n Config.String('npm_package_version').pipe(\n Config.orElse(() => Config.String('COMMIT_SHA')),\n Config.orElse(() => Config.String('RAILWAY_GIT_COMMIT_SHA')),\n Config.orElse(() => Config.String('VERCEL_GIT_COMMIT_SHA')),\n Config.orElse(() => Config.String('CF_PAGES_COMMIT_SHA')),\n Config.orElse(() => Config.String('RENDER_GIT_COMMIT')),\n ),\n);\n\n/**\n * Resolve deployment environment from env vars.\n *\n * Priority: NODE_ENV > DEPLOYMENT_ENV > \"development\"\n */\nexport const environment = Config.String('NODE_ENV').pipe(\n Config.orElse(() => Config.String('DEPLOYMENT_ENV')),\n Config.withDefault('development'),\n);\n\n/** OTel-standard service name override. */\nexport const otelServiceName = Config.option(\n Config.String('OTEL_SERVICE_NAME'),\n);\n\n/**\n * Parse the OTel-standard `OTEL_RESOURCE_ATTRIBUTES` env var.\n *\n * Format per the OTel spec: comma-separated `key=value` pairs, values may be\n * URL-encoded.\n */\nexport const parseOtelResourceAttributes = (\n input: string,\n): Record<string, string> => {\n const result: Record<string, string> = {};\n for (const pair of input.split(',')) {\n const eq = pair.indexOf('=');\n if (eq === -1) continue;\n const key = pair.slice(0, eq).trim();\n if (!key) continue;\n const raw = pair.slice(eq + 1).trim();\n let value = raw;\n try {\n value = decodeURIComponent(raw);\n } catch {\n // Fall back to raw string when decoding fails.\n }\n result[key] = value;\n }\n return result;\n};\n\n/** Resolve and parse `OTEL_RESOURCE_ATTRIBUTES`. */\nexport const otelResourceAttributes = Effect.gen(function* () {\n const raw = yield* Config.option(Config.String('OTEL_RESOURCE_ATTRIBUTES'));\n return Option.match(raw, {\n onNone: () => ({}) as Record<string, string>,\n onSome: (value) => parseOtelResourceAttributes(value),\n });\n});\n\n/**\n * Parse `OTEL_EXPORTER_OTLP_HEADERS` (`key=value,key2=value2`) into a header map.\n */\nexport const parseOtlpHeaders = (input: string): Record<string, string> => {\n const result: Record<string, string> = {};\n for (const pair of input.split(',')) {\n const eq = pair.indexOf('=');\n if (eq === -1) continue;\n const key = pair.slice(0, eq).trim();\n if (!key) continue;\n const raw = pair.slice(eq + 1).trim();\n try {\n result[key] = decodeURIComponent(raw);\n } catch {\n result[key] = raw;\n }\n }\n return result;\n};\n\n/** Resolve OTLP export headers from env. */\nexport const otlpHeaders = Effect.gen(function* () {\n const raw = yield* Config.option(Config.String('OTEL_EXPORTER_OTLP_HEADERS'));\n return Option.match(raw, {\n onNone: () => ({}) as Record<string, string>,\n onSome: (value) => parseOtlpHeaders(value),\n });\n});\n","// A throwing host call, as a value.\n//\n// The SDK runs inside someone else's app, so it touches host APIs that throw\n// rather than return a failure: `Intl` in a locale-stripped build, `BigInt` on a\n// wire value that isn't numeric, `decodeURIComponent` on a literal `%`, a\n// `node:fs` read the sandbox refuses. Every one of those is best-effort — the\n// SDK degrades an attribute rather than breaking the host — and `Effect.try` is\n// what makes that an `Option` the caller has to answer for instead of a `catch`\n// block that quietly covers the next three statements too.\nimport { Effect, Option } from 'effect';\n\n/** Run a throwing synchronous call, `None` if it threw. */\nexport const trySync = <A>(thunk: () => A): Option.Option<A> =>\n Effect.runSync(Effect.option(Effect.try(thunk)));\n\n/** Run a throwing synchronous call, `undefined` if it threw. */\nexport const trySyncOrUndefined = <A>(thunk: () => A): A | undefined =>\n Option.getOrUndefined(trySync(thunk));\n","// Best-effort Docker container identity detection\n//\n// Emits `container.runtime` / `container.id` resource attributes so spans and\n// logs from an app running inside a plain Docker container correlate with the\n// docker_stats metrics the Maple Docker agent collects.\n//\n// Detection is inherently best-effort on modern Docker:\n// - cgroup v2 with a private cgroup namespace (the default) renders\n// `/proc/self/cgroup` as `0::/`, hiding the container id — but\n// `/proc/self/mountinfo` usually still carries the id in the overlay paths.\n// - The hostname fallback only fires when `/.dockerenv` exists AND the hostname\n// is 12 hex chars (Docker's default); a user-set `hostname:` defeats it.\n// The reliable path is documented instead: set\n// `OTEL_RESOURCE_ATTRIBUTES=container.id=…,container.name=…`, which takes\n// precedence over these values (later writers win in `resolveResource`).\n//\n// No static `node:fs`/`node:os` imports: this module is bundled into the\n// Cloudflare preset's dependency graph, where those specifiers break the\n// build. `process.getBuiltinModule` (Node ≥ 20.16, Bun) loads them lazily and\n// synchronously; when it's absent, detection just reports nothing.\n\nimport { trySyncOrUndefined } from '../shared/try-sync.js';\n\nconst CONTAINER_ID_RE = /\\/docker\\/containers\\/([0-9a-f]{64})\\//;\nconst CGROUP_ID_RE = /([0-9a-f]{64})/;\nconst SHORT_ID_HOSTNAME_RE = /^[0-9a-f]{12}$/;\n\nexport interface ContainerProbe {\n /** True when the path exists — `/.dockerenv` is the Docker marker file. */\n readonly exists: (path: string) => boolean;\n readonly readFile: (path: string) => string;\n readonly hostname: () => string;\n}\n\n/**\n * Pure derivation from probed inputs — the testable core. Every probe call is\n * guarded by the caller (`getContainerAttributes` wraps the whole thing).\n */\nexport const deriveContainerAttributes = (\n probe: ContainerProbe,\n): Record<string, string> => {\n const inDocker =\n trySyncOrUndefined(() => probe.exists('/.dockerenv')) ?? false;\n\n const attrs: Record<string, string> = {};\n // `container.runtime.name` since semconv v1.37.0; the bare `container.runtime`\n // it replaced is not emitted, because every read path coalesces both\n // spellings anyway (`containerRuntimeExpr`) for the sake of third-party\n // collectors that still send the old one.\n if (inDocker) attrs['container.runtime.name'] = 'docker';\n\n // Lazy fallback chain — this runs at every SDK boot (customer processes),\n // and mountinfo can run to hundreds of KB, so later probes only fire when\n // the earlier ones miss.\n const containerId =\n trySyncOrUndefined(\n () => probe.readFile('/proc/self/mountinfo').match(CONTAINER_ID_RE)?.[1],\n ) ??\n trySyncOrUndefined(\n () => probe.readFile('/proc/self/cgroup').match(CGROUP_ID_RE)?.[1],\n ) ??\n (inDocker\n ? trySyncOrUndefined(() => {\n const name = probe.hostname();\n return SHORT_ID_HOSTNAME_RE.test(name) ? name : undefined;\n })\n : undefined);\n if (containerId) attrs['container.id'] = containerId;\n return attrs;\n};\n\ntype FsModule = {\n existsSync: (path: string) => boolean;\n readFileSync: (path: string, enc: string) => string;\n};\ntype OsModule = { hostname: () => string };\n\n/**\n * The two builtin loads this module performs, declared as an overload pair so\n * `getBuiltinModule` never surfaces an untyped value to callers.\n */\ntype LoadBuiltin = ((id: 'node:fs') => FsModule | undefined) &\n ((id: 'node:os') => OsModule | undefined);\n\nlet cached: Record<string, string> | undefined;\n\n/**\n * Read live container identity from the filesystem, memoized for the process\n * lifetime (container identity cannot change under a running process). Returns\n * `{}` anywhere the probes aren't available — non-Linux, workerd, browsers.\n */\nexport const getContainerAttributes = (): Record<string, string> => {\n if (cached) return cached;\n const proc = (\n globalThis as {\n process?: { platform?: string; getBuiltinModule?: LoadBuiltin };\n }\n ).process;\n const loadBuiltin = proc?.getBuiltinModule;\n if (proc?.platform !== 'linux' || typeof loadBuiltin !== 'function') {\n cached = {};\n return cached;\n }\n const fs = trySyncOrUndefined(() => loadBuiltin('node:fs'));\n const os = trySyncOrUndefined(() => loadBuiltin('node:os'));\n if (!fs || !os) {\n cached = {};\n return cached;\n }\n\n cached = deriveContainerAttributes({\n exists: (path) => fs.existsSync(path),\n readFile: (path) => fs.readFileSync(path, 'utf8'),\n hostname: () => os.hostname(),\n });\n return cached;\n};\n","import {\n context as otelContext,\n propagation,\n SpanKind,\n SpanStatusCode,\n trace as traceApi,\n} from '@opentelemetry/api';\nimport { Effect } from 'effect';\n\nexport type DbSystem = 'clickhouse' | 'postgresql' | 'redis';\n\nexport type DependencySpanKind = 'client' | 'producer' | 'consumer';\n\nconst MAX_FLUSH_SPAN_LINKS = 32;\n\nexport interface QueueTraceContextCarrier {\n readonly traceparent?: string | undefined;\n readonly tracestate?: string | undefined;\n readonly baggage?: string | undefined;\n}\n\nexport function dbClientSpanAttributes(\n dbSystem: DbSystem,\n operation?: string,\n): Record<string, string> {\n return {\n 'db.system': dbSystem,\n 'db.system.name': dbSystem,\n 'peer.service': dbSystem,\n ...(operation ? { 'db.operation.name': operation } : {}),\n };\n}\n\nexport function queueProducerSpanAttributes(\n destinationName: string,\n peerService = 'mxl-worker',\n): Record<string, string> {\n return {\n 'messaging.destination.name': destinationName,\n 'messaging.system': 'bullmq',\n 'peer.service': peerService,\n };\n}\n\nexport function queueConsumerSpanAttributes(\n destinationName: string,\n): Record<string, string> {\n return {\n 'messaging.destination.name': destinationName,\n 'messaging.system': 'bullmq',\n };\n}\n\nexport function kafkaProducerSpanAttributes(\n topic: string,\n peerService = 'kafka',\n): Record<string, string> {\n return {\n 'messaging.destination.name': topic,\n 'messaging.system': 'kafka',\n 'peer.service': peerService,\n };\n}\n\nexport function bufferSpanAttributes(\n bufferName: string,\n operation: string,\n): Record<string, string> {\n return {\n 'buffer.name': bufferName,\n 'db.operation.name': operation,\n 'db.system': 'redis',\n 'db.system.name': 'redis',\n 'peer.service': 'redis',\n };\n}\n\nexport function geoSpanAttributes(): Record<string, string> {\n return {\n 'db.operation.name': 'resolve',\n 'db.system': 'maxmind',\n 'db.system.name': 'maxmind',\n 'peer.service': 'maxmind',\n };\n}\n\nexport function addSpanLinksFromTraceCarriers(\n carriers: readonly QueueTraceContextCarrier[],\n): number {\n const span = traceApi.getActiveSpan();\n if (!span) {\n return 0;\n }\n\n const seen = new Set<string>();\n let linked = 0;\n\n for (const carrier of carriers) {\n if (!carrier.traceparent || seen.has(carrier.traceparent)) {\n continue;\n }\n seen.add(carrier.traceparent);\n\n const extracted = propagation.extract(otelContext.active(), carrier);\n const linkedContext = traceApi.getSpanContext(extracted);\n if (!linkedContext) {\n continue;\n }\n\n span.addLink({ context: linkedContext });\n linked += 1;\n\n if (linked >= MAX_FLUSH_SPAN_LINKS) {\n break;\n }\n }\n\n return linked;\n}\n\nexport interface WithDependencySpanOptions {\n readonly attributes?: Record<string, string> | undefined;\n readonly kind?: DependencySpanKind | undefined;\n}\n\nexport function withDependencySpan<A, E, R>(\n name: string,\n attributes: Record<string, string>,\n program: Effect.Effect<A, E, R>,\n): Effect.Effect<A, E, R>;\nexport function withDependencySpan<A, E, R>(\n name: string,\n options: WithDependencySpanOptions,\n program: Effect.Effect<A, E, R>,\n): Effect.Effect<A, E, R>;\nexport function withDependencySpan<A, E, R>(\n name: string,\n attributesOrOptions: Record<string, string> | WithDependencySpanOptions,\n program: Effect.Effect<A, E, R>,\n): Effect.Effect<A, E, R> {\n const options = isWithDependencySpanOptions(attributesOrOptions)\n ? attributesOrOptions\n : { attributes: attributesOrOptions };\n\n const attributes = options.attributes ?? {};\n const kind: DependencySpanKind = options.kind ?? 'client';\n\n return program.pipe(Effect.withSpan(name, { attributes, kind }));\n}\n\nfunction isWithDependencySpanOptions(\n value: Record<string, string> | WithDependencySpanOptions,\n): value is WithDependencySpanOptions {\n return (\n typeof value === 'object' &&\n ('kind' in value ||\n ('attributes' in value && typeof value.attributes === 'object'))\n );\n}\n\n/** Promise-based dependency span for non-Effect code paths. */\nexport async function withPromiseDependencySpan<T>(\n name: string,\n attributes: Record<string, string>,\n operation: () => Promise<T>,\n kind: DependencySpanKind = 'client',\n): Promise<T> {\n const tracer = traceApi.getTracer('mxl-effect-sdk');\n const spanKind =\n kind === 'producer'\n ? SpanKind.PRODUCER\n : kind === 'consumer'\n ? SpanKind.CONSUMER\n : SpanKind.CLIENT;\n return tracer.startActiveSpan(\n name,\n { attributes, kind: spanKind },\n async (span) => {\n try {\n const result = await operation();\n span.end();\n return result;\n } catch (error) {\n if (error instanceof Error) {\n span.recordException(error);\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: error.message,\n });\n } else {\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: String(error),\n });\n }\n span.end();\n throw error;\n }\n },\n );\n}\n","export type ProductEventSource = 'server' | 'browser';\n\nexport const MAX_EVENT_NAME_LENGTH = 80;\nexport const RESERVED_EVENT_NAMES = ['session_start', 'session_end'] as const;\n\nexport interface ProductEventLine {\n readonly attributes: Record<string, string>;\n readonly group_id: string;\n readonly name: string;\n readonly page_path: string;\n readonly service_name: string;\n readonly session_id: string;\n readonly source: ProductEventSource;\n readonly timestamp: string;\n readonly traceparent?: string | undefined;\n readonly url: string;\n readonly user_id: string;\n readonly visitor_id: string;\n}\n\nexport interface TrackProps {\n readonly [key: string]: unknown;\n}\n\nexport interface TrackOptions {\n readonly attributes?: TrackProps | undefined;\n readonly groupId?: string | undefined;\n readonly pagePath?: string | undefined;\n readonly sessionId?: string | undefined;\n readonly timestamp?: Date | number | undefined;\n readonly traceparent?: string | undefined;\n readonly url?: string | undefined;\n readonly userId?: string | undefined;\n readonly visitorId?: string | undefined;\n}\n\nconst isReservedEventName = (name: string): boolean =>\n RESERVED_EVENT_NAMES.some((reserved) => reserved === name);\n\nexport const coerceTrackProps = (\n props: TrackProps | undefined,\n): Record<string, string> => {\n if (props === undefined) {\n return {};\n }\n const attributes: Record<string, string> = {};\n for (const [key, value] of Object.entries(props)) {\n if (value === undefined) {\n continue;\n }\n attributes[key] = typeof value === 'string' ? value : String(value);\n }\n return attributes;\n};\n\nexport const toEventTimestamp = (value: Date | number | undefined): string =>\n (value instanceof Date ? value : new Date(value ?? Date.now())).toISOString();\n\nexport const encodeProductEventLine = (input: {\n readonly name: string;\n readonly options?: TrackOptions | undefined;\n readonly serviceName: string;\n readonly source: ProductEventSource;\n}): ProductEventLine | undefined => {\n const trimmed = typeof input.name === 'string' ? input.name.trim() : '';\n if (trimmed.length === 0 || isReservedEventName(trimmed)) {\n return undefined;\n }\n const options = input.options ?? {};\n return {\n attributes: coerceTrackProps(options.attributes),\n group_id: options.groupId ?? '',\n name: trimmed.slice(0, MAX_EVENT_NAME_LENGTH),\n page_path: options.pagePath ?? '',\n service_name: input.serviceName,\n session_id: options.sessionId ?? '',\n source: input.source,\n timestamp: toEventTimestamp(options.timestamp),\n traceparent: options.traceparent,\n url: options.url ?? '',\n user_id: options.userId ?? '',\n visitor_id: options.visitorId ?? '',\n };\n};\n\nexport const encodeNdjson = (lines: ReadonlyArray<ProductEventLine>): string =>\n `${lines.map((line) => JSON.stringify(line)).join('\\n')}\\n`;\n","export const SDK_NAME = 'mxl-effect-sdk';\nexport const SDK_VERSION = '0.0.24';\n","import {\n Cause,\n Context,\n Duration,\n Effect,\n Layer,\n ManagedRuntime,\n Option,\n Schedule,\n Schema,\n Semaphore,\n} from 'effect';\nimport { FetchHttpClient, HttpClient, HttpClientRequest } from 'effect/http';\nimport { SchemaJITCompiler } from 'effect/schema';\nimport type {\n ProductEventLine,\n TrackOptions,\n} from '../shared/product-event.js';\nimport {\n encodeNdjson,\n encodeProductEventLine,\n} from '../shared/product-event.js';\nimport { SDK_NAME, SDK_VERSION } from '../version.js';\n\nexport type { TrackOptions } from '../shared/product-event.js';\n\nconst DEFAULT_FLUSH_INTERVAL = Duration.seconds(5);\nconst DEFAULT_MAX_BATCH_SIZE = 100;\nconst MAX_BUFFERED_EVENTS = 1_000;\nconst WARN_INTERVAL_MS = 30_000;\nconst DEFAULT_BASKET_URL = 'http://127.0.0.1:8000';\n\nexport interface MxlEventsConfig {\n readonly apiKey?: string | undefined;\n readonly clientId?: string | undefined;\n readonly endpoint?: string | undefined;\n readonly eventsPath?: string | undefined;\n readonly flushInterval?: Duration.Input | undefined;\n readonly maxBatchSize?: number | undefined;\n readonly serviceName?: string | undefined;\n}\n\nexport interface MxlEventsApi {\n readonly flush: Effect.Effect<void>;\n readonly track: (name: string, options?: TrackOptions) => Effect.Effect<void>;\n}\n\nexport class MxlEvents extends Context.Service<MxlEvents, MxlEventsApi>()(\n '@safaricom-mxl/effect-sdk/MxlEvents',\n) {}\n\nexport class ProductEventsPostError extends Schema.TaggedError<ProductEventsPostError>()(\n '@safaricom-mxl/effect-sdk/ProductEventsPostError',\n {\n cause: Schema.optionalKey(Schema.Defect()),\n message: Schema.String,\n status: Schema.optionalKey(Schema.Number),\n },\n) {}\n\nSchemaJITCompiler.enable(ProductEventsPostError.ast);\nconst stringOrUndefined = (value: string | undefined): string | undefined =>\n value && value.length > 0 ? value : undefined;\n\nconst resolveEventsConfig = (config: MxlEventsConfig) => {\n const endpoint = (\n config.endpoint ??\n process.env['MXL_BASKET_URL'] ??\n DEFAULT_BASKET_URL\n ).replace(/\\/$/, '');\n return {\n apiKey: stringOrUndefined(config.apiKey ?? process.env['MXL_API_KEY']),\n clientId: stringOrUndefined(\n config.clientId ?? process.env['MXL_CLIENT_ID'],\n ),\n serviceName:\n config.serviceName ?? process.env['OTEL_SERVICE_NAME'] ?? 'unknown',\n url: `${endpoint}${config.eventsPath ?? '/events'}`,\n };\n};\n\nexport const make = Effect.fn('MxlEvents.make')(function* (\n config: MxlEventsConfig = {},\n) {\n const resolved = resolveEventsConfig(config);\n const maxBatchSize = Math.max(\n 1,\n config.maxBatchSize ?? DEFAULT_MAX_BATCH_SIZE,\n );\n const client = (yield* HttpClient.HttpClient).pipe(HttpClient.filterStatusOk);\n const flushing = yield* Semaphore.make(1);\n\n let buffer: Array<ProductEventLine> = [];\n let warnedAboutName = false;\n let warnedAboutClient = false;\n let lastPostWarnAt = 0;\n\n const warnPost = (error: ProductEventsPostError): void => {\n const now = Date.now();\n if (now - lastPostWarnAt < WARN_INTERVAL_MS) return;\n lastPostWarnAt = now;\n console.warn(\n `[MxlEvents] ${error.message} (dropping batch)`,\n error.cause ?? '',\n );\n };\n const warnMissingClient = (): void => {\n if (warnedAboutClient) return;\n warnedAboutClient = true;\n console.warn(\n '[MxlEvents] no client id — set MXL_CLIENT_ID or pass `clientId`; dropping events',\n );\n };\n const warnEmptyName = (): void => {\n if (warnedAboutName) return;\n warnedAboutName = true;\n console.warn(\n '[MxlEvents] track() needs a non-empty event name; the call was ignored.',\n );\n };\n\n const post = (lines: ReadonlyArray<ProductEventLine>) => {\n const headers: Record<string, string> = {\n 'mxl-client-id': resolved.clientId ?? '',\n 'mxl-sdk-name': SDK_NAME,\n 'mxl-sdk-version': SDK_VERSION,\n 'user-agent': `${SDK_NAME}-server/${SDK_VERSION}`,\n };\n if (resolved.apiKey) {\n headers['mxl-api-key'] = resolved.apiKey;\n }\n return HttpClientRequest.post(resolved.url).pipe(\n HttpClientRequest.setHeaders(headers),\n HttpClientRequest.bodyText(encodeNdjson(lines), 'application/x-ndjson'),\n client.execute,\n Effect.asVoid,\n Effect.mapError((error) =>\n error.response !== undefined\n ? new ProductEventsPostError({\n message: `POST ${resolved.url} → ${error.response.status}`,\n status: error.response.status,\n })\n : new ProductEventsPostError({\n cause: error,\n message: `POST ${resolved.url} failed: ${error.message}`,\n }),\n ),\n );\n };\n\n const flush: Effect.Effect<void> = flushing.withPermits(1)(\n Effect.suspend(() => {\n if (buffer.length === 0) return Effect.void;\n const batch = buffer;\n buffer = [];\n if (resolved.clientId === undefined) {\n warnMissingClient();\n return Effect.void;\n }\n return post(batch).pipe(\n Effect.catchCause((cause) =>\n Effect.sync(() => {\n warnPost(\n Option.getOrElse(\n Cause.findErrorOption(cause),\n () =>\n new ProductEventsPostError({\n cause: Cause.squash(cause),\n message: `POST ${resolved.url} failed`,\n }),\n ),\n );\n }),\n ),\n );\n }),\n );\n\n const track = (\n name: string,\n options: TrackOptions = {},\n ): Effect.Effect<void> =>\n Effect.sync(() => {\n const line = encodeProductEventLine({\n name,\n options,\n serviceName: resolved.serviceName,\n source: 'server',\n });\n if (line === undefined) {\n warnEmptyName();\n return false;\n }\n buffer.push(line);\n if (buffer.length > MAX_BUFFERED_EVENTS) {\n buffer.splice(0, buffer.length - MAX_BUFFERED_EVENTS);\n }\n return buffer.length >= maxBatchSize;\n }).pipe(\n Effect.flatMap((full) => (full ? Effect.forkDetach(flush) : Effect.void)),\n Effect.asVoid,\n );\n\n const interval = config.flushInterval ?? DEFAULT_FLUSH_INTERVAL;\n if (Duration.toMillis(interval) > 0) {\n yield* Effect.forkScoped(\n flush.pipe(Effect.schedule(Schedule.spaced(interval))),\n );\n }\n yield* Effect.addFinalizer(() => flush);\n\n return { flush, track } satisfies MxlEventsApi;\n});\n\nexport const layer = (config: MxlEventsConfig = {}): Layer.Layer<MxlEvents> =>\n Layer.effect(MxlEvents, make(config)).pipe(\n Layer.provide(FetchHttpClient.layer),\n );\n\nexport interface MxlEventsHandle {\n readonly dispose: () => Promise<void>;\n readonly flush: () => Promise<void>;\n readonly track: (name: string, options?: TrackOptions) => void;\n}\n\nexport const makeHandle = (config: MxlEventsConfig = {}): MxlEventsHandle => {\n const runtime = ManagedRuntime.make(layer(config));\n const swallow = (promise: Promise<unknown>): Promise<void> =>\n promise.then(\n () => undefined,\n () => undefined,\n );\n return {\n dispose: () => swallow(runtime.dispose()),\n flush: () =>\n swallow(\n runtime.runPromise(\n Effect.gen(function* () {\n const events = yield* MxlEvents;\n yield* events.flush;\n }),\n ),\n ),\n track: (name, options) => {\n void swallow(\n runtime.runPromise(\n Effect.gen(function* () {\n const events = yield* MxlEvents;\n yield* events.track(name, options);\n }),\n ),\n );\n },\n };\n};\n","import { context as otelContext, trace as traceApi } from '@opentelemetry/api';\nimport { Effect } from 'effect';\nimport * as Option from 'effect/Option';\n\nexport interface TraceCorrelation {\n spanId?: string;\n traceId?: string;\n}\n\nexport interface TraceLogAnnotations extends Record<string, string> {}\n\nconst ZERO_TRACE_ID = '00000000000000000000000000000000';\nconst ZERO_SPAN_ID = '0000000000000000';\n\n/** Parse W3C `traceparent` (`00-{traceId}-{spanId}-{flags}`). */\nexport function parseTraceparent(\n traceparent: string | undefined,\n): TraceCorrelation {\n if (!traceparent) return {};\n const parts = traceparent.trim().split('-');\n if (parts.length < 4) return {};\n const traceId = parts[1];\n const spanId = parts[2];\n if (!traceId || !spanId) return {};\n if (traceId.length !== 32 || spanId.length !== 16) return {};\n if (traceId === ZERO_TRACE_ID || spanId === ZERO_SPAN_ID) return {};\n return { spanId, traceId };\n}\n\n/**\n * Resolve trace/span IDs for log correlation.\n *\n * Prefers the active OpenTelemetry span (when a host bridge or queue propagation\n * is active), then falls back to a W3C `traceparent` carrier.\n */\nexport function getEffectTraceCorrelation(options?: {\n traceparent?: string | undefined;\n}): TraceCorrelation {\n const activeSpan = traceApi.getSpan(otelContext.active());\n if (activeSpan) {\n const spanContext = activeSpan.spanContext();\n if (\n spanContext.traceId &&\n spanContext.traceId !== ZERO_TRACE_ID &&\n spanContext.spanId &&\n spanContext.spanId !== ZERO_SPAN_ID\n ) {\n return {\n spanId: spanContext.spanId,\n traceId: spanContext.traceId,\n };\n }\n }\n\n return parseTraceparent(options?.traceparent);\n}\n\n/** Build log annotation fields from active span correlation. */\nexport function traceCorrelationLogAnnotations(\n options?: {\n traceparent?: string | undefined;\n } & Record<string, string>,\n): TraceLogAnnotations {\n const { traceparent, ...extra } = options ?? {};\n const correlation = getEffectTraceCorrelation({ traceparent });\n const annotations: TraceLogAnnotations = { ...extra };\n\n if (correlation.traceId) {\n annotations['trace.trace_id'] = correlation.traceId;\n annotations['trace_id'] = correlation.traceId;\n }\n if (correlation.spanId) {\n annotations['trace.span_id'] = correlation.spanId;\n annotations['span_id'] = correlation.spanId;\n }\n\n return annotations;\n}\n\n/** Annotate Effect logs with the active span's trace/span IDs. */\nexport function annotateLogsWithActiveSpanCorrelation<A, E, R>(\n program: Effect.Effect<A, E, R>,\n fields?: Record<string, string>,\n): Effect.Effect<A, E, R> {\n return Effect.gen(function* () {\n const { traceparent, ...extra } = fields ?? {};\n const annotations: TraceLogAnnotations = { ...extra };\n\n const currentSpan = yield* Effect.currentSpan.pipe(Effect.option);\n if (Option.isSome(currentSpan)) {\n annotations['trace.trace_id'] = currentSpan.value.traceId;\n annotations['trace_id'] = currentSpan.value.traceId;\n annotations['trace.span_id'] = currentSpan.value.spanId;\n annotations['span_id'] = currentSpan.value.spanId;\n } else {\n Object.assign(\n annotations,\n traceCorrelationLogAnnotations({\n ...(traceparent !== undefined ? { traceparent } : {}),\n ...extra,\n }),\n );\n }\n\n if (Object.keys(annotations).length === 0) {\n return yield* program;\n }\n\n return yield* program.pipe(Effect.annotateLogs(annotations));\n });\n}\n","import {\n getEffectTraceCorrelation,\n parseTraceparent,\n} from './trace-correlation.js';\n\n/** Minimal evlog enricher context (compatible with `evlog` EnrichContext). */\nexport interface EffectTraceEnrichContext {\n readonly event: Record<string, unknown>;\n readonly headers?: Record<string, string> | undefined;\n}\n\nexport interface EffectTraceEnricherOptions {\n readonly overwrite?: boolean | undefined;\n}\n\nfunction headerValue(\n headers: Record<string, string> | undefined,\n name: string,\n): string | undefined {\n if (!headers) return undefined;\n const direct = headers[name];\n if (direct !== undefined) return direct;\n const lower = headers[name.toLowerCase()];\n if (lower !== undefined) return lower;\n return undefined;\n}\n\nfunction assignTraceFields(\n event: Record<string, unknown>,\n traceId: string,\n spanId: string,\n overwrite: boolean,\n): void {\n if (overwrite || event['trace_id'] === undefined) {\n event['trace_id'] = traceId;\n }\n if (overwrite || event['span_id'] === undefined) {\n event['span_id'] = spanId;\n }\n if (overwrite || event['traceId'] === undefined) {\n event['traceId'] = traceId;\n }\n if (overwrite || event['spanId'] === undefined) {\n event['spanId'] = spanId;\n }\n\n const trace =\n typeof event['trace'] === 'object' && event['trace'] !== null\n ? (event['trace'] as Record<string, unknown>)\n : {};\n\n if (overwrite || trace['trace_id'] === undefined) {\n trace['trace_id'] = traceId;\n }\n if (overwrite || trace['span_id'] === undefined) {\n trace['span_id'] = spanId;\n }\n\n if (Object.keys(trace).length > 0) {\n event['trace'] = trace;\n }\n}\n\n/**\n * Enrich evlog wide events with trace/span IDs from OTel global context or W3C headers.\n *\n * Use `createEffectTraceEnricher` in the MXL evlog enricher chain.\n */\nexport function createEffectTraceEnricher(\n options: EffectTraceEnricherOptions = {},\n): (ctx: EffectTraceEnrichContext) => void {\n const overwrite = options.overwrite ?? false;\n\n return (ctx) => {\n const traceparent = headerValue(ctx.headers, 'traceparent');\n const correlation = getEffectTraceCorrelation({ traceparent });\n\n if (correlation.traceId && correlation.spanId) {\n assignTraceFields(\n ctx.event,\n correlation.traceId,\n correlation.spanId,\n overwrite,\n );\n return;\n }\n\n const parsed = parseTraceparent(traceparent);\n if (parsed.traceId && parsed.spanId) {\n assignTraceFields(ctx.event, parsed.traceId, parsed.spanId, overwrite);\n }\n };\n}\n","import * as Otel from '@opentelemetry/api';\nimport { AsyncLocalStorageContextManager } from '@opentelemetry/context-async-hooks';\nimport { Effect, Layer } from 'effect';\nimport * as Tracer from 'effect/Tracer';\n\nconst evaluate = '~effect/Effect/evaluate' as const;\nconst contextManagerProbe = Otel.createContextKey(\n 'mxl.effect-sdk.context-manager-probe',\n);\n\nlet contextManagerInstalled = false;\n\nfunction hasWorkingContextManager(): boolean {\n return Otel.context.with(\n Otel.ROOT_CONTEXT.setValue(contextManagerProbe, true),\n () => Otel.context.active().getValue(contextManagerProbe) === true,\n );\n}\n\n/**\n * Install AsyncLocalStorage so `Otel.context.with` actually propagates.\n * Does not replace a context manager the host app already registered.\n */\nexport function ensureOtelContextManager(): void {\n if (contextManagerInstalled) return;\n if (hasWorkingContextManager()) {\n contextManagerInstalled = true;\n return;\n }\n const manager = new AsyncLocalStorageContextManager();\n manager.enable();\n if (!Otel.context.setGlobalContextManager(manager)) {\n manager.disable();\n contextManagerInstalled = true;\n return;\n }\n contextManagerInstalled = true;\n}\n\nexport function formatTraceparent(span: Tracer.AnySpan): string {\n const flags = span.sampled ? '01' : '00';\n return `00-${span.traceId}-${span.spanId}-${flags}`;\n}\n\nexport function buildTraceCarrierFromSpan(\n span: Tracer.AnySpan,\n headers?: Record<string, string>,\n): Record<string, string> {\n const carrier: Record<string, string> = {\n traceparent: formatTraceparent(span),\n };\n\n if (headers?.['tracestate']) {\n carrier['tracestate'] = headers['tracestate'];\n }\n if (headers?.['baggage']) {\n carrier['baggage'] = headers['baggage'];\n }\n\n return carrier;\n}\n\n/**\n * Put Effect span ids on the global OpenTelemetry context.\n *\n * Id-only `setSpanContext`. Live `Otel.Span` objects come from\n * `OtelTracer.currentOtelSpan` in Effect space, not from a private TypeId.\n */\nexport function effectSpanToOtelContext(\n activeContext: Otel.Context,\n span: Tracer.AnySpan,\n): Otel.Context {\n return Otel.trace.setSpanContext(activeContext, {\n isRemote: span._tag === 'ExternalSpan',\n spanId: span.spanId,\n traceFlags: span.sampled ? Otel.TraceFlags.SAMPLED : Otel.TraceFlags.NONE,\n traceId: span.traceId,\n });\n}\n\n/**\n * Wrap a tracer so Effect spans activate global `@opentelemetry/api` context.\n *\n * Prefer this over `Otlp.layerJson({ tracerContext })` until Effect changes\n * that hook. On effect@4.0.6 the callback is still `(primitive, span)`\n * and must return the evaluation, but `EffectPrimitive` only evaluates with a\n * `fiber`. Keep this wrap until Effect passes fiber or evaluates after the hook.\n */\nexport function wrapTracerWithOtelContextBridge(\n base: Tracer.Tracer,\n): Tracer.Tracer {\n ensureOtelContextManager();\n const existingContext = base.context;\n\n return Tracer.make({\n span(options) {\n return base.span(options);\n },\n context(primitive, fiber) {\n if (fiber.cache.span === undefined) {\n if (existingContext) {\n return existingContext(primitive, fiber);\n }\n return primitive[evaluate](fiber);\n }\n\n return Otel.context.with(\n effectSpanToOtelContext(Otel.context.active(), fiber.cache.span),\n () => {\n if (existingContext) {\n return existingContext(primitive, fiber);\n }\n return primitive[evaluate](fiber);\n },\n );\n },\n });\n}\n\n/**\n * Layer that wraps the configured Effect tracer with a global OTel context bridge.\n *\n * Must be provided over `Otlp.layerJson` so queue propagation, log correlation,\n * and outbound W3C headers see the active server span.\n */\nexport const otelGlobalContextBridgeLayer = Layer.effect(\n Tracer.Tracer,\n Effect.gen(function* () {\n const base = yield* Tracer.Tracer;\n return wrapTracerWithOtelContextBridge(base);\n }),\n);\n","export function normalizeOtlpBaseUrl(url: string): string {\n const trimmed = url.replace(/\\/$/, '');\n if (trimmed.endsWith('/v1/traces') || trimmed.endsWith('/v1/logs')) {\n return trimmed.replace(/\\/v1\\/(traces|logs|metrics)$/, '');\n }\n return trimmed;\n}\n","import { Match } from 'effect';\nimport { platform, provider, runtime } from 'std-env';\n\nexport interface PlatformEnv {\n readonly AWS_LAMBDA_FUNCTION_NAME?: string | undefined;\n readonly AWS_LAMBDA_FUNCTION_VERSION?: string | undefined;\n readonly AWS_LAMBDA_LOG_STREAM_NAME?: string | undefined;\n readonly AWS_REGION?: string | undefined;\n readonly AWS_DEFAULT_REGION?: string | undefined;\n readonly VERCEL?: string | undefined;\n readonly VERCEL_REGION?: string | undefined;\n readonly VERCEL_DEPLOYMENT_ID?: string | undefined;\n readonly K_SERVICE?: string | undefined;\n readonly K_REVISION?: string | undefined;\n readonly CLOUD_RUN_REGION?: string | undefined;\n readonly DENO_REGION?: string | undefined;\n readonly DENO_DEPLOYMENT_ID?: string | undefined;\n readonly RENDER_INSTANCE_ID?: string | undefined;\n readonly RAILWAY_REPLICA_ID?: string | undefined;\n}\n\nexport interface PlatformInputs {\n readonly runtime: string;\n readonly provider: string;\n readonly platform: string;\n readonly arch: string;\n readonly env: PlatformEnv;\n}\n\ntype Attrs = Record<string, string>;\nconst empty: Attrs = {};\n\nconst runtimeAttrs = (rt: string): Attrs =>\n Match.value(rt).pipe(\n Match.when('node', () => ({ 'process.runtime.name': 'nodejs' })),\n Match.whenOr('bun', 'deno', 'workerd', 'edge-light', 'fastly', (name) => ({\n 'process.runtime.name': name,\n })),\n Match.orElse((): Attrs => empty),\n );\n\nconst osAttrs = (plat: string): Attrs =>\n Match.value(plat).pipe(\n Match.when('win32', () => ({ 'os.type': 'windows' })),\n Match.whenOr('darwin', 'linux', 'freebsd', 'openbsd', 'netbsd', (p) => ({\n 'os.type': p,\n })),\n Match.orElse((): Attrs => empty),\n );\n\nconst archAttrs = (a: string): Attrs =>\n a === ''\n ? empty\n : {\n 'host.arch': Match.value(a).pipe(\n Match.when('x64', () => 'amd64'),\n Match.when('ia32', () => 'x86'),\n Match.orElse((other) => other),\n ),\n };\n\nconst lambdaAttrs = (env: PlatformEnv): Attrs => ({\n 'cloud.provider': 'aws',\n 'cloud.platform': 'aws_lambda',\n 'faas.name': env.AWS_LAMBDA_FUNCTION_NAME!,\n ...(env.AWS_LAMBDA_FUNCTION_VERSION && {\n 'faas.version': env.AWS_LAMBDA_FUNCTION_VERSION,\n }),\n ...(env.AWS_LAMBDA_LOG_STREAM_NAME && {\n 'faas.instance': env.AWS_LAMBDA_LOG_STREAM_NAME,\n }),\n ...(env.AWS_REGION\n ? { 'cloud.region': env.AWS_REGION }\n : env.AWS_DEFAULT_REGION\n ? { 'cloud.region': env.AWS_DEFAULT_REGION }\n : {}),\n});\n\nconst providerAttrs = (prov: string, env: PlatformEnv): Attrs =>\n Match.value(prov).pipe(\n Match.when('cloudflare_workers', (): Attrs => ({\n 'cloud.provider': 'cloudflare',\n 'cloud.platform': 'cloudflare.workers',\n })),\n Match.when('cloudflare_pages', (): Attrs => ({\n 'cloud.provider': 'cloudflare',\n 'cloud.platform': 'cloudflare.pages',\n })),\n Match.when('vercel', (): Attrs => ({\n 'cloud.provider': 'vercel',\n 'cloud.platform': 'vercel',\n ...(env.VERCEL_REGION && { 'cloud.region': env.VERCEL_REGION }),\n ...(env.VERCEL_DEPLOYMENT_ID && {\n 'faas.instance': env.VERCEL_DEPLOYMENT_ID,\n }),\n })),\n Match.when('netlify', (): Attrs => ({\n 'cloud.provider': 'netlify',\n 'cloud.platform': 'netlify',\n })),\n Match.whenOr('google_cloudrun', 'google_cloudrun_job', (): Attrs => ({\n 'cloud.provider': 'gcp',\n 'cloud.platform': 'gcp_cloud_run',\n ...(env.K_SERVICE && { 'faas.name': env.K_SERVICE }),\n ...(env.K_REVISION && { 'faas.version': env.K_REVISION }),\n ...(env.CLOUD_RUN_REGION && { 'cloud.region': env.CLOUD_RUN_REGION }),\n })),\n Match.when('firebase_app_hosting', (): Attrs => ({\n 'cloud.provider': 'gcp',\n 'cloud.platform': 'gcp_firebase_app_hosting',\n })),\n Match.when('aws_amplify', (): Attrs => ({\n 'cloud.provider': 'aws',\n 'cloud.platform': 'aws_amplify',\n })),\n Match.when('deno-deploy', (): Attrs => ({\n 'cloud.provider': 'deno',\n 'cloud.platform': 'deno_deploy',\n ...(env.DENO_REGION && { 'cloud.region': env.DENO_REGION }),\n ...(env.DENO_DEPLOYMENT_ID && {\n 'faas.instance': env.DENO_DEPLOYMENT_ID,\n }),\n })),\n Match.when('render', (): Attrs => ({\n 'cloud.provider': 'render',\n 'cloud.platform': 'render',\n ...(env.RENDER_INSTANCE_ID && {\n 'faas.instance': env.RENDER_INSTANCE_ID,\n }),\n })),\n Match.when('railway', (): Attrs => ({\n 'cloud.provider': 'railway',\n 'cloud.platform': 'railway',\n ...(env.RAILWAY_REPLICA_ID && {\n 'faas.instance': env.RAILWAY_REPLICA_ID,\n }),\n })),\n Match.when('edgeone_pages', (): Attrs => ({\n 'cloud.provider': 'tencent_cloud',\n 'cloud.platform': 'tencent_edgeone_pages',\n })),\n Match.orElse((): Attrs => empty),\n );\n\nconst workerdFallback = (rt: string, alreadyResolved: boolean): Attrs =>\n rt === 'workerd' && !alreadyResolved\n ? {\n 'cloud.provider': 'cloudflare',\n 'cloud.platform': 'cloudflare.workers',\n }\n : empty;\n\nconst vercelEdgeFallback = (\n rt: string,\n alreadyResolved: boolean,\n env: PlatformEnv,\n): Attrs =>\n rt === 'edge-light' && !alreadyResolved && env.VERCEL\n ? { 'cloud.provider': 'vercel', 'cloud.platform': 'vercel' }\n : empty;\n\nexport const derivePlatformAttributes = (\n inputs: PlatformInputs,\n): PlatformAttributes => {\n const { runtime: rt, provider: prov, platform: plat, arch, env } = inputs;\n\n const cloudAttrs = env.AWS_LAMBDA_FUNCTION_NAME\n ? lambdaAttrs(env)\n : providerAttrs(prov, env);\n const cloudResolved = 'cloud.provider' in cloudAttrs;\n\n return {\n ...(rt && { 'mxl.runtime': rt }),\n ...(prov && { 'mxl.provider': prov }),\n ...runtimeAttrs(rt),\n ...osAttrs(plat),\n ...archAttrs(arch),\n ...cloudAttrs,\n ...workerdFallback(rt, cloudResolved),\n ...vercelEdgeFallback(rt, cloudResolved, env),\n };\n};\n\nexport type PlatformAttributes = Attrs;\n\nconst PLATFORM_ENV_KEYS = [\n 'AWS_LAMBDA_FUNCTION_NAME',\n 'AWS_LAMBDA_FUNCTION_VERSION',\n 'AWS_LAMBDA_LOG_STREAM_NAME',\n 'AWS_REGION',\n 'AWS_DEFAULT_REGION',\n 'VERCEL',\n 'VERCEL_REGION',\n 'VERCEL_DEPLOYMENT_ID',\n 'K_SERVICE',\n 'K_REVISION',\n 'CLOUD_RUN_REGION',\n 'DENO_REGION',\n 'DENO_DEPLOYMENT_ID',\n 'RENDER_INSTANCE_ID',\n 'RAILWAY_REPLICA_ID',\n] as const;\n\nexport const getAutoPlatformAttributes = (): PlatformAttributes => {\n const proc = (\n globalThis as { process?: { env?: Record<string, string>; arch?: string } }\n ).process;\n const procEnv = proc?.env ?? {};\n const env: PlatformEnv = {};\n for (const key of PLATFORM_ENV_KEYS) {\n const value = procEnv[key];\n if (value !== undefined) {\n (env as Record<string, string | undefined>)[key] = value;\n }\n }\n\n return derivePlatformAttributes({\n runtime: runtime ?? '',\n provider: provider ?? '',\n platform: platform ?? '',\n arch: proc?.arch ?? '',\n env,\n });\n};\n","import { Effect, Option } from 'effect';\nimport { v7 as uuidv7 } from 'uuid';\n\nimport * as EnvConfig from './config.js';\nimport { getContainerAttributes } from './container.js';\nimport { getAutoPlatformAttributes } from './platform.js';\n\nconst stringOrUndefined = (value: unknown): string | undefined =>\n typeof value === 'string' && value.length > 0 ? value : undefined;\n\nconst DEFAULT_VCS_REPOSITORY_URL =\n 'https://gitlab.safaricom.co.ke/mxl/apm/mxl-effect-sdk';\n\nfunction resolveCommitRevision(): string | undefined {\n return (\n stringOrUndefined(process.env['COMMIT_SHA']) ??\n stringOrUndefined(process.env['VERCEL_GIT_COMMIT_SHA']) ??\n stringOrUndefined(process.env['GITHUB_SHA']) ??\n stringOrUndefined(process.env['RAILWAY_GIT_COMMIT_SHA']) ??\n stringOrUndefined(process.env['CF_PAGES_COMMIT_SHA']) ??\n stringOrUndefined(process.env['RENDER_GIT_COMMIT'])\n );\n}\n\nlet serviceInstanceId: string | undefined;\nconst getServiceInstanceId = (): string => (serviceInstanceId ??= uuidv7());\n\n/**\n * Best-effort guard for `vcs.ref.head.revision`: only stamp values that look\n * like a git commit SHA — `serviceVersion` may legitimately be a semver\n * release string, which belongs in `service.version` but not in `vcs.*`.\n */\nconst isCommitSha = (value: string | undefined): value is string =>\n value !== undefined && /^[0-9a-f]{7,40}$/i.test(value);\n\nexport interface ResourceConfigInput {\n readonly serviceName?: string | undefined;\n readonly serviceVersion?: string | undefined;\n readonly serviceNamespace?: string | undefined;\n readonly environment?: string | undefined;\n readonly endpoint?: string | undefined;\n readonly headers?: Record<string, string> | undefined;\n readonly attributes?: Record<string, string> | undefined;\n readonly sdkType?: 'server' | undefined;\n}\n\nexport interface ResolvedResource {\n readonly endpoint: string | undefined;\n readonly headers: Record<string, string> | undefined;\n readonly resource: {\n readonly serviceName: string;\n readonly serviceVersion: string | undefined;\n readonly attributes: Record<string, string>;\n };\n readonly environment: string | undefined;\n}\n\nexport const resolveResource = (\n config: ResourceConfigInput,\n): Effect.Effect<ResolvedResource> =>\n Effect.gen(function* () {\n const disabled = yield* EnvConfig.sdkDisabled;\n if (disabled) {\n return {\n endpoint: undefined,\n environment: undefined,\n headers: undefined,\n resource: {\n attributes: {},\n serviceName: config.serviceName ?? 'unknown',\n serviceVersion: undefined,\n },\n } satisfies ResolvedResource;\n }\n\n const envEndpoint = yield* EnvConfig.endpoint;\n const endpoint =\n config.endpoint ??\n Option.getOrUndefined(envEndpoint) ??\n EnvConfig.defaultOtlpEndpoint;\n\n const envHeaders = yield* EnvConfig.otlpHeaders;\n const headers =\n config.headers && Object.keys(config.headers).length > 0\n ? config.headers\n : Object.keys(envHeaders).length > 0\n ? envHeaders\n : undefined;\n\n const envServiceVersion = yield* EnvConfig.serviceVersion;\n const serviceVersion =\n config.serviceVersion ?? Option.getOrUndefined(envServiceVersion);\n\n const envEnvironment = yield* EnvConfig.environment;\n const environment = config.environment ?? envEnvironment;\n\n const envOtelServiceName = yield* EnvConfig.otelServiceName;\n const serviceName =\n config.serviceName ??\n Option.getOrUndefined(envOtelServiceName) ??\n 'unknown';\n\n const envResourceAttributes = yield* EnvConfig.otelResourceAttributes;\n\n const attributes: Record<string, string> = {};\n Object.assign(attributes, getAutoPlatformAttributes());\n Object.assign(attributes, getContainerAttributes());\n attributes['mxl.sdk.type'] = config.sdkType ?? 'server';\n attributes['service.instance.id'] = getServiceInstanceId();\n if (environment) {\n attributes['deployment.environment'] = environment;\n attributes['deployment.environment.name'] = environment;\n }\n if (serviceVersion) {\n attributes['service.version'] = serviceVersion;\n }\n const commitRevision = resolveCommitRevision();\n if (commitRevision) {\n attributes['deployment.commit_sha'] = commitRevision;\n }\n const headRevision =\n commitRevision ??\n (isCommitSha(serviceVersion) ? serviceVersion : undefined);\n if (headRevision) {\n attributes['vcs.ref.head.revision'] = headRevision;\n }\n attributes['vcs.repository.url.full'] =\n stringOrUndefined(process.env['MXL_VCS_REPOSITORY_URL']) ??\n DEFAULT_VCS_REPOSITORY_URL;\n if (config.serviceNamespace) {\n attributes['service.namespace'] = config.serviceNamespace;\n }\n Object.assign(attributes, envResourceAttributes);\n if (config.attributes) Object.assign(attributes, config.attributes);\n\n return {\n endpoint,\n environment,\n headers,\n resource: { serviceName, serviceVersion, attributes },\n } satisfies ResolvedResource;\n }).pipe(Effect.orDie);\n","import type { Duration } from 'effect';\nimport { Effect, Layer } from 'effect';\nimport { FetchHttpClient } from 'effect/http';\nimport { Otlp } from 'effect/observability';\n\nimport type { MxlSpanOptions } from '../shared/span-options.js';\nimport { otelGlobalContextBridgeLayer } from './otel-context-bridge.js';\nimport { normalizeOtlpBaseUrl } from './otlp.js';\nimport { resolveResource } from './resource.js';\n\nexport interface MxlConfig extends MxlSpanOptions {\n readonly serviceName?: string | undefined;\n readonly serviceVersion?: string | undefined;\n readonly serviceNamespace?: string | undefined;\n readonly environment?: string | undefined;\n readonly endpoint?: string | undefined;\n readonly headers?: Record<string, string> | undefined;\n readonly attributes?: Record<string, string> | undefined;\n readonly maxBatchSize?: number | undefined;\n readonly loggerExportInterval?: Duration.Input | undefined;\n readonly metricsExportInterval?: Duration.Input | undefined;\n readonly tracerExportInterval?: Duration.Input | undefined;\n readonly shutdownTimeout?: Duration.Input | undefined;\n}\n\n/**\n * Create an Effect Layer that provides OpenTelemetry traces, logs, and metrics\n * configured for MXL's OTLP collector.\n *\n * Returns a no-op layer when `OTEL_SDK_DISABLED=true`.\n *\n * Wraps the OTLP tracer with `otelGlobalContextBridgeLayer` via `provideMerge`.\n * Measured on effect@4.0.6: `Otlp.layerJson({ tracerContext })` still\n * types the hook as `(primitive, span) => X` and Effect returns that result as\n * the evaluation, so the callback cannot call `~effect/Effect/evaluate` without\n * a `fiber`. `Layer.updateService` also cannot wrap a Tracer the OTLP layer\n * already provides. Keep the merge wrap until Effect passes fiber or evaluates\n * after a side-effect-only context hook.\n */\nexport const layer = (config: MxlConfig = {}) =>\n Layer.unwrap(\n Effect.gen(function* () {\n const resolved = yield* resolveResource({ ...config, sdkType: 'server' });\n if (!resolved.endpoint) return Layer.empty;\n\n const otlp = Otlp.layerJson({\n baseUrl: normalizeOtlpBaseUrl(resolved.endpoint),\n headers: resolved.headers,\n resource: resolved.resource,\n maxBatchSize: config.maxBatchSize,\n loggerExportInterval: config.loggerExportInterval,\n metricsExportInterval: config.metricsExportInterval,\n tracerExportInterval: config.tracerExportInterval,\n shutdownTimeout: config.shutdownTimeout,\n }).pipe(Layer.provide(FetchHttpClient.layer));\n\n return otelGlobalContextBridgeLayer.pipe(Layer.provideMerge(otlp));\n }),\n );\n","import { Layer } from 'effect';\nimport type { MxlEventsConfig, MxlEventsHandle } from './events.js';\nimport { layer as eventsLayer, makeHandle } from './events.js';\nimport type { MxlConfig } from './layer.js';\nimport { layer as otelLayer } from './layer.js';\n\nexport interface MxlFlushableConfig extends MxlConfig {\n readonly apiKey?: string | undefined;\n readonly autoFlushInterval?: number | false | undefined;\n readonly clientId?: string | undefined;\n readonly ingestUrl?: string | undefined;\n}\n\nexport interface FlushableTelemetry extends MxlEventsHandle {\n readonly layer: Layer.Layer<never, never, never>;\n}\n\nexport const make = (config: MxlFlushableConfig = {}): FlushableTelemetry => {\n const eventsConfig: MxlEventsConfig = {\n apiKey: config.apiKey,\n clientId: config.clientId,\n endpoint: config.ingestUrl,\n flushInterval:\n config.autoFlushInterval === false ? 0 : config.autoFlushInterval,\n serviceName: config.serviceName,\n };\n const handle = makeHandle(eventsConfig);\n return {\n dispose: handle.dispose,\n flush: handle.flush,\n layer: Layer.mergeAll(\n otelLayer(config),\n eventsLayer(eventsConfig),\n ) as Layer.Layer<never, never, never>,\n track: handle.track,\n };\n};\n","import { Layer } from 'effect';\nimport { HttpMiddleware } from 'effect/http';\n\nexport function shouldDisableHttpTrace(request: {\n url: string;\n method: string;\n}): boolean {\n return (\n request.method === 'OPTIONS' ||\n request.url === '/health' ||\n request.url === '/healthcheck' ||\n request.url.startsWith('/healthz') ||\n request.url === '/metrics' ||\n /\\.(png|ico|jpg|jpeg|gif|css|js|svg|webp|woff2?)(\\?.*)?$/i.test(request.url)\n );\n}\n\nexport function tracerDisabledWhenLayer(\n filter: (request: {\n url: string;\n method: string;\n }) => boolean = shouldDisableHttpTrace,\n) {\n return Layer.succeed(HttpMiddleware.TracerDisabledWhen, filter);\n}\n","import { Effect, Layer, References } from 'effect';\n\nexport type EffectLogLevel = 'Debug' | 'Info' | 'Warn' | 'Error' | 'Fatal';\n\nexport interface SerializedLogError {\n readonly message: string;\n readonly name: string;\n readonly stack?: string;\n readonly cause?: SerializedLogError;\n}\n\nconst LOG_LEVEL_BY_ENV: Record<string, EffectLogLevel> = {\n trace: 'Debug',\n debug: 'Debug',\n info: 'Info',\n warn: 'Warn',\n warning: 'Warn',\n error: 'Error',\n fatal: 'Fatal',\n};\n\nexport function resolveLogLevelFromEnv(\n env: NodeJS.ProcessEnv = process.env,\n): EffectLogLevel {\n const raw = env['OTEL_LOG_LEVEL'] ?? env['LOG_LEVEL'] ?? 'info';\n return LOG_LEVEL_BY_ENV[raw.trim().toLowerCase()] ?? 'Info';\n}\n\nfunction isFiniteHttpStatus(status: number | undefined): status is number {\n return typeof status === 'number' && Number.isFinite(status) && status >= 0;\n}\n\n/** Map HTTP status to Effect log level for response/failure logs. */\nexport function resolveEffectLogLevelFromHttpStatus(\n status: number | undefined,\n): EffectLogLevel {\n if (!isFiniteHttpStatus(status) || status < 400) {\n return 'Info';\n }\n\n if (status >= 500) {\n return 'Error';\n }\n\n return 'Warn';\n}\n\nexport type HttpLogOutcome = 'error' | 'success';\n\nexport interface HttpStatusLogFields {\n readonly 'http.response.status_code': string;\n readonly 'http.status': string;\n readonly 'log.level': 'error' | 'info' | 'warn';\n readonly outcome: HttpLogOutcome;\n}\n\n/** Standard log fields for HTTP response correlation in OTEL drains. */\nexport function buildHttpStatusLogFields(\n status: number | undefined,\n): Partial<HttpStatusLogFields> {\n const level = resolveEffectLogLevelFromHttpStatus(status);\n const outcome: HttpLogOutcome =\n isFiniteHttpStatus(status) && status >= 400 ? 'error' : 'success';\n const logLevel =\n level === 'Error' ? 'error' : level === 'Warn' ? 'warn' : 'info';\n\n if (!isFiniteHttpStatus(status)) {\n return {\n 'log.level': logLevel,\n outcome,\n };\n }\n\n const statusText = String(status);\n return {\n 'http.response.status_code': statusText,\n 'http.status': statusText,\n 'log.level': logLevel,\n outcome,\n };\n}\n\n/** Filter Effect logs below the configured minimum level. */\nexport function minimumLogLevelLayer(\n level: EffectLogLevel = resolveLogLevelFromEnv(),\n): Layer.Layer<never> {\n return Layer.succeed(References.MinimumLogLevel, level);\n}\n\nfunction resolveErrorMessage(error: Error): string {\n if (error.message.trim().length > 0) {\n return error.message;\n }\n\n if (error.cause !== undefined) {\n if (error.cause instanceof Error && error.cause.message.trim().length > 0) {\n return error.cause.message;\n }\n\n if (typeof error.cause === 'string' && error.cause.trim().length > 0) {\n return error.cause;\n }\n }\n\n if (\n 'reason' in error &&\n typeof error.reason === 'string' &&\n error.reason.trim().length > 0\n ) {\n return error.reason;\n }\n\n return error.name;\n}\n\nexport function serializeLogError(error: unknown): SerializedLogError {\n if (error instanceof Error) {\n return {\n message: resolveErrorMessage(error),\n name: error.name,\n ...(error.stack ? { stack: error.stack } : {}),\n ...(error.message.trim().length === 0 && error.cause !== undefined\n ? { cause: serializeLogError(error.cause) }\n : {}),\n };\n }\n\n return {\n message: String(error),\n name: 'UnknownError',\n };\n}\n\nfunction annotateFields(\n fields: Record<string, unknown> | undefined,\n): <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R> {\n if (!fields || Object.keys(fields).length === 0) {\n return (effect) => effect;\n }\n\n const serialized = Object.fromEntries(\n Object.entries(fields).map(([key, value]) => [\n key,\n value instanceof Error ? serializeLogError(value) : value,\n ]),\n );\n\n return (effect) => effect.pipe(Effect.annotateLogs(serialized));\n}\n\nexport function logDebug(\n message: string,\n fields?: Record<string, unknown>,\n): Effect.Effect<void> {\n return annotateFields(fields)(Effect.logDebug(message));\n}\n\nexport function logInfo(\n message: string,\n fields?: Record<string, unknown>,\n): Effect.Effect<void> {\n return annotateFields(fields)(Effect.logInfo(message));\n}\n\nexport function logWarning(\n message: string,\n fields?: Record<string, unknown>,\n): Effect.Effect<void> {\n return annotateFields(fields)(Effect.logWarning(message));\n}\n\nexport function logError(\n message: string,\n fields?: Record<string, unknown>,\n): Effect.Effect<void> {\n return annotateFields(fields)(Effect.logError(message));\n}\n\nexport function logAtLevel(\n level: EffectLogLevel,\n message: string,\n fields?: Record<string, unknown>,\n): Effect.Effect<void> {\n switch (level) {\n case 'Debug':\n return logDebug(message, fields);\n case 'Info':\n return logInfo(message, fields);\n case 'Warn':\n return logWarning(message, fields);\n case 'Error':\n case 'Fatal':\n return logError(message, fields);\n }\n}\n","import * as OtelTracer from '@effect/opentelemetry/OtelTracer';\nimport type { SpanContext } from '@opentelemetry/api';\nimport {\n context as otelContext,\n propagation,\n SpanStatusCode,\n TraceFlags,\n trace as traceApi,\n} from '@opentelemetry/api';\nimport { Effect } from 'effect';\nimport * as Option from 'effect/Option';\n\nimport {\n buildHttpStatusLogFields,\n logAtLevel,\n logError,\n resolveEffectLogLevelFromHttpStatus,\n serializeLogError,\n} from './logging.js';\nimport { buildTraceCarrierFromSpan } from './otel-context-bridge.js';\nimport {\n annotateLogsWithActiveSpanCorrelation,\n parseTraceparent,\n} from './trace-correlation.js';\n\nfunction headerValue(\n value: string | ReadonlyArray<string> | undefined,\n): string | undefined {\n if (value === undefined) return undefined;\n return typeof value === 'string' ? value : value[0];\n}\n\nexport function spanContextFromTraceparent(\n traceparent: string | undefined,\n): SpanContext | undefined {\n const { traceId, spanId } = parseTraceparent(traceparent);\n if (!traceId || !spanId) return undefined;\n\n return {\n isRemote: true,\n spanId,\n traceFlags: TraceFlags.SAMPLED,\n traceId,\n };\n}\n\nexport function resolveTraceparentFromHeaders(\n headers: Record<string, string | ReadonlyArray<string> | undefined>,\n): string | undefined {\n return headerValue(headers['traceparent']);\n}\n\nexport function withParentFromTraceparent<A, E, R>(\n headers: Record<string, string | ReadonlyArray<string> | undefined>,\n program: Effect.Effect<A, E, R>,\n): Effect.Effect<A, E, R> {\n const parentSpanContext = spanContextFromTraceparent(\n resolveTraceparentFromHeaders(headers),\n );\n\n if (parentSpanContext === undefined) {\n return program;\n }\n\n return OtelTracer.withSpanContext(program, parentSpanContext);\n}\n\nexport interface HttpSpanAttributes {\n readonly method: string;\n readonly route: string;\n readonly requestId?: string | undefined;\n readonly url?: string | undefined;\n}\n\nexport interface QueueTraceContextCarrier {\n readonly baggage?: string;\n readonly traceparent?: string;\n readonly tracestate?: string;\n}\n\nfunction toSpanAttributes(\n attributes: HttpSpanAttributes,\n): Record<string, string> {\n const result: Record<string, string> = {\n 'http.request.method': attributes.method,\n 'http.route': attributes.route,\n 'url.path': attributes.route,\n };\n\n if (attributes.requestId !== undefined) {\n result['http.request_id'] = attributes.requestId;\n result['request.id'] = attributes.requestId;\n }\n\n if (attributes.url !== undefined) {\n result['url.full'] = attributes.url;\n }\n\n return result;\n}\n\nexport function withHttpServerSpan<A, E, R>(\n name: string,\n attributes: HttpSpanAttributes,\n program: Effect.Effect<A, E, R>,\n): Effect.Effect<A, E, R> {\n return program.pipe(\n Effect.withSpan(name, {\n attributes: toSpanAttributes(attributes),\n kind: 'server',\n }),\n Effect.withLogSpan(name),\n );\n}\n\nexport function finalizeHttpSpan(\n status: number,\n route?: string,\n): Effect.Effect<void> {\n const annotations: Record<string, string | number> = {\n 'http.response.status_code': status,\n };\n\n if (route !== undefined) {\n annotations['http.route'] = route;\n annotations['url.path'] = route;\n }\n\n return Effect.sync(() => {\n if (status >= 500) {\n const activeSpan = traceApi.getActiveSpan();\n activeSpan?.setStatus({\n code: SpanStatusCode.ERROR,\n message: String(status),\n });\n }\n }).pipe(Effect.andThen(() => Effect.annotateCurrentSpan(annotations)));\n}\n\nexport interface LogHttpResponseOptions {\n readonly status: number;\n readonly durationMs?: number | undefined;\n readonly method?: string | undefined;\n readonly url?: string | undefined;\n readonly route?: string | undefined;\n readonly error?: unknown;\n readonly traceparent?: string | undefined;\n}\n\nfunction stringifyLogFieldValue(value: unknown): string {\n if (value === undefined) {\n return '';\n }\n return String(value);\n}\n\nfunction buildHttpResponseLogFields(\n options: LogHttpResponseOptions,\n): Record<string, unknown> {\n const fields: Record<string, unknown> = {\n ...buildHttpStatusLogFields(options.status),\n ...(options.durationMs === undefined\n ? {}\n : { durationMs: options.durationMs }),\n ...(options.method === undefined\n ? {}\n : { 'http.request.method': options.method }),\n ...(options.url === undefined ? {} : { 'url.full': options.url }),\n ...(options.route === undefined ? {} : { 'http.route': options.route }),\n ...(options.route === undefined ? {} : { 'url.path': options.route }),\n ...(options.traceparent === undefined\n ? {}\n : { traceparent: options.traceparent }),\n };\n\n if (options.error !== undefined) {\n fields['error'] = serializeLogError(options.error);\n }\n\n return fields;\n}\n\n/** Log an HTTP response at info/warn/error severity based on status code. */\nexport function logHttpResponse(\n message: string,\n options: LogHttpResponseOptions,\n): Effect.Effect<void> {\n const level = resolveEffectLogLevelFromHttpStatus(options.status);\n const fields = buildHttpResponseLogFields(options);\n const correlationFields = Object.fromEntries(\n Object.entries(fields)\n .filter(([, value]) => value !== undefined)\n .map(([key, value]) => [key, stringifyLogFieldValue(value)]),\n );\n\n return annotateLogsWithActiveSpanCorrelation(\n logAtLevel(level, message, fields),\n correlationFields,\n );\n}\n\nexport function logHttpRequestFailure(\n message: string,\n error: unknown,\n fields?: Record<string, unknown>,\n): Effect.Effect<void> {\n const logFields: Record<string, string> = {};\n if (fields) {\n for (const [key, value] of Object.entries(fields)) {\n if (value !== undefined) {\n logFields[key] = String(value);\n }\n }\n }\n\n return annotateLogsWithActiveSpanCorrelation(\n logError(message, {\n error: serializeLogError(error),\n ...fields,\n }),\n logFields,\n );\n}\n\nfunction normalizeHeaderRecord(\n headers: Record<string, string | ReadonlyArray<string> | undefined>,\n): Record<string, string> {\n const normalized: Record<string, string> = {};\n for (const [key, value] of Object.entries(headers)) {\n if (value === undefined) continue;\n normalized[key.toLowerCase()] =\n typeof value === 'string' ? value : (value[0] ?? '');\n }\n return normalized;\n}\n\nfunction normalizeCarrierRecord(\n carrier: QueueTraceContextCarrier | Record<string, string> | undefined,\n): Record<string, string> | undefined {\n if (!carrier) return undefined;\n const normalized: Record<string, string> = {};\n for (const [key, value] of Object.entries(carrier)) {\n if (value === undefined || value === '') continue;\n normalized[key.toLowerCase()] = value;\n }\n return Object.keys(normalized).length > 0 ? normalized : undefined;\n}\n\n/** Resolve parent span context from a W3C trace carrier. */\nexport function spanContextFromCarrier(\n carrier: QueueTraceContextCarrier | Record<string, string> | undefined,\n): SpanContext | undefined {\n const normalized = normalizeCarrierRecord(carrier);\n if (!normalized) return undefined;\n\n const extracted = propagation.extract(otelContext.active(), normalized);\n const spanContext = traceApi.getSpan(extracted)?.spanContext();\n if (\n spanContext?.traceId &&\n spanContext.traceId !== '00000000000000000000000000000000' &&\n spanContext.spanId &&\n spanContext.spanId !== '0000000000000000'\n ) {\n return spanContext;\n }\n\n return spanContextFromTraceparent(normalized['traceparent']);\n}\n\nexport function withParentFromTraceCarrier<A, E, R>(\n carrier: QueueTraceContextCarrier | Record<string, string> | undefined,\n program: Effect.Effect<A, E, R>,\n): Effect.Effect<A, E, R> {\n const parentSpanContext = spanContextFromCarrier(carrier);\n if (parentSpanContext === undefined) {\n return program;\n }\n return OtelTracer.withSpanContext(program, parentSpanContext);\n}\n\n/** Build W3C trace carrier for queue/job propagation from request headers + active OTel context. */\nexport function buildQueueTraceCarrier(\n headers?: Record<string, string | ReadonlyArray<string> | undefined>,\n): Record<string, string> | undefined {\n const normalized = headers ? normalizeHeaderRecord(headers) : {};\n const parentContext = propagation.extract(otelContext.active(), normalized);\n const carrier: Record<string, string> = {};\n propagation.inject(parentContext, carrier);\n return Object.keys(carrier).length > 0 ? carrier : undefined;\n}\n\n/** Build W3C trace carrier using the active Effect span when available. */\nexport function buildQueueTraceCarrierEffect(\n headers?: Record<string, string | ReadonlyArray<string> | undefined>,\n): Effect.Effect<Record<string, string> | undefined> {\n return Effect.gen(function* () {\n const normalized = headers ? normalizeHeaderRecord(headers) : {};\n const currentSpan = yield* Effect.currentSpan.pipe(Effect.option);\n\n if (Option.isSome(currentSpan)) {\n return buildTraceCarrierFromSpan(currentSpan.value, normalized);\n }\n\n return buildQueueTraceCarrier(headers);\n });\n}\n","import * as OtelTracer from '@effect/opentelemetry/OtelTracer';\nimport type { SpanContext } from '@opentelemetry/api';\nimport type { ManagedRuntime } from 'effect';\nimport { Effect } from 'effect';\nimport type { QueueTraceContextCarrier } from './http-tracing.js';\nimport { spanContextFromCarrier } from './http-tracing.js';\nimport { logError, logInfo, serializeLogError } from './logging.js';\nimport { annotateLogsWithActiveSpanCorrelation } from './trace-correlation.js';\n\nexport interface RunJobWithSpanOptions {\n readonly name: string;\n readonly attributes?: Record<string, string> | undefined;\n readonly parentSpanContext?: SpanContext | undefined;\n readonly parentTraceCarrier?:\n | QueueTraceContextCarrier\n | Record<string, string>\n | undefined;\n readonly logAttributes?: Record<string, string> | undefined;\n}\n\nfunction resolveParentSpanContext(\n options: RunJobWithSpanOptions,\n): SpanContext | undefined {\n if (options.parentSpanContext !== undefined) {\n return options.parentSpanContext;\n }\n return spanContextFromCarrier(options.parentTraceCarrier);\n}\n\nexport function jobWithSpanEffect<A, E, R>(\n options: RunJobWithSpanOptions,\n program: Effect.Effect<A, E, R>,\n): Effect.Effect<A, E, R> {\n const parentSpanContext = resolveParentSpanContext(options);\n const startedAt = Date.now();\n\n let wrapped = program.pipe(\n Effect.tap(() =>\n logInfo('Job completed', {\n durationMs: Date.now() - startedAt,\n 'job.name': options.name,\n outcome: 'success',\n ...options.logAttributes,\n }),\n ),\n Effect.tapError((error) =>\n logError('Job failed', {\n durationMs: Date.now() - startedAt,\n error: serializeLogError(error),\n 'job.name': options.name,\n outcome: 'error',\n ...options.logAttributes,\n }),\n ),\n (effect) =>\n annotateLogsWithActiveSpanCorrelation(effect, {\n 'job.name': options.name,\n ...options.logAttributes,\n }),\n Effect.withLogSpan(options.name),\n Effect.withSpan(options.name, {\n attributes: options.attributes,\n kind: 'consumer',\n }),\n );\n\n if (parentSpanContext !== undefined) {\n wrapped = OtelTracer.withSpanContext(wrapped, parentSpanContext);\n }\n\n return wrapped;\n}\n\nexport function runJobWithSpan<A, E, R>(\n runtime: ManagedRuntime.ManagedRuntime<R, unknown>,\n options: RunJobWithSpanOptions,\n program: Effect.Effect<A, E>,\n): Promise<A> {\n return runtime.runPromise(jobWithSpanEffect(options, program));\n}\n"],"mappings":";;;;;;;;;;;;;;AAsFA,MAAM,iBACJ,aAC4C;CAC5C,MAAM,OAAO,aAAa,KAAA,IAAY,CAAC,IAAI,CAAC,GAAG,QAAQ;CACvD,OAAO,KAAK,SAAS,KAChB,SAAS,KAAK,MAAM,WAAW,KAAK,WAAW,MAAM,CAAC,IACvD,KAAA;AACN;AAMA,MAAa,qBAAqB,UAAuC;CACvE,IAAI,UAAU,YAAY,OAAO,MAAM,KAAK,OAAO,MAAM,SAAS,UAChE,OAAO,MAAM;CACf,IAAI,UAAU,YAAY,OAAO,MAAM,KAAK,OAAO,MAAM,SAAS,UAChE,OAAO,MAAM;CACf,MAAM,OAAO,UAAU,YAAY,OAAO,OAAO,IAAI,MAAM,QAAQ,KAAA;CACnE,IAAI,UAAU,YAAY,MAAM,MAAM,KAAK,OAAO,KAAK,SAAS,UAC9D,OAAO,KAAK;AAEhB;AAEA,MAAa,qBAAqB,QAAyB,CAAC,MAAkB;CAC5E,MAAM,WAAW,cAAc,MAAM,aAAa;CAClD,MAAM,gBAAgB,MAAM;CAC5B,MAAM,OACJ,aAAa,KAAA,KAAa,kBAAkB,KAAA,KACvC,SAAuB,SAAS,KAAK,IAAI,KAAK,cAAc,IAAI,IACjE,aAAa,KAAA,KACV,SAAuB,SAAS,KAAK,IAAI,IAC1C;CAER,MAAM,8BAAc,IAAI,IAAI,CAC1B,GAAI,MAAM,+BAA+B,CAAC,GAC1C,GAAI,MAAM,wBAAwB,CAAC,CACrC,CAAC;CACD,MAAM,eACJ,YAAY,OAAO,KACd,UAAmB;EAClB,MAAM,aAAa,kBAAkB,KAAK;EAC1C,OAAO,e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4
  "description": "MXL OpenTelemetry and product-analytics SDK for Effect applications",
5
+ "keywords": [
6
+ "effect",
7
+ "mxl",
8
+ "observability",
9
+ "opentelemetry",
10
+ "telemetry"
11
+ ],
5
12
  "license": "Apache-2.0",
6
- "type": "module",
7
- "main": "./dist/index.server.mjs",
8
- "module": "./dist/index.server.mjs",
9
- "types": "./dist/index.server.d.mts",
10
- "publishConfig": {
11
- "access": "public"
13
+ "author": "MXL <ServiceAvailability@Safaricom.co.ke>",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "https://gitlab.safaricom.co.ke/mxl/apm/mxl-effect-sdk.git",
17
+ "directory": "packages/effect-sdk"
12
18
  },
13
19
  "files": [
14
20
  "dist",
15
21
  "README.md"
16
22
  ],
23
+ "type": "module",
24
+ "main": "./dist/index.server.mjs",
25
+ "module": "./dist/index.server.mjs",
26
+ "types": "./dist/index.server.d.mts",
27
+ "typesVersions": {
28
+ "*": {
29
+ ".": [
30
+ "./dist/index.server.d.mts"
31
+ ],
32
+ "server": [
33
+ "./dist/server/index.d.mts"
34
+ ],
35
+ "browser": [
36
+ "./dist/browser/index.d.ts"
37
+ ],
38
+ "client": [
39
+ "./dist/browser/index.d.ts"
40
+ ],
41
+ "cloudflare": [
42
+ "./dist/cloudflare/index.d.ts"
43
+ ],
44
+ "foldkit": [
45
+ "./dist/foldkit/index.d.ts"
46
+ ]
47
+ }
48
+ },
17
49
  "exports": {
18
50
  ".": {
19
51
  "node": {
@@ -45,26 +77,15 @@
45
77
  "types": "./dist/cloudflare/index.d.ts",
46
78
  "import": "./dist/cloudflare/index.js",
47
79
  "default": "./dist/cloudflare/index.js"
80
+ },
81
+ "./foldkit": {
82
+ "types": "./dist/foldkit/index.d.ts",
83
+ "import": "./dist/foldkit/index.js",
84
+ "default": "./dist/foldkit/index.js"
48
85
  }
49
86
  },
50
- "typesVersions": {
51
- "*": {
52
- ".": [
53
- "./dist/index.server.d.mts"
54
- ],
55
- "server": [
56
- "./dist/server/index.d.mts"
57
- ],
58
- "browser": [
59
- "./dist/browser/index.d.ts"
60
- ],
61
- "client": [
62
- "./dist/browser/index.d.ts"
63
- ],
64
- "cloudflare": [
65
- "./dist/cloudflare/index.d.ts"
66
- ]
67
- }
87
+ "publishConfig": {
88
+ "access": "public"
68
89
  },
69
90
  "scripts": {
70
91
  "build": "tsdown",
@@ -73,39 +94,26 @@
73
94
  "test": "vitest run"
74
95
  },
75
96
  "dependencies": {
76
- "@opentelemetry/api": "^1.9.1",
77
- "@opentelemetry/context-async-hooks": "^2.12.0",
78
- "@opentelemetry/exporter-trace-otlp-http": "^0.223.0",
79
- "@opentelemetry/sdk-trace-base": "^2.12.0",
80
- "std-env": "^4.3.0",
81
- "uuid": "^14.0.2"
97
+ "@opentelemetry/api": "catalog:otel",
98
+ "@opentelemetry/context-async-hooks": "catalog:otel",
99
+ "@opentelemetry/exporter-trace-otlp-http": "catalog:otel",
100
+ "@opentelemetry/sdk-trace-base": "catalog:otel",
101
+ "std-env": "catalog:runtime",
102
+ "uuid": "catalog:runtime"
82
103
  },
83
104
  "devDependencies": {
84
- "@effect/opentelemetry": "^4.0.2",
85
- "@types/node": "^26.6.4",
86
- "effect": "^4.0.2",
87
- "tsdown": "^0.23.0",
88
- "typescript": "^7.0.2",
89
- "vitest": "^5.0.3"
105
+ "@effect/opentelemetry": "catalog:effect",
106
+ "@types/node": "catalog:tooling",
107
+ "effect": "catalog:effect",
108
+ "tsdown": "catalog:tooling",
109
+ "typescript": "catalog:tooling",
110
+ "vitest": "catalog:test"
90
111
  },
91
112
  "peerDependencies": {
92
- "@effect/opentelemetry": "^4.0.2",
93
- "effect": "^4.0.2"
94
- },
95
- "author": "MXL <ServiceAvailability@Safaricom.co.ke>",
96
- "repository": {
97
- "type": "git",
98
- "url": "https://gitlab.safaricom.co.ke/mxl/apm/mxl-effect-sdk.git",
99
- "directory": "packages/effect-sdk"
113
+ "@effect/opentelemetry": "catalog:effect",
114
+ "effect": "catalog:effect"
100
115
  },
101
116
  "engines": {
102
117
  "node": "^20.19.0 || >=22.12.0"
103
- },
104
- "keywords": [
105
- "mxl",
106
- "effect",
107
- "opentelemetry",
108
- "observability",
109
- "telemetry"
110
- ]
118
+ }
111
119
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-CPZhMHLl.d.mts","names":[],"sources":["../src/server/layer.ts","../src/shared/product-event.ts","../src/server/events.ts","../src/server/flushable.ts","../src/server/platform.ts","../src/server/config.ts","../src/server/otlp.ts","../src/server/http-middleware.ts","../src/server/trace-correlation.ts","../src/server/http-tracing.ts","../src/server/jobs.ts","../src/server/logging.ts","../src/server/otel-context-bridge.ts","../src/server/evlog-bridge.ts","../src/shared/dependency-spans.ts"],"mappings":";;;;;;;UASiB;WACN;WACA;WACA;WACA;WACA,UAAU;WACV,aAAa;WACb;WACA,uBAAuB,SAAS;WAChC,wBAAwB,SAAS;WACjC,uBAAuB,SAAS;WAChC,kBAAkB,SAAS;;;;;;;;;;;;;;;;cAiBzB,UAAK,SAAY,cAAS,MAAA;;;UCjBtB;YACL;;UAGK;WACN,aAAa;WACb;WACA;WACA;WACA,YAAY;WACZ;WACA;WACA;WACA;;;;;UCFM;WACN;WACA;WACA;WACA;WACA,gBAAgB,SAAS;WACzB;WACA;;UAGM;WACN,OAAO,OAAO;WACd,QAAQ,cAAc,UAAU,iBAAiB,OAAO;;;cAGtD,kBAAkB;;;;;;cAIlB,+BAA+B;cA4B/B,SAAI,SAAA,gCAAA,OAAA;;EAuFM,QAAA,cAAM,UAAW,iBAAoB,OAAO;UA6BjE,WAAA,oCAAA;cAEW,QAAK,SAAY,oBAAuB,MAAM,MAAM;UAGhD;WACN,eAAe;WACf,aAAa;WACb,QAAQ,cAAc,UAAU;;cAG9B,aAAU,SAAY,oBAAuB;;;;UClMzC,2BAA2B;WACjC;WACA;WACA;WACA;;UAGM,2BAA2B;WACjC,OAAO,MAAM;;cAGX,OAAI,SAAY,uBAA0B;;;UCnBtC;WACN;WACA;WACA;WACA;WACA;WACA;WACA;WACA;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