Class: Gitlab::Metrics::ElasticsearchRackMiddleware

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/metrics/elasticsearch_rack_middleware.rb

Overview

Rack middleware for tracking Elasticsearch metrics from Grape and Web requests.

Constant Summary collapse

HISTOGRAM_BUCKETS =
[0.1, 0.5, 1, 10, 50].freeze

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ ElasticsearchRackMiddleware

Returns a new instance of ElasticsearchRackMiddleware.


9
10
11
# File 'lib/gitlab/metrics/elasticsearch_rack_middleware.rb', line 9

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object


13
14
15
16
17
18
19
# File 'lib/gitlab/metrics/elasticsearch_rack_middleware.rb', line 13

def call(env)
  transaction = Gitlab::Metrics.current_transaction

  @app.call(env)
ensure
  record_metrics(transaction)
end