@@ -145,12 +145,13 @@ defmodule Sentry.Config do
145145 ] ,
146146 traces_sample_rate: [
147147 type: { :custom , __MODULE__ , :__validate_traces_sample_rate__ , [ ] } ,
148- default: 0.0 ,
148+ default: nil ,
149149 doc: """
150150 The sample rate for transaction events. A value between `0.0` and `1.0` (inclusive).
151151 A value of `0.0` means no transactions will be sampled, while `1.0` means all transactions
152- will be sampled. This value is also used to determine if tracing is enabled: if it's
153- greater than `0`, tracing is enabled.
152+ will be sampled.
153+
154+ This value is also used to determine if tracing is enabled: if it's not `nil`, tracing is enabled.
154155
155156 Tracing requires OpenTelemetry packages to work. See [the
156157 OpenTelemetry setup documentation](https://opentelemetry.io/docs/languages/erlang/getting-started/)
@@ -662,7 +663,7 @@ defmodule Sentry.Config do
662663 def integrations , do: fetch! ( :integrations )
663664
664665 @ spec tracing? ( ) :: boolean ( )
665- def tracing? , do: fetch! ( :traces_sample_rate ) > 0.0
666+ def tracing? , do: not is_nil ( fetch! ( :traces_sample_rate ) )
666667
667668 @ spec put_config ( atom ( ) , term ( ) ) :: :ok
668669 def put_config ( key , value ) when is_atom ( key ) do
@@ -763,12 +764,12 @@ defmodule Sentry.Config do
763764 end
764765 end
765766
766- def __validate_traces_sample_rate__ ( float ) do
767- if is_float ( float ) and float >= 0.0 and float <= 1.0 do
768- { :ok , float }
767+ def __validate_traces_sample_rate__ ( value ) do
768+ if is_nil ( value ) or ( is_float ( value ) and value >= 0.0 and value <= 1.0 ) do
769+ { :ok , value }
769770 else
770771 { :error ,
771- "expected :traces_sample_rate to be a float between 0.0 and 1.0 (included), got: #{ inspect ( float ) } " }
772+ "expected :traces_sample_rate to be nil or a value between 0.0 and 1.0 (included), got: #{ inspect ( value ) } " }
772773 end
773774 end
774775
0 commit comments