@salesforce/lds-instrumentation 1.100.2

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/dist/main.d.ts ADDED
@@ -0,0 +1,81 @@
1
+ import type { Luvio, InMemoryStore, Adapter, CacheMissOutOfTtlEvent, DataOutOfTtlDurationUpdateEvent } from '@luvio/engine';
2
+ import type { Registration as LdsUiapiRegistration } from '@salesforce/lds-adapters-uiapi';
3
+ import type { Registration as LdsNetworkAdapterRegistration } from '@salesforce/lds-network-adapter';
4
+ import type { AdapterReport } from '@salesforce/lds-utils-adapters';
5
+ export * as METRIC_KEYS from './metric-keys';
6
+ export { LRUCache } from './utils/lru-cache';
7
+ interface AdapterMetadata {
8
+ apiFamily: string;
9
+ name: string;
10
+ ttl?: number;
11
+ }
12
+ export declare class Instrumentation {
13
+ /**
14
+ * Injected to LDS for Luvio specific instrumentation.
15
+ *
16
+ * @param context The transaction context.
17
+ */
18
+ instrumentLuvio(_context: unknown): void;
19
+ }
20
+ /**
21
+ * Provide this method for the instrument option for a Luvio instance.
22
+ * @param context The transaction context.
23
+ */
24
+ export declare function instrumentLuvio(context: unknown): void;
25
+ export type ReportObserver = (report: AdapterReport) => void;
26
+ interface AdapterInstrumentationOptions {
27
+ trackL1Hits: boolean;
28
+ trackL2Hits: boolean;
29
+ reportObserver?: ReportObserver;
30
+ }
31
+ export declare function instrumentAdapter<C, D>(adapter: Adapter<C, D>, metadata: AdapterMetadata, adapterInstrumentationOptions?: AdapterInstrumentationOptions): Adapter<C, D>;
32
+ /**
33
+ * Wraps methods to collect runtime performance using o11y's trackValue API
34
+ * @param obj Object instance containing the methods to instrument
35
+ * @param methods array containing objects with keys for the method name and the metric key to use in o11y
36
+ */
37
+ export declare function instrumentMethods(obj: any, methods: {
38
+ methodName: string;
39
+ metricKey: string;
40
+ }[]): void;
41
+ /**
42
+ * Calls instrumentation/service telemetry counter
43
+ * @param name Name of the metric
44
+ * @param value number to increment by, if undefined increment by 1
45
+ */
46
+ export declare function incrementCounterMetric(name: string, number?: number): void;
47
+ /**
48
+ * Calls instrumentation/service telemetry percentileHistogram
49
+ * @param name Name of the metric
50
+ * @param value number used to update the percentileHistogram
51
+ */
52
+ export declare function updatePercentileHistogramMetric(name: string, value: number): void;
53
+ export declare function incrementGetRecordNormalInvokeCount(): void;
54
+ export declare function incrementGetRecordNotifyChangeAllowCount(): void;
55
+ export declare function incrementGetRecordNotifyChangeDropCount(): void;
56
+ export declare function incrementNotifyRecordUpdateAvailableAllowCount(): void;
57
+ export declare function incrementNotifyRecordUpdateAvailableDropCount(): void;
58
+ /**
59
+ * Sets up instrumentation for @salesforce/lds-adapters-uiapi
60
+ */
61
+ export declare function setLdsAdaptersUiapiInstrumentation(uiapiRegistration: LdsUiapiRegistration): void;
62
+ /**
63
+ * Sets up instrumentation for @salesforce/lds-network-adapter
64
+ */
65
+ export declare function setLdsNetworkAdapterInstrumentation(networkAdapterRegistration: LdsNetworkAdapterRegistration): void;
66
+ /**
67
+ * Provides concrete implementations using o11y/client for instrumentation hooks
68
+ */
69
+ export declare function setInstrumentationHooks(): void;
70
+ /**
71
+ * Initialize the instrumentation and instrument the LDS instance and the InMemoryStore.
72
+ *
73
+ * @param luvio The Luvio instance to instrument.
74
+ * @param store The InMemoryStore to instrument.
75
+ */
76
+ export declare function setupInstrumentation(luvio: Luvio, store: InMemoryStore): void;
77
+ export declare function instrumentStoreMethods(luvio: Luvio, _store: InMemoryStore): void;
78
+ export declare function handleIngestedNewData(event: CacheMissOutOfTtlEvent): void;
79
+ export declare function handleOnDataOutOfTtlDurationUpdate(event: DataOutOfTtlDurationUpdateEvent): void;
80
+ export declare function setStoreEventObservers(store: InMemoryStore): void;
81
+ export declare const instrumentation: Instrumentation;
@@ -0,0 +1,191 @@
1
+ export declare const ADAPTER_CACHE_HIT_COUNT_METRIC_NAME = "cache-hit-count";
2
+ export declare const ADAPTER_CACHE_HIT_DURATION_METRIC_NAME = "cache-hit-duration";
3
+ export declare const ADAPTER_CACHE_HIT_L2_COUNT_METRIC_NAME = "cache-hit-l2-count";
4
+ export declare const ADAPTER_CACHE_HIT_L2_DURATION_METRIC_NAME = "cache-hit-l2-duration";
5
+ export declare const ADAPTER_CACHE_MISS_COUNT_METRIC_NAME = "cache-miss-count";
6
+ export declare const ADAPTER_CACHE_MISS_DURATION_METRIC_NAME = "cache-miss-duration";
7
+ export declare const ADAPTER_CACHE_MISS_OUT_OF_TTL_COUNT_METRIC_NAME = "cache-miss-out-of-ttl-count";
8
+ export declare const ADAPTER_CACHE_MISS_OUT_OF_TTL_DURATION_METRIC_NAME = "cache-miss-out-of-ttl-duration";
9
+ export declare const REPRESENTATION_CACHE_MISS_OUT_OF_TTL_DATA_CHANGED_COUNT_METRIC_NAME = "cache-miss-out-of-ttl-data-changed-count";
10
+ export declare const REPRESENTATION_CACHE_MISS_OUT_OF_TTL_DATA_UNCHANGED_COUNT_METRIC_NAME = "cache-miss-out-of-ttl-data-unchanged-count";
11
+ export declare const REPRESENTATION_CACHE_MISS_OUT_OF_TTL_DATA_CHANGED_DURATION_METRIC_NAME = "cache-miss-out-of-ttl-data-changed-duration";
12
+ export declare const REPRESENTATION_CACHE_MISS_OUT_OF_TTL_DATA_UNCHANGED_DURATION_METRIC_NAME = "cache-miss-out-of-ttl-data-unchanged-duration";
13
+ /**
14
+ * W-8121791
15
+ * Number of subqueries used when aggregateUi is invoked for getRecord
16
+ */
17
+ export declare const AGGREGATE_UI_CHUNK_COUNT = "aggregate-ui-chunk-count";
18
+ /**
19
+ * W-6981216
20
+ * Counter for overall LDS cache hits.
21
+ * Note: This is also being recorded in AILTN logging.
22
+ */
23
+ export declare const CACHE_HIT_COUNT = "cache-hit-count";
24
+ /**
25
+ * W-6981216
26
+ * Counter for overall LDS cache hits.
27
+ * Note: This is also being recorded in AILTN logging.
28
+ */
29
+ export declare const CACHE_MISS_COUNT = "cache-miss-count";
30
+ /**
31
+ * W-9949353
32
+ * Used to track how often we dedupe HTTP requests
33
+ * Invoked when an HTTP request is deduped against an already in-flight request
34
+ */
35
+ export declare const DUPLICATE_REQUEST_COUNT = "duplicate-request-count";
36
+ /**
37
+ * W-7667066
38
+ * This count represents the number of times getRecord() was invoked, but not including
39
+ * executeAggregateUi calls. It can be represented as the sum of the Aura Action invocations
40
+ * GetRecordWithLayouts and GetRecordWithFields.
41
+ */
42
+ export declare const GET_RECORD_NORMAL_INVOKE_COUNT = "get-record-normal-invoke-count";
43
+ /**
44
+ * W-7667066
45
+ * This count represents the number of times getRecord() was invoked, with a large enough payload
46
+ * that executeAggregateUi was used.
47
+ */
48
+ export declare const GET_RECORD_AGGREGATE_INVOKE_COUNT = "get-record-aggregate-invoke-count";
49
+ /**
50
+ * W-7301684
51
+ * Counter for when getRecordNotifyChange api calls are allowed through.
52
+ */
53
+ export declare const GET_RECORD_NOTIFY_CHANGE_ALLOW_COUNT = "get-record-notify-change-allow-count";
54
+ /**
55
+ * W-7301684
56
+ * Counter for when getRecordNotifyChange api calls are dropped/throttled.
57
+ */
58
+ export declare const GET_RECORD_NOTIFY_CHANGE_DROP_COUNT = "get-record-notify-change-drop-count";
59
+ /**
60
+ * W-11118785
61
+ * Counter for when notifyRecordUpdateAvailable api calls are allowed through.
62
+ */
63
+ export declare const NOTIFY_RECORD_UPDATE_AVAILABLE_ALLOW_COUNT = "notify-record-update-available-allow-count";
64
+ /**
65
+ * W-11118785
66
+ * Counter for when notifyRecordUpdateAvailable api calls are dropped/throttled.
67
+ */
68
+ export declare const NOTIFY_RECORD_UPDATE_AVAILABLE_DROP_COUNT = "notify-record-update-available-drop-count";
69
+ /**
70
+ * W-8278006
71
+ * Counter for rate limiting telemetry. Is updated whenever the network adapter hits the specified limit.
72
+ */
73
+ export declare const NETWORK_RATE_LIMIT_EXCEEDED_COUNT = "network-rate-limit-exceeded-count";
74
+ /**
75
+ * W-6981216
76
+ * Timer to measure performance for Luvio.storeBroadcast() method.
77
+ */
78
+ export declare const STORE_BROADCAST_DURATION = "store-broadcast-duration";
79
+ /**
80
+ * W-6981216
81
+ * Timer to measure performance for Luvio.storeIngest() method.
82
+ */
83
+ export declare const STORE_INGEST_DURATION = "store-ingest-duration";
84
+ /**
85
+ * W-6981216
86
+ * Timer to measure performance for Luvio.storeLookup() method.
87
+ */
88
+ export declare const STORE_LOOKUP_DURATION = "store-lookup-duration";
89
+ /**
90
+ * W-9805009
91
+ * Timer to measure performance for Luvio.storeSetTTLOverride() method.
92
+ */
93
+ export declare const STORE_SET_TTL_OVERRIDE_DURATION = "store-set-ttl-override-duration";
94
+ /**
95
+ * W-9805009
96
+ * Timer to measure performance for Luvio.storeSetDefaultTTLOverride() method.
97
+ */
98
+ export declare const STORE_SET_DEFAULT_TTL_OVERRIDE_DURATION = "store-set-default-ttl-override-duration";
99
+ /**
100
+ * W-11118785
101
+ * Timer to measure performance for Luvio.notifyStoreUpdateAvailable() method.
102
+ */
103
+ export declare const NOTIFY_STORE_UPDATE_AVAILABLE_DURATION = "notify-store-update-available-duration";
104
+ /**
105
+ * W-6981216
106
+ * Counter for number of records in LDS store. Is updated by periodicLogger invocations.
107
+ * Note: This is also being recorded in AILTN logging.
108
+ */
109
+ export declare const STORE_SIZE_COUNT = "store-size-count";
110
+ /**
111
+ * W-6981216
112
+ * Counter for number of LDS snapshot subscription. Is updated by periodicLogger invocations.
113
+ * Note: This is also being recorded in AILTN logging.
114
+ */
115
+ export declare const STORE_SNAPSHOT_SUBSCRIPTIONS_COUNT = "store-snapshot-subscriptions-count";
116
+ /**
117
+ * W-6981216
118
+ * Counter for number of LDS watch subscriptions. Is updated by periodicLogger invocations.
119
+ * Note: This is also being recorded in AILTN logging.
120
+ */
121
+ export declare const STORE_WATCH_SUBSCRIPTIONS_COUNT = "store-watch-subscriptions-count";
122
+ /**
123
+ * W-9131128
124
+ * Counter for graphQL get adapter response with mixed bag of both data and error in response
125
+ */
126
+ export declare const GET_GRAPHQL_RESPONSE_MIXED = "get-graphql-response-mixed-count";
127
+ /**
128
+ * W-9537401
129
+ * Counter for Luvio store trim task invocation
130
+ */
131
+ export declare const STORE_TRIM_TASK_COUNT = "store-trim-task-count";
132
+ /**
133
+ * W-9537401
134
+ * Timer to measure performance for Luvio store trim task
135
+ */
136
+ export declare const STORE_TRIM_TASK_DURATION = "store-trim-task-duration";
137
+ /**
138
+ * W-9804037
139
+ * Counters for Luvio cache policy usage
140
+ * Note: Undefined cache policy defaults to different cache policies based on runtime
141
+ */
142
+ export declare const CACHE_POLICY_COUNTERS: {
143
+ 'cache-and-network': string;
144
+ 'cache-then-network': string;
145
+ 'no-cache': string;
146
+ 'only-if-cached': string;
147
+ 'stale-while-revalidate': string;
148
+ 'valid-at': string;
149
+ };
150
+ export declare const CACHE_POLICY_UNDEFINED_COUNTER = "cache-policy-undefined";
151
+ export declare const STALE_TAG = "stale";
152
+ /**
153
+ * W-9804037
154
+ * Durable Store health metric
155
+ * Counter to track Durable Store read, write and error rates
156
+ */
157
+ export declare const DURABLE_STORE_COUNT = "durable-store-count";
158
+ /**
159
+ * W-10490363
160
+ * GraphQL Eval health metric
161
+ * Counter to track Success and Error Rate on Eval
162
+ */
163
+ export declare const GRAPHQL_ADAPTER_COUNT = "graphql-adapter-count";
164
+ /**
165
+ * Counter for tracking invalid record type IDs
166
+ */
167
+ export declare const RECORD_TYPE_ID_IS_NULL_COUNT = "record-type-id-is-null-count";
168
+ /**
169
+ * W-12293528
170
+ * GraphQL health metric
171
+ * Counter to track size of the top-level GraphQL object
172
+ */
173
+ export declare const STORE_GRAPHQL_SIZE_COUNT = "store-graphql-size-count";
174
+ /**
175
+ * W-12293528
176
+ * GraphQL health metric
177
+ * Counter to track validation errors in query
178
+ */
179
+ export declare const GRAPHQL_QUERY_VALIDATION_ERROR_COUNT = "graphql-query-validation-error-count";
180
+ /**
181
+ * W-12293528
182
+ * GraphQL health metric
183
+ * Counter to track syntax errors in query
184
+ */
185
+ export declare const GRAPHQL_QUERY_SYNTAX_ERROR_COUNT = "graphql-query-syntax-error-count";
186
+ /**
187
+ * W-12293528
188
+ * GraphQL health metric
189
+ * Counter to track miscellaneous errors in query
190
+ */
191
+ export declare const GRAPHQL_QUERY_OTHER_ERROR_COUNT = "graphql-query-other-error-count";
@@ -0,0 +1,13 @@
1
+ declare const create: {
2
+ (o: object | null): any;
3
+ (o: object | null, properties: PropertyDescriptorMap & ThisType<any>): any;
4
+ }, keys: {
5
+ (o: object): string[];
6
+ (o: {}): string[];
7
+ };
8
+ declare const isArray: (arg: any) => arg is any[];
9
+ declare const parse: (text: string, reviver?: ((this: any, key: string, value: any) => any) | undefined) => any, stringify: {
10
+ (value: any, replacer?: ((this: any, key: string, value: any) => any) | undefined, space?: string | number | undefined): string;
11
+ (value: any, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): string;
12
+ };
13
+ export { create as ObjectCreate, keys as ObjectKeys, isArray as ArrayIsArray, stringify as JSONStringify, parse as JSONParse, };
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Inspired by https://www.npmjs.com/package/hashlru
3
+ */
4
+ export declare class LRUCache {
5
+ private oldCache;
6
+ private newCache;
7
+ private size;
8
+ private limit;
9
+ constructor(limit: number);
10
+ private checkSize;
11
+ get(key: string): any;
12
+ set(key: string, value: any): void;
13
+ delete(key: string): void;
14
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Observability / Critical Availability Program (230+)
3
+ *
4
+ * This file is intended to be used as a consolidated place for all definitions, functions,
5
+ * and helpers related to "M1"[1].
6
+ *
7
+ * Below are the R.E.A.D.S. metrics for the Lightning Data Service, defined here[2].
8
+ *
9
+ * [1] https://salesforce.quip.com/NfW9AsbGEaTY
10
+ * [2] https://salesforce.quip.com/1dFvAba1b0eq
11
+ */
12
+ export declare const OBSERVABILITY_NAMESPACE = "LIGHTNING.lds.service";
13
+ export declare const ADAPTER_INVOCATION_COUNT_METRIC_NAME = "request";
14
+ export declare const ADAPTER_ERROR_COUNT_METRIC_NAME = "error";
15
+ /**
16
+ * W-8828410
17
+ * Counter for the number of UnfulfilledSnapshotErrors the luvio engine has.
18
+ */
19
+ export declare const TOTAL_ADAPTER_ERROR_COUNT = "error";
20
+ /**
21
+ * W-8828410
22
+ * Counter for the number of invocations made into LDS by a wire adapter.
23
+ */
24
+ export declare const TOTAL_ADAPTER_REQUEST_SUCCESS_COUNT = "request";
@@ -0,0 +1,15 @@
1
+ /**
2
+ * A deterministic JSON stringify implementation. Heavily adapted from https://github.com/epoberezkin/fast-json-stable-stringify.
3
+ * This is needed because insertion order for JSON.stringify(object) affects output:
4
+ * JSON.stringify({a: 1, b: 2})
5
+ * "{"a":1,"b":2}"
6
+ * JSON.stringify({b: 2, a: 1})
7
+ * "{"b":2,"a":1}"
8
+ * Modified from the apex implementation to sort arrays non-destructively.
9
+ * @param data Data to be JSON-stringified.
10
+ * @returns JSON.stringified value with consistent ordering of keys.
11
+ */
12
+ export declare function stableJSONStringify(node: any): string | undefined;
13
+ export declare function isPromise<D>(value: D | Promise<D> | null): value is Promise<D>;
14
+ export declare function isAdapterError(error: unknown): boolean;
15
+ export declare function throttle(callback: () => void, ms: number): () => void;
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@salesforce/lds-instrumentation",
3
+ "version": "1.100.2",
4
+ "license": "SEE LICENSE IN LICENSE.txt",
5
+ "description": "Instrumentation utils for Lightning Data Service",
6
+ "main": "dist/ldsInstrumentation.js",
7
+ "module": "dist/ldsInstrumentation.js",
8
+ "types": "dist/main.d.ts",
9
+ "files": [
10
+ "dist"
11
+ ],
12
+ "exports": {
13
+ ".": {
14
+ "import": "./dist/ldsInstrumentation.js",
15
+ "types": "./dist/main.d.ts",
16
+ "default": "./dist/ldsInstrumentation.js"
17
+ }
18
+ },
19
+ "sfdc": {
20
+ "path": "forcelds/ldsInstrumentation/",
21
+ "publishedFileName": "ldsInstrumentation.js",
22
+ "overrides": {
23
+ "artifactDirectory": "dist"
24
+ }
25
+ },
26
+ "scripts": {
27
+ "prepare": "yarn build",
28
+ "build": "rollup --config rollup.config.js",
29
+ "clean": "rm -rf dist",
30
+ "test:unit": "jest",
31
+ "test:debug": "node --inspect-brk ../../node_modules/.bin/jest --runInBand",
32
+ "test:size": "bundlesize",
33
+ "release:corejar": "yarn build && ../core-build/scripts/core.js --name=lds-instrumentation"
34
+ },
35
+ "dependencies": {
36
+ "@salesforce/lds-bindings": "^1.100.2",
37
+ "@salesforce/lds-default-luvio": "^1.100.2",
38
+ "@salesforce/lds-utils-adapters": "^1.100.2",
39
+ "o11y": "244.0.0",
40
+ "o11y_schema": "244.0.0"
41
+ },
42
+ "devDependencies": {
43
+ "@salesforce/lds-adapters-uiapi": "^1.100.2",
44
+ "@salesforce/lds-network-adapter": "^1.100.2"
45
+ },
46
+ "bundlesize": [
47
+ {
48
+ "path": "./dist/ldsInstrumentation.js",
49
+ "maxSize": "15 kB",
50
+ "compression": "brotli"
51
+ }
52
+ ]
53
+ }