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