您如何抑制来自 Prometheus 库的警告?

时间:2021-01-04 23:02:51

标签: elixir

我们在代码库中使用了一个外部库 Prometeus,它会在 Elixir 1.11 中生成警告。通常,这不会成为问题,但我们在编译代码库时将警告视为错误以确保代码质量。有没有办法抑制这个宏的警告?

使用 {:prometheus_plugs, "1.1.5"} 和 Elixir 1.11.2 的示例:

defmodule Company.Api.PrometheusExporter do
  use Prometheus.PlugPipelineInstrumenter
end

给出这个输出:

==> api
Compiling 99 files (.ex)
warning: System.stacktrace/0 is deprecated, use __STACKTRACE__ instead
  lib/api/pipeline_instrumenter.ex:2

1 个答案:

答案 0 :(得分:2)

该问题已在最新版本的 prometheus_ex 中修复:https://github.com/deadtrickster/prometheus.ex/commit/dea38d0b2c8edc2c8c97979f42f06d48135a12b6

我会暂时将依赖项升级到最新提交 mix.exs 文件:

改变

  {:prometheus_ex, "~> 3.0.6"}

  # We need to use the master branch of prometheus_ex because it contains a fix for a warning
  # that is not released yet. The commit containing the fix is
  # https://github.com/deadtrickster/prometheus.ex/commit/dea38d0b2c8edc2c8c97979f42f06d48135a12b6.
  # We should change this to `{:prometheus_ex, "~> 3.0.6"},` when the fix is released
  # (changing the version to the correct one). The latest broken version is 3.0.5
  {:prometheus_ex, git: "https://github.com/deadtrickster/prometheus.ex", override: true},