Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion sentry-ruby/lib/sentry/check_in_event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

require "securerandom"
require "sentry/cron/monitor_config"
require "sentry/utils/uuid"

module Sentry
class CheckInEvent < Event
Expand Down Expand Up @@ -43,7 +44,7 @@ def initialize(
self.status = status
self.duration = duration
self.monitor_config = monitor_config
self.check_in_id = check_in_id || SecureRandom.uuid.delete("-")
self.check_in_id = check_in_id || Utils.uuid
end

# @return [Hash]
Expand Down
3 changes: 2 additions & 1 deletion sentry-ruby/lib/sentry/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
require "sentry/utils/real_ip"
require "sentry/utils/request_id"
require "sentry/utils/custom_inspection"
require "sentry/utils/uuid"

module Sentry
# This is an abstract class that defines the shared attributes of an event.
Expand Down Expand Up @@ -50,7 +51,7 @@ class Event
# @param message [String, nil]
def initialize(configuration:, integration_meta: nil, message: nil)
# Set some simple default values
@event_id = SecureRandom.uuid.delete("-")
@event_id = Utils.uuid
@timestamp = Sentry.utc_now.iso8601
@platform = :ruby
@type = self.class::TYPE
Expand Down
3 changes: 2 additions & 1 deletion sentry-ruby/lib/sentry/profiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

require "securerandom"
require_relative "profiler/helpers"
require "sentry/utils/uuid"

module Sentry
class Profiler
Expand All @@ -17,7 +18,7 @@ class Profiler
attr_reader :sampled, :started, :event_id

def initialize(configuration)
@event_id = SecureRandom.uuid.delete("-")
@event_id = Utils.uuid
@started = false
@sampled = nil

Expand Down
5 changes: 3 additions & 2 deletions sentry-ruby/lib/sentry/propagation_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

require "securerandom"
require "sentry/baggage"
require "sentry/utils/uuid"

module Sentry
class PropagationContext
Expand Down Expand Up @@ -66,8 +67,8 @@ def initialize(scope, env = nil)
end
end

@trace_id ||= SecureRandom.uuid.delete("-")
@span_id = SecureRandom.uuid.delete("-").slice(0, 16)
@trace_id ||= Utils.uuid
@span_id = Utils.uuid.slice(0, 16)
end

# Extract the trace_id, parent_span_id and parent_sampled values from a sentry-trace header.
Expand Down
5 changes: 3 additions & 2 deletions sentry-ruby/lib/sentry/span.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

require "securerandom"
require "sentry/metrics/local_aggregator"
require "sentry/utils/uuid"

module Sentry
class Span
Expand Down Expand Up @@ -127,8 +128,8 @@ def initialize(
timestamp: nil,
origin: nil
)
@trace_id = trace_id || SecureRandom.uuid.delete("-")
@span_id = span_id || SecureRandom.uuid.delete("-").slice(0, 16)
@trace_id = trace_id || Utils.uuid
@span_id = span_id || Utils.uuid.slice(0, 16)
@parent_span_id = parent_span_id
@sampled = sampled
@start_timestamp = start_timestamp || Sentry.utc_now.to_f
Expand Down
13 changes: 13 additions & 0 deletions sentry-ruby/lib/sentry/utils/uuid.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

require "securerandom"

module Sentry
module Utils
DELIMITER = "-"

def self.uuid
SecureRandom.uuid.delete(DELIMITER)
end
end
end
3 changes: 2 additions & 1 deletion sentry-ruby/lib/sentry/vernier/profiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require "securerandom"
require_relative "../profiler/helpers"
require_relative "output"
require "sentry/utils/uuid"

module Sentry
module Vernier
Expand All @@ -12,7 +13,7 @@ class Profiler
attr_reader :started, :event_id, :result

def initialize(configuration)
@event_id = SecureRandom.uuid.delete("-")
@event_id = Utils.uuid

@started = false
@sampled = nil
Expand Down
Loading