@safaricom-mxl/effect-sdk 0.0.14 → 0.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +33 -6
- package/dist/browser/index.d.ts +81 -17
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/browser/index.js +474 -12
- package/dist/browser/index.js.map +1 -1
- package/dist/cloudflare/index.d.ts +25 -0
- package/dist/cloudflare/index.d.ts.map +1 -0
- package/dist/cloudflare/index.js +547 -0
- package/dist/cloudflare/index.js.map +1 -0
- package/dist/{index-8yBtnSxJ.d.mts → index-BF4-zL-9.d.mts} +71 -6
- package/dist/index-BF4-zL-9.d.mts.map +1 -0
- package/dist/index.server.d.mts +2 -2
- package/dist/index.server.mjs +2 -2
- package/dist/server/index.d.mts +2 -2
- package/dist/server/index.mjs +2 -2
- package/dist/{server-BhmjaLrj.mjs → server-DU685moi.mjs} +201 -21
- package/dist/server-DU685moi.mjs.map +1 -0
- package/package.json +35 -22
- package/dist/index-8yBtnSxJ.d.mts.map +0 -1
- package/dist/server-BhmjaLrj.mjs.map +0 -1
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { Config, Duration, Effect, Layer, ManagedRuntime, Option } from "effect";
|
|
1
|
+
import { Cause, Config, Context, Duration, Effect, Layer, ManagedRuntime, Option, Schema } from "effect";
|
|
2
2
|
import * as Tracer from "effect/Tracer";
|
|
3
|
+
import { HttpClient } from "effect/unstable/http";
|
|
3
4
|
import { SpanContext } from "@opentelemetry/api";
|
|
4
5
|
declare namespace layer_d_exports {
|
|
5
|
-
export { MxlConfig, layer };
|
|
6
|
+
export { MxlConfig, layer$1 as layer };
|
|
6
7
|
}
|
|
7
8
|
interface MxlConfig {
|
|
8
9
|
readonly serviceName?: string | undefined;
|
|
@@ -23,7 +24,71 @@ interface MxlConfig {
|
|
|
23
24
|
*
|
|
24
25
|
* Returns a no-op layer when `OTEL_SDK_DISABLED=true`.
|
|
25
26
|
*/
|
|
26
|
-
declare const layer: (config?: MxlConfig) => Layer.Layer<never, never, never>;
|
|
27
|
+
declare const layer$1: (config?: MxlConfig) => Layer.Layer<never, never, never>;
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/shared/product-event.d.ts
|
|
30
|
+
interface TrackProps {
|
|
31
|
+
readonly [key: string]: unknown;
|
|
32
|
+
}
|
|
33
|
+
interface TrackOptions {
|
|
34
|
+
readonly attributes?: TrackProps | undefined;
|
|
35
|
+
readonly groupId?: string | undefined;
|
|
36
|
+
readonly pagePath?: string | undefined;
|
|
37
|
+
readonly sessionId?: string | undefined;
|
|
38
|
+
readonly timestamp?: Date | number | undefined;
|
|
39
|
+
readonly traceparent?: string | undefined;
|
|
40
|
+
readonly url?: string | undefined;
|
|
41
|
+
readonly userId?: string | undefined;
|
|
42
|
+
readonly visitorId?: string | undefined;
|
|
43
|
+
}
|
|
44
|
+
declare namespace events_d_exports {
|
|
45
|
+
export { MxlEvents, MxlEventsApi, MxlEventsConfig, MxlEventsHandle, ProductEventsPostError, TrackOptions, layer, make$1 as make, makeHandle };
|
|
46
|
+
}
|
|
47
|
+
interface MxlEventsConfig {
|
|
48
|
+
readonly apiKey?: string | undefined;
|
|
49
|
+
readonly clientId?: string | undefined;
|
|
50
|
+
readonly endpoint?: string | undefined;
|
|
51
|
+
readonly eventsPath?: string | undefined;
|
|
52
|
+
readonly flushInterval?: Duration.Input | undefined;
|
|
53
|
+
readonly maxBatchSize?: number | undefined;
|
|
54
|
+
readonly serviceName?: string | undefined;
|
|
55
|
+
}
|
|
56
|
+
interface MxlEventsApi {
|
|
57
|
+
readonly flush: Effect.Effect<void>;
|
|
58
|
+
readonly track: (name: string, options?: TrackOptions) => Effect.Effect<void>;
|
|
59
|
+
}
|
|
60
|
+
declare const MxlEvents_base: Context.ServiceClass<MxlEvents, "@safaricom-mxl/effect-sdk/MxlEvents", MxlEventsApi>;
|
|
61
|
+
declare class MxlEvents extends MxlEvents_base {}
|
|
62
|
+
declare const ProductEventsPostError_base: Schema.Class<ProductEventsPostError, Schema.TaggedStruct<"@safaricom-mxl/effect-sdk/ProductEventsPostError", {
|
|
63
|
+
readonly cause: Schema.optionalKey<Schema.Defect>;
|
|
64
|
+
readonly message: Schema.String;
|
|
65
|
+
readonly status: Schema.optionalKey<Schema.Number>;
|
|
66
|
+
}>, Cause.YieldableError>;
|
|
67
|
+
declare class ProductEventsPostError extends ProductEventsPostError_base {}
|
|
68
|
+
declare const make$1: (config?: MxlEventsConfig) => Effect.Effect<{
|
|
69
|
+
flush: Effect.Effect<void, never, never>;
|
|
70
|
+
track: (name: string, options?: TrackOptions) => Effect.Effect<void>;
|
|
71
|
+
}, never, HttpClient.HttpClient | import("effect/Scope").Scope>;
|
|
72
|
+
declare const layer: (config?: MxlEventsConfig) => Layer.Layer<MxlEvents>;
|
|
73
|
+
interface MxlEventsHandle {
|
|
74
|
+
readonly dispose: () => Promise<void>;
|
|
75
|
+
readonly flush: () => Promise<void>;
|
|
76
|
+
readonly track: (name: string, options?: TrackOptions) => void;
|
|
77
|
+
}
|
|
78
|
+
declare const makeHandle: (config?: MxlEventsConfig) => MxlEventsHandle;
|
|
79
|
+
declare namespace flushable_d_exports {
|
|
80
|
+
export { FlushableTelemetry, MxlFlushableConfig, make };
|
|
81
|
+
}
|
|
82
|
+
interface MxlFlushableConfig extends MxlConfig {
|
|
83
|
+
readonly apiKey?: string | undefined;
|
|
84
|
+
readonly autoFlushInterval?: number | false | undefined;
|
|
85
|
+
readonly clientId?: string | undefined;
|
|
86
|
+
readonly ingestUrl?: string | undefined;
|
|
87
|
+
}
|
|
88
|
+
interface FlushableTelemetry extends MxlEventsHandle {
|
|
89
|
+
readonly layer: Layer.Layer<never, never, never>;
|
|
90
|
+
}
|
|
91
|
+
declare const make: (config?: MxlFlushableConfig) => FlushableTelemetry;
|
|
27
92
|
//#endregion
|
|
28
93
|
//#region src/server/platform.d.ts
|
|
29
94
|
interface PlatformInputs {
|
|
@@ -190,7 +255,7 @@ interface EffectTraceEnricherOptions {
|
|
|
190
255
|
/**
|
|
191
256
|
* Enrich evlog wide events with trace/span IDs from OTel global context or W3C headers.
|
|
192
257
|
*
|
|
193
|
-
* Use in the MXL evlog enricher chain
|
|
258
|
+
* Use `createEffectTraceEnricher` in the MXL evlog enricher chain.
|
|
194
259
|
*/
|
|
195
260
|
declare function createEffectTraceEnricher(options?: EffectTraceEnricherOptions): (ctx: EffectTraceEnrichContext) => void;
|
|
196
261
|
//#endregion
|
|
@@ -218,5 +283,5 @@ declare function withDependencySpan<A, E, R>(name: string, options: WithDependen
|
|
|
218
283
|
/** Promise-based dependency span for non-Effect code paths. */
|
|
219
284
|
declare function withPromiseDependencySpan<T>(name: string, attributes: Record<string, string>, operation: () => Promise<T>, kind?: DependencySpanKind): Promise<T>;
|
|
220
285
|
//#endregion
|
|
221
|
-
export { annotateLogsWithActiveSpanCorrelation as $, minimumLogLevelLayer as A, buildQueueTraceCarrier as B, SerializedLogError as C, logError as D, logDebug as E, jobWithSpanEffect as F, resolveTraceparentFromHeaders as G, finalizeHttpSpan as H, runJobWithSpan as I, withHttpServerSpan as J, spanContextFromCarrier as K, HttpSpanAttributes as L, resolveLogLevelFromEnv as M, serializeLogError as N, logInfo as O, RunJobWithSpanOptions as P, TraceLogAnnotations as Q, LogHttpResponseOptions as R, HttpStatusLogFields as S, logAtLevel as T, logHttpRequestFailure as U, buildQueueTraceCarrierEffect as V, logHttpResponse as W, withParentFromTraceparent as X, withParentFromTraceCarrier as Y, TraceCorrelation as Z, formatTraceparent as _, bufferSpanAttributes as a, normalizeOtlpBaseUrl as at, EffectLogLevel as b, kafkaProducerSpanAttributes as c, PlatformInputs as ct, withDependencySpan as d,
|
|
222
|
-
//# sourceMappingURL=index-
|
|
286
|
+
export { annotateLogsWithActiveSpanCorrelation as $, minimumLogLevelLayer as A, buildQueueTraceCarrier as B, SerializedLogError as C, logError as D, logDebug as E, jobWithSpanEffect as F, resolveTraceparentFromHeaders as G, finalizeHttpSpan as H, runJobWithSpan as I, withHttpServerSpan as J, spanContextFromCarrier as K, HttpSpanAttributes as L, resolveLogLevelFromEnv as M, serializeLogError as N, logInfo as O, RunJobWithSpanOptions as P, TraceLogAnnotations as Q, LogHttpResponseOptions as R, HttpStatusLogFields as S, logAtLevel as T, logHttpRequestFailure as U, buildQueueTraceCarrierEffect as V, logHttpResponse as W, withParentFromTraceparent as X, withParentFromTraceCarrier as Y, TraceCorrelation as Z, formatTraceparent as _, events_d_exports as _t, bufferSpanAttributes as a, normalizeOtlpBaseUrl as at, EffectLogLevel as b, layer_d_exports as bt, kafkaProducerSpanAttributes as c, PlatformInputs as ct, withDependencySpan as d, FlushableTelemetry as dt, getEffectTraceCorrelation as et, withPromiseDependencySpan as f, MxlFlushableConfig as ft, buildTraceCarrierFromSpan as g, MxlEventsHandle as gt, createEffectTraceEnricher as h, MxlEventsConfig as ht, addSpanLinksFromTraceCarriers as i, tracerDisabledWhenLayer as it, resolveEffectLogLevelFromHttpStatus as j, logWarning as k, queueConsumerSpanAttributes as l, derivePlatformAttributes as lt, EffectTraceEnricherOptions as m, MxlEventsApi as mt, DependencySpanKind as n, traceCorrelationLogAnnotations as nt, dbClientSpanAttributes as o, parseOtelResourceAttributes as ot, EffectTraceEnrichContext as p, flushable_d_exports as pt, spanContextFromTraceparent as q, WithDependencySpanOptions as r, shouldDisableHttpTrace as rt, geoSpanAttributes as s, parseOtlpHeaders as st, DbSystem as t, parseTraceparent as tt, queueProducerSpanAttributes as u, getAutoPlatformAttributes as ut, otelGlobalContextBridgeLayer as v, TrackOptions as vt, buildHttpStatusLogFields as w, HttpLogOutcome as x, wrapTracerWithOtelContextBridge as y, MxlConfig as yt, QueueTraceContextCarrier$1 as z };
|
|
287
|
+
//# sourceMappingURL=index-BF4-zL-9.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-BF4-zL-9.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":"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"}
|
package/dist/index.server.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as annotateLogsWithActiveSpanCorrelation, A as minimumLogLevelLayer, B as buildQueueTraceCarrier, C as SerializedLogError, D as logError, E as logDebug, F as jobWithSpanEffect, G as resolveTraceparentFromHeaders, H as finalizeHttpSpan, I as runJobWithSpan, J as withHttpServerSpan, K as spanContextFromCarrier, L as HttpSpanAttributes, M as resolveLogLevelFromEnv, N as serializeLogError, O as logInfo, P as RunJobWithSpanOptions, Q as TraceLogAnnotations, R as LogHttpResponseOptions, S as HttpStatusLogFields, T as logAtLevel, U as logHttpRequestFailure, V as buildQueueTraceCarrierEffect, W as logHttpResponse, X as withParentFromTraceparent, Y as withParentFromTraceCarrier, Z as TraceCorrelation, _ as formatTraceparent, a as bufferSpanAttributes, at as normalizeOtlpBaseUrl, b as EffectLogLevel, c as kafkaProducerSpanAttributes, ct as PlatformInputs, d as withDependencySpan, dt as
|
|
2
|
-
export { type DbSystem, type DependencySpanKind, type EffectLogLevel, type EffectTraceEnrichContext, type EffectTraceEnricherOptions, type HttpLogOutcome, type HttpSpanAttributes, type HttpStatusLogFields, type LogHttpResponseOptions, layer_d_exports as Mxl, type MxlConfig, type PlatformInputs, type QueueTraceContextCarrier, type RunJobWithSpanOptions, type SerializedLogError, type TraceCorrelation, type TraceLogAnnotations, type WithDependencySpanOptions, addSpanLinksFromTraceCarriers, annotateLogsWithActiveSpanCorrelation, bufferSpanAttributes, buildHttpStatusLogFields, buildQueueTraceCarrier, buildQueueTraceCarrierEffect, buildTraceCarrierFromSpan, createEffectTraceEnricher, dbClientSpanAttributes, derivePlatformAttributes, finalizeHttpSpan, formatTraceparent, geoSpanAttributes, getAutoPlatformAttributes, getEffectTraceCorrelation, jobWithSpanEffect, kafkaProducerSpanAttributes, logAtLevel, logDebug, logError, logHttpRequestFailure, logHttpResponse, logInfo, logWarning, minimumLogLevelLayer, normalizeOtlpBaseUrl, otelGlobalContextBridgeLayer, parseOtelResourceAttributes, parseOtlpHeaders, parseTraceparent, queueConsumerSpanAttributes, queueProducerSpanAttributes, resolveEffectLogLevelFromHttpStatus, resolveLogLevelFromEnv, resolveTraceparentFromHeaders, runJobWithSpan, serializeLogError, shouldDisableHttpTrace, spanContextFromCarrier, spanContextFromTraceparent, traceCorrelationLogAnnotations, tracerDisabledWhenLayer, withDependencySpan, withHttpServerSpan, withParentFromTraceCarrier, withParentFromTraceparent, withPromiseDependencySpan, wrapTracerWithOtelContextBridge };
|
|
1
|
+
import { $ as annotateLogsWithActiveSpanCorrelation, A as minimumLogLevelLayer, B as buildQueueTraceCarrier, C as SerializedLogError, D as logError, E as logDebug, F as jobWithSpanEffect, G as resolveTraceparentFromHeaders, H as finalizeHttpSpan, I as runJobWithSpan, J as withHttpServerSpan, K as spanContextFromCarrier, L as HttpSpanAttributes, M as resolveLogLevelFromEnv, N as serializeLogError, O as logInfo, P as RunJobWithSpanOptions, Q as TraceLogAnnotations, R as LogHttpResponseOptions, S as HttpStatusLogFields, T as logAtLevel, U as logHttpRequestFailure, V as buildQueueTraceCarrierEffect, W as logHttpResponse, X as withParentFromTraceparent, Y as withParentFromTraceCarrier, Z as TraceCorrelation, _ as formatTraceparent, _t as events_d_exports, a as bufferSpanAttributes, at as normalizeOtlpBaseUrl, b as EffectLogLevel, bt as layer_d_exports, c as kafkaProducerSpanAttributes, ct as PlatformInputs, d as withDependencySpan, dt as FlushableTelemetry, et as getEffectTraceCorrelation, f as withPromiseDependencySpan, ft as MxlFlushableConfig, g as buildTraceCarrierFromSpan, gt as MxlEventsHandle, h as createEffectTraceEnricher, ht as MxlEventsConfig, i as addSpanLinksFromTraceCarriers, it as tracerDisabledWhenLayer, j as resolveEffectLogLevelFromHttpStatus, k as logWarning, l as queueConsumerSpanAttributes, lt as derivePlatformAttributes, m as EffectTraceEnricherOptions, mt as MxlEventsApi, n as DependencySpanKind, nt as traceCorrelationLogAnnotations, o as dbClientSpanAttributes, ot as parseOtelResourceAttributes, p as EffectTraceEnrichContext, pt as flushable_d_exports, q as spanContextFromTraceparent, r as WithDependencySpanOptions, rt as shouldDisableHttpTrace, s as geoSpanAttributes, st as parseOtlpHeaders, t as DbSystem, tt as parseTraceparent, u as queueProducerSpanAttributes, ut as getAutoPlatformAttributes, v as otelGlobalContextBridgeLayer, vt as TrackOptions, w as buildHttpStatusLogFields, x as HttpLogOutcome, y as wrapTracerWithOtelContextBridge, yt as MxlConfig, z as QueueTraceContextCarrier } from "./index-BF4-zL-9.mjs";
|
|
2
|
+
export { type DbSystem, type DependencySpanKind, type EffectLogLevel, type EffectTraceEnrichContext, type EffectTraceEnricherOptions, type FlushableTelemetry, type HttpLogOutcome, type HttpSpanAttributes, type HttpStatusLogFields, type LogHttpResponseOptions, layer_d_exports as Mxl, type MxlConfig, events_d_exports as MxlEvents, type MxlEventsApi, type MxlEventsConfig, type MxlEventsHandle, flushable_d_exports as MxlFlush, type MxlFlushableConfig, type PlatformInputs, type QueueTraceContextCarrier, type RunJobWithSpanOptions, type SerializedLogError, type TraceCorrelation, type TraceLogAnnotations, type TrackOptions, type WithDependencySpanOptions, addSpanLinksFromTraceCarriers, annotateLogsWithActiveSpanCorrelation, bufferSpanAttributes, buildHttpStatusLogFields, buildQueueTraceCarrier, buildQueueTraceCarrierEffect, buildTraceCarrierFromSpan, createEffectTraceEnricher, dbClientSpanAttributes, derivePlatformAttributes, finalizeHttpSpan, formatTraceparent, geoSpanAttributes, getAutoPlatformAttributes, getEffectTraceCorrelation, jobWithSpanEffect, kafkaProducerSpanAttributes, logAtLevel, logDebug, logError, logHttpRequestFailure, logHttpResponse, logInfo, logWarning, minimumLogLevelLayer, normalizeOtlpBaseUrl, otelGlobalContextBridgeLayer, parseOtelResourceAttributes, parseOtlpHeaders, parseTraceparent, queueConsumerSpanAttributes, queueProducerSpanAttributes, resolveEffectLogLevelFromHttpStatus, resolveLogLevelFromEnv, resolveTraceparentFromHeaders, runJobWithSpan, serializeLogError, shouldDisableHttpTrace, spanContextFromCarrier, spanContextFromTraceparent, traceCorrelationLogAnnotations, tracerDisabledWhenLayer, withDependencySpan, withHttpServerSpan, withParentFromTraceCarrier, withParentFromTraceparent, withPromiseDependencySpan, wrapTracerWithOtelContextBridge };
|
package/dist/index.server.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as minimumLogLevelLayer, B as
|
|
2
|
-
export { layer_exports as Mxl, addSpanLinksFromTraceCarriers, annotateLogsWithActiveSpanCorrelation, bufferSpanAttributes, buildHttpStatusLogFields, buildQueueTraceCarrier, buildQueueTraceCarrierEffect, buildTraceCarrierFromSpan, createEffectTraceEnricher, dbClientSpanAttributes, derivePlatformAttributes, finalizeHttpSpan, formatTraceparent, geoSpanAttributes, getAutoPlatformAttributes, getEffectTraceCorrelation, jobWithSpanEffect, kafkaProducerSpanAttributes, logAtLevel, logDebug, logError, logHttpRequestFailure, logHttpResponse, logInfo, logWarning, minimumLogLevelLayer, normalizeOtlpBaseUrl, otelGlobalContextBridgeLayer, parseOtelResourceAttributes, parseOtlpHeaders, parseTraceparent, queueConsumerSpanAttributes, queueProducerSpanAttributes, resolveEffectLogLevelFromHttpStatus, resolveLogLevelFromEnv, resolveTraceparentFromHeaders, runJobWithSpan, serializeLogError, shouldDisableHttpTrace, spanContextFromCarrier, spanContextFromTraceparent, traceCorrelationLogAnnotations, tracerDisabledWhenLayer, withDependencySpan, withHttpServerSpan, withParentFromTraceCarrier, withParentFromTraceparent, withPromiseDependencySpan, wrapTracerWithOtelContextBridge };
|
|
1
|
+
import { A as minimumLogLevelLayer, B as flushable_exports, C as withParentFromTraceparent, D as logError, E as logDebug, F as getEffectTraceCorrelation, G as parseOtelResourceAttributes, H as layer_exports, I as parseTraceparent, J as buildTraceCarrierFromSpan, K as parseOtlpHeaders, L as traceCorrelationLogAnnotations, M as resolveLogLevelFromEnv, N as serializeLogError, O as logInfo, P as annotateLogsWithActiveSpanCorrelation, R as shouldDisableHttpTrace, S as withParentFromTraceCarrier, T as logAtLevel, U as derivePlatformAttributes, V as events_exports, W as getAutoPlatformAttributes, X as otelGlobalContextBridgeLayer, Y as formatTraceparent, Z as wrapTracerWithOtelContextBridge, _ as logHttpResponse, a as kafkaProducerSpanAttributes, b as spanContextFromTraceparent, c as withDependencySpan, d as jobWithSpanEffect, f as runJobWithSpan, g as logHttpRequestFailure, h as finalizeHttpSpan, i as geoSpanAttributes, j as resolveEffectLogLevelFromHttpStatus, k as logWarning, l as withPromiseDependencySpan, m as buildQueueTraceCarrierEffect, n as bufferSpanAttributes, o as queueConsumerSpanAttributes, p as buildQueueTraceCarrier, q as normalizeOtlpBaseUrl, r as dbClientSpanAttributes, s as queueProducerSpanAttributes, t as addSpanLinksFromTraceCarriers, u as createEffectTraceEnricher, v as resolveTraceparentFromHeaders, w as buildHttpStatusLogFields, x as withHttpServerSpan, y as spanContextFromCarrier, z as tracerDisabledWhenLayer } from "./server-DU685moi.mjs";
|
|
2
|
+
export { layer_exports as Mxl, events_exports as MxlEvents, flushable_exports as MxlFlush, addSpanLinksFromTraceCarriers, annotateLogsWithActiveSpanCorrelation, bufferSpanAttributes, buildHttpStatusLogFields, buildQueueTraceCarrier, buildQueueTraceCarrierEffect, buildTraceCarrierFromSpan, createEffectTraceEnricher, dbClientSpanAttributes, derivePlatformAttributes, finalizeHttpSpan, formatTraceparent, geoSpanAttributes, getAutoPlatformAttributes, getEffectTraceCorrelation, jobWithSpanEffect, kafkaProducerSpanAttributes, logAtLevel, logDebug, logError, logHttpRequestFailure, logHttpResponse, logInfo, logWarning, minimumLogLevelLayer, normalizeOtlpBaseUrl, otelGlobalContextBridgeLayer, parseOtelResourceAttributes, parseOtlpHeaders, parseTraceparent, queueConsumerSpanAttributes, queueProducerSpanAttributes, resolveEffectLogLevelFromHttpStatus, resolveLogLevelFromEnv, resolveTraceparentFromHeaders, runJobWithSpan, serializeLogError, shouldDisableHttpTrace, spanContextFromCarrier, spanContextFromTraceparent, traceCorrelationLogAnnotations, tracerDisabledWhenLayer, withDependencySpan, withHttpServerSpan, withParentFromTraceCarrier, withParentFromTraceparent, withPromiseDependencySpan, wrapTracerWithOtelContextBridge };
|
package/dist/server/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as annotateLogsWithActiveSpanCorrelation, A as minimumLogLevelLayer, B as buildQueueTraceCarrier, C as SerializedLogError, D as logError, E as logDebug, F as jobWithSpanEffect, G as resolveTraceparentFromHeaders, H as finalizeHttpSpan, I as runJobWithSpan, J as withHttpServerSpan, K as spanContextFromCarrier, L as HttpSpanAttributes, M as resolveLogLevelFromEnv, N as serializeLogError, O as logInfo, P as RunJobWithSpanOptions, Q as TraceLogAnnotations, R as LogHttpResponseOptions, S as HttpStatusLogFields, T as logAtLevel, U as logHttpRequestFailure, V as buildQueueTraceCarrierEffect, W as logHttpResponse, X as withParentFromTraceparent, Y as withParentFromTraceCarrier, Z as TraceCorrelation, _ as formatTraceparent, a as bufferSpanAttributes, at as normalizeOtlpBaseUrl, b as EffectLogLevel, c as kafkaProducerSpanAttributes, ct as PlatformInputs, d as withDependencySpan, dt as
|
|
2
|
-
export { type DbSystem, type DependencySpanKind, type EffectLogLevel, type EffectTraceEnrichContext, type EffectTraceEnricherOptions, type HttpLogOutcome, type HttpSpanAttributes, type HttpStatusLogFields, type LogHttpResponseOptions, layer_d_exports as Mxl, type MxlConfig, type PlatformInputs, type QueueTraceContextCarrier, type RunJobWithSpanOptions, type SerializedLogError, type TraceCorrelation, type TraceLogAnnotations, type WithDependencySpanOptions, addSpanLinksFromTraceCarriers, annotateLogsWithActiveSpanCorrelation, bufferSpanAttributes, buildHttpStatusLogFields, buildQueueTraceCarrier, buildQueueTraceCarrierEffect, buildTraceCarrierFromSpan, createEffectTraceEnricher, dbClientSpanAttributes, derivePlatformAttributes, finalizeHttpSpan, formatTraceparent, geoSpanAttributes, getAutoPlatformAttributes, getEffectTraceCorrelation, jobWithSpanEffect, kafkaProducerSpanAttributes, logAtLevel, logDebug, logError, logHttpRequestFailure, logHttpResponse, logInfo, logWarning, minimumLogLevelLayer, normalizeOtlpBaseUrl, otelGlobalContextBridgeLayer, parseOtelResourceAttributes, parseOtlpHeaders, parseTraceparent, queueConsumerSpanAttributes, queueProducerSpanAttributes, resolveEffectLogLevelFromHttpStatus, resolveLogLevelFromEnv, resolveTraceparentFromHeaders, runJobWithSpan, serializeLogError, shouldDisableHttpTrace, spanContextFromCarrier, spanContextFromTraceparent, traceCorrelationLogAnnotations, tracerDisabledWhenLayer, withDependencySpan, withHttpServerSpan, withParentFromTraceCarrier, withParentFromTraceparent, withPromiseDependencySpan, wrapTracerWithOtelContextBridge };
|
|
1
|
+
import { $ as annotateLogsWithActiveSpanCorrelation, A as minimumLogLevelLayer, B as buildQueueTraceCarrier, C as SerializedLogError, D as logError, E as logDebug, F as jobWithSpanEffect, G as resolveTraceparentFromHeaders, H as finalizeHttpSpan, I as runJobWithSpan, J as withHttpServerSpan, K as spanContextFromCarrier, L as HttpSpanAttributes, M as resolveLogLevelFromEnv, N as serializeLogError, O as logInfo, P as RunJobWithSpanOptions, Q as TraceLogAnnotations, R as LogHttpResponseOptions, S as HttpStatusLogFields, T as logAtLevel, U as logHttpRequestFailure, V as buildQueueTraceCarrierEffect, W as logHttpResponse, X as withParentFromTraceparent, Y as withParentFromTraceCarrier, Z as TraceCorrelation, _ as formatTraceparent, _t as events_d_exports, a as bufferSpanAttributes, at as normalizeOtlpBaseUrl, b as EffectLogLevel, bt as layer_d_exports, c as kafkaProducerSpanAttributes, ct as PlatformInputs, d as withDependencySpan, dt as FlushableTelemetry, et as getEffectTraceCorrelation, f as withPromiseDependencySpan, ft as MxlFlushableConfig, g as buildTraceCarrierFromSpan, gt as MxlEventsHandle, h as createEffectTraceEnricher, ht as MxlEventsConfig, i as addSpanLinksFromTraceCarriers, it as tracerDisabledWhenLayer, j as resolveEffectLogLevelFromHttpStatus, k as logWarning, l as queueConsumerSpanAttributes, lt as derivePlatformAttributes, m as EffectTraceEnricherOptions, mt as MxlEventsApi, n as DependencySpanKind, nt as traceCorrelationLogAnnotations, o as dbClientSpanAttributes, ot as parseOtelResourceAttributes, p as EffectTraceEnrichContext, pt as flushable_d_exports, q as spanContextFromTraceparent, r as WithDependencySpanOptions, rt as shouldDisableHttpTrace, s as geoSpanAttributes, st as parseOtlpHeaders, t as DbSystem, tt as parseTraceparent, u as queueProducerSpanAttributes, ut as getAutoPlatformAttributes, v as otelGlobalContextBridgeLayer, vt as TrackOptions, w as buildHttpStatusLogFields, x as HttpLogOutcome, y as wrapTracerWithOtelContextBridge, yt as MxlConfig, z as QueueTraceContextCarrier } from "../index-BF4-zL-9.mjs";
|
|
2
|
+
export { type DbSystem, type DependencySpanKind, type EffectLogLevel, type EffectTraceEnrichContext, type EffectTraceEnricherOptions, type FlushableTelemetry, type HttpLogOutcome, type HttpSpanAttributes, type HttpStatusLogFields, type LogHttpResponseOptions, layer_d_exports as Mxl, type MxlConfig, events_d_exports as MxlEvents, type MxlEventsApi, type MxlEventsConfig, type MxlEventsHandle, flushable_d_exports as MxlFlush, type MxlFlushableConfig, type PlatformInputs, type QueueTraceContextCarrier, type RunJobWithSpanOptions, type SerializedLogError, type TraceCorrelation, type TraceLogAnnotations, type TrackOptions, type WithDependencySpanOptions, addSpanLinksFromTraceCarriers, annotateLogsWithActiveSpanCorrelation, bufferSpanAttributes, buildHttpStatusLogFields, buildQueueTraceCarrier, buildQueueTraceCarrierEffect, buildTraceCarrierFromSpan, createEffectTraceEnricher, dbClientSpanAttributes, derivePlatformAttributes, finalizeHttpSpan, formatTraceparent, geoSpanAttributes, getAutoPlatformAttributes, getEffectTraceCorrelation, jobWithSpanEffect, kafkaProducerSpanAttributes, logAtLevel, logDebug, logError, logHttpRequestFailure, logHttpResponse, logInfo, logWarning, minimumLogLevelLayer, normalizeOtlpBaseUrl, otelGlobalContextBridgeLayer, parseOtelResourceAttributes, parseOtlpHeaders, parseTraceparent, queueConsumerSpanAttributes, queueProducerSpanAttributes, resolveEffectLogLevelFromHttpStatus, resolveLogLevelFromEnv, resolveTraceparentFromHeaders, runJobWithSpan, serializeLogError, shouldDisableHttpTrace, spanContextFromCarrier, spanContextFromTraceparent, traceCorrelationLogAnnotations, tracerDisabledWhenLayer, withDependencySpan, withHttpServerSpan, withParentFromTraceCarrier, withParentFromTraceparent, withPromiseDependencySpan, wrapTracerWithOtelContextBridge };
|
package/dist/server/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as minimumLogLevelLayer, B as
|
|
2
|
-
export { layer_exports as Mxl, addSpanLinksFromTraceCarriers, annotateLogsWithActiveSpanCorrelation, bufferSpanAttributes, buildHttpStatusLogFields, buildQueueTraceCarrier, buildQueueTraceCarrierEffect, buildTraceCarrierFromSpan, createEffectTraceEnricher, dbClientSpanAttributes, derivePlatformAttributes, finalizeHttpSpan, formatTraceparent, geoSpanAttributes, getAutoPlatformAttributes, getEffectTraceCorrelation, jobWithSpanEffect, kafkaProducerSpanAttributes, logAtLevel, logDebug, logError, logHttpRequestFailure, logHttpResponse, logInfo, logWarning, minimumLogLevelLayer, normalizeOtlpBaseUrl, otelGlobalContextBridgeLayer, parseOtelResourceAttributes, parseOtlpHeaders, parseTraceparent, queueConsumerSpanAttributes, queueProducerSpanAttributes, resolveEffectLogLevelFromHttpStatus, resolveLogLevelFromEnv, resolveTraceparentFromHeaders, runJobWithSpan, serializeLogError, shouldDisableHttpTrace, spanContextFromCarrier, spanContextFromTraceparent, traceCorrelationLogAnnotations, tracerDisabledWhenLayer, withDependencySpan, withHttpServerSpan, withParentFromTraceCarrier, withParentFromTraceparent, withPromiseDependencySpan, wrapTracerWithOtelContextBridge };
|
|
1
|
+
import { A as minimumLogLevelLayer, B as flushable_exports, C as withParentFromTraceparent, D as logError, E as logDebug, F as getEffectTraceCorrelation, G as parseOtelResourceAttributes, H as layer_exports, I as parseTraceparent, J as buildTraceCarrierFromSpan, K as parseOtlpHeaders, L as traceCorrelationLogAnnotations, M as resolveLogLevelFromEnv, N as serializeLogError, O as logInfo, P as annotateLogsWithActiveSpanCorrelation, R as shouldDisableHttpTrace, S as withParentFromTraceCarrier, T as logAtLevel, U as derivePlatformAttributes, V as events_exports, W as getAutoPlatformAttributes, X as otelGlobalContextBridgeLayer, Y as formatTraceparent, Z as wrapTracerWithOtelContextBridge, _ as logHttpResponse, a as kafkaProducerSpanAttributes, b as spanContextFromTraceparent, c as withDependencySpan, d as jobWithSpanEffect, f as runJobWithSpan, g as logHttpRequestFailure, h as finalizeHttpSpan, i as geoSpanAttributes, j as resolveEffectLogLevelFromHttpStatus, k as logWarning, l as withPromiseDependencySpan, m as buildQueueTraceCarrierEffect, n as bufferSpanAttributes, o as queueConsumerSpanAttributes, p as buildQueueTraceCarrier, q as normalizeOtlpBaseUrl, r as dbClientSpanAttributes, s as queueProducerSpanAttributes, t as addSpanLinksFromTraceCarriers, u as createEffectTraceEnricher, v as resolveTraceparentFromHeaders, w as buildHttpStatusLogFields, x as withHttpServerSpan, y as spanContextFromCarrier, z as tracerDisabledWhenLayer } from "../server-DU685moi.mjs";
|
|
2
|
+
export { layer_exports as Mxl, events_exports as MxlEvents, flushable_exports as MxlFlush, addSpanLinksFromTraceCarriers, annotateLogsWithActiveSpanCorrelation, bufferSpanAttributes, buildHttpStatusLogFields, buildQueueTraceCarrier, buildQueueTraceCarrierEffect, buildTraceCarrierFromSpan, createEffectTraceEnricher, dbClientSpanAttributes, derivePlatformAttributes, finalizeHttpSpan, formatTraceparent, geoSpanAttributes, getAutoPlatformAttributes, getEffectTraceCorrelation, jobWithSpanEffect, kafkaProducerSpanAttributes, logAtLevel, logDebug, logError, logHttpRequestFailure, logHttpResponse, logInfo, logWarning, minimumLogLevelLayer, normalizeOtlpBaseUrl, otelGlobalContextBridgeLayer, parseOtelResourceAttributes, parseOtlpHeaders, parseTraceparent, queueConsumerSpanAttributes, queueProducerSpanAttributes, resolveEffectLogLevelFromHttpStatus, resolveLogLevelFromEnv, resolveTraceparentFromHeaders, runJobWithSpan, serializeLogError, shouldDisableHttpTrace, spanContextFromCarrier, spanContextFromTraceparent, traceCorrelationLogAnnotations, tracerDisabledWhenLayer, withDependencySpan, withHttpServerSpan, withParentFromTraceCarrier, withParentFromTraceparent, withPromiseDependencySpan, wrapTracerWithOtelContextBridge };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
-
import { Config, Effect, Layer, Match, Option, References } from "effect";
|
|
2
|
+
import { Cause, Config, Context, Duration, Effect, Layer, ManagedRuntime, Match, Option, References, Schedule, Schema, Semaphore } from "effect";
|
|
3
3
|
import * as Tracer from "effect/Tracer";
|
|
4
|
-
import { FetchHttpClient, HttpMiddleware } from "effect/unstable/http";
|
|
4
|
+
import { FetchHttpClient, HttpClient, HttpClientRequest, HttpMiddleware } from "effect/unstable/http";
|
|
5
5
|
import { Otlp } from "effect/unstable/observability";
|
|
6
6
|
import * as Otel from "@opentelemetry/api";
|
|
7
7
|
import { SpanKind, SpanStatusCode, TraceFlags, context, propagation, trace } from "@opentelemetry/api";
|
|
@@ -40,11 +40,11 @@ function wrapTracerWithOtelContextBridge(base) {
|
|
|
40
40
|
return base.span(options);
|
|
41
41
|
},
|
|
42
42
|
context(primitive, fiber) {
|
|
43
|
-
if (fiber.
|
|
43
|
+
if (fiber.cache.span === void 0) {
|
|
44
44
|
if (existingContext) return existingContext(primitive, fiber);
|
|
45
45
|
return primitive[evaluate](fiber);
|
|
46
46
|
}
|
|
47
|
-
return Otel.context.with(effectSpanToOtelContext(Otel.context.active(), fiber.
|
|
47
|
+
return Otel.context.with(effectSpanToOtelContext(Otel.context.active(), fiber.cache.span), () => {
|
|
48
48
|
if (existingContext) return existingContext(primitive, fiber);
|
|
49
49
|
return primitive[evaluate](fiber);
|
|
50
50
|
});
|
|
@@ -69,26 +69,26 @@ function normalizeOtlpBaseUrl(url) {
|
|
|
69
69
|
}
|
|
70
70
|
/** Resolve the OTLP exporter endpoint from standard env vars. */
|
|
71
71
|
const endpoint = Effect.gen(function* () {
|
|
72
|
-
const otlp = yield* Config.option(Config.
|
|
72
|
+
const otlp = yield* Config.option(Config.String("OTEL_EXPORTER_OTLP_ENDPOINT"));
|
|
73
73
|
if (Option.isSome(otlp)) return otlp;
|
|
74
|
-
return yield* Config.option(Config.
|
|
74
|
+
return yield* Config.option(Config.String("OTLP_ENDPOINT"));
|
|
75
75
|
});
|
|
76
|
-
const sdkDisabled = Config.
|
|
76
|
+
const sdkDisabled = Config.Boolean("OTEL_SDK_DISABLED").pipe(Config.withDefault(false));
|
|
77
77
|
/**
|
|
78
78
|
* Resolve service version / commit SHA from platform-specific env vars.
|
|
79
79
|
*
|
|
80
80
|
* Priority: npm_package_version > COMMIT_SHA > RAILWAY_GIT_COMMIT_SHA >
|
|
81
81
|
* VERCEL_GIT_COMMIT_SHA > CF_PAGES_COMMIT_SHA > RENDER_GIT_COMMIT
|
|
82
82
|
*/
|
|
83
|
-
const serviceVersion = Config.option(Config.
|
|
83
|
+
const serviceVersion = Config.option(Config.String("npm_package_version").pipe(Config.orElse(() => Config.String("COMMIT_SHA")), Config.orElse(() => Config.String("RAILWAY_GIT_COMMIT_SHA")), Config.orElse(() => Config.String("VERCEL_GIT_COMMIT_SHA")), Config.orElse(() => Config.String("CF_PAGES_COMMIT_SHA")), Config.orElse(() => Config.String("RENDER_GIT_COMMIT"))));
|
|
84
84
|
/**
|
|
85
85
|
* Resolve deployment environment from env vars.
|
|
86
86
|
*
|
|
87
87
|
* Priority: NODE_ENV > DEPLOYMENT_ENV > "development"
|
|
88
88
|
*/
|
|
89
|
-
const environment = Config.
|
|
89
|
+
const environment = Config.String("NODE_ENV").pipe(Config.orElse(() => Config.String("DEPLOYMENT_ENV")), Config.withDefault("development"));
|
|
90
90
|
/** OTel-standard service name override. */
|
|
91
|
-
const otelServiceName = Config.option(Config.
|
|
91
|
+
const otelServiceName = Config.option(Config.String("OTEL_SERVICE_NAME"));
|
|
92
92
|
/**
|
|
93
93
|
* Parse the OTel-standard `OTEL_RESOURCE_ATTRIBUTES` env var.
|
|
94
94
|
*
|
|
@@ -113,7 +113,7 @@ const parseOtelResourceAttributes = (input) => {
|
|
|
113
113
|
};
|
|
114
114
|
/** Resolve and parse `OTEL_RESOURCE_ATTRIBUTES`. */
|
|
115
115
|
const otelResourceAttributes = Effect.gen(function* () {
|
|
116
|
-
const raw = yield* Config.option(Config.
|
|
116
|
+
const raw = yield* Config.option(Config.String("OTEL_RESOURCE_ATTRIBUTES"));
|
|
117
117
|
return Option.match(raw, {
|
|
118
118
|
onNone: () => ({}),
|
|
119
119
|
onSome: (value) => parseOtelResourceAttributes(value)
|
|
@@ -140,7 +140,7 @@ const parseOtlpHeaders = (input) => {
|
|
|
140
140
|
};
|
|
141
141
|
/** Resolve OTLP export headers from env. */
|
|
142
142
|
const otlpHeaders = Effect.gen(function* () {
|
|
143
|
-
const raw = yield* Config.option(Config.
|
|
143
|
+
const raw = yield* Config.option(Config.String("OTEL_EXPORTER_OTLP_HEADERS"));
|
|
144
144
|
return Option.match(raw, {
|
|
145
145
|
onNone: () => ({}),
|
|
146
146
|
onSome: (value) => parseOtlpHeaders(value)
|
|
@@ -258,10 +258,10 @@ const getAutoPlatformAttributes = () => {
|
|
|
258
258
|
};
|
|
259
259
|
//#endregion
|
|
260
260
|
//#region src/server/resource.ts
|
|
261
|
-
const stringOrUndefined = (value) => typeof value === "string" && value.length > 0 ? value : void 0;
|
|
262
|
-
const DEFAULT_VCS_REPOSITORY_URL = "https://gitlab.safaricom.co.ke/mxl/apm/mxl-
|
|
261
|
+
const stringOrUndefined$1 = (value) => typeof value === "string" && value.length > 0 ? value : void 0;
|
|
262
|
+
const DEFAULT_VCS_REPOSITORY_URL = "https://gitlab.safaricom.co.ke/mxl/apm/mxl-effect-sdk";
|
|
263
263
|
function resolveCommitRevision() {
|
|
264
|
-
return stringOrUndefined(process.env.COMMIT_SHA) ?? stringOrUndefined(process.env.VERCEL_GIT_COMMIT_SHA) ?? stringOrUndefined(process.env.GITHUB_SHA) ?? stringOrUndefined(process.env.RAILWAY_GIT_COMMIT_SHA) ?? stringOrUndefined(process.env.CF_PAGES_COMMIT_SHA) ?? stringOrUndefined(process.env.RENDER_GIT_COMMIT);
|
|
264
|
+
return stringOrUndefined$1(process.env.COMMIT_SHA) ?? stringOrUndefined$1(process.env.VERCEL_GIT_COMMIT_SHA) ?? stringOrUndefined$1(process.env.GITHUB_SHA) ?? stringOrUndefined$1(process.env.RAILWAY_GIT_COMMIT_SHA) ?? stringOrUndefined$1(process.env.CF_PAGES_COMMIT_SHA) ?? stringOrUndefined$1(process.env.RENDER_GIT_COMMIT);
|
|
265
265
|
}
|
|
266
266
|
let serviceInstanceId;
|
|
267
267
|
const getServiceInstanceId = () => serviceInstanceId ??= v7();
|
|
@@ -301,7 +301,7 @@ const resolveResource = (config) => Effect.gen(function* () {
|
|
|
301
301
|
attributes["deployment.commit_sha"] = commitRevision;
|
|
302
302
|
attributes["vcs.ref.head.revision"] = commitRevision;
|
|
303
303
|
}
|
|
304
|
-
attributes["vcs.repository.url.full"] = stringOrUndefined(process.env.MXL_VCS_REPOSITORY_URL) ?? DEFAULT_VCS_REPOSITORY_URL;
|
|
304
|
+
attributes["vcs.repository.url.full"] = stringOrUndefined$1(process.env.MXL_VCS_REPOSITORY_URL) ?? DEFAULT_VCS_REPOSITORY_URL;
|
|
305
305
|
Object.assign(attributes, envResourceAttributes);
|
|
306
306
|
if (config.attributes) Object.assign(attributes, config.attributes);
|
|
307
307
|
return {
|
|
@@ -317,14 +317,14 @@ const resolveResource = (config) => Effect.gen(function* () {
|
|
|
317
317
|
}).pipe(Effect.orDie);
|
|
318
318
|
//#endregion
|
|
319
319
|
//#region src/server/layer.ts
|
|
320
|
-
var layer_exports = /* @__PURE__ */ __exportAll({ layer: () => layer });
|
|
320
|
+
var layer_exports = /* @__PURE__ */ __exportAll({ layer: () => layer$1 });
|
|
321
321
|
/**
|
|
322
322
|
* Create an Effect Layer that provides OpenTelemetry traces, logs, and metrics
|
|
323
323
|
* configured for MXL's OTLP collector.
|
|
324
324
|
*
|
|
325
325
|
* Returns a no-op layer when `OTEL_SDK_DISABLED=true`.
|
|
326
326
|
*/
|
|
327
|
-
const layer = (config = {}) => Layer.unwrap(Effect.gen(function* () {
|
|
327
|
+
const layer$1 = (config = {}) => Layer.unwrap(Effect.gen(function* () {
|
|
328
328
|
const resolved = yield* resolveResource({
|
|
329
329
|
...config,
|
|
330
330
|
sdkType: "server"
|
|
@@ -341,6 +341,186 @@ const layer = (config = {}) => Layer.unwrap(Effect.gen(function* () {
|
|
|
341
341
|
shutdownTimeout: config.shutdownTimeout
|
|
342
342
|
}).pipe(Layer.provide(FetchHttpClient.layer));
|
|
343
343
|
})).pipe(Layer.updateService(Tracer.Tracer, wrapTracerWithOtelContextBridge));
|
|
344
|
+
const RESERVED_EVENT_NAMES = ["session_start", "session_end"];
|
|
345
|
+
const isReservedEventName = (name) => RESERVED_EVENT_NAMES.some((reserved) => reserved === name);
|
|
346
|
+
const coerceTrackProps = (props) => {
|
|
347
|
+
if (props === void 0) return {};
|
|
348
|
+
const attributes = {};
|
|
349
|
+
for (const [key, value] of Object.entries(props)) {
|
|
350
|
+
if (value === void 0) continue;
|
|
351
|
+
attributes[key] = typeof value === "string" ? value : String(value);
|
|
352
|
+
}
|
|
353
|
+
return attributes;
|
|
354
|
+
};
|
|
355
|
+
const toEventTimestamp = (value) => (value instanceof Date ? value : new Date(value ?? Date.now())).toISOString();
|
|
356
|
+
const encodeProductEventLine = (input) => {
|
|
357
|
+
const trimmed = typeof input.name === "string" ? input.name.trim() : "";
|
|
358
|
+
if (trimmed.length === 0 || isReservedEventName(trimmed)) return;
|
|
359
|
+
const options = input.options ?? {};
|
|
360
|
+
return {
|
|
361
|
+
attributes: coerceTrackProps(options.attributes),
|
|
362
|
+
group_id: options.groupId ?? "",
|
|
363
|
+
name: trimmed.slice(0, 80),
|
|
364
|
+
page_path: options.pagePath ?? "",
|
|
365
|
+
service_name: input.serviceName,
|
|
366
|
+
session_id: options.sessionId ?? "",
|
|
367
|
+
source: input.source,
|
|
368
|
+
timestamp: toEventTimestamp(options.timestamp),
|
|
369
|
+
traceparent: options.traceparent,
|
|
370
|
+
url: options.url ?? "",
|
|
371
|
+
user_id: options.userId ?? "",
|
|
372
|
+
visitor_id: options.visitorId ?? ""
|
|
373
|
+
};
|
|
374
|
+
};
|
|
375
|
+
const encodeNdjson = (lines) => `${lines.map((line) => JSON.stringify(line)).join("\n")}\n`;
|
|
376
|
+
//#endregion
|
|
377
|
+
//#region src/version.ts
|
|
378
|
+
const SDK_NAME = "mxl-effect-sdk";
|
|
379
|
+
const SDK_VERSION = "0.0.15";
|
|
380
|
+
//#endregion
|
|
381
|
+
//#region src/server/events.ts
|
|
382
|
+
var events_exports = /* @__PURE__ */ __exportAll({
|
|
383
|
+
MxlEvents: () => MxlEvents,
|
|
384
|
+
ProductEventsPostError: () => ProductEventsPostError,
|
|
385
|
+
layer: () => layer,
|
|
386
|
+
make: () => make$1,
|
|
387
|
+
makeHandle: () => makeHandle
|
|
388
|
+
});
|
|
389
|
+
const DEFAULT_FLUSH_INTERVAL = Duration.seconds(5);
|
|
390
|
+
const DEFAULT_MAX_BATCH_SIZE = 100;
|
|
391
|
+
const MAX_BUFFERED_EVENTS = 1e3;
|
|
392
|
+
const WARN_INTERVAL_MS = 3e4;
|
|
393
|
+
const DEFAULT_BASKET_URL = "http://127.0.0.1:8000";
|
|
394
|
+
var MxlEvents = class extends Context.Service()("@safaricom-mxl/effect-sdk/MxlEvents") {};
|
|
395
|
+
var ProductEventsPostError = class extends Schema.TaggedError()("@safaricom-mxl/effect-sdk/ProductEventsPostError", {
|
|
396
|
+
cause: Schema.optionalKey(Schema.Defect()),
|
|
397
|
+
message: Schema.String,
|
|
398
|
+
status: Schema.optionalKey(Schema.Number)
|
|
399
|
+
}) {};
|
|
400
|
+
const stringOrUndefined = (value) => value && value.length > 0 ? value : void 0;
|
|
401
|
+
const resolveEventsConfig = (config) => {
|
|
402
|
+
const endpoint = (config.endpoint ?? process.env.MXL_BASKET_URL ?? DEFAULT_BASKET_URL).replace(/\/$/, "");
|
|
403
|
+
return {
|
|
404
|
+
apiKey: stringOrUndefined(config.apiKey ?? process.env.MXL_API_KEY),
|
|
405
|
+
clientId: stringOrUndefined(config.clientId ?? process.env.MXL_CLIENT_ID),
|
|
406
|
+
serviceName: config.serviceName ?? process.env.OTEL_SERVICE_NAME ?? "unknown",
|
|
407
|
+
url: `${endpoint}${config.eventsPath ?? "/events"}`
|
|
408
|
+
};
|
|
409
|
+
};
|
|
410
|
+
const make$1 = Effect.fn("MxlEvents.make")(function* (config = {}) {
|
|
411
|
+
const resolved = resolveEventsConfig(config);
|
|
412
|
+
const maxBatchSize = Math.max(1, config.maxBatchSize ?? DEFAULT_MAX_BATCH_SIZE);
|
|
413
|
+
const client = (yield* HttpClient.HttpClient).pipe(HttpClient.filterStatusOk);
|
|
414
|
+
const flushing = yield* Semaphore.make(1);
|
|
415
|
+
let buffer = [];
|
|
416
|
+
let warnedAboutName = false;
|
|
417
|
+
let warnedAboutClient = false;
|
|
418
|
+
let lastPostWarnAt = 0;
|
|
419
|
+
const warnPost = (error) => {
|
|
420
|
+
const now = Date.now();
|
|
421
|
+
if (now - lastPostWarnAt < WARN_INTERVAL_MS) return;
|
|
422
|
+
lastPostWarnAt = now;
|
|
423
|
+
console.warn(`[MxlEvents] ${error.message} (dropping batch)`, error.cause ?? "");
|
|
424
|
+
};
|
|
425
|
+
const warnMissingClient = () => {
|
|
426
|
+
if (warnedAboutClient) return;
|
|
427
|
+
warnedAboutClient = true;
|
|
428
|
+
console.warn("[MxlEvents] no client id — set MXL_CLIENT_ID or pass `clientId`; dropping events");
|
|
429
|
+
};
|
|
430
|
+
const warnEmptyName = () => {
|
|
431
|
+
if (warnedAboutName) return;
|
|
432
|
+
warnedAboutName = true;
|
|
433
|
+
console.warn("[MxlEvents] track() needs a non-empty event name; the call was ignored.");
|
|
434
|
+
};
|
|
435
|
+
const post = (lines) => {
|
|
436
|
+
const headers = {
|
|
437
|
+
"mxl-client-id": resolved.clientId ?? "",
|
|
438
|
+
"mxl-sdk-name": SDK_NAME,
|
|
439
|
+
"mxl-sdk-version": SDK_VERSION,
|
|
440
|
+
"user-agent": `${SDK_NAME}-server/${SDK_VERSION}`
|
|
441
|
+
};
|
|
442
|
+
if (resolved.apiKey) headers["mxl-api-key"] = resolved.apiKey;
|
|
443
|
+
return HttpClientRequest.post(resolved.url).pipe(HttpClientRequest.setHeaders(headers), HttpClientRequest.bodyText(encodeNdjson(lines), "application/x-ndjson"), client.execute, Effect.asVoid, Effect.mapError((error) => error.response !== void 0 ? new ProductEventsPostError({
|
|
444
|
+
message: `POST ${resolved.url} → ${error.response.status}`,
|
|
445
|
+
status: error.response.status
|
|
446
|
+
}) : new ProductEventsPostError({
|
|
447
|
+
cause: error,
|
|
448
|
+
message: `POST ${resolved.url} failed: ${error.message}`
|
|
449
|
+
})));
|
|
450
|
+
};
|
|
451
|
+
const flush = flushing.withPermits(1)(Effect.suspend(() => {
|
|
452
|
+
if (buffer.length === 0) return Effect.void;
|
|
453
|
+
const batch = buffer;
|
|
454
|
+
buffer = [];
|
|
455
|
+
if (resolved.clientId === void 0) {
|
|
456
|
+
warnMissingClient();
|
|
457
|
+
return Effect.void;
|
|
458
|
+
}
|
|
459
|
+
return post(batch).pipe(Effect.catchCause((cause) => Effect.sync(() => {
|
|
460
|
+
warnPost(Option.getOrElse(Cause.findErrorOption(cause), () => new ProductEventsPostError({
|
|
461
|
+
cause: Cause.squash(cause),
|
|
462
|
+
message: `POST ${resolved.url} failed`
|
|
463
|
+
})));
|
|
464
|
+
})));
|
|
465
|
+
}));
|
|
466
|
+
const track = (name, options = {}) => Effect.sync(() => {
|
|
467
|
+
const line = encodeProductEventLine({
|
|
468
|
+
name,
|
|
469
|
+
options,
|
|
470
|
+
serviceName: resolved.serviceName,
|
|
471
|
+
source: "server"
|
|
472
|
+
});
|
|
473
|
+
if (line === void 0) {
|
|
474
|
+
warnEmptyName();
|
|
475
|
+
return false;
|
|
476
|
+
}
|
|
477
|
+
buffer.push(line);
|
|
478
|
+
if (buffer.length > MAX_BUFFERED_EVENTS) buffer.splice(0, buffer.length - MAX_BUFFERED_EVENTS);
|
|
479
|
+
return buffer.length >= maxBatchSize;
|
|
480
|
+
}).pipe(Effect.flatMap((full) => full ? Effect.forkDetach(flush) : Effect.void), Effect.asVoid);
|
|
481
|
+
const interval = config.flushInterval ?? DEFAULT_FLUSH_INTERVAL;
|
|
482
|
+
if (Duration.toMillis(interval) > 0) yield* Effect.forkScoped(flush.pipe(Effect.schedule(Schedule.spaced(interval))));
|
|
483
|
+
yield* Effect.addFinalizer(() => flush);
|
|
484
|
+
return {
|
|
485
|
+
flush,
|
|
486
|
+
track
|
|
487
|
+
};
|
|
488
|
+
});
|
|
489
|
+
const layer = (config = {}) => Layer.effect(MxlEvents, make$1(config)).pipe(Layer.provide(FetchHttpClient.layer));
|
|
490
|
+
const makeHandle = (config = {}) => {
|
|
491
|
+
const runtime = ManagedRuntime.make(layer(config));
|
|
492
|
+
const swallow = (promise) => promise.then(() => void 0, () => void 0);
|
|
493
|
+
return {
|
|
494
|
+
dispose: () => swallow(runtime.dispose()),
|
|
495
|
+
flush: () => swallow(runtime.runPromise(Effect.gen(function* () {
|
|
496
|
+
yield* (yield* MxlEvents).flush;
|
|
497
|
+
}))),
|
|
498
|
+
track: (name, options) => {
|
|
499
|
+
swallow(runtime.runPromise(Effect.gen(function* () {
|
|
500
|
+
yield* (yield* MxlEvents).track(name, options);
|
|
501
|
+
})));
|
|
502
|
+
}
|
|
503
|
+
};
|
|
504
|
+
};
|
|
505
|
+
//#endregion
|
|
506
|
+
//#region src/server/flushable.ts
|
|
507
|
+
var flushable_exports = /* @__PURE__ */ __exportAll({ make: () => make });
|
|
508
|
+
const make = (config = {}) => {
|
|
509
|
+
const eventsConfig = {
|
|
510
|
+
apiKey: config.apiKey,
|
|
511
|
+
clientId: config.clientId,
|
|
512
|
+
endpoint: config.ingestUrl,
|
|
513
|
+
flushInterval: config.autoFlushInterval === false ? 0 : config.autoFlushInterval,
|
|
514
|
+
serviceName: config.serviceName
|
|
515
|
+
};
|
|
516
|
+
const handle = makeHandle(eventsConfig);
|
|
517
|
+
return {
|
|
518
|
+
dispose: handle.dispose,
|
|
519
|
+
flush: handle.flush,
|
|
520
|
+
layer: Layer.mergeAll(layer$1(config), layer(eventsConfig)),
|
|
521
|
+
track: handle.track
|
|
522
|
+
};
|
|
523
|
+
};
|
|
344
524
|
//#endregion
|
|
345
525
|
//#region src/server/http-middleware.ts
|
|
346
526
|
function shouldDisableHttpTrace(request) {
|
|
@@ -704,7 +884,7 @@ function assignTraceFields(event, traceId, spanId, overwrite) {
|
|
|
704
884
|
/**
|
|
705
885
|
* Enrich evlog wide events with trace/span IDs from OTel global context or W3C headers.
|
|
706
886
|
*
|
|
707
|
-
* Use in the MXL evlog enricher chain
|
|
887
|
+
* Use `createEffectTraceEnricher` in the MXL evlog enricher chain.
|
|
708
888
|
*/
|
|
709
889
|
function createEffectTraceEnricher(options = {}) {
|
|
710
890
|
const overwrite = options.overwrite ?? false;
|
|
@@ -825,6 +1005,6 @@ async function withPromiseDependencySpan(name, attributes, operation, kind = "cl
|
|
|
825
1005
|
});
|
|
826
1006
|
}
|
|
827
1007
|
//#endregion
|
|
828
|
-
export { minimumLogLevelLayer as A,
|
|
1008
|
+
export { minimumLogLevelLayer as A, flushable_exports as B, withParentFromTraceparent as C, logError as D, logDebug as E, getEffectTraceCorrelation as F, parseOtelResourceAttributes as G, layer_exports as H, parseTraceparent as I, buildTraceCarrierFromSpan as J, parseOtlpHeaders as K, traceCorrelationLogAnnotations as L, resolveLogLevelFromEnv as M, serializeLogError as N, logInfo as O, annotateLogsWithActiveSpanCorrelation as P, shouldDisableHttpTrace as R, withParentFromTraceCarrier as S, logAtLevel as T, derivePlatformAttributes as U, events_exports as V, getAutoPlatformAttributes as W, otelGlobalContextBridgeLayer as X, formatTraceparent as Y, wrapTracerWithOtelContextBridge as Z, logHttpResponse as _, kafkaProducerSpanAttributes as a, spanContextFromTraceparent as b, withDependencySpan as c, jobWithSpanEffect as d, runJobWithSpan as f, logHttpRequestFailure as g, finalizeHttpSpan as h, geoSpanAttributes as i, resolveEffectLogLevelFromHttpStatus as j, logWarning as k, withPromiseDependencySpan as l, buildQueueTraceCarrierEffect as m, bufferSpanAttributes as n, queueConsumerSpanAttributes as o, buildQueueTraceCarrier as p, normalizeOtlpBaseUrl as q, dbClientSpanAttributes as r, queueProducerSpanAttributes as s, addSpanLinksFromTraceCarriers as t, createEffectTraceEnricher as u, resolveTraceparentFromHeaders as v, buildHttpStatusLogFields as w, withHttpServerSpan as x, spanContextFromCarrier as y, tracerDisabledWhenLayer as z };
|
|
829
1009
|
|
|
830
|
-
//# sourceMappingURL=server-
|
|
1010
|
+
//# sourceMappingURL=server-DU685moi.mjs.map
|