@@ -396,6 +396,17 @@ defmodule Sentry.Config do
396396 *Available since 12.0.0*.
397397 """
398398 ] ,
399+ enable_metrics: [
400+ type: :boolean ,
401+ default: true ,
402+ doc: """
403+ Whether to enable sending metric events to Sentry. When enabled, the SDK will
404+ capture and send metrics (counters, gauges, distributions) according to the
405+ [Sentry Metrics Protocol](https://develop.sentry.dev/sdk/telemetry/metrics/).
406+ Use `Sentry.Metrics` functions to record metrics.
407+ *Available since 13.0.0*.
408+ """
409+ ] ,
399410 logs: [
400411 type: :keyword_list ,
401412 default: [ ] ,
@@ -434,8 +445,8 @@ defmodule Sentry.Config do
434445 ]
435446 ] ,
436447 telemetry_processor_categories: [
437- type: { :list , { :in , [ :error , :check_in , :transaction , :log ] } } ,
438- default: [ :log ] ,
448+ type: { :list , { :in , [ :error , :check_in , :transaction , :log , :metric ] } } ,
449+ default: [ :log , :metric ] ,
439450 doc: """
440451 List of event categories that should be processed through the TelemetryProcessor.
441452 Categories in this list use the TelemetryProcessor's ring buffer and weighted
@@ -447,6 +458,7 @@ defmodule Sentry.Config do
447458 * `:check_in` - Cron check-ins (high priority, batch_size=1)
448459 * `:transaction` - Performance transactions (medium priority, batch_size=1)
449460 * `:log` - Log entries (low priority, batch_size=100, 5s timeout)
461+ * `:metric` - Metric events (low priority, batch_size=100, 5s timeout)
450462
451463 *Available since 12.0.0*.
452464 """
@@ -533,13 +545,13 @@ defmodule Sentry.Config do
533545 """
534546 ] ,
535547 telemetry_buffer_capacities: [
536- type: { :map , { :in , [ :error , :check_in , :transaction , :log ] } , :pos_integer } ,
548+ type: { :map , { :in , [ :error , :check_in , :transaction , :log , :metric ] } , :pos_integer } ,
537549 default: % { } ,
538550 type_doc: "`%{category => pos_integer()}`" ,
539551 doc: """
540552 Overrides for the maximum number of items each telemetry buffer can hold.
541553 When a buffer reaches capacity, oldest items are dropped to make room.
542- Default: error=100, check_in=100, transaction=1000, log=1000.
554+ Default: error=100, check_in=100, transaction=1000, log=1000, metric=1000 .
543555 *Available since v12.0.0*.
544556 """
545557 ] ,
@@ -702,6 +714,17 @@ defmodule Sentry.Config do
702714 (potentially-updated) `Sentry.LogEvent`, then the updated log event is used instead.
703715 *Available since v12.0.0*.
704716 """
717+ ] ,
718+ before_send_metric: [
719+ type: { :or , [ nil , { :fun , 1 } , { :tuple , [ :atom , :atom ] } ] } ,
720+ type_doc: "`t:before_send_metric_callback/0`" ,
721+ doc: """
722+ Allows performing operations on a metric *before* it is sent, as
723+ well as filtering out the metric altogether.
724+ If the callback returns `nil` or `false`, the metric is not reported. If it returns a
725+ (potentially-updated) `Sentry.Metric`, then the updated metric is used instead.
726+ *Available since v13.0.0*.
727+ """
705728 ]
706729 ]
707730
@@ -905,6 +928,9 @@ defmodule Sentry.Config do
905928 @ spec enable_logs? ( ) :: boolean ( )
906929 def enable_logs? , do: fetch! ( :enable_logs )
907930
931+ @ spec enable_metrics? ( ) :: boolean ( )
932+ def enable_metrics? , do: fetch! ( :enable_metrics )
933+
908934 @ spec logs ( ) :: keyword ( )
909935 def logs , do: fetch! ( :logs )
910936
@@ -937,6 +963,10 @@ defmodule Sentry.Config do
937963 ( Sentry.LogEvent . t ( ) -> Sentry.LogEvent . t ( ) | nil | false ) | { module ( ) , atom ( ) } | nil
938964 def before_send_log , do: get ( :before_send_log )
939965
966+ @ spec before_send_metric ( ) ::
967+ ( Sentry.Metric . t ( ) -> Sentry.Metric . t ( ) | nil | false ) | { module ( ) , atom ( ) } | nil
968+ def before_send_metric , do: get ( :before_send_metric )
969+
940970 @ spec put_config ( atom ( ) , term ( ) ) :: :ok
941971 def put_config ( key , value ) when is_atom ( key ) do
942972 unless key in @ valid_keys do
0 commit comments