Commit Graph
687 Commits
Author SHA1 Message Date
Yorick Peterse f181f05e8a Track object counts using the "allocations" Gem
This allows us to track the counts of actual classes instead of "T_XXX"
nodes. This is only enabled on CRuby as it uses CRuby specific APIs.
2015-12-17 17:25:48 +01:00
Yorick Peterse bcee44ad33 Instrument all ActiveRecord model methods
This works by searching the raw source code for any references to
commonly used ActiveRecord methods. While not bulletproof it saves us
from having to list hundreds of methods by hand. It also ensures that
(most) newly added methods are instrumented automatically.

This _only_ instruments models defined in app/models, should a model
reside somewhere else (e.g. somewhere in lib/) it _won't_ be
instrumented.
2015-12-17 17:25:48 +01:00
Yorick Peterse 141e946c3d Storing of application metrics in InfluxDB
This adds the ability to write application metrics (e.g. SQL timings) to
InfluxDB. These metrics can in turn be visualized using Grafana, or
really anything else that can read from InfluxDB. These metrics can be
used to track application performance over time, between different Ruby
versions, different GitLab versions, etc.

== Transaction Metrics

Currently the following is tracked on a per transaction basis (a
transaction is a Rails request or a single Sidekiq job):

* Timings per query along with the raw (obfuscated) SQL and information
  about what file the query originated from.
* Timings per view along with the path of the view and information about
  what file triggered the rendering process.
* The duration of a request itself along with the controller/worker
  class and method name.
* The duration of any instrumented method calls (more below).

== Sampled Metrics

Certain metrics can't be directly associated with a transaction. For
example, a process' total memory usage is unrelated to any running
transactions. While a transaction can result in the memory usage going
up there's no accurate way to determine what transaction is to blame,
this becomes especially problematic in multi-threaded environments.

To solve this problem there's a separate thread that takes samples at a
fixed interval. This thread (using the class Gitlab::Metrics::Sampler)
currently tracks the following:

* The process' total memory usage.
* The number of file descriptors opened by the process.
* The amount of Ruby objects (using ObjectSpace.count_objects).
* GC statistics such as timings, heap slots, etc.

The default/current interval is 15 seconds, any smaller interval might
put too much pressure on InfluxDB (especially when running dozens of
processes).

== Method Instrumentation

While currently not yet used methods can be instrumented to track how
long they take to run. Unlike the likes of New Relic this doesn't
require modifying the source code (e.g. including modules), it all
happens from the outside. For example, to track `User.by_login` we'd add
the following code somewhere in an initializer:

    Gitlab::Metrics::Instrumentation.
      instrument_method(User, :by_login)

to instead instrument an instance method:

    Gitlab::Metrics::Instrumentation.
      instrument_instance_method(User, :save)

Instrumentation for either all public model methods or a few crucial
ones will be added in the near future, I simply haven't gotten to doing
so just yet.

== Configuration

By default metrics are disabled. This means users don't have to bother
setting anything up if they don't want to. Metrics can be enabled by
editing one's gitlab.yml configuration file (see
config/gitlab.yml.example for example settings).

== Writing Data To InfluxDB

Because InfluxDB is still a fairly young product I expect the worse.
Data loss, unexpected reboots, the database not responding, you name it.
Because of this data is _not_ written to InfluxDB directly, instead it's
queued and processed by Sidekiq. This ensures that users won't notice
anything when InfluxDB is giving trouble.

The metrics worker can be started in a standalone manner as following:

    bundle exec sidekiq -q metrics

The corresponding class is called MetricsWorker.
2015-12-17 17:25:48 +01:00
Rubén Dávila a4e0c7c7d6 Upgrade Poltergeist to 1.8.1. #4131 2015-12-17 01:01:08 -05:00
Dmitriy Zaporozhets 76642d7a80 Merge branch 'feature/remove-celluloid' into 'master'
Update rerun to remove celluloid as dependency

After sidekiq 4 migration, we no longer need celluloid. `rerun` recent version also removed it from its dependency, so by getting this MR merged, we can solve #3797 

See merge request !2088
2015-12-16 18:24:25 +00:00
Gabriel Mazetto 0b2c5003e6 Updated Rubocop to latest version 2015-12-14 17:18:32 -02:00
Gabriel Mazetto 08e67983be Update rerun to remove celluloid as dependency 2015-12-13 01:20:38 -02:00
Douwe Maan 22999a6fa6 Revert "Merge branch 'remove-redcloth' into 'master' "
This reverts commit e426c027b0, reversing
changes made to c3676aa156.
2015-12-11 16:16:07 +01:00
Valery Sizov 73942b15e7 Merge branch 'rs-update-gitlab_emoji' into 'master'
Bump gitlab_emoji to ~> 0.2.0

A new version of this gem was released October 29th
but was never bumped in GitLab.

See merge request !1994
2015-12-11 07:43:59 +00:00
Dmitriy Zaporozhets 3a82302fcb Merge branch 'bump-devise-3.5.3' into 'master'
Bump devise to 3.5.3 to fix reset token expiring after account creation

Also fixes an incorrect redirect after login with relative URL root:

Closes https://github.com/gitlabhq/gitlabhq/issues/8228

Closes #2750

See merge request !2056
2015-12-11 01:37:56 +00:00
Stan Hu 7f1b60cc66 Bump devise to 3.5.3 to fix reset token expiring after account creation
Also fixes an incorrect redirect after login with relative URL root:

Closes https://github.com/gitlabhq/gitlabhq/issues/8228

Closes #2750
2015-12-10 11:37:37 -08:00
Gabriel Mazetto 3e5b24d46a Upgraded Sidekiq to 4.x 2015-12-10 17:18:03 -02:00
Douwe Maan 905090dbe9 Remove RedCloth and no longer allow bundle-audit to fail 2015-12-09 11:18:21 +01:00
Stan Hu f36fe92fcb Bump gollum-lib to 4.1.0 and fix dependency mismatch with rouge
Closes #3767
2015-12-08 04:43:17 -08:00
Valery Sizov 2e270c0705 add explicit reference to rouge 1.10.1 2015-12-08 09:05:02 +02:00
Dmitriy Zaporozhets 1da71fa9ed Merge branch 'feature/sidekiq-cron' into 'master'
Migrate from Sidetiq to Sidekiq-cron

Migrate from Sidetiq to Sidekiq-cron
Updated Sidekiq to 3.5.x

This will solve #2355

See merge request !1982
2015-12-07 18:53:59 +00:00
Robert Speicher 6ee43ada3a Bump gitlab_emoji to ~> 0.2.0 2015-12-05 17:49:32 -05:00
Stan Hu d800a949d2 Fix Error 500 when creating global milestones with Unicode characters
Two issues:

1. The constraints in the resources were incorrect. Here's what it was before:
```
group_milestone  GET /groups/:group_id/milestones/:id(.:format)  groups/milestones#show {:id=>/[a-zA-Z.0-9_\-]+(?<!\.atom)/, :group_id=>/[a-zA-Z.0-9_\-]+(?<!\.atom)/}
```

In this case, id is actually the title of the milestone, which can be anything at the moment.

After:

```
group_milestone  GET /groups/:group_id/milestones/:id(.:format)  groups/milestones#show {:id=>/[^\/]+/, :group_id=>/[a-zA-Z.0-9_\-]+(?<!\.atom)/}
```

2. `parameterize` would strip all Unicode characters, leaving a blank string. Rails would report something like:

ActionView::Template::Error (No route matches {:action=>"show", :controller=>"groups/milestones", :group_id=>#<Group id: 48, name: "ops-dev", path: "ops-dev", owner_id: nil, created_at: "2015-11-15 08:55:30", updated_at: "2015-12-02 06:23:26", type: "Group", description: "", avatar: "sha1.c71e73d51af1865c1bbbf6208e10044d46c9bb93.png", public: false>, :id=>"", :title=>"肯定不是中文的问题"} missing required keys: [:id]):

This change uses the babosa library to create a better slug, which surprisingly
isn't actually used by the global milestone controllers. Instead, they use the
title passed as a query string for some reason.

Closes https://github.com/gitlabhq/gitlabhq/issues/9881

Fix constraints
2015-12-05 00:04:44 -08:00
Gabriel Mazetto 496870ddec Migrate from Sidetiq to Sidekiq-cron
Updated Sidekiq to 3.5.x
2015-12-04 11:29:45 -02:00
Valery Sizov e0131c5d07 Merge branch 'rails_update_to_4_2' into 'master'
Rails update to 4.2.4

https://gitlab.com/gitlab-org/gitlab-ce/issues/2694

See merge request !1902
2015-11-30 16:49:09 +00:00
Robert Speicher 344cb89718 Bump jquery-turbolinks to ~> 2.1.0
See #2857
2015-11-27 16:34:59 -05:00
Valery SizovandValery Sizov 7f214cee74 Migrate mailers to ActiveJob 2015-11-26 17:03:43 +02:00
Valery Sizov 3e0fe27627 Merge remote-tracking branch 'origin/master' into rails_update_to_4_2 2015-11-26 12:30:28 +02:00
Valery Sizov 38489d8d7d update test_after_commit gem to 0.4.2 2015-11-26 11:57:04 +02:00
Dmitriy Zaporozhets 1befbbf57d Merge branch 'rs-remove-enumerize' into 'master'
Remove enumerize gem

Closes #2803 

See merge request !1912
2015-11-26 09:03:04 +00:00
Dmitriy Zaporozhets 21003c0cb2 Merge branch 'rs-update-asana' into 'master'
Bump asana to ~> 0.4.0

Closes #2830

See merge request !1911
2015-11-26 09:01:52 +00:00
Robert Speicher 5f0d1f30b0 Remove enumerize gem 2015-11-25 17:06:04 -05:00
Robert Speicher 91c0aa5e98 Bump asana to ~> 0.4.0
Closes #2830
2015-11-25 17:03:30 -05:00
Robert Speicher 59cc61e246 Bump doorkeeper to ~> 2.2.0
Closes #2746
2015-11-25 17:01:02 -05:00
Valery Sizov 40ff1318d2 Rails update to 4.2.4 2015-11-25 18:18:44 +02:00
Dmitriy Zaporozhets 3fd885fd91 Merge branch 'rs-update-colorize' into 'master'
Bump colorize to ~> 0.7.0

Also removes `colored` which came in during the CI merge and is
redundant.

Closes #2822

See merge request !1895
2015-11-25 09:02:06 +00:00
Dmitriy Zaporozhets 85d537ac73 Merge branch 'rs-update-rack-oauth2' into 'master'
Bump rack-oauth2 to ~> 1.2.1

Closes #2748

See merge request !1891
2015-11-25 09:01:12 +00:00
Dmitriy Zaporozhets cbdccf66bf Merge branch 'rs-update-creole' into 'master'
Bump creole to ~> 0.5.0

Closes #2815

See merge request !1890
2015-11-25 09:00:38 +00:00
Robert Speicher 28de6770fa Bump colorize to ~> 0.7.0
Also removes `colored` which came in during the CI merge and is
redundant.

Closes #2822
2015-11-24 16:29:21 -05:00
Robert Speicher 446a95d307 Bump rack-oauth2 to ~> 1.2.1 2015-11-24 15:48:49 -05:00
Robert Speicher 26f9dbf8a9 Bump creole to ~> 0.5.0
Closes #2815
2015-11-24 15:42:42 -05:00
Robert Speicher 776027e4c7 Bump gon to ~> 6.0.1
Closes #2856
2015-11-24 15:36:36 -05:00
Dmitriy Zaporozhets 36f7b624be Merge branch 'bundler-audit' into 'master'
Add bundler-audit to CI

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>

cc @DouweM @rspeicher @vsizov 

See merge request !1874
2015-11-23 15:51:39 +00:00
Dmitriy Zaporozhets 93f32b25d2 Add bundler-audit to CI
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2015-11-23 14:57:41 +01:00
Ferdinand Rosario 9b724baa7f Updated rails patch 2015-11-19 15:17:12 +05:30
Dmitriy Zaporozhets 12b35c6fe8 Merge branch 'flay' into 'master'
Add flay: tool to find duplicate code

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>

See merge request !1789
2015-11-11 16:21:35 +00:00
Dmitriy Zaporozhets 7bca4cabc2 Merge branch 'flog' into 'master'
Add method complexity check to CI

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>

See merge request !1783
2015-11-11 15:29:19 +00:00
Dmitriy Zaporozhets 98c954ee81 Add flay: tool to find duplicate code
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2015-11-11 16:29:00 +01:00
Kamil Trzciński fb5c3c7021 Merge branch 'artifacts' into 'master'
Implement Build Artifacts

This implements #3028 

1. It stores artifacts in shared/artifacts,
1. It adds `artifacts` to `.gitlab-ci.yml`,
1. We use GitLab Workhorse to offload artifacts uploading,
1. To download artifacts it uses GitLab Workhorse X-Sendfile extension,
1. There's one "artifact" per-build. The new upload removes previous one and creates a new one,
1. Default max artifact size is set to 100MB - this can be changed in settings.

Missing things:
1. Support for `.gitlab-ci.yml`: `artifacts: true or git-ls-files` which will upload all non tracked files,
1. Artifacts passing between builds.

GitLab Workhorse changes: https://gitlab.com/gitlab-org/gitlab-workhorse/merge_requests/5
GitLab Runner changes: https://gitlab.com/gitlab-org/gitlab-ci-multi-runner/merge_requests/46

Syntax:
```
artifacts:
  untracked: true # default: false
  paths: # default: empty
  - bin/files
```


See merge request !1584
2015-11-11 12:44:37 +00:00
Dmitriy Zaporozhets 58429d9b26 Add method complexity check to CI
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2015-11-10 18:34:05 +01:00
Dmitriy Zaporozhets 8972aef558 Merge branch 'state-machine-to-state-machines-activerecord' into 'master'
Switch to state_machines-activerecord (Fixes: #3374)

state_machine is unmaintained

See merge request !1764
2015-11-10 12:20:59 +00:00
Kamil Trzcinski d0e3e823a2 Implement Build Artifacts
- Offloads uploading to GitLab Workhorse
- Use /authorize request for fast uploading
- Added backup recipes for artifacts
- Support download acceleration using X-Sendfile
2015-11-10 12:51:50 +01:00
Stan Hu 4017a4fcbc Upgrade gitlab_git to 7.2.20 and rugged to 0.23.3.
Switch back to github-linguist
2015-11-09 08:17:17 -08:00
Yorick Peterse dec3e4ce64 Added Sherlock, a custom profiling tool for GitLab
Sherlock will be a new GitLab specific tool for measuring the
performance of Rails requests (and SideKiq jobs at some point). Some of
the things that are currently tracked:

* SQL queries along with their timings, backtraces and query plans
  (using "EXPLAIN ANALYZE" for PostgreSQL and regular "EXPLAIN" for
  MySQL)
* Timings of application files (including views) on a per line basis
* Some meta data such as the request method, path, total duration, etc

More tracking (e.g. Rugged or gitlab-shell timings) might be added in
the future.

Sherlock will replace any existing tools we have used so far (e.g.
active_record_query_trace and rack-mini-profiler), hence the
corresponding Gems have been removed from the Gemfile.

Sherlock can be enabled by starting Rails as following:

    ENABLE_SHERLOCK=1 bundle exec rails s

Recorded transactions can be found at `/sherlock/transactions`.
2015-11-09 14:29:10 +01:00
Pirate Praveen 2e5d32e07a Switch to state_machines-activerecord (Fixes: #3374) 2015-11-08 12:15:58 -05:00