@lark-apaas/observable 1.0.4-alpha.2 → 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.cjs CHANGED
@@ -8894,39 +8894,35 @@ var SnipingConfigManager = class _SnipingConfigManager {
8894
8894
  }
8895
8895
  };
8896
8896
  static getConfig() {
8897
- return this.config;
8898
- }
8899
- static getLogConfig() {
8900
- return this.config.logs.modules;
8901
- }
8902
- static getTraceConfig() {
8903
- return this.config.traces.modules;
8904
- }
8905
- static getMetricConfig() {
8906
- return this.config.metrics.modules;
8897
+ return _SnipingConfigManager.config;
8907
8898
  }
8908
8899
  static setConfig(configStr) {
8900
+ console.log("configStr", configStr);
8909
8901
  if (!configStr) return;
8910
8902
  try {
8911
8903
  const res = JSON.parse(configStr);
8912
8904
  const { logs: logs2, traces, metrics } = res ?? {};
8913
- if (Array.isArray(logs2?.modules)) {
8914
- this.config.logs.modules = logs2.modules;
8915
- }
8916
- if (Array.isArray(traces?.modules)) {
8917
- this.config.traces.modules = traces.modules;
8918
- }
8919
- if (Array.isArray(metrics?.modules)) {
8920
- this.config.metrics.modules = metrics.modules;
8905
+ if (res) {
8906
+ _SnipingConfigManager.config = {
8907
+ logs: {
8908
+ modules: Array.isArray(logs2?.modules) ? logs2.modules : []
8909
+ },
8910
+ traces: {
8911
+ modules: Array.isArray(traces?.modules) ? traces.modules : []
8912
+ },
8913
+ metrics: {
8914
+ modules: Array.isArray(metrics?.modules) ? metrics.modules : []
8915
+ }
8916
+ };
8921
8917
  }
8922
8918
  } catch (error) {
8923
8919
  console.error("Failed to parse sniping config:", error);
8924
8920
  }
8925
8921
  }
8926
8922
  static updateFromHeaders(headers) {
8927
- const snipingConfig = headers[_SnipingConfigManager.CONFIG_HEADER_NAME];
8923
+ const snipingConfig = headers[_SnipingConfigManager.CONFIG_HEADER_NAME] || headers[_SnipingConfigManager.CONFIG_HEADER_NAME.toLowerCase()];
8928
8924
  if (snipingConfig) {
8929
- this.setConfig(snipingConfig);
8925
+ _SnipingConfigManager.setConfig(snipingConfig);
8930
8926
  }
8931
8927
  }
8932
8928
  };
@@ -8941,8 +8937,9 @@ var CustomExporter = class {
8941
8937
  constructor() {
8942
8938
  }
8943
8939
  export(logs2, resultCallback) {
8944
- const snipingConfig = SnipingConfigManager.getLogConfig();
8945
- if (snipingConfig.includes("*")) {
8940
+ const snipingConfig = SnipingConfigManager.getConfig();
8941
+ console.log("snipingConfig", snipingConfig);
8942
+ if (snipingConfig.logs.modules.includes("*")) {
8946
8943
  resultCallback({
8947
8944
  code: core.ExportResultCode.SUCCESS
8948
8945
  });
@@ -8950,7 +8947,7 @@ var CustomExporter = class {
8950
8947
  }
8951
8948
  const filteredLogs = logs2.filter((log) => {
8952
8949
  const module = log.attributes?.module;
8953
- if (module && snipingConfig.includes(module)) {
8950
+ if (module && snipingConfig.logs.modules.includes(module)) {
8954
8951
  return false;
8955
8952
  }
8956
8953
  return true;
@@ -9031,8 +9028,9 @@ var CustomTraceExporter = class {
9031
9028
  tracePrefix = "force-trace-prefix";
9032
9029
  traceSuffix = "force-trace-suffix";
9033
9030
  export(spans, resultCallback) {
9034
- const snipingConfig = SnipingConfigManager.getTraceConfig();
9035
- if (snipingConfig.includes("*")) {
9031
+ const snipingConfig = SnipingConfigManager.getConfig();
9032
+ console.log("snipingConfig", snipingConfig);
9033
+ if (snipingConfig.traces.modules.includes("*")) {
9036
9034
  resultCallback({
9037
9035
  code: core.ExportResultCode.SUCCESS
9038
9036
  });
@@ -9044,10 +9042,11 @@ var CustomTraceExporter = class {
9044
9042
  app_env: isDev ? AppEnv.Dev : AppEnv.Prod
9045
9043
  };
9046
9044
  const finalSpans = spans.filter((span) => {
9047
- const attrs = span.attributes ?? {};
9048
- if (attrs[TraceDropToken]) return false;
9049
- const module = attrs.module;
9050
- if (module && snipingConfig.includes(module)) return false;
9045
+ if ((span.attributes ?? {})[TraceDropToken]) return false;
9046
+ const module = span.attributes?.module;
9047
+ if (module && snipingConfig.traces.modules.includes(module)) {
9048
+ return false;
9049
+ }
9051
9050
  return true;
9052
9051
  });
9053
9052
  if (!finalSpans.length) {