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

How do you suppress warnings coming from Prometheus library?

我们在我们的代码库中使用了一个外部库 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

此问题已在 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},