Skip to content

Commit

Permalink
Do not lazy load class variables, as its not thread safe
Browse files Browse the repository at this point in the history
  • Loading branch information
pawelchcki committed Jul 2, 2018
1 parent a87126e commit 4eea97d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
17 changes: 3 additions & 14 deletions lib/ddtrace.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
module Datadog
@tracer = Tracer.new
@registry = Registry.new
@configuration = Configuration.new(registry: @registry)

# Default tracer that can be used as soon as +ddtrace+ is required:
#
Expand All @@ -28,21 +29,9 @@ module Datadog
# tracer = Datadog::Tracer.new
# pin = Datadog::Pin.get_from(mypatchcomponent)
# pin.tracer = tracer

def self.tracer
@tracer
end

def self.registry
@registry
end

class << self
attr_writer :configuration

def configuration
@configuration ||= Configuration.new
end
attr_reader :tracer, :registry
attr_accessor :configuration

def configure(target = configuration, opts = {})
if target.is_a?(Configuration)
Expand Down
2 changes: 1 addition & 1 deletion lib/ddtrace/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Configuration
InvalidIntegrationError = Class.new(StandardError)

def initialize(options = {})
@registry = options.fetch(:registry, Datadog.registry)
@registry = options.fetch(:registry) { Datadog.registry }
@wrapped_registry = {}
end

Expand Down

0 comments on commit 4eea97d

Please sign in to comment.