getsentry / sentry-docs

Sentry's documentation (and tools to build it)
https://docs.sentry.io
Other
326 stars 1.43k forks source link

Incorrect configuration for Elixir Sentry LoggerHandler #10646

Open ijdickinson opened 2 months ago

ijdickinson commented 2 months ago

Core or SDK?

Platform/SDK

Which part? Which one?

Elixir

Description

On this page you suggest the following configuration for the log handler:

config :my_app, :logger, [
  {:handler, :my_sentry_handler, Sentry.LoggerHandler, %{
    config: %{
      metadata: [:file, :line],
      rate_limiting: [max_events: 10, duration: _1_second = 1_000],
      capture_log_messages: true
    }
  }}
]

duration is incorrect, and causes the initialisation to exit:

{"message":{"logger":"callback_crashed","process":"logger","reason":["error",{"message":"expected :rate_limiting option to match at least one given type, but didn't match any. Here are the reasons why it didn't match each of the allowed types:\n\n  * unknown options [:duration], valid options are: [:max_events, :interval] (in options [:rate_limiting])\n  * invalid value for :rate_limiting option: expected one of [nil], got: [max_events: 10, duration: 1000]","value":{"duration":1000,"max_events":10},"key":"rate_limiting","__exception__":true,"keys_path":[]}

Suggested Solution

Replace the duration key with interval.

config :my_app, :logger, [
  {:handler, :my_sentry_handler, Sentry.LoggerHandler, %{
    config: %{
      metadata: [:file, :line],
      rate_limiting: [max_events: 10, interval: _1_second = 1_000],
      capture_log_messages: true
    }
  }}
]
getsantry[bot] commented 2 months ago

Assigning to @getsentry/support for routing ⏲️

stephanie-anderson commented 1 week ago

Could you maybe have a look at this, @solnic? 🙏