Sha256: 02f584e5bb3e6549f994752257797d302602f2b371192e1ef663916a3e0e02dc
Contents?: true
Size: 836 Bytes
Versions: 2
Compression:
Stored size: 836 Bytes
Contents
# frozen_string_literal: true ## # Aspect that provides application metrics using prometheus. module PrometheusAspect def call_endpoint(prometheus_middleware, *args) return super(*args) if prometheus_middleware.nil? start_time = Time.now begin response = super(*args) ensure duration = (Time.now - start_time) * 1_000 endpoint_name = args[2].split('.').join('/') prometheus_middleware.request_duration_milliseconds.with_labels(endpoint: endpoint_name).observe(duration) prometheus_middleware.request_count.with_labels(endpoint: endpoint_name).increment if response prometheus_middleware.response_count.with_labels(endpoint: endpoint_name, status: response[1]).increment end end response end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
macaw_framework-1.3.21 | lib/macaw_framework/aspects/prometheus_aspect.rb |
macaw_framework-1.3.1 | lib/macaw_framework/aspects/prometheus_aspect.rb |