@@ -125,13 +125,14 @@ defmodule Sentry.Config do
125125 be used as the value for this option.
126126 """
127127 ] ,
128- tracing : [
129- type: :boolean ,
130- default: false ,
128+ traces_sample_rate : [
129+ type: { :custom , __MODULE__ , :__validate_traces_sample_rate__ , [ ] } ,
130+ default: 0.0 ,
131131 doc: """
132- Whether to enable tracing functionality based on OpenTelemetry. When enabled,
133- the Sentry SDK will use OpenTelemetry to collect and report distributed tracing
134- data to Sentry.
132+ The sample rate for transaction events. A value between 0.0 and 1.0 (inclusive).
133+ A value of 0.0 means no transactions will be sampled, while 1.0 means all transactions
134+ will be sampled. This value is also used to determine if tracing is enabled - if it's
135+ greater than 0, tracing is enabled.
135136
136137 This feature requires `opentelemetry` package and you can optionally use integrations with Bandit, Phoenix or Ecto.
137138 """
@@ -601,6 +602,9 @@ defmodule Sentry.Config do
601602 @ spec sample_rate ( ) :: float ( )
602603 def sample_rate , do: fetch! ( :sample_rate )
603604
605+ @ spec traces_sample_rate ( ) :: float ( )
606+ def traces_sample_rate , do: fetch! ( :traces_sample_rate )
607+
604608 @ spec hackney_opts ( ) :: keyword ( )
605609 def hackney_opts , do: fetch! ( :hackney_opts )
606610
@@ -639,7 +643,7 @@ defmodule Sentry.Config do
639643 def integrations , do: fetch! ( :integrations )
640644
641645 @ spec tracing? ( ) :: boolean ( )
642- def tracing? , do: fetch! ( :tracing )
646+ def tracing? , do: fetch! ( :traces_sample_rate ) > 0.0
643647
644648 @ spec put_config ( atom ( ) , term ( ) ) :: :ok
645649 def put_config ( key , value ) when is_atom ( key ) do
@@ -740,6 +744,15 @@ defmodule Sentry.Config do
740744 end
741745 end
742746
747+ def __validate_traces_sample_rate__ ( float ) do
748+ if is_float ( float ) and float >= 0.0 and float <= 1.0 do
749+ { :ok , float }
750+ else
751+ { :error ,
752+ "expected :traces_sample_rate to be a float between 0.0 and 1.0 (included), got: #{ inspect ( float ) } " }
753+ end
754+ end
755+
743756 def __validate_json_library__ ( nil ) do
744757 { :error , "nil is not a valid value for the :json_library option" }
745758 end
0 commit comments