Only the first shallow call of a sequence of calls is recorded on shallow mode

Open
#355 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
ruby
Domain
observability

Research direction

Start in lib/appmap/hook/method.rb at the shallow-package check around line 98, then reproduce the Calc example using minutes.ago and year.ago. Inspect how AppMap.tracing tracks the last package and evaluate a stack-based approach so every shallow call is recorded, including both ago invocations.

Written by the indexing model from the issue text.

Description

bug

While implementing the shallow mode for appmap-node agent I noticed this and it's been checked by @dividedmind:

I just checked and for example
require 'active_support/core_ext'

class Calc
  def calc x
    y = x.minutes.ago
    z = 1.year.ago
    y.to_i - z.to_i
  end
end

indeed only records #minutes, ignoring #year and both invocations of #ago.

It seems that the problem is with this line return false if hook_package&.shallow? && AppMap.tracing.last_package_for_current_thread == hook_package that checks the last recorded package. Because no other package is recorded between the calls mentioned, the last package stays the same. This causes subsequent calls to be skipped from recording, even if they are also "shallow" calls. A stack based approach can be used to fix this.

Dominant language
Ruby
Stars
101
Forks
13
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from getappmap/appmap-ruby

All issues in getappmap/appmap-ruby

Similar issues

More Ruby issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.