|
1 | 1 | # frozen_string_literal: true
|
2 | 2 |
|
3 |
| -# rubocop:disable Lint/AssignmentInCondition |
| 3 | +require_relative '../core/utils/time' |
4 | 4 |
|
5 |
| -require 'benchmark' |
| 5 | +# rubocop:disable Lint/AssignmentInCondition |
6 | 6 |
|
7 | 7 | module Datadog
|
8 | 8 | module DI
|
@@ -115,22 +115,21 @@ def hook_method(probe, &block)
|
115 | 115 | depth: probe.max_capture_depth || settings.dynamic_instrumentation.max_capture_depth,
|
116 | 116 | attribute_count: probe.max_capture_attribute_count || settings.dynamic_instrumentation.max_capture_attribute_count)
|
117 | 117 | end
|
118 |
| - rv = nil |
| 118 | + start_time = Core::Utils::Time.get_time |
119 | 119 | # Under Ruby 2.6 we cannot just call super(*args, **kwargs)
|
120 | 120 | # for methods defined via method_missing.
|
121 |
| - duration = Benchmark.realtime do # steep:ignore |
122 |
| - rv = if args.any? |
123 |
| - if kwargs.any? |
124 |
| - super(*args, **kwargs, &target_block) |
125 |
| - else |
126 |
| - super(*args, &target_block) |
127 |
| - end |
128 |
| - elsif kwargs.any? |
129 |
| - super(**kwargs, &target_block) |
| 121 | + rv = if args.any? |
| 122 | + if kwargs.any? |
| 123 | + super(*args, **kwargs, &target_block) |
130 | 124 | else
|
131 |
| - super(&target_block) |
| 125 | + super(*args, &target_block) |
132 | 126 | end
|
| 127 | + elsif kwargs.any? |
| 128 | + super(**kwargs, &target_block) |
| 129 | + else |
| 130 | + super(&target_block) |
133 | 131 | end
|
| 132 | + duration = Core::Utils::Time.get_time - start_time |
134 | 133 | # The method itself is not part of the stack trace because
|
135 | 134 | # we are getting the stack trace from outside of the method.
|
136 | 135 | # Add the method in manually as the top frame.
|
|
0 commit comments