Skip to content

Commit

Permalink
trace point object contains actual path of the target file
Browse files Browse the repository at this point in the history
  • Loading branch information
p committed Oct 26, 2024
1 parent ce609fc commit 7d4f254
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
19 changes: 4 additions & 15 deletions lib/datadog/di/probe_notification_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,13 @@ def build_executed(probe,
# this should be all frames for enriched probes and no frames for
# non-enriched probes?
build_snapshot(probe, rv: rv, snapshot: snapshot,
# Actual path of the instrumented file.
path: trace_point&.path,
duration: duration, caller_locations: caller_locations, args: args, kwargs: kwargs,
serialized_entry_args: serialized_entry_args)
end

def build_snapshot(probe, rv: nil, snapshot: nil,
def build_snapshot(probe, rv: nil, snapshot: nil, path: nil,
duration: nil, caller_locations: nil, args: nil, kwargs: nil,
serialized_entry_args: nil)
# TODO also verify that non-capturing probe does not pass
Expand Down Expand Up @@ -85,21 +87,8 @@ def build_snapshot(probe, rv: nil, snapshot: nil,
end

location = if probe.line?
# TODO figure out what to do here for line probes with
# untargeted trace points, since we don't have actual path at
# the instrumentation time. Path should come from the trace point
# invocation when we decide whether the invocation matches
# a particular probe.
actual_file = probe.instrumented_path || if probe.file
# Normally caller_locations should always be filled for a line probe
# but in the test suite we don't always provide all arguments.
actual_file_basename = File.basename(probe.file)
caller_locations&.detect do |loc|
File.basename(loc.path) == actual_file_basename
end&.path || probe.file
end
{
file: actual_file,
file: path,
lines: [probe.line_no],
}
elsif probe.method?
Expand Down
1 change: 1 addition & 0 deletions spec/datadog/di/probe_notification_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
instance_double(TracePoint).tap do |tp|
# Returns an empty binding
expect(tp).to receive(:binding).and_return(binding)
expect(tp).to receive(:path).and_return('/foo.rb')
end
end

Expand Down

0 comments on commit 7d4f254

Please sign in to comment.