@capxul/observability 4.2.0 → 4.20.0-beta.10
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/README.md +14 -0
- package/dist/engineering.d.mts +58 -5
- package/dist/engineering.mjs +837 -55
- package/dist/index.d.mts +1011 -14
- package/dist/index.mjs +2 -2292
- package/dist/src-Dhf8f_EV.mjs +3295 -0
- package/package.json +2 -2
- package/dist/src-CWfRYsBI.mjs +0 -302
package/README.md
CHANGED
|
@@ -94,3 +94,17 @@ vp run --filter @capxul/observability build
|
|
|
94
94
|
|
|
95
95
|
Read [`CONTEXT.md`](./CONTEXT.md) before changing event names, schemas,
|
|
96
96
|
redaction, journeys, or adapter behavior.
|
|
97
|
+
|
|
98
|
+
## Engineering composition
|
|
99
|
+
|
|
100
|
+
Import `makeEngineeringTelemetryLayer` and `flushEngineeringTelemetry` from
|
|
101
|
+
`@capxul/observability/engineering`. The layer shares OTLP logs, traces, and delta
|
|
102
|
+
metrics. The flush Effect attempts delivery without claiming ingestion. Optional
|
|
103
|
+
`enabled` stops collection for the acquired layer when false or when its callback
|
|
104
|
+
throws. `shutdownTimeout` applies per exporter; a host can set it to zero after
|
|
105
|
+
it runs an explicit flush under its own total deadline.
|
|
106
|
+
|
|
107
|
+
Set `privacy: "minimal"` for hosts that must export only closed operation/error
|
|
108
|
+
codes, timings, environment, and validated correlation. This opt-in removes
|
|
109
|
+
free-form logs, provider messages, URLs, bodies, and source paths, including
|
|
110
|
+
span exception events. Default consumers retain the existing redaction policy.
|
package/dist/engineering.d.mts
CHANGED
|
@@ -1,5 +1,43 @@
|
|
|
1
|
-
import { Layer, Tracer } from "effect";
|
|
2
|
-
import {
|
|
1
|
+
import { Context, Duration, Effect, Layer, Logger, Metric, References, Tracer } from "effect";
|
|
2
|
+
import { HttpClient, HttpClientError } from "effect/unstable/http";
|
|
3
|
+
import { OtlpExporter, OtlpSerialization } from "effect/unstable/observability";
|
|
4
|
+
//#region src/engineering-delivery.d.ts
|
|
5
|
+
/** Fixed admission limits for one CLI invocation and its SDK client. */
|
|
6
|
+
declare const CLI_ENGINEERING_LIMITS: Readonly<{
|
|
7
|
+
records: 80;
|
|
8
|
+
ordinaryRecords: 64;
|
|
9
|
+
recordBytes: 16384;
|
|
10
|
+
requests: 5;
|
|
11
|
+
ordinaryRequests: 2;
|
|
12
|
+
requestBytes: 1572864;
|
|
13
|
+
metricSeries: 16;
|
|
14
|
+
requestTimeoutMs: 1000;
|
|
15
|
+
}>;
|
|
16
|
+
type MetricEntry = Metric.Metric.Metadata<unknown, unknown>;
|
|
17
|
+
interface CliEngineeringStats {
|
|
18
|
+
readonly records: number;
|
|
19
|
+
readonly reservedRecordBytes: number;
|
|
20
|
+
readonly peakRecords: number;
|
|
21
|
+
readonly peakReservedRecordBytes: number;
|
|
22
|
+
readonly activeRequests: number;
|
|
23
|
+
readonly requestBytes: number;
|
|
24
|
+
readonly peakRequests: number;
|
|
25
|
+
readonly peakRequestBytes: number;
|
|
26
|
+
/** Rejected records, fields, metric registrations and export attempts; not delivered-event count. */
|
|
27
|
+
readonly dropped: number;
|
|
28
|
+
readonly metricSeries: number;
|
|
29
|
+
}
|
|
30
|
+
/** Shared, closure-owned admission state; no queue or mutable counters are exposed. */
|
|
31
|
+
declare function makeCliEngineeringBudget(): Readonly<{
|
|
32
|
+
metricRegistry: Map<string, MetricEntry>;
|
|
33
|
+
emptyMetricRegistry: () => Map<string, MetricEntry>;
|
|
34
|
+
drop: () => void;
|
|
35
|
+
admitRecord(terminal: boolean): (() => void) | undefined;
|
|
36
|
+
admitRequest(bytes: number, terminal: boolean): (() => void) | undefined;
|
|
37
|
+
snapshot(): CliEngineeringStats;
|
|
38
|
+
}>;
|
|
39
|
+
type CliEngineeringBudget = ReturnType<typeof makeCliEngineeringBudget>;
|
|
40
|
+
//#endregion
|
|
3
41
|
//#region src/engineering.d.ts
|
|
4
42
|
type EngineeringProducer = "browser" | "server";
|
|
5
43
|
declare const ENGINEERING_CAPXUL_ENVS: readonly ["development", "staging", "production", "local"];
|
|
@@ -11,15 +49,30 @@ interface EngineeringTelemetryConfig {
|
|
|
11
49
|
readonly producer: EngineeringProducer;
|
|
12
50
|
readonly sdkVersion: string;
|
|
13
51
|
readonly serviceName?: string;
|
|
52
|
+
/** False or a thrown callback disables this acquired layer for its remaining lifetime. */
|
|
53
|
+
readonly enabled?: boolean | (() => boolean);
|
|
54
|
+
/** Codes, timings, and correlation only; no free text or private source paths. */
|
|
55
|
+
readonly privacy?: "minimal";
|
|
56
|
+
readonly shutdownTimeout?: Duration.Input;
|
|
57
|
+
readonly exportInterval?: Duration.Input;
|
|
58
|
+
/** CLI-only shared admission and transport lifetime. Omission preserves host defaults. */
|
|
59
|
+
readonly deliveryBudget?: CliEngineeringBudget;
|
|
14
60
|
}
|
|
15
61
|
declare const traceHeaderFilter: (_name: string) => boolean;
|
|
16
62
|
declare const postHogOtlpEndpoints: (host: string) => {
|
|
17
63
|
readonly logs: `${string}/i/v1/logs`;
|
|
18
64
|
readonly traces: `${string}/i/v1/traces`;
|
|
65
|
+
readonly metrics: `${string}/i/v1/metrics`;
|
|
19
66
|
};
|
|
20
67
|
/** Preserve domain exits while preventing the OTLP serializer from seeing raw causes. */
|
|
21
|
-
declare const makeLeakSafeEngineeringTracer: (delegate: Tracer.Tracer) => Tracer.Tracer;
|
|
68
|
+
declare const makeLeakSafeEngineeringTracer: (delegate: Tracer.Tracer, enabled?: () => boolean) => Tracer.Tracer;
|
|
69
|
+
/** Attempt to drain all engineering signals; completion does not prove ingestion. */
|
|
70
|
+
declare const flushEngineeringTelemetry: Effect.Effect<void, never, OtlpExporter.Flusher>;
|
|
71
|
+
declare const EngineeringLog_base: Context.ServiceClass<EngineeringLog, "capxul/EngineeringLog", Logger.Logger<unknown, void>>;
|
|
72
|
+
declare class EngineeringLog extends EngineeringLog_base {}
|
|
73
|
+
/** Deliver an owned engineering record without changing the caller's console verbosity. */
|
|
74
|
+
declare const logEngineeringInfo: (message: string, attributes: Readonly<Record<string, unknown>>) => Effect.Effect<void, never, never>;
|
|
22
75
|
/** Shared browser/server OTLP layer. OtlpLogger merges with incumbent loggers once. */
|
|
23
|
-
declare const makeEngineeringTelemetryLayer: (config: EngineeringTelemetryConfig) => Layer.Layer<OtlpExporter.Flusher, never, never>;
|
|
76
|
+
declare const makeEngineeringTelemetryLayer: (config: EngineeringTelemetryConfig) => Layer.Layer<EngineeringLog | OtlpExporter.Flusher, never, never>;
|
|
24
77
|
//#endregion
|
|
25
|
-
export { ENGINEERING_CAPXUL_ENVS, EngineeringCapxulEnv, EngineeringProducer, EngineeringTelemetryConfig, makeEngineeringTelemetryLayer, makeLeakSafeEngineeringTracer, postHogOtlpEndpoints, traceHeaderFilter };
|
|
78
|
+
export { CLI_ENGINEERING_LIMITS, type CliEngineeringBudget, type CliEngineeringStats, ENGINEERING_CAPXUL_ENVS, EngineeringCapxulEnv, EngineeringProducer, EngineeringTelemetryConfig, flushEngineeringTelemetry, logEngineeringInfo, makeCliEngineeringBudget, makeEngineeringTelemetryLayer, makeLeakSafeEngineeringTracer, postHogOtlpEndpoints, traceHeaderFilter };
|