@lark-apaas/observable 1.0.4-alpha.1 → 1.0.4-alpha.3

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.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.1"};
8845
+ version: "1.0.4-alpha.2"};
8846
8846
 
8847
8847
  // src/const.ts
8848
8848
  var AppEnv = /* @__PURE__ */ (function(AppEnv2) {
@@ -8882,49 +8882,45 @@ var SnipingConfigManager = class _SnipingConfigManager {
8882
8882
  static CONFIG_HEADER_NAME = "x-force-observability-pointkill";
8883
8883
  static config = {
8884
8884
  logs: {
8885
- module: []
8885
+ modules: []
8886
8886
  },
8887
8887
  traces: {
8888
- module: []
8888
+ modules: []
8889
8889
  },
8890
8890
  metrics: {
8891
- module: []
8891
+ modules: []
8892
8892
  }
8893
8893
  };
8894
8894
  static getConfig() {
8895
- return this.config;
8896
- }
8897
- static getLogConfig() {
8898
- return this.config.logs.module;
8899
- }
8900
- static getTraceConfig() {
8901
- return this.config.traces.module;
8902
- }
8903
- static getMetricConfig() {
8904
- return this.config.metrics.module;
8895
+ return _SnipingConfigManager.config;
8905
8896
  }
8906
8897
  static setConfig(configStr) {
8898
+ console.log("configStr", configStr);
8907
8899
  if (!configStr) return;
8908
8900
  try {
8909
8901
  const res = JSON.parse(configStr);
8910
8902
  const { logs: logs2, traces, metrics } = res ?? {};
8911
- if (Array.isArray(logs2?.module)) {
8912
- this.config.logs.module = logs2.module;
8913
- }
8914
- if (Array.isArray(traces?.module)) {
8915
- this.config.traces.module = traces.module;
8916
- }
8917
- if (Array.isArray(metrics?.module)) {
8918
- this.config.metrics.module = metrics.module;
8903
+ if (res) {
8904
+ _SnipingConfigManager.config = {
8905
+ logs: {
8906
+ modules: Array.isArray(logs2?.modules) ? logs2.modules : []
8907
+ },
8908
+ traces: {
8909
+ modules: Array.isArray(traces?.modules) ? traces.modules : []
8910
+ },
8911
+ metrics: {
8912
+ modules: Array.isArray(metrics?.modules) ? metrics.modules : []
8913
+ }
8914
+ };
8919
8915
  }
8920
8916
  } catch (error) {
8921
8917
  console.error("Failed to parse sniping config:", error);
8922
8918
  }
8923
8919
  }
8924
8920
  static updateFromHeaders(headers) {
8925
- const snipingConfig = headers[_SnipingConfigManager.CONFIG_HEADER_NAME];
8921
+ const snipingConfig = headers[_SnipingConfigManager.CONFIG_HEADER_NAME] || headers[_SnipingConfigManager.CONFIG_HEADER_NAME.toLowerCase()];
8926
8922
  if (snipingConfig) {
8927
- this.setConfig(snipingConfig);
8923
+ _SnipingConfigManager.setConfig(snipingConfig);
8928
8924
  }
8929
8925
  }
8930
8926
  };
@@ -8939,8 +8935,9 @@ var CustomExporter = class {
8939
8935
  constructor() {
8940
8936
  }
8941
8937
  export(logs2, resultCallback) {
8942
- const snipingConfig = SnipingConfigManager.getLogConfig();
8943
- if (snipingConfig.includes("*")) {
8938
+ const snipingConfig = SnipingConfigManager.getConfig();
8939
+ console.log("snipingConfig", snipingConfig);
8940
+ if (snipingConfig.logs.modules.includes("*")) {
8944
8941
  resultCallback({
8945
8942
  code: ExportResultCode.SUCCESS
8946
8943
  });
@@ -8948,7 +8945,7 @@ var CustomExporter = class {
8948
8945
  }
8949
8946
  const filteredLogs = logs2.filter((log) => {
8950
8947
  const module = log.attributes?.module;
8951
- if (module && snipingConfig.includes(module)) {
8948
+ if (module && snipingConfig.logs.modules.includes(module)) {
8952
8949
  return false;
8953
8950
  }
8954
8951
  return true;
@@ -9029,8 +9026,9 @@ var CustomTraceExporter = class {
9029
9026
  tracePrefix = "force-trace-prefix";
9030
9027
  traceSuffix = "force-trace-suffix";
9031
9028
  export(spans, resultCallback) {
9032
- const snipingConfig = SnipingConfigManager.getTraceConfig();
9033
- if (snipingConfig.includes("*")) {
9029
+ const snipingConfig = SnipingConfigManager.getConfig();
9030
+ console.log("snipingConfig", snipingConfig);
9031
+ if (snipingConfig.traces.modules.includes("*")) {
9034
9032
  resultCallback({
9035
9033
  code: ExportResultCode.SUCCESS
9036
9034
  });
@@ -9042,10 +9040,11 @@ var CustomTraceExporter = class {
9042
9040
  app_env: isDev ? AppEnv.Dev : AppEnv.Prod
9043
9041
  };
9044
9042
  const finalSpans = spans.filter((span) => {
9045
- const attrs = span.attributes ?? {};
9046
- if (attrs[TraceDropToken]) return false;
9047
- const module = attrs.module;
9048
- if (module && snipingConfig.includes(module)) return false;
9043
+ if ((span.attributes ?? {})[TraceDropToken]) return false;
9044
+ const module = span.attributes?.module;
9045
+ if (module && snipingConfig.traces.modules.includes(module)) {
9046
+ return false;
9047
+ }
9049
9048
  return true;
9050
9049
  });
9051
9050
  if (!finalSpans.length) {