- 07 1月, 2016 5 次提交
-
-
由 schneems 提交于
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`.
-
由 Rafael França 提交于
Refactor `connection.insert_sql`
-
由 Ryuta Kamizono 提交于
`connection.insert_sql` is almost the same as `connection.insert`.
-
由 Richard Schneeman 提交于
[close #22917] Don't output to `STDOUT` twice
-
由 schneems 提交于
-
- 06 1月, 2016 18 次提交
-
-
由 schneems 提交于
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
-
由 Matthew Draper 提交于
Fix remove_index for postgresql when running legacy migrations
-
由 Matthew Draper 提交于
remove activemodel dependency on builder
-
由 Lachlan Sylvester 提交于
-
由 Lachlan Sylvester 提交于
-
由 Rafael França 提交于
make generated controller test work correctly
-
由 yuuji.yaginuma 提交于
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.
-
由 Rafael França 提交于
Autoload ReferenceDefinition class in abstract adapter so that it can be used by #add_reference in schema_statements
-
由 Rafael Mendonça França 提交于
Add short-hand methods for text and blob types in MySQL
-
由 Rafael França 提交于
Per-form CSRF tokens
-
由 Rafael França 提交于
Provide a better error message if a user mistypes the name of script …
-
由 Stephen Blackstone 提交于
Add tests for detecting bad options for runner
-
由 Rafael Mendonça França 提交于
While the type definition is in Active Model the change of behavior will be only user facing in Active Record so better to put the entry in its changelog. [ci skip]
-
由 Rafael França 提交于
Take UTC offset into account when assigning string value to time attributes.
-
由 Rafael França 提交于
Fix `connection#create` in PG adapter
-
由 schneems 提交于
This reverts related commits due to #22917.
-
由 Santiago Pastorino 提交于
-
由 Santiago Pastorino 提交于
This fixes the case when you try to render an html you know safe and the file is named something.html. With this commit the content of the html won't be escaped anymore because AV won't use Raw handler and choose Html handler instead.
-
- 05 1月, 2016 17 次提交
-
-
由 Andrey Novikov 提交于
-
由 Claudio B 提交于
[ci skip] Update doc/resource link removed by #21211
-
由 Claudio B 提交于
[ci skip] Add job suffix to sample's job file name
-
由 Manu 提交于
-
由 Victor Felder 提交于
-
由 Prathamesh Sonpatki 提交于
Autoload ReferenceDefinition class in abstract adapter so that it can be used by #add_reference in schema_statements - Fixes #22916.
-
由 Akira Matsuda 提交于
-
由 Ryuta Kamizono 提交于
In Pg and Sqlite3, `:text` and `:binary` have variable unlimited length. But in MySQL, these have limited length for each types (ref #21591, #21619). This change adds short-hand methods for each text and blob types. Example: create_table :foos do |t| t.tinyblob :tiny_blob t.mediumblob :medium_blob t.longblob :long_blob t.tinytext :tiny_text t.mediumtext :medium_text t.longtext :long_text end
-
由 Ryuta Kamizono 提交于
Originally `connection#create` had aliased to `connection#insert` in PG adapter. But it was broken by #7447. Re-alias `create` to `insert` for fixing it.
-
由 Rafael França 提交于
Fix `unsigned?` and `blob_or_text_column` for Enum columns in MySQL
-
由 Rafael França 提交于
Add ActionController:Renderers test
-
由 Sean Griffin 提交于
activerecord: allocate fewer objects
-
由 Eileen M. Uchitelle 提交于
Fix user name in doc [ci skip]
-
由 Ben Toews 提交于
-
由 Rafael Mendonça França 提交于
-
由 Arthur Nogueira Neves 提交于
Allow add_to_transaction with null transaction
-
由 Tamir Duberstein 提交于
-