discourse.plugins.discourse-prometheus: Init

+115
+1
pkgs/servers/web-apps/discourse/plugins/all-plugins.nix
··· 15 15 discourse-math = callPackage ./discourse-math {}; 16 16 discourse-migratepassword = callPackage ./discourse-migratepassword {}; 17 17 discourse-openid-connect = callPackage ./discourse-openid-connect {}; 18 + discourse-prometheus = callPackage ./discourse-prometheus {}; 18 19 discourse-solved = callPackage ./discourse-solved {}; 19 20 discourse-spoiler-alert = callPackage ./discourse-spoiler-alert {}; 20 21 discourse-yearly-review = callPackage ./discourse-yearly-review {};
+8
pkgs/servers/web-apps/discourse/plugins/discourse-prometheus/Gemfile
··· 1 + # frozen_string_literal: true 2 + 3 + source "https://rubygems.org" 4 + 5 + git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } 6 + 7 + # gem "rails" 8 + gem 'prometheus_exporter', '0.5.0'
+13
pkgs/servers/web-apps/discourse/plugins/discourse-prometheus/Gemfile.lock
··· 1 + GEM 2 + remote: https://rubygems.org/ 3 + specs: 4 + prometheus_exporter (0.5.0) 5 + 6 + PLATFORMS 7 + ruby 8 + 9 + DEPENDENCIES 10 + prometheus_exporter (= 0.5.0) 11 + 12 + BUNDLED WITH 13 + 2.1.4
+26
pkgs/servers/web-apps/discourse/plugins/discourse-prometheus/default.nix
··· 1 + { lib, stdenv, mkDiscoursePlugin, fetchFromGitHub }: 2 + 3 + mkDiscoursePlugin { 4 + bundlerEnvArgs.gemdir = ./.; 5 + name = "discourse-prometheus"; 6 + src = fetchFromGitHub { 7 + owner = "discourse"; 8 + repo = "discourse-prometheus"; 9 + rev = "46260710e8770344af438f86b47409d864a1c499"; 10 + sha256 = "0nmpi0nysp59x4hyn1c3niypvxw1jkz86acb6m8acacw0c6682k2"; 11 + }; 12 + 13 + patches = [ 14 + # The metrics collector tries to run git to get the commit id but fails 15 + # because we don't run Discourse from a Git repository. 16 + ./no-git-version.patch 17 + ./spec-import-fix-abi-version.patch 18 + ]; 19 + 20 + meta = with lib; { 21 + homepage = "https://github.com/discourse/discourse-prometheus"; 22 + maintainers = with maintainers; [ dpausp ]; 23 + license = licenses.mit; 24 + description = "Official Discourse Plugin for Prometheus Monitoring"; 25 + }; 26 + }
+12
pkgs/servers/web-apps/discourse/plugins/discourse-prometheus/gemset.nix
··· 1 + { 2 + prometheus_exporter = { 3 + groups = ["default"]; 4 + platforms = []; 5 + source = { 6 + remotes = ["https://rubygems.org"]; 7 + sha256 = "1kmabnxz466zqnyqlzc693ny4l7i0rxvmc0znswvizc0zg4pri80"; 8 + type = "gem"; 9 + }; 10 + version = "0.5.0"; 11 + }; 12 + }
+36
pkgs/servers/web-apps/discourse/plugins/discourse-prometheus/no-git-version.patch
··· 1 + diff --git a/lib/internal_metric/global.rb b/lib/internal_metric/global.rb 2 + index 682571b..7bdd431 100644 3 + --- a/lib/internal_metric/global.rb 4 + +++ b/lib/internal_metric/global.rb 5 + @@ -30,30 +30,7 @@ module DiscoursePrometheus::InternalMetric 6 + @active_app_reqs = 0 7 + @queued_app_reqs = 0 8 + @fault_logged = {} 9 + - 10 + - begin 11 + - @@version = nil 12 + - 13 + - out, error, status = Open3.capture3('git rev-parse HEAD') 14 + - 15 + - if status.success? 16 + - @@version ||= out.chomp 17 + - else 18 + - raise error 19 + - end 20 + - rescue => e 21 + - if defined?(::Discourse) 22 + - Discourse.warn_exception(e, message: "Failed to calculate discourse_version_info metric") 23 + - else 24 + - STDERR.puts "Failed to calculate discourse_version_info metric: #{e}\n#{e.backtrace.join("\n")}" 25 + - end 26 + - 27 + - @@retries ||= 10 28 + - @@retries -= 1 29 + - if @@retries < 0 30 + - @@version = -1 31 + - end 32 + - end 33 + + @@version = -1 34 + end 35 + 36 + def collect
+16
pkgs/servers/web-apps/discourse/plugins/discourse-prometheus/spec-import-fix-abi-version.patch
··· 1 + diff --git a/bin/collector b/bin/collector 2 + index 4fec65e..e59eac7 100755 3 + --- a/bin/collector 4 + +++ b/bin/collector 5 + @@ -3,8 +3,10 @@ 6 + 7 + Process.setproctitle("discourse prometheus-collector") 8 + 9 + +# We need the ABI version {MAJOR}.{MINOR}.0 here. 10 + +abi_version = ENV['GEM_PATH'].split("/")[-1] 11 + version = File.read(File.expand_path("../../prometheus_exporter_version", __FILE__)).strip 12 + -spec_file = File.expand_path("../../gems/#{RUBY_VERSION}/specifications/prometheus_exporter-#{version}.gemspec", __FILE__) 13 + +spec_file = File.expand_path("../../gems/#{abi_version}/specifications/prometheus_exporter-#{version}.gemspec", __FILE__) 14 + 15 + spec = Gem::Specification.load spec_file 16 + spec.activate
+3
pkgs/servers/web-apps/discourse/update.py
··· 212 212 {'name': 'discourse-ldap-auth', 'owner': 'jonmbake'}, 213 213 {'name': 'discourse-math'}, 214 214 {'name': 'discourse-migratepassword', 'owner': 'discoursehosting'}, 215 + # We can't update this automatically at the moment because the plugin.rb 216 + # tries to load a version number which breaks bundler called by this script. 217 + # {'name': 'discourse-prometheus'}, 215 218 {'name': 'discourse-solved'}, 216 219 {'name': 'discourse-spoiler-alert'}, 217 220 {'name': 'discourse-yearly-review'},