@@ -125,13 +125,14 @@ defmodule Sentry.Config do
125
125
be used as the value for this option.
126
126
"""
127
127
] ,
128
- tracing : [
129
- type: :boolean ,
130
- default: false ,
128
+ traces_sample_rate : [
129
+ type: { :custom , __MODULE__ , :__validate_traces_sample_rate__ , [ ] } ,
130
+ default: 0.0 ,
131
131
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.
135
136
136
137
This feature requires `opentelemetry` package and you can optionally use integrations with Bandit, Phoenix or Ecto.
137
138
"""
@@ -601,6 +602,9 @@ defmodule Sentry.Config do
601
602
@ spec sample_rate ( ) :: float ( )
602
603
def sample_rate , do: fetch! ( :sample_rate )
603
604
605
+ @ spec traces_sample_rate ( ) :: float ( )
606
+ def traces_sample_rate , do: fetch! ( :traces_sample_rate )
607
+
604
608
@ spec hackney_opts ( ) :: keyword ( )
605
609
def hackney_opts , do: fetch! ( :hackney_opts )
606
610
@@ -639,7 +643,7 @@ defmodule Sentry.Config do
639
643
def integrations , do: fetch! ( :integrations )
640
644
641
645
@ spec tracing? ( ) :: boolean ( )
642
- def tracing? , do: fetch! ( :tracing )
646
+ def tracing? , do: fetch! ( :traces_sample_rate ) > 0.0
643
647
644
648
@ spec put_config ( atom ( ) , term ( ) ) :: :ok
645
649
def put_config ( key , value ) when is_atom ( key ) do
@@ -740,6 +744,15 @@ defmodule Sentry.Config do
740
744
end
741
745
end
742
746
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
+
743
756
def __validate_json_library__ ( nil ) do
744
757
{ :error , "nil is not a valid value for the :json_library option" }
745
758
end
0 commit comments