@lark-apaas/observable 1.0.4-alpha.2 → 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 +60 -35
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +60 -35
- 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,43 +8894,64 @@ var SnipingConfigManager = class _SnipingConfigManager {
|
|
|
8893
8894
|
modules: []
|
|
8894
8895
|
}
|
|
8895
8896
|
};
|
|
8896
|
-
|
|
8897
|
-
return this.config;
|
|
8897
|
+
constructor() {
|
|
8898
8898
|
}
|
|
8899
|
-
static
|
|
8900
|
-
|
|
8899
|
+
static getInstance() {
|
|
8900
|
+
if (!_PointKillManager.instance) {
|
|
8901
|
+
_PointKillManager.instance = new _PointKillManager();
|
|
8902
|
+
}
|
|
8903
|
+
return _PointKillManager.instance;
|
|
8901
8904
|
}
|
|
8902
|
-
|
|
8903
|
-
return this.config
|
|
8905
|
+
getConfig() {
|
|
8906
|
+
return this.config;
|
|
8904
8907
|
}
|
|
8905
|
-
|
|
8906
|
-
|
|
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
|
+
};
|
|
8907
8926
|
}
|
|
8908
|
-
|
|
8927
|
+
setConfig(configStr) {
|
|
8909
8928
|
if (!configStr) return;
|
|
8910
8929
|
try {
|
|
8911
8930
|
const res = JSON.parse(configStr);
|
|
8912
8931
|
const { logs: logs2, traces, metrics } = res ?? {};
|
|
8913
|
-
|
|
8914
|
-
|
|
8915
|
-
|
|
8916
|
-
|
|
8917
|
-
|
|
8918
|
-
|
|
8919
|
-
|
|
8920
|
-
|
|
8921
|
-
|
|
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
|
+
});
|
|
8922
8943
|
} catch (error) {
|
|
8923
8944
|
console.error("Failed to parse sniping config:", error);
|
|
8924
8945
|
}
|
|
8925
8946
|
}
|
|
8926
|
-
|
|
8927
|
-
const snipingConfig = headers[
|
|
8947
|
+
updateFromHeaders(headers) {
|
|
8948
|
+
const snipingConfig = headers[_PointKillManager.CONFIG_HEADER_NAME] || headers[_PointKillManager.CONFIG_HEADER_NAME.toLowerCase()];
|
|
8928
8949
|
if (snipingConfig) {
|
|
8929
8950
|
this.setConfig(snipingConfig);
|
|
8930
8951
|
}
|
|
8931
8952
|
}
|
|
8932
8953
|
};
|
|
8954
|
+
var pointKillManager = PointKillManager.getInstance();
|
|
8933
8955
|
|
|
8934
8956
|
// src/core/log-exporter.ts
|
|
8935
8957
|
var CustomExporter = class {
|
|
@@ -8941,8 +8963,9 @@ var CustomExporter = class {
|
|
|
8941
8963
|
constructor() {
|
|
8942
8964
|
}
|
|
8943
8965
|
export(logs2, resultCallback) {
|
|
8944
|
-
const snipingConfig =
|
|
8945
|
-
|
|
8966
|
+
const snipingConfig = pointKillManager.getConfig();
|
|
8967
|
+
console.log("snipingConfig", snipingConfig);
|
|
8968
|
+
if (snipingConfig.logs.modules.includes("*")) {
|
|
8946
8969
|
resultCallback({
|
|
8947
8970
|
code: core.ExportResultCode.SUCCESS
|
|
8948
8971
|
});
|
|
@@ -8950,7 +8973,7 @@ var CustomExporter = class {
|
|
|
8950
8973
|
}
|
|
8951
8974
|
const filteredLogs = logs2.filter((log) => {
|
|
8952
8975
|
const module = log.attributes?.module;
|
|
8953
|
-
if (module && snipingConfig.includes(module)) {
|
|
8976
|
+
if (module && snipingConfig.logs.modules.includes(module)) {
|
|
8954
8977
|
return false;
|
|
8955
8978
|
}
|
|
8956
8979
|
return true;
|
|
@@ -9031,8 +9054,9 @@ var CustomTraceExporter = class {
|
|
|
9031
9054
|
tracePrefix = "force-trace-prefix";
|
|
9032
9055
|
traceSuffix = "force-trace-suffix";
|
|
9033
9056
|
export(spans, resultCallback) {
|
|
9034
|
-
const snipingConfig =
|
|
9035
|
-
|
|
9057
|
+
const snipingConfig = pointKillManager.getConfig();
|
|
9058
|
+
console.log("snipingConfig", snipingConfig);
|
|
9059
|
+
if (snipingConfig.traces.modules.includes("*")) {
|
|
9036
9060
|
resultCallback({
|
|
9037
9061
|
code: core.ExportResultCode.SUCCESS
|
|
9038
9062
|
});
|
|
@@ -9044,10 +9068,11 @@ var CustomTraceExporter = class {
|
|
|
9044
9068
|
app_env: isDev ? AppEnv.Dev : AppEnv.Prod
|
|
9045
9069
|
};
|
|
9046
9070
|
const finalSpans = spans.filter((span) => {
|
|
9047
|
-
|
|
9048
|
-
|
|
9049
|
-
|
|
9050
|
-
|
|
9071
|
+
if ((span.attributes ?? {})[TraceDropToken]) return false;
|
|
9072
|
+
const module = span.attributes?.module;
|
|
9073
|
+
if (module && snipingConfig.traces.modules.includes(module)) {
|
|
9074
|
+
return false;
|
|
9075
|
+
}
|
|
9051
9076
|
return true;
|
|
9052
9077
|
});
|
|
9053
9078
|
if (!finalSpans.length) {
|
|
@@ -9137,7 +9162,7 @@ var AppOTelSDK = class _AppOTelSDK {
|
|
|
9137
9162
|
* wrapper 形式
|
|
9138
9163
|
*/
|
|
9139
9164
|
startContext(headers, name, fn) {
|
|
9140
|
-
|
|
9165
|
+
pointKillManager.updateFromHeaders(headers);
|
|
9141
9166
|
const carrier = {};
|
|
9142
9167
|
const customTraceId = headers["rpc-persist-apaas-observability-trace"];
|
|
9143
9168
|
if (customTraceId && _AppOTelSDK.CUSTOM_FORMAT_REGEX.test(customTraceId)) {
|