getappmap / appmap-ruby Goto Github PK
View Code? Open in Web Editor NEWAppMap client agent for Ruby
Home Page: https://appland.org
License: Other
AppMap client agent for Ruby
Home Page: https://appland.org
License: Other
By using "type", we can introduce "subtype" which captures the language-specific name of an object.
The set of "types" will be limited to:
Whereas "subtype" can include language-specific concepts such as "module", "struct", "procedure", "method", etc.
Hey there,
My name is Maciej Mensfeld and I run security & quality assessment for Ruby libraries using WhiteSource Diffend.io.
While reviewing the changes for this lib, I noticed, that the node modules directory is being included.
Is this needed? Usually, it's added by mistake and causes:
a) confusion
b) problems when tracking changes
c) extensive library size
ref: https://rubygems.org/gems/appmap - see the last release. 10x bigger than all the previous.
ref https://my.diffend.io/gems/appmap/0.62.0/0.62.1#d2h-432957
If the presence of vendor data is valid I would love the reasoning. Thanks!
Installation failure observed:
Running command: `bundle install`
Fetching gem metadata from https://rails-assets.org/..
Fetching gem metadata from https://enterprise.contribsys.com/..
Could not find gem 'appmap' in rubygems repository
https://64499936:[email protected]/ or installed locally.
User: 954ea87b675622e08bd48162d81d3507b525d7b7bdc13cfcf402bdac1c265fab
Lists relevant project and configuration-related files. This will be consumed by the IDE to watch for changes and poll the project status
JSON, stdout:
{
"configuration": ["Gemfile"],
"test_directories": ["spec", “test”],
"integration_test_directories": ["spec/request", "spec/system"],
"appmap_directory": "tmp/appmap",
}
Running APPMAP=true bundle exec rake
in the cocoapods-generate repo results in almost half the tests failing due to an issue with appmap-ruby
failing to write appmap.json files.
Errno::ENOENT: No such file or directory @ rb_sysopen - tmp/appmap/rspec/somefile.appmap.json
Hi, is there any news on when Ruby 3.0 might be supported?
Currently when I try it, my tests fail very early (at what I think is the first method call during pre-test setup) with this error:
ArgumentError:
wrong number of arguments (given 1, expected 0; required keyword: category)
Googling that found me this similar-sounding issue in what I think is another one of your projects? No idea if there's any connection or not though 🙂
Specify a method (or methods) before which, and after which, the data is not recorded.
This can be useful when the application trace begins with a lot of useless preamble and setup.; such as with chef-solo
.
In order to ensure that all requests are captured as a function call, the AppMap Rack middleware should be automatically inserted into the middleware stack.
The AppMap Rack middleware source code should also be included in the class map.
It looks like this change broke things for Minitest. The save
method takes 3 position args, but here it is called with only two.
appmap-ruby version: 0.35.1
Similar issue to ruby-rrule, appmap-ruby
is generating appmaps that have return
events without a corresponding call
event.
Path: PeopleController_show_shows_specific_meta_title_and_description.appmap.json
ID: 219575
Issue: Missing Return
event
Path: PeopleController_show_works.appmap.json
ID: 217060
Issue: Missing Return
event
Warning if appmap.yml is missing
Error if appmap.yml is not valid YAML
Error if appmap gem is not in the Gemfile
Warning if appmap gem is not the first gem in the Gemfile
Warning if appmap gem is in the production group
Warning if middleware exists and doesn’t contain remote recording
I was helping a user map his closed source application, the application would not start with the appmap gem installed.
Starting the app with DISABLE_SPRING=true
did not make any difference.
Gemfile:
Gemfile.txt
Provides project and configuration-related telemetry properties as well as information related to the execution of the application.
JSON, stdout:
{
"start_command": {
"workingDirectory": ".",
"command": "APPMAP=true rails s -p {{port}}",
"baseURL": "/",
},
"test_commands": [
{
"directory": "spec",
"command": "APPMAP=true rspec {{files}}",
},
{
"directory": "test",
"command": "APPMAP=true rails test {{files}}",
},
},
"properties": {
"config": {
"app": "my_git_project",
"valid": true,
"present": true,
},
"project": {
"agentVersionGlobal": "0.42.0",
"agentVersionProject": "0.40.0",
"language": "ruby",
"remoteRecordingCapable": true,
"integrationTests": true,
}
}
}
RDoc provides :stopdoc:
and :nodoc:
to disable documentation of code internals.
appmap-ruby should not inspect this code unless explicitly instructed to do so.
rake appmap
should be documented at https://appland.com/docs/reference/appmap-ruby.html.
class_name
is implicit from the name of the containing class
object.
The appmap
command should be automatically installed by gem install appmap
.
With prune
and reparent
enabled, the class diagram is completely pruned when uploading the Rails sample app:
$ env APPLAND_URL=http://localhost:32770 BUNDLE_GEMFILE=~/source/appland/appmap-ruby/Gemfile bundle exec /Users/kgilpin/source/appland/appmap-ruby/exe/upload appmap.json
Full classMap contains 68 classes
Pruned classMap contains 0 classes
Update parameter name and object id in accordance with - getappmap/appmap#22
Primarily, remove object id for primitive types - numeric, boolean.
Valid appmap.yml files are reported as invalid in projects that are not rails apps (i.e. in rails gems).
Example: https://github.com/refinery/refinerycms
Generated appmap.yml:
---
name: refinerycms
packages:
- path: lib
appmap gem info:
gem info appmap
*** LOCAL GEMS ***
appmap (0.61.1)
Author: Kevin Gilpin
Homepage: https://github.com/applandinc/appmap-ruby
License: MIT
Installed at: /Users/ptrdvrk/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0
Record the operation of a Ruby program, using the AppLand 'AppMap'
format.
‣ bundle exec appmap-agent-status
{
"test_commands": [
],
"properties": {
"config": {
"app": "refinerycms",
"present": true,
"valid": false
},
"project": {
"agentVersion": "0.61.1",
"language": "ruby",
"remoteRecordingCapable": false,
"integrationTests": false
}
}
}
Loom: https://www.loom.com/share/1e69604e586b4e00a21342579b4bd503
rake appmap:swagger
should be documented at https://appland.com/docs/reference/appmap-ruby.html.
When running minitest tests with APPMAP=true, the tests break.
Gemfile:
source "https://rubygems.org"
gem 'appmap', :groups => [:development, :test]
gemspec
gem "rails", "~> 6.1.0"
gem "rake"
gem "minitest"
gem "combustion"
gem "sqlite3"
gem "pg"
# gem "mysql2"
# TODO use rubygems when > 7.2.0 is released
gem "mongoid", github: "mongodb/mongoid"
gem "browser", "~> 2.0"
gem "user_agent_parser"
appmap.yml:
---
name: ahoy
packages:
- path: app/controllers
- path: lib
Error log:
# ptrdvrk • ~/work/github/ruby/5mtv/ahoy • master*
‣ APPMAP=true bundle exec rake test
Run options: --seed 2769
# Running:
.......................Traceback (most recent call last):
20: from /Users/ptrdvrk/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/minitest-5.14.4/lib/minitest.rb:68:in `block in autorun'
19: from /Users/ptrdvrk/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/minitest-5.14.4/lib/minitest.rb:141:in `run'
18: from /Users/ptrdvrk/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/minitest-5.14.4/lib/minitest.rb:164:in `__run'
17: from /Users/ptrdvrk/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/minitest-5.14.4/lib/minitest.rb:164:in `map'
16: from /Users/ptrdvrk/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/minitest-5.14.4/lib/minitest.rb:164:in `block in __run'
15: from /Users/ptrdvrk/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/minitest-5.14.4/lib/minitest.rb:326:in `run'
14: from /Users/ptrdvrk/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/minitest-5.14.4/lib/minitest.rb:354:in `with_info_handler'
13: from /Users/ptrdvrk/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/minitest-5.14.4/lib/minitest.rb:367:in `on_signal'
12: from /Users/ptrdvrk/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/minitest-5.14.4/lib/minitest.rb:327:in `block in run'
11: from /Users/ptrdvrk/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/minitest-5.14.4/lib/minitest.rb:327:in `each'
10: from /Users/ptrdvrk/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/minitest-5.14.4/lib/minitest.rb:328:in `block (2 levels) in run'
9: from /Users/ptrdvrk/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/minitest-5.14.4/lib/minitest.rb:341:in `run_one_method'
8: from /Users/ptrdvrk/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/minitest-5.14.4/lib/minitest.rb:1029:in `run_one_method'
7: from /Users/ptrdvrk/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/appmap-0.58.0/lib/appmap/minitest.rb:148:in `run'
6: from /Users/ptrdvrk/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/appmap-0.58.0/lib/appmap/minitest.rb:81:in `end_test'
5: from /Users/ptrdvrk/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/appmap-0.58.0/lib/appmap/minitest.rb:48:in `finish'
4: from /Users/ptrdvrk/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/appmap-0.58.0/lib/appmap/minitest.rb:122:in `save'
3: from /Users/ptrdvrk/.rbenv/versions/2.7.2/lib/ruby/2.7.0/json/common.rb:224:in `generate'
2: from /Users/ptrdvrk/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/appmap-0.58.0/lib/appmap/hook/method.rb:77:in `block in activate'
1: from /Users/ptrdvrk/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/appmap-0.58.0/lib/appmap/hook/method.rb:62:in `block (2 levels) in activate'
/Users/ptrdvrk/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/appmap-0.58.0/lib/appmap/hook/method.rb:62:in `generate': source sequence is illegal/malformed utf-8 (JSON::GeneratorError)
rake aborted!
Command failed with status (1)
/Users/ptrdvrk/.rbenv/versions/2.7.2/bin/bundle:23:in `load'
/Users/ptrdvrk/.rbenv/versions/2.7.2/bin/bundle:23:in `<main>'
Tasks: TOP => test
(See full trace by running task with --trace)
✖ 1
Here's a representative table of Redis methods which can be hooked automatically:
├───────────────────────────────────────────────────────────┼─────────────────────────────────┼────────────────────────────────┤
│ │ redis/Redis#expire │ │
│ │ redis/Redis#get │ │
│ │ redis/Redis#llen │ │
│ │ redis/Redis#lpop │ │
│ │ redis/Redis#lpush │ │
│ app/integrations/FileCacheMaintainer.assign_blocklist_ids │ redis/Redis#sadd │ │
│ app/integrations/FileCacheMaintainer.blocklist │ redis/Redis#smembers │ │
│ app/integrations/FileCacheMaintainer.blocklist │ redis/Redis#type │ │
│ app/integrations/FileCacheMaintainer.blocklist_include? │ redis/Redis#sismember │ │
│ app/integrations/FileCacheMaintainer.files │ redis/Redis#hgetall │ │
│ app/integrations/FileCacheMaintainer.files │ redis/Redis#type │ │
│ app/integrations/FileCacheMaintainer.redis │ redis/Redis.current │ │
│ app/integrations/FileCacheMaintainer.remove_file │ redis/Redis#hdel │ │
│ app/integrations/FileCacheMaintainer.reset_blocklist_ids │ redis/Redis#expire │ │
│ app/integrations/FileCacheMaintainer.reset_file_info │ redis/Redis#expire │ │
│ app/integrations/FileCacheMaintainer.update_file_info │ redis/Redis#hset │ │
│ app/models/Counts.assign_for │ redis/Redis#hset │ │
│ app/models/Counts.retrieve_for │ redis/Redis#hget │ │
│ app/models/Counts.retrieve_for │ redis/Redis::Connection.drivers │ │
│ app/models/Counts.week_creation_chart │ redis/Redis#hget │ │
│ app/workers/EmailUpdatedTermsWorker#perform │ redis/Redis#llen │ │
│ app/workers/EmailUpdatedTermsWorker#perform │ redis/Redis#lpop │ │
│ app/workers/EmailUpdatedTermsWorker#perform │ redis/Redis#rpush │ │
│ app/workers/EmailUpdatedTermsWorker#redis │ redis/Redis.current │ │
│ app/workers/ScheduledWorker.redis │ redis/Redis#expire │ │
│ app/workers/ScheduledWorker.redis │ redis/Redis#hget │ │
│ app/workers/ScheduledWorker.redis │ redis/Redis#hset │ │
│ app/workers/ScheduledWorker.redis │ redis/Redis::Connection.drivers │ │
│ sidekiq/Sidekiq.redis │ redis/Redis#llen │ │
│ sidekiq/Sidekiq.redis │ redis/Redis#lrange │ │
│ sidekiq/Sidekiq.redis │ redis/Redis::Connection.drivers │ │
│ sidekiq/Sidekiq::Testing.inline! │ redis/Redis#get │ │
│ vcr/VCR.use_cassette │ redis/Redis#get │ │
└───────────────────────────────────────────────────────────┴─────────────────────────────────┴────────────────────────────────┘
"package" better captures the file-path organization of Classes and Modules, and reserves the word Modules for the specific "module" subtype of the "class" type, as it's used in Ruby.
In JavaScript, the term "module" has the same semantics as what we are using "package" for now. So in the class map, a JavaScript "module" will have type=package
and subtype=module
. In Ruby, the files in a directory will be organized by type=package
and subtype=directory
.
A Module will be type=class
, subtype=module
.
There's no one way that will work without modification for all languages. We just need to pick something reasonable and allow for language-specific terminology as needed.
The documentation describes appmap inspect
, appmap record
and appmap upload
commands. Refactor the CLI programs into a single program with subcommands.
Segfault occurs when running Appmap tests on Redmine.
[BUG] Segmentation fault at 0x0000000000000000
Appears to happen on multiple tests such as:
Original:
source 'https://rubygems.org'
ruby '>=2.5.0'
# Ensure github repositories are fetched using HTTPS
git_source(:github) do |repo_name|
"https://github.com/#{repo_name}.git"
end
# Load vendored dotenv gem and .env file
require File.join(File.dirname(__FILE__), 'lib/gemfile_helper.rb')
GemfileHelper.load_dotenv do |dotenv_dir|
path dotenv_dir do
gem 'dotenv'
gem 'dotenv-rails'
end
end
After init
source 'https://rubygems.org'
ruby '>=2.5.0'
# Ensure github repositories are fetched using HTTPS
git_source(:github) do |repo_name|
"https://github.com/#{repo_name}.git"
end
# Load vendored dotenv gem and .env file
require File.join(File.dirname(__FILE__), 'lib/gemfile_helper.rb')
GemfileHelper.load_dotenv do |dotenv_dir|
path dotenv_dir do
gem 'appmap', :groups => [:development, :test]
gem 'dotenv'
gem 'dotenv-rails'
end
end
bundle
fails with
Fetching gem metadata from https://rubygems.org/........
Fetching gem metadata from https://rubygems.org/.
Could not find gem 'appmap' in source at `vendor/gems/dotenv-2.0.1`.
The source does not contain any versions of 'appmap'
I am using RSpec for tests and used appmap for this test file.
As you can see, I am using before hook for my tests. So, empty diagrams are generated because of before hook.
If I updated my tests by removing before hook, diagrams are generated correctly.
Is it possible to fix this issue? Or, can a warning about usage of before hook be added to readme file?
method
is more of an OOP name, where as function
is a better generic name.
method
generally means "a member function of a class", which is a more specific notion.
Record the initial function call into a Gem. Don't perform a "deep" recording of the subsequent function calls inside that gem, unless the call stack leaves the gem and then re-enters it.
I have been creating copies of the Gemfile manually to recover from potential bugs quickly. It would be good if the init function created a pre-appmap backup of the Gemfile instead.
Also, creating backups of files modified by setup scripts is IMO considered a good etiquette.
Some classes were included into my Rails map without being explicitly required. My config was listing several packages from app
folder only. I had to exclude these classes manually to reduce the "noise" in the map:
exclude:
- ActiveSupport::Callbacks::CallbackSequence
- ActionController::Instrumentation
- JSON::Ext::Generator
In Ruby 2.7, the following call sequence will produce an ArgumentError:
class Kwargs
class << self
def no_kwargs(args)
args
end
def has_kwrest_calls_no_kwargs(args, **kwargs)
no_kwargs(**kwargs)
end
end
end
Failure/Error:
def no_kwargs(args)
args
end
ArgumentError:
wrong number of arguments (given 0, expected 1)
# spec/fixtures/hook/kwargs.rb:3:in `no_kwargs'
# ./lib/appmap/hook/method.rb:77:in `block (2 levels) in activate'
# ./lib/appmap/hook/method.rb:100:in `block in activate'
# spec/fixtures/hook/kwargs.rb:20:in `has_kwrest_calls_no_kwargs'
Here' an example in which method names are duplicated in a class:
The inspector algorithm has methods to coalesce and compact the parse tree so that, for example, all the methods of a class show up in the same JSON object even if they are declared across multiple files. These algorithms are getting it wrong sometimes, though.
appmap-ruby version: 0.33.0
When it's not skipped, this test in ruby-rrule: https://github.com/land-of-apps/ruby-rrule/blob/appland/spec/rule_spec.rb#L7 produces an appmap that has a return
event without a corresponding call
.
Record the invocation of the Rails "view", so that other calls made from the view layer (such as SQL) can be identified as being performed in the view.
Creates a base appmap.yml configuration for the current project. The name property is derived from a git remote, and the package paths from the current project directory.
.appmap.yml
:
name: my_git_project
packages:
- path: app/models
- path: app/controllers
current directory: /home/server/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/appmap-0.64.0/ext/appmap
/home/server/.rbenv/versions/2.4.0/bin/ruby -r ./siteconf20210825-23872-14ulfow.rb extconf.rb
creating Makefile
current directory: /home/server/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/appmap-0.64.0/ext/appmap
make "DESTDIR=" clean
current directory: /home/server/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/appmap-0.64.0/ext/appmap
make "DESTDIR="
compiling appmap.c
In file included from /home/server/.rbenv/versions/2.4.0/include/ruby-2.4.0/ruby.h:33,
from appmap.c:1:
/home/server/.rbenv/versions/2.4.0/include/ruby-2.4.0/ruby/ruby.h:627:1: error: ‘const’ attribute on function returning ‘void’ [-Werror=attributes]
627 | CONSTFUNC(void rb_secure_update(VALUE));
| ^~~~~~~~~
In file included from /home/server/.rbenv/versions/2.4.0/include/ruby-2.4.0/ruby/ruby.h:2001,
from /home/server/.rbenv/versions/2.4.0/include/ruby-2.4.0/ruby.h:33,
from appmap.c:1:
/home/server/.rbenv/versions/2.4.0/include/ruby-2.4.0/ruby/intern.h:257:1: error: ‘const’ attribute on function returning ‘void’ [-Werror=attributes]
257 | CONSTFUNC(void rb_error_untrusted(VALUE));
| ^~~~~~~~~
/home/server/.rbenv/versions/2.4.0/include/ruby-2.4.0/ruby/intern.h:259:1: error: ‘const’ attribute on function returning ‘void’ [-Werror=attributes]
259 | CONSTFUNC(void rb_check_trusted(VALUE));
| ^~~~~~~~~
cc1: all warnings being treated as errors
make: *** [Makefile:242: appmap.o] Ошибка 1
make failed, exit code 2
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.