Module: StackServiceBase

Defined in:
lib/version.rb,
lib/stack-service-base.rb

Defined Under Namespace

Classes: Base

Class Method Summary collapse

Class Method Details

.rack_setup(app) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/stack-service-base.rb', line 7

def rack_setup app
  # skip if called within Rspec task
  # TODO: warn if called not within Rspec task but with a wrong app class
  return unless app.respond_to? :use

  app.instance_eval do
    RackHelpers.rack_setup app
    if ENV.fetch('PROMETHEUS_METRICS_EXPORT', 'true') == 'true'
      require 'stack-service-base/prometheus'

      # use Rack::Deflater
      use Prometheus::Middleware::Collector
      use Prometheus::Middleware::Exporter
    end

    if OTEL_ENABLED
      otel_initialize app
    end

  end
end