Sha256: e9d284ce378845f62237ff4465f115dfde6e3b2fa7cff5f48e90a704258e7cc1

Contents?: true

Size: 489 Bytes

Versions: 2

Compression:

Stored size: 489 Bytes

Contents

# frozen_string_literal: true

class Async::App::WebServer::MetricsApp
  include Async::App::Component

  PATHS = ["/metrics", "/metrics/"].freeze

  def initialize(metrics_prefix:)
    store = Store.new
    @serializer = Serializer.new(prefix: metrics_prefix, store:)

    bus.subscribe("metrics.updated") do |metrics|
      metrics.each { store.set(_1, **_2) }
    end
  end

  def can_handle?(request) = PATHS.include?(request.path)
  def call(*) = [200, {}, @serializer.serialize]
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
async-tools-0.2.9 lib/async/app/web_server/metrics_app.rb
async-tools-0.2.8 lib/async/app/web_server/metrics_app.rb