# Generated from prometheus-collector-0.0.1.gem by gem2rpm -*- rpm-spec -*- %global gem_name prometheus-collector Name: rubygem-%{gem_name} Version: 0.0.1 Release: 1%{?dist} Summary: Scaffold to collect prometheus style metrics from an application via a RACK interface License: MIT URL: https://github.com/essjayhch/prometheus-collector Source0: https://rubygems.org/gems/%{gem_name}-%{version}.gem BuildRequires: ruby(release) BuildRequires: rubygems-devel BuildRequires: ruby # BuildRequires: rubygem(fileutils) BuildArch: noarch %description Application to gather prometheus style metrics # Usage Install the gem into your gemfile ```gem prometheus-collector``` Install your gemset ```bundle install``` Consume the program. ``` require 'prometheus/collector' class Guage < Prometheus::Collector::Extensions::Base install def run # Do some things that would be collected in Prometheus::Client Objects end end ``` Mount the Prometheus::Collector::Application application, or start it from your app.rb ``` Prometheus::Collector::Application.start ``` # How it works The collector app makes use of the Prometheus client collector and exporter middleware to allow you to write custom applications that export prometheus style metrics. It is designed as a bare-bones scaffold to get you off the ground with a ruby applet to get some statistics. It utilizes rack and its middleware. The interface is fairly straightforward: Your Metric Executing code needs to extend Prometheus::Collector::Extensions::Base for 'repeatedly-runbable' operations and Prometheus::Collector::Extensions::Once for something that should only be executed Once. Your class should implement an instance level `run` function, and may optionally implement a class level `schedule` function: This must return a `cron` style string to tell the application when to invoke your `run` code. By default, `schedule` is set to `* * * * *` which would allow the code to be executed every minute. ### Scheduling Scheduling is implemented via em-cron. Thus the re-scheduling of a task should occur within the parameters of the `schedule` string but is evaluated upon completion. Thus in normal operation, the code should not execute more than one `run` of a given worker definition at a time. %package doc Summary: Documentation for %{name} Requires: %{name} = %{version}-%{release} BuildArch: noarch %description doc Documentation for %{name}. %prep %setup -q -n %{gem_name}-%{version} %build # Create the gem as gem install only works on a gem file gem build ../%{gem_name}-%{version}.gemspec # %%gem_install compiles any C extensions and installs the gem into ./%%gem_dir # by default, so that we can move it into the buildroot in %%install %gem_install %install mkdir -p %{buildroot}%{gem_dir} cp -a .%{gem_dir}/* \ %{buildroot}%{gem_dir}/ mkdir -p %{buildroot}%{_bindir} cp -a .%{_bindir}/* \ %{buildroot}%{_bindir}/ find %{buildroot}%{gem_instdir}/bin -type f | xargs chmod a+x %check pushd .%{gem_instdir} # Run the test suite. popd %files %dir %{gem_instdir} %{_bindir}/prometheus-collector %{gem_instdir}/bin %{gem_instdir}/config.ru %{gem_libdir} %{gem_instdir}/template %exclude %{gem_cache} %{gem_spec} %files doc %doc %{gem_docdir} %{gem_instdir}/Gemfile %doc %{gem_instdir}/README.md %{gem_instdir}/prometheus-collector.gemspec %changelog * Tue Apr 19 2022 mockbuilder - 0.0.1-1 - Initial package