about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--app/assets/javascripts/components/actions/notifications.jsx2
-rw-r--r--app/assets/javascripts/components/features/ui/components/columns_area.jsx5
-rw-r--r--app/assets/stylesheets/components.scss27
-rw-r--r--config/application.rb3
-rw-r--r--config/initializers/instrumentation.rb18
-rw-r--r--config/initializers/statsd.rb22
-rw-r--r--config/initializers/timeout.rb5
-rw-r--r--lib/statsd_monitor.rb11
8 files changed, 62 insertions, 31 deletions
diff --git a/app/assets/javascripts/components/actions/notifications.jsx b/app/assets/javascripts/components/actions/notifications.jsx
index 1731c1857..4caf9c75b 100644
--- a/app/assets/javascripts/components/actions/notifications.jsx
+++ b/app/assets/javascripts/components/actions/notifications.jsx
@@ -40,7 +40,7 @@ export function updateNotifications(notification, intlMessages, intlLocale) {
     // Desktop notifications
     if (typeof window.Notification !== 'undefined' && showAlert) {
       const title = new IntlMessageFormat(intlMessages[`notification.${notification.type}`], intlLocale).format({ name: notification.account.display_name.length > 0 ? notification.account.display_name : notification.account.username });
-      const body  = $('<p>').html(notification.status ? notification.status.content : '').text();
+      const body  = (notification.status && notification.status.spoiler_text.length > 0) ? notification.status.spoiler_text : $('<p>').html(notification.status ? notification.status.content : '').text();
 
       new Notification(title, { body, icon: notification.account.avatar, tag: notification.id });
     }
diff --git a/app/assets/javascripts/components/features/ui/components/columns_area.jsx b/app/assets/javascripts/components/features/ui/components/columns_area.jsx
index 8d316e26b..dd771900d 100644
--- a/app/assets/javascripts/components/features/ui/components/columns_area.jsx
+++ b/app/assets/javascripts/components/features/ui/components/columns_area.jsx
@@ -3,12 +3,15 @@ import PureRenderMixin from 'react-addons-pure-render-mixin';
 const style = {
   display: 'flex',
   flex: '1 1 auto',
-  justifyContent: 'flex-start',
   overflowX: 'auto'
 };
 
 const ColumnsArea = React.createClass({
 
+  propTypes: {
+    children: React.PropTypes.node
+  },
+
   mixins: [PureRenderMixin],
 
   render () {
diff --git a/app/assets/stylesheets/components.scss b/app/assets/stylesheets/components.scss
index 663969c32..f8f1b9d6c 100644
--- a/app/assets/stylesheets/components.scss
+++ b/app/assets/stylesheets/components.scss
@@ -139,10 +139,10 @@
   }
 
   .status__content__spoiler-link {
-    background: lighten($color1, 26%);
+    background: lighten($color1, 30%);
 
     &:hover {
-      background: lighten($color1, 29%);
+      background: lighten($color1, 33%);
       text-decoration: none;
     }
   }
@@ -261,6 +261,15 @@
   .status__avatar {
     opacity: 0.5;
   }
+
+  .status__content__spoiler-link {
+    background: lighten($color1, 26%);
+
+    &:hover {
+      background: lighten($color1, 29%);
+      text-decoration: none;
+    }
+  }
 }
 
 .notification__display-name {
@@ -354,6 +363,7 @@
 
 .columns-area {
   flex-direction: row;
+  justify-content: flex-start;
 }
 
 @media screen and (min-width: 360px) {
@@ -371,6 +381,19 @@
   width: 280px;
 }
 
+@media screen and (min-width: 2560px) {
+  .columns-area {
+    justify-content: center;
+  }
+
+  .column, .drawer {
+    width: 350px;
+    border-radius: 4px;
+    height: 90vh;
+    margin-top: 5vh;
+  }
+}
+
 .drawer__inner {
   background: linear-gradient(rgba(lighten($color1, 13%), 1), rgba(lighten($color1, 13%), 0.65));
 }
diff --git a/config/application.rb b/config/application.rb
index d0b06bf95..e561d0473 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -3,7 +3,6 @@ require_relative 'boot'
 require 'rails/all'
 
 require_relative '../app/lib/exceptions'
-require_relative '../lib/statsd_monitor'
 
 # Require the gems listed in Gemfile, including any gems
 # you've limited to :test, :development, or :production.
@@ -31,8 +30,6 @@ module Mastodon
 
     config.active_job.queue_adapter = :sidekiq
 
-    config.middleware.insert(0, ::StatsDMonitor)
-
     config.middleware.insert_before 0, Rack::Cors do
       allow do
         origins  '*'
diff --git a/config/initializers/instrumentation.rb b/config/initializers/instrumentation.rb
new file mode 100644
index 000000000..8483f2be2
--- /dev/null
+++ b/config/initializers/instrumentation.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+instrumentation_hostname = ENV.fetch('INSTRUMENTATION_HOSTNAME') { 'localhost' }
+
+ActiveSupport::Notifications.subscribe(/process_action.action_controller/) do |*args|
+  event      = ActiveSupport::Notifications::Event.new(*args)
+  controller = event.payload[:controller]
+  action     = event.payload[:action]
+  format     = event.payload[:format] || 'all'
+  format     = 'all' if format == '*/*'
+  status     = event.payload[:status]
+  key        = "#{controller}.#{action}.#{format}.#{instrumentation_hostname}"
+
+  ActiveSupport::Notifications.instrument :performance, action: :measure, measurement: "#{key}.total_duration", value: event.duration
+  ActiveSupport::Notifications.instrument :performance, action: :measure, measurement: "#{key}.db_time", value: event.payload[:db_runtime]
+  ActiveSupport::Notifications.instrument :performance, action: :measure, measurement: "#{key}.view_time", value: event.payload[:view_runtime]
+  ActiveSupport::Notifications.instrument :performance, measurement: "#{key}.status.#{status}"
+end
diff --git a/config/initializers/statsd.rb b/config/initializers/statsd.rb
index c9c754e7f..f00b1d401 100644
--- a/config/initializers/statsd.rb
+++ b/config/initializers/statsd.rb
@@ -1,20 +1,18 @@
 # frozen_string_literal: true
+RESERVED_CHARACTERS_REGEX = /[\:\|\@]/
 
 StatsD.prefix              = 'mastodon'
 StatsD.default_sample_rate = 1
 
-StatsDMonitor.extend(StatsD::Instrument)
-StatsDMonitor.statsd_measure(:call, 'request.duration')
+def clean_name(str)
+  str.gsub('::', '.').gsub(RESERVED_CHARACTERS_REGEX, '_')
+end
 
-STATSD_REQUEST_METRICS = {
-  'request.status.success'               => 200,
-  'request.status.not_found'             => 404,
-  'request.status.too_many_requests'     => 429,
-  'request.status.internal_server_error' => 500,
-}.freeze
+ActiveSupport::Notifications.subscribe(/performance/) do |name, _start, _finish, _id, payload|
+  action      = payload[:action] || :increment
+  measurement = payload[:measurement]
+  value       = payload[:value]
+  key_name    = clean_name("#{name}.#{measurement}")
 
-STATSD_REQUEST_METRICS.each do |name, code|
-  StatsDMonitor.statsd_count_if(:call, name) do |status, _env, _body|
-    status.to_i == code
-  end
+  StatsD.send(action.to_s, key_name, (value || 1))
 end
diff --git a/config/initializers/timeout.rb b/config/initializers/timeout.rb
index 1e6315b2b..643780884 100644
--- a/config/initializers/timeout.rb
+++ b/config/initializers/timeout.rb
@@ -1 +1,4 @@
-Rack::Timeout.timeout = 30 if Rails.env.production?
+if Rails.env.production?
+  Rack::Timeout.service_timeout = 15
+  Rack::Timeout::Logger.disable
+end
diff --git a/lib/statsd_monitor.rb b/lib/statsd_monitor.rb
deleted file mode 100644
index e48ce6541..000000000
--- a/lib/statsd_monitor.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-# frozen_string_literal: true
-
-class StatsDMonitor
-  def initialize(app)
-    @app = app
-  end
-
-  def call(env)
-    @app.call(env)
-  end
-end