@lark-apaas/observable 1.0.4-alpha.3 → 1.0.4-alpha.4
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/index.cjs +54 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +54 -28
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -8842,7 +8842,7 @@ __name(hrTimeToNanosNumber, "hrTimeToNanosNumber");
|
|
|
8842
8842
|
|
|
8843
8843
|
// package.json
|
|
8844
8844
|
var package_default = {
|
|
8845
|
-
version: "1.0.4-alpha.
|
|
8845
|
+
version: "1.0.4-alpha.3"};
|
|
8846
8846
|
|
|
8847
8847
|
// src/const.ts
|
|
8848
8848
|
var AppEnv = /* @__PURE__ */ (function(AppEnv2) {
|
|
@@ -8874,13 +8874,14 @@ function convertAttributesToString(attributes) {
|
|
|
8874
8874
|
}
|
|
8875
8875
|
__name(convertAttributesToString, "convertAttributesToString");
|
|
8876
8876
|
|
|
8877
|
-
// src/core/
|
|
8878
|
-
var
|
|
8877
|
+
// src/core/point-kill/index.ts
|
|
8878
|
+
var PointKillManager = class _PointKillManager {
|
|
8879
8879
|
static {
|
|
8880
|
-
__name(this, "
|
|
8880
|
+
__name(this, "PointKillManager");
|
|
8881
8881
|
}
|
|
8882
|
+
static instance;
|
|
8882
8883
|
static CONFIG_HEADER_NAME = "x-force-observability-pointkill";
|
|
8883
|
-
|
|
8884
|
+
config = {
|
|
8884
8885
|
logs: {
|
|
8885
8886
|
modules: []
|
|
8886
8887
|
},
|
|
@@ -8891,39 +8892,64 @@ var SnipingConfigManager = class _SnipingConfigManager {
|
|
|
8891
8892
|
modules: []
|
|
8892
8893
|
}
|
|
8893
8894
|
};
|
|
8894
|
-
|
|
8895
|
-
|
|
8895
|
+
constructor() {
|
|
8896
|
+
}
|
|
8897
|
+
static getInstance() {
|
|
8898
|
+
if (!_PointKillManager.instance) {
|
|
8899
|
+
_PointKillManager.instance = new _PointKillManager();
|
|
8900
|
+
}
|
|
8901
|
+
return _PointKillManager.instance;
|
|
8902
|
+
}
|
|
8903
|
+
getConfig() {
|
|
8904
|
+
return this.config;
|
|
8905
|
+
}
|
|
8906
|
+
updateConfig(newConfig) {
|
|
8907
|
+
this.config = {
|
|
8908
|
+
logs: {
|
|
8909
|
+
modules: [
|
|
8910
|
+
...newConfig.logs.modules
|
|
8911
|
+
]
|
|
8912
|
+
},
|
|
8913
|
+
traces: {
|
|
8914
|
+
modules: [
|
|
8915
|
+
...newConfig.traces.modules
|
|
8916
|
+
]
|
|
8917
|
+
},
|
|
8918
|
+
metrics: {
|
|
8919
|
+
modules: [
|
|
8920
|
+
...newConfig.metrics.modules
|
|
8921
|
+
]
|
|
8922
|
+
}
|
|
8923
|
+
};
|
|
8896
8924
|
}
|
|
8897
|
-
|
|
8898
|
-
console.log("configStr", configStr);
|
|
8925
|
+
setConfig(configStr) {
|
|
8899
8926
|
if (!configStr) return;
|
|
8900
8927
|
try {
|
|
8901
8928
|
const res = JSON.parse(configStr);
|
|
8902
8929
|
const { logs: logs2, traces, metrics } = res ?? {};
|
|
8903
|
-
|
|
8904
|
-
|
|
8905
|
-
|
|
8906
|
-
|
|
8907
|
-
|
|
8908
|
-
traces:
|
|
8909
|
-
|
|
8910
|
-
|
|
8911
|
-
metrics:
|
|
8912
|
-
|
|
8913
|
-
|
|
8914
|
-
};
|
|
8915
|
-
}
|
|
8930
|
+
this.updateConfig({
|
|
8931
|
+
logs: {
|
|
8932
|
+
modules: Array.isArray(logs2?.modules) ? logs2.modules : []
|
|
8933
|
+
},
|
|
8934
|
+
traces: {
|
|
8935
|
+
modules: Array.isArray(traces?.modules) ? traces.modules : []
|
|
8936
|
+
},
|
|
8937
|
+
metrics: {
|
|
8938
|
+
modules: Array.isArray(metrics?.modules) ? metrics.modules : []
|
|
8939
|
+
}
|
|
8940
|
+
});
|
|
8916
8941
|
} catch (error) {
|
|
8917
8942
|
console.error("Failed to parse sniping config:", error);
|
|
8918
8943
|
}
|
|
8919
8944
|
}
|
|
8920
|
-
|
|
8921
|
-
const snipingConfig = headers[
|
|
8945
|
+
updateFromHeaders(headers) {
|
|
8946
|
+
const snipingConfig = headers[_PointKillManager.CONFIG_HEADER_NAME] || headers[_PointKillManager.CONFIG_HEADER_NAME.toLowerCase()];
|
|
8922
8947
|
if (snipingConfig) {
|
|
8923
|
-
|
|
8948
|
+
this.setConfig(snipingConfig);
|
|
8924
8949
|
}
|
|
8925
8950
|
}
|
|
8926
8951
|
};
|
|
8952
|
+
var pointKillManager = PointKillManager.getInstance();
|
|
8927
8953
|
|
|
8928
8954
|
// src/core/log-exporter.ts
|
|
8929
8955
|
var CustomExporter = class {
|
|
@@ -8935,7 +8961,7 @@ var CustomExporter = class {
|
|
|
8935
8961
|
constructor() {
|
|
8936
8962
|
}
|
|
8937
8963
|
export(logs2, resultCallback) {
|
|
8938
|
-
const snipingConfig =
|
|
8964
|
+
const snipingConfig = pointKillManager.getConfig();
|
|
8939
8965
|
console.log("snipingConfig", snipingConfig);
|
|
8940
8966
|
if (snipingConfig.logs.modules.includes("*")) {
|
|
8941
8967
|
resultCallback({
|
|
@@ -9026,7 +9052,7 @@ var CustomTraceExporter = class {
|
|
|
9026
9052
|
tracePrefix = "force-trace-prefix";
|
|
9027
9053
|
traceSuffix = "force-trace-suffix";
|
|
9028
9054
|
export(spans, resultCallback) {
|
|
9029
|
-
const snipingConfig =
|
|
9055
|
+
const snipingConfig = pointKillManager.getConfig();
|
|
9030
9056
|
console.log("snipingConfig", snipingConfig);
|
|
9031
9057
|
if (snipingConfig.traces.modules.includes("*")) {
|
|
9032
9058
|
resultCallback({
|
|
@@ -9134,7 +9160,7 @@ var AppOTelSDK = class _AppOTelSDK {
|
|
|
9134
9160
|
* wrapper 形式
|
|
9135
9161
|
*/
|
|
9136
9162
|
startContext(headers, name, fn) {
|
|
9137
|
-
|
|
9163
|
+
pointKillManager.updateFromHeaders(headers);
|
|
9138
9164
|
const carrier = {};
|
|
9139
9165
|
const customTraceId = headers["rpc-persist-apaas-observability-trace"];
|
|
9140
9166
|
if (customTraceId && _AppOTelSDK.CUSTOM_FORMAT_REGEX.test(customTraceId)) {
|