aboutsummaryrefslogtreecommitdiffstats
path: root/railties
Commit message (Collapse)AuthorAgeFilesLines
* Default new apps to tag logs with `request_id`schneems2016-01-062-1/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In high volume applications it can be very difficult to figure out what is happening in logs because each request is not easily identified. For example 3 requests could look something like this: ``` Started GET "/" for 72.48.77.213 at 2016-01-06 20:30:21 +0000 Rendered welcome/index.html.erb within layouts/application (0.1ms) Started GET "/" for 72.48.77.213 at 2016-01-06 20:30:22 +0000 Started GET "/" for 72.48.77.213 at 2016-01-06 20:30:23 +0000 Rendered welcome/index.html.erb within layouts/application (0.1ms) Processing by WelcomeController#index as HTML Completed 200 OK in 5ms (Views: 3.8ms | ActiveRecord: 0.0ms) Processing by WelcomeController#index as HTML Rendered welcome/index.html.erb within layouts/application (0.1ms) Completed 200 OK in 5ms (Views: 3.8ms | ActiveRecord: 0.0ms) Processing by WelcomeController#index as HTML Completed 200 OK in 5ms (Views: 3.8ms | ActiveRecord: 0.0ms) ``` The `:request_id` log tag ensures that each request is tagged with a unique identifier. While they are still interleaved it is possible to figure out which lines belong to which requests. Like: ``` [c6034478-4026-4ded-9e3c-088c76d056f1] Started GET "/" for 72.48.77.213 at 2016-01-06 20:30:21 +0000 [c6034478-4026-4ded-9e3c-088c76d056f1] Rendered welcome/index.html.erb within layouts/application (0.1ms) [abuqw781-5026-6ded-7e2v-788c7md0L6fQ] Started GET "/" for 72.48.77.213 at 2016-01-06 20:30:22 +0000 [acfab2a7-f1b7-4e15-8bf6-cdaa008d102c] Started GET "/" for 72.48.77.213 at 2016-01-06 20:30:23 +0000 [abuqw781-5026-6ded-7e2v-788c7md0L6fQ] Rendered welcome/index.html.erb within layouts/application (0.1ms) [c6034478-4026-4ded-9e3c-088c76d056f1] Processing by WelcomeController#index as HTML [c6034478-4026-4ded-9e3c-088c76d056f1] Completed 200 OK in 5ms (Views: 3.8ms | ActiveRecord: 0.0ms) [abuqw781-5026-6ded-7e2v-788c7md0L6fQ] Processing by WelcomeController#index as HTML [abuqw781-5026-6ded-7e2v-788c7md0L6fQ] Rendered welcome/index.html.erb within layouts/application (0.1ms) [abuqw781-5026-6ded-7e2v-788c7md0L6fQ] Completed 200 OK in 5ms (Views: 3.8ms | ActiveRecord: 0.0ms) [acfab2a7-f1b7-4e15-8bf6-cdaa008d102c] Processing by WelcomeController#index as HTML [acfab2a7-f1b7-4e15-8bf6-cdaa008d102c] Completed 200 OK in 5ms (Views: 3.8ms | ActiveRecord: 0.0ms) ``` Now if you have the logs and you find this unique ID you can filter to only look at information from that request. So a filtered log output would be very clear: ``` [c6034478-4026-4ded-9e3c-088c76d056f1] Started GET "/" for 72.48.77.213 at 2016-01-06 20:30:21 +0000 [c6034478-4026-4ded-9e3c-088c76d056f1] Rendered welcome/index.html.erb within layouts/application (0.1ms) [c6034478-4026-4ded-9e3c-088c76d056f1] Processing by WelcomeController#index as HTML [c6034478-4026-4ded-9e3c-088c76d056f1] Completed 200 OK in 5ms (Views: 3.8ms | ActiveRecord: 0.0ms) ``` In addition to this benefit the `:request_id` can be set via the `X-Request-ID` header so that the same request could be traced between multiple components. For example a request comes in Nginx (or another load balancer) could assign a request id. As the load balancer processes the request I can log using that id, then when the request is passed on to Rails, the same id is used. That way if a problem is determined to be not caused in Rails it could be traced back to other components with the same ID. You can set a value in nginx for example using something like this: ``` location / { proxy_pass http://upstream; proxy_set_header X-Request-Id $pid-$msec-$remote_addr-$request_length; } # http://stackoverflow.com/questions/17748735/setting-a-trace-id-in-nginx-load-balancer ``` Heroku sets this header value so problems like timeouts that are logged by like router can be traced back to specific request within the application. Whether you are using components that are setting request ID or not, all production applications can benefit from the additional debugging information of having a unique identifier for all requests. This change will only affect new applications, anyone can opt out by commenting or removing the line in `config/production.rb`.
* Merge pull request #22933 from schneems/schneems/fix-broadcastRichard Schneeman2016-01-061-2/+4
|\ | | | | [close #22917] Don't output to `STDOUT` twice
| * [close #22917] Don't output to `STDOUT` twiceschneems2016-01-061-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | When `rails console` or `rails server` are used along with a logger set to output to `STDOUT` then the contents will show up twice. This happens because the logger is extended with `ActiveSupportLogger.broadcast` with a destination of STDOUT even if it is already outputting to `STDOUT`. Previously PR #22592 attempted to fix this issue, but it ended up causing NoMethodErrors. A better approach than relying on adding a method and flow control is to inspect the log destination directly. For this `ActiveSupport::Logger.logger_outputs_to?` was introduced ```ruby logger = Logger.new(STDOUT) ActiveSupport::Logger.logger_outputs_to?(logger, STDOUT) # => true ``` To accomplish this we must look inside of an instance variable of standard lib's Logger `@logdev`. There is a related Ruby proposal to expose this method in a standard way: https://bugs.ruby-lang.org/issues/11955
* | Merge pull request #22939 from ↵Rafael França2016-01-063-1/+14
|\ \ | | | | | | | | | | | | y-yagi/make_generated_controller_test_file_work_correctly make generated controller test work correctly
| * | make generated controller test work correctlyyuuji.yaginuma2016-01-063-1/+14
| |/ | | | | | | | | | | | | Since the `#file_name` that not consideration for the namespace, if generate a controller with a namespace, not the correct url helper generation, it had become an error to run the test. Modified to generate the correct url helper, even if it is produced a namespace with controller.
* | Merge pull request #22275 from mastahyeti/per-form-csrfRafael França2016-01-062-1/+5
|\ \ | | | | | | Per-form CSRF tokens
| * | add option for per-form CSRF tokensBen Toews2016-01-042-1/+5
| | |
* | | Provide a better error message if a user mistypes the name of script with runnerStephen Blackstone2016-01-052-1/+17
| |/ |/| | | | | Add tests for detecting bad options for runner
* | :scissors: Unnecessary spacing in the generated codeAkira Matsuda2016-01-051-1/+1
|/
* correctly presence check of `application_record.rb` in pluginyuuji.yaginuma2016-01-021-0/+9
|
* add test of that `application_record.rb` is generated in pluginyuuji.yaginuma2016-01-021-3/+7
|
* Merge pull request #22874 from ↵Rafael França2016-01-012-0/+0
|\ | | | | | | | | prathamesh-sonpatki/create-application-model-under-namespaced-dir-in-plugin Create application_record.rb under namespaced directory in plugin
| * Create application_record under namespaced directory in pluginPrathamesh Sonpatki2016-01-012-0/+0
| | | | | | | | | | | | - Earlier it was creating application_record.rb under `app/models`, after this change, it will create application_record.rb under `app/models/plugin_name` similar to other application classes.
* | Remove a wasted spaceShota Iguchi2016-01-011-1/+1
| |
* | Update copyright notices to 2016 [ci skip]Rashmi Yadav2015-12-311-2/+2
|/
* Merge pull request #22826 from timrogers/actiondispatch-ssl-configRafael França2015-12-312-2/+9
|\ | | | | Configurable redirect and secure cookies for ActionDispatch::SSL
| * Flexible configuration for ActionDispatch::SSLTim Rogers2015-12-292-2/+9
| |
* | [ci skip] Space out framework names in USAGEKasper Timm Hansen2015-12-302-5/+5
| | | | | | | | | | | | Two USAGE files were referring to Active Record and Active Model without a space, which is incorrect because we're referring to the framework name and not the constants.
* | Add sass-rails back to the default GemfileRafael Mendonça França2015-12-302-0/+9
|/ | | | It was removed by mistake at 877a411d0c16baa4e670dae9a28f5cfcc201adc1
* Changed default value of `:rc` option to `nil`Prathamesh Sonpatki2015-12-251-1/+1
| | | | | | | - This fixes an error thrown by Thor because type of default value of `:rc` option which is `:boolean` does not match with it's default type which is `string`. - Ref - https://github.com/erikhuda/thor/blob/master/lib/thor/parser/option.rb#L125
* :scissors: whitespace in generated config files [skip ci]Jon Atack2015-12-242-2/+2
|
* Merge pull request #22750 from nettofarah/patch-1Sean Griffin2015-12-231-1/+26
|\ | | | | Plugin Usage and Installation instructions
| * Plugin Usage and Installation instructionsNetto Farah2015-12-231-1/+26
| |
* | Move test coloring closer to where it's used.Kasper Timm Hansen2015-12-231-15/+9
| | | | | | | | | | | | | | | | | | | | | | Didn't like the constant being at the top of the file, gave it overdue importance. Now that `color_output` expects a result we can shorten some of the flexibility from earlier: * Inline COLOR_CODES constant (keep local variable for readability, but don't need names of colors at run time). * Inline color variable in `color_output`. Looks just as clear without it.
* | Remove local variable color.Kasper Timm Hansen2015-12-231-5/+5
| | | | | | | | | | Focus `color_output`'s intent on coloring output by a result. We aren't meant to pass it arbitrary codes to color output.
* | Rename color to color_output.Kasper Timm Hansen2015-12-231-6/+5
| | | | | | | | | | | | The word color is being thrown all around with slightly different meanings. Right now, I understand it. But I'd like to be more immediately clear.
* | Remove unused blue color.Kasper Timm Hansen2015-12-231-2/+1
| | | | | | | | I got the blues because we aren't coloring any lines blue.
* | Color failure line by result code.Kasper Timm Hansen2015-12-231-1/+1
| | | | | | | | | | | | | | The static red color wouldn't paint skips in their designated yellow. Use the color name we got from the result label earlier, which marks skips as yellow.
* | Rewrite aggregated results suppression.Kasper Timm Hansen2015-12-231-10/+4
| | | | | | | | | | | | | | | | I should have replaced the summary reporter with a subclass the first time I wrote this. For whatever reason, I didn't. Do it right and slim the methods added to Minitest in the process.
* | [ci skip] Clarify why we're clearing reporters.Kasper Timm Hansen2015-12-231-1/+1
| | | | | | | | | | | | Minitest by default includes a summary reporter and a progress reporter. To print colored output, we have to replace the progress reporter.
* | Merge pull request #22756 from lucasmazza/lm-test-reporter-colored-outputKasper Timm Hansen2015-12-233-4/+82
|\ \ | | | | | | Add colored output to the new test reporter.
| * | Add colored output to the new test reporter.Lucas Mazza2015-12-223-4/+82
| | |
* | | Merge pull request #22757 from paulkogel/patch-1Rafael França2015-12-221-1/+1
|\ \ \ | | | | | | | | seeds.rb.tt: fix English.
| * | | seeds.rb.tt: fix English.Paul Kögel2015-12-221-1/+1
| | | |
* | | | Merge pull request #22755 from y-yagi/remove_cors_initializer_from_rails_appSean Griffin2015-12-222-0/+12
|\ \ \ \ | |/ / / |/| | | remove cors initializer from rails app
| * | | remove cors initializer from rails appyuuji.yaginuma2015-12-222-0/+12
| | | | | | | | | | | | | | | | | | | | `rack-cors` gem is defined in Gemfile by default only if the api, not defined by default in rails app.
* | | | release notes, extract notable changes from Railties CHANGELOG.Yves Senn2015-12-221-4/+4
|/ / / | | | | | | | | | [ci skip]
* | | Merge pull request #22753 from gwincr11/keeps-options-breaks-assetsMatthew Draper2015-12-221-1/+1
|\ \ \ | |_|/ |/| | Fix .keep file issue with ActionCable
| * | Fix .keep file issue with ActionCableCory Gwin2015-12-211-1/+1
| | | | | | | | | | | | | | | | | | Fixes #22708 Make sure the channels file is create in assets/javascript/ so require tree works in asset pipeline.
* | | Fix Rails tutorial linkclaudiob2015-12-211-1/+1
| |/ |/| | | | | | | | | | | | | | | | | [ci skip] The old link is 404 not found. The link matches what the rest of the documentation already points to: * https://github.com/rails/rails/blame/2de2263118d6763c11a02db05079a5b7a97a0a34/guides/source/getting_started.md#L2052 * https://github.com/rails/rails/blame/2de2263118d6763c11a02db05079a5b7a97a0a34/README.md#L74
* | Merge pull request #22685 from jeyb/remove_cable_files_for_skip_action_cableRafael França2015-12-212-0/+11
|\ \ | | | | | | Ensure Action Cable files are removed when `skip_action_cable` is set.
| * | Ensure Action Cable files are removed when `skip_action_cable` is set.Jey Balachandran2015-12-212-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Action Cable generators creates four files which need to be removed if `skip_action_cable` is set. 1. `app/assets/javascripts/cable.coffee` 2. `app/channels/application_cable/channel.rb` 3. `app/channels/application_cable/connection.rb` 4. `config/redis/cable.yml` Fixes #22669.
* | | Use the generators options to not generate channel assetsRafael Mendonça França2015-12-211-6/+2
| | |
* | | Merge pull request #22727 from prathamesh-sonpatki/fix-masterKasper Timm Hansen2015-12-211-1/+4
|\ \ \ | | | | | | | | Ensure that assets are enabled back after the test that tests assets are disabled
| * | | Ensure that assets are enabled back after the test that tests assets are ↵Prathamesh Sonpatki2015-12-211-1/+4
| | | | | | | | | | | | | | | | disabled
* | | | [ci skip] No more no changes entries in the CHANGELOGs (cases left in #22718)Akshay Vishnoi2015-12-221-3/+0
| | | |
* | | | Merge pull request #22684 from ↵Yves Senn2015-12-213-1/+14
|\ \ \ \ | |/ / / |/| | | | | | | | | | | teknofire/fix-using-add_resource-with-a-block-after-gem-call Fix using add_resource with a block after gem in custom generators
| * | | Fixes using `add_source` with a block after using `gem` in a custom railsWill Fisher2015-12-213-1/+14
| |/ / | | | | | | | | | generator template.
* | | Merge pull request #22692 from ryohashimoto/22669_api_generatorDavid Heinemeier Hansson2015-12-211-0/+30
|\ \ \ | | | | | | | | Action Cable channel generator doesn't create JS assets if options[:rails][:assets] is false
| * | | Action Cable channel generator should not create JS assets in --api modeRyo Hashimoto2015-12-191-0/+30
| |/ /