@salesforce/lds-instrumentation 1.419.0 → 1.421.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,9 +14,9 @@
14
14
  /* proxy-compat-disable */
15
15
  import { getInstrumentation, idleDetector } from 'o11y/client';
16
16
  import { adapterUnfulfilledErrorSchema } from 'o11y_schema/sf_lds';
17
- import { pdpEventSchema } from 'o11y_schema/sf_pdp';
18
- import pftAdapterInvocationDisabledGate from '@salesforce/gate/lds.pft.adapterInvocation.disabled';
19
17
  import { ADAPTER_UNFULFILLED_ERROR, instrument } from 'force/ldsBindings';
18
+ import pftAdapterInvocationDisabledGate from '@salesforce/gate/lds.pft.adapterInvocation.disabled';
19
+ import { pdpEventSchema } from 'o11y_schema/sf_pdp';
20
20
 
21
21
  var SnapshotState;
22
22
  (function (SnapshotState) {
@@ -109,7 +109,7 @@ var TypeCheckShapes;
109
109
  TypeCheckShapes[TypeCheckShapes["Integer"] = 3] = "Integer";
110
110
  TypeCheckShapes[TypeCheckShapes["Unsupported"] = 4] = "Unsupported";
111
111
  })(TypeCheckShapes || (TypeCheckShapes = {}));
112
- // engine version: 0.160.1-e075b880
112
+ // engine version: 0.160.3-354dc58b
113
113
 
114
114
  const DurableEnvironmentEventDiscriminator = 'durable';
115
115
  function isDurableEnvironmentEvent(event) {
@@ -866,17 +866,85 @@ function throttle(callback, ms) {
866
866
  }
867
867
  };
868
868
  }
869
+ // Take 1 out of N adapter invocations to PFT (Don't hug PFT to death $$$$)
870
+ const PFT_DEFAULT_SAMPLING_RATE = 1000;
871
+ const LDS_PRODUCT_FEATURE_ID = 'aJCEE0000000mBk4AI'; // Product Feature ID for Lightning Data Service
872
+ const PFT_DEFAULT_PAYLOAD = {
873
+ productFeatureId: LDS_PRODUCT_FEATURE_ID,
874
+ };
875
+ function logToPFT(instrumentation, payload, samplingRate = PFT_DEFAULT_SAMPLING_RATE) {
876
+ if (!pftAdapterInvocationDisabledGate.isOpen({ fallback: false }) &&
877
+ Math.random() * samplingRate <= 1) {
878
+ instrumentation.log(pdpEventSchema, {
879
+ ...PFT_DEFAULT_PAYLOAD,
880
+ ...payload,
881
+ });
882
+ }
883
+ }
884
+
885
+ const STATE_MANAGERS_NAMESPACE = 'state-managers';
886
+ const stateManagersInstrumentation = getInstrumentation(STATE_MANAGERS_NAMESPACE);
887
+ const STATE_CREATED_OPERATION = 'create';
888
+ const STATE_DEFINED_OPERATION = 'define';
889
+ const CONTEXT_CONSUMED_OPERATION = 'context';
890
+ const PFT_SM_SAMPLING_RATE = 100;
891
+ var OperationTypeValue;
892
+ (function (OperationTypeValue) {
893
+ OperationTypeValue["Internal"] = "internal";
894
+ OperationTypeValue["External"] = "external";
895
+ OperationTypeValue["UiApi"] = "uiapi";
896
+ OperationTypeValue["Unknown"] = "unknown";
897
+ OperationTypeValue["Other"] = "other";
898
+ })(OperationTypeValue || (OperationTypeValue = {}));
899
+ /**
900
+ * Increments the state-created counter.
901
+ * @remarks Excludes `definedBy` from tags to avoid unbound cardinality.
902
+ */
903
+ function incrementStateCreatedCount(tags) {
904
+ stateManagersInstrumentation.incrementCounter(STATE_CREATED_OPERATION, 1, undefined, {
905
+ type: tags.type,
906
+ });
907
+ logToPFT(stateManagersInstrumentation, {
908
+ eventName: `state-manager.create`,
909
+ contextName: 'type',
910
+ contextValue: tags.type,
911
+ }, PFT_SM_SAMPLING_RATE);
912
+ }
913
+ /**
914
+ * Increments the state-defined counter.
915
+ * @remarks Includes `definedBy` in tags; low cardinality makes unbound cardinality acceptable.
916
+ * No PFT log—single key:value without definedBy would be meaningless.
917
+ */
918
+ function incrementStateDefinedCount(tags) {
919
+ stateManagersInstrumentation.incrementCounter(STATE_DEFINED_OPERATION, 1, undefined, tags);
920
+ }
921
+ /**
922
+ * Increments the context-consumed counter.
923
+ * @remarks Excludes `definedBy` from tags to avoid unbound cardinality.
924
+ */
925
+ function incrementStateContextConsumedCount(tags) {
926
+ stateManagersInstrumentation.incrementCounter(CONTEXT_CONSUMED_OPERATION, 1, undefined, {
927
+ type: tags.type,
928
+ });
929
+ logToPFT(stateManagersInstrumentation, {
930
+ eventName: `state-manager.context`,
931
+ contextName: 'type',
932
+ contextValue: tags.type,
933
+ }, PFT_SM_SAMPLING_RATE);
934
+ }
935
+ const stateManagerInstrumentation = {
936
+ incrementStateCreatedCount,
937
+ incrementStateDefinedCount,
938
+ incrementStateContextConsumedCount,
939
+ };
869
940
 
870
941
  const NAMESPACE = 'lds';
871
942
  const APEX_ADAPTER_NAME = 'getApex';
872
- const STATE_MANAGERS_NAMESPACE = 'state-managers';
873
943
  const NORMALIZED_APEX_ADAPTER_NAME = createMetricsKey('Apex', APEX_ADAPTER_NAME);
874
944
  const GRAPHQL_ADAPTER_NAME = 'graphQL';
875
945
  const GRAPHQL_RECORDS_KEY = 'GraphQL::graphql__uiapi__query';
876
946
  const ldsInstrumentation = getInstrumentation(NAMESPACE);
877
947
  const observabilityInstrumentation = getInstrumentation(OBSERVABILITY_NAMESPACE);
878
- const stateManagersInstrumentation = getInstrumentation(STATE_MANAGERS_NAMESPACE);
879
- const LDS_PRODUCT_FEATURE_ID = 'aJCEE0000000mBk4AI'; // Product Feature ID for Lightning Data Service
880
948
  class Instrumentation {
881
949
  /**
882
950
  * Injected to LDS for Luvio specific instrumentation.
@@ -944,22 +1012,16 @@ function logObjectInfoChanged() {
944
1012
  function logMessage(message) {
945
1013
  ldsInstrumentation.log(message);
946
1014
  }
947
- // Take 1 out of N adapter invocations to PFT (Don't hug PFT to death $$$$)
948
- const PFT_SAMPLING_RATE = 1000;
949
1015
  /**
950
1016
  * W-13639107
951
1017
  * Logs to PFT (Product Feature Taxonomy) when an adapter is invoked
952
1018
  */
953
1019
  function logAdapterInvocationToPFT(adapterName) {
954
- if (!pftAdapterInvocationDisabledGate.isOpen({ fallback: false }) &&
955
- Math.random() * PFT_SAMPLING_RATE <= 1) {
956
- ldsInstrumentation.log(pdpEventSchema, {
957
- event_name: `luvioAdapter.invoked`,
958
- productFeatureId: LDS_PRODUCT_FEATURE_ID,
959
- contextName: 'adapter.name',
960
- contextValue: adapterName,
961
- });
962
- }
1020
+ logToPFT(ldsInstrumentation, {
1021
+ eventName: `luvioAdapter.invoked`,
1022
+ contextName: 'adapter.name',
1023
+ contextValue: adapterName,
1024
+ });
963
1025
  }
964
1026
  /**
965
1027
  * Increment the counter based on the cache policy type for an adapter call
@@ -1405,9 +1467,6 @@ function incrementNotifyRecordUpdateAvailableDropCount() {
1405
1467
  function incrementNetworkRateLimitExceededCount() {
1406
1468
  incrementCounterMetric(NETWORK_RATE_LIMIT_EXCEEDED_COUNT);
1407
1469
  }
1408
- function incrementStateCreatedCount() {
1409
- stateManagersInstrumentation.incrementCounter(STATE_CREATED_COUNT);
1410
- }
1411
1470
  function instrumentStoreTrimTask(callback) {
1412
1471
  return () => {
1413
1472
  ldsInstrumentation.incrementCounter(STORE_TRIM_TASK_COUNT);
@@ -1604,5 +1663,5 @@ function onIdleDetected(callback) {
1604
1663
  }
1605
1664
  const instrumentation = new Instrumentation();
1606
1665
 
1607
- export { Instrumentation, LRUCache, metricKeys as METRIC_KEYS, executeAsyncActivity, handleIngestedNewData, handleOnDataOutOfTtlDurationUpdate, incrementCounterMetric, incrementGetRecordNormalInvokeCount, incrementGetRecordNotifyChangeAllowCount, incrementGetRecordNotifyChangeDropCount, incrementNotifyRecordUpdateAvailableAllowCount, incrementNotifyRecordUpdateAvailableDropCount, incrementStateCreatedCount, instrumentAdapter, instrumentLuvio, instrumentMethods, instrumentStoreMethods, instrumentation, logAdapterInvocationToPFT, logError, logMessage, logObjectInfoChanged, onIdleDetected, setInstrumentationHooks, setLdsAdaptersUiapiInstrumentation, setLdsNetworkAdapterInstrumentation, setStoreEventObservers, setupInstrumentation, startAdapterActivity, updatePercentileHistogramMetric };
1608
- // version: 1.419.0-ade430921b
1666
+ export { Instrumentation, LRUCache, metricKeys as METRIC_KEYS, OperationTypeValue, executeAsyncActivity, handleIngestedNewData, handleOnDataOutOfTtlDurationUpdate, incrementCounterMetric, incrementGetRecordNormalInvokeCount, incrementGetRecordNotifyChangeAllowCount, incrementGetRecordNotifyChangeDropCount, incrementNotifyRecordUpdateAvailableAllowCount, incrementNotifyRecordUpdateAvailableDropCount, instrumentAdapter, instrumentLuvio, instrumentMethods, instrumentStoreMethods, instrumentation, logAdapterInvocationToPFT, logError, logMessage, logObjectInfoChanged, onIdleDetected, setInstrumentationHooks, setLdsAdaptersUiapiInstrumentation, setLdsNetworkAdapterInstrumentation, setStoreEventObservers, setupInstrumentation, startAdapterActivity, stateManagerInstrumentation, updatePercentileHistogramMetric };
1667
+ // version: 1.421.0-2828c95aef
@@ -6,6 +6,7 @@ import type { AdapterReport } from '@salesforce/lds-utils-adapters';
6
6
  import type { ObservabilityContext } from '@salesforce/nimbus-plugin-lds';
7
7
  export * as METRIC_KEYS from './metric-keys';
8
8
  export { LRUCache } from './utils/lru-cache';
9
+ export * from './state-managers';
9
10
  interface AdapterMetadata {
10
11
  apiFamily: string;
11
12
  name: string;
@@ -93,7 +94,6 @@ export declare function incrementGetRecordNotifyChangeAllowCount(): void;
93
94
  export declare function incrementGetRecordNotifyChangeDropCount(): void;
94
95
  export declare function incrementNotifyRecordUpdateAvailableAllowCount(): void;
95
96
  export declare function incrementNotifyRecordUpdateAvailableDropCount(): void;
96
- export declare function incrementStateCreatedCount(): void;
97
97
  /**
98
98
  * Sets up instrumentation for @salesforce/lds-adapters-uiapi
99
99
  */
@@ -0,0 +1,33 @@
1
+ export declare enum OperationTypeValue {
2
+ Internal = "internal",
3
+ External = "external",
4
+ UiApi = "uiapi",
5
+ Unknown = "unknown",
6
+ Other = "other"
7
+ }
8
+ export type OperationTags = {
9
+ type: OperationTypeValue;
10
+ definedBy: string;
11
+ };
12
+ /**
13
+ * Increments the state-created counter.
14
+ * @remarks Excludes `definedBy` from tags to avoid unbound cardinality.
15
+ */
16
+ declare function incrementStateCreatedCount(tags: OperationTags): void;
17
+ /**
18
+ * Increments the state-defined counter.
19
+ * @remarks Includes `definedBy` in tags; low cardinality makes unbound cardinality acceptable.
20
+ * No PFT log—single key:value without definedBy would be meaningless.
21
+ */
22
+ declare function incrementStateDefinedCount(tags: OperationTags): void;
23
+ /**
24
+ * Increments the context-consumed counter.
25
+ * @remarks Excludes `definedBy` from tags to avoid unbound cardinality.
26
+ */
27
+ declare function incrementStateContextConsumedCount(tags: OperationTags): void;
28
+ export declare const stateManagerInstrumentation: {
29
+ incrementStateCreatedCount: typeof incrementStateCreatedCount;
30
+ incrementStateDefinedCount: typeof incrementStateDefinedCount;
31
+ incrementStateContextConsumedCount: typeof incrementStateContextConsumedCount;
32
+ };
33
+ export {};
@@ -1,3 +1,4 @@
1
+ import { getInstrumentation } from 'o11y/client';
1
2
  /**
2
3
  * A deterministic JSON stringify implementation. Heavily adapted from https://github.com/epoberezkin/fast-json-stable-stringify.
3
4
  * This is needed because insertion order for JSON.stringify(object) affects output:
@@ -13,3 +14,10 @@ export declare function stableJSONStringify(node: any): string | undefined;
13
14
  export declare function isPromise<D>(value: D | Promise<D> | null): value is Promise<D>;
14
15
  export declare function isAdapterError(error: unknown): boolean;
15
16
  export declare function throttle(callback: () => void, ms: number): () => void;
17
+ export type PFTLogPayload = {
18
+ eventName: string;
19
+ productFeatureId?: string;
20
+ contextName?: string;
21
+ contextValue?: string;
22
+ };
23
+ export declare function logToPFT(instrumentation: ReturnType<typeof getInstrumentation>, payload: PFTLogPayload, samplingRate?: number): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-instrumentation",
3
- "version": "1.419.0",
3
+ "version": "1.421.0",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "description": "Instrumentation utils for Lightning Data Service",
6
6
  "main": "dist/ldsInstrumentation.js",
@@ -33,24 +33,24 @@
33
33
  "release:corejar": "yarn build && ../core-build/scripts/core.js --name=lds-instrumentation"
34
34
  },
35
35
  "dependencies": {
36
- "@salesforce/lds-bindings": "^1.419.0",
37
- "@salesforce/lds-default-luvio": "^1.419.0",
38
- "@salesforce/lds-utils-adapters": "^1.419.0",
36
+ "@salesforce/lds-bindings": "^1.421.0",
37
+ "@salesforce/lds-default-luvio": "^1.421.0",
38
+ "@salesforce/lds-utils-adapters": "^1.421.0",
39
39
  "o11y": "262.6.0",
40
40
  "o11y_schema": "260.37.0"
41
41
  },
42
42
  "devDependencies": {
43
- "@salesforce/lds-adapters-uiapi": "^1.419.0",
44
- "@salesforce/lds-network-adapter": "^1.419.0",
45
- "@salesforce/nimbus-plugin-lds": "^1.419.0"
43
+ "@salesforce/lds-adapters-uiapi": "^1.421.0",
44
+ "@salesforce/lds-network-adapter": "^1.421.0",
45
+ "@salesforce/nimbus-plugin-lds": "^1.421.0"
46
46
  },
47
47
  "luvioBundlesize": [
48
48
  {
49
49
  "path": "./dist/ldsInstrumentation.js",
50
50
  "maxSize": {
51
- "none": "64 kB",
52
- "min": "28 kB",
53
- "compressed": "12 kB"
51
+ "none": "70 kB",
52
+ "min": "29 kB",
53
+ "compressed": "12.2 kB"
54
54
  }
55
55
  }
56
56
  ],