Method: Sentry::Profiler#set_initial_sample_decision

Defined in:
lib/sentry/profiler.rb

#set_initial_sample_decision(transaction_sampled) ⇒ void

This method returns an undefined value.

Sets initial sampling decision of the profile.

[View source]

56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/sentry/profiler.rb', line 56

def set_initial_sample_decision(transaction_sampled)
  unless @profiling_enabled
    @sampled = false
    return
  end

  unless transaction_sampled
    @sampled = false
    log("Discarding profile because transaction not sampled")
    return
  end

  case @profiles_sample_rate
  when 0.0
    @sampled = false
    log("Discarding profile because sample_rate is 0")
    return
  when 1.0
    @sampled = true
    return
  else
    @sampled = Random.rand < @profiles_sample_rate
  end

  log("Discarding profile due to sampling decision") unless @sampled
end