lib/datadog/di/probe.rb in datadog-2.6.0 vs lib/datadog/di/probe.rb in datadog-2.7.0

- old
+ new

@@ -45,10 +45,14 @@ if line_no && method_name raise ArgumentError, "Probe contains both line number and method name: #{id}" end + if line_no && !file + raise ArgumentError, "Probe contains line number but not file: #{id}" + end + if type_name && !method_name || method_name && !type_name raise ArgumentError, "Partial method probe definition: #{id}" end @id = id @@ -69,10 +73,12 @@ raise ArgumentError, "Unhandled probe type: neither method nor line probe: #{id}" end @rate_limit = rate_limit || (@capture_snapshot ? 1 : 5000) @rate_limiter = Datadog::Core::TokenBucket.new(@rate_limit) + + @emitting_notified = false end attr_reader :id attr_reader :type attr_reader :file @@ -99,11 +105,14 @@ # # Method probes may still specify a file name (to aid in locating the # method or for stack traversal purposes?), therefore we do not check # for file name/path presence here and just consider the line number. def line? - !line_no.nil? + # Constructor checks that file is given if line number is given, + # but for safety, check again here since we somehow got a probe with + # a line number but no file in the wild. + !!(file && line_no) end # Returns whether the probe is a method probe. def method? !!(type_name && method_name) @@ -155,8 +164,21 @@ attr_accessor :instrumentation_module # Line trace point for line probes. Normally this would be a targeted # trace point. attr_accessor :instrumentation_trace_point + + # Actual path to the file instrumented by the probe, for line probes, + # when code tracking is available and line trace point is targeted. + # For untargeted line trace points instrumented path will be nil. + attr_accessor :instrumented_path + + # TODO emitting_notified reads and writes should in theory be locked, + # however since DI is only implemented for MRI in practice the missing + # locking should not cause issues. + attr_writer :emitting_notified + def emitting_notified? + !!@emitting_notified + end end end end