@@ -145,12 +145,13 @@ defmodule Sentry.Config do
145
145
] ,
146
146
traces_sample_rate: [
147
147
type: { :custom , __MODULE__ , :__validate_traces_sample_rate__ , [ ] } ,
148
- default: 0.0 ,
148
+ default: nil ,
149
149
doc: """
150
150
The sample rate for transaction events. A value between `0.0` and `1.0` (inclusive).
151
151
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.
154
155
155
156
Tracing requires OpenTelemetry packages to work. See [the
156
157
OpenTelemetry setup documentation](https://opentelemetry.io/docs/languages/erlang/getting-started/)
@@ -662,7 +663,7 @@ defmodule Sentry.Config do
662
663
def integrations , do: fetch! ( :integrations )
663
664
664
665
@ spec tracing? ( ) :: boolean ( )
665
- def tracing? , do: fetch! ( :traces_sample_rate ) > 0.0
666
+ def tracing? , do: not is_nil ( fetch! ( :traces_sample_rate ) )
666
667
667
668
@ spec put_config ( atom ( ) , term ( ) ) :: :ok
668
669
def put_config ( key , value ) when is_atom ( key ) do
@@ -763,12 +764,12 @@ defmodule Sentry.Config do
763
764
end
764
765
end
765
766
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 }
769
770
else
770
771
{ :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 ) } " }
772
773
end
773
774
end
774
775
0 commit comments