Expose Prometheus metrics at /metrics

[?]
Jun 10, 2021, 9:45 PM
QOV7KWRH2W7X2SC23A7FPXHUQHAAVAQ22TC4C3MBPDACZT73DAOQC

Dependencies

  • [2] 2SP37OH2 Send ETag and Expires headers
  • [3] 2G37UFZF flake: add TestPostgreSQL for per-test DBs
  • [4] MQLCUSZL Test the fake derivations channel, asserting nested packages are properly represented.
  • [5] S66BOMVU * Added authentication.
  • [6] U2ZK6LZ7 Fix some warnings
  • [7] YUND3DAA Disable access log
  • [8] XJRJ4J7M Add user registration
  • [*] RWNXH3H2 lastModified -> lastModifiedDate
  • [*] J5UVLXOK * Start of a basic Catalyst web interface.

Change contents

  • edit in flake.nix at line 69
    [3.1481]
    [3.1481]
    license = with final.lib.licenses; [ artistic1 gpl1Plus ];
    };
    };
    CatalystPluginPrometheusTiny = final.buildPerlPackage {
    pname = "Catalyst-Plugin-PrometheusTiny";
    version = "0.005";
    src = final.fetchurl {
    url = "mirror://cpan/authors/id/S/SY/SYSPETE/Catalyst-Plugin-PrometheusTiny-0.005.tar.gz";
    sha256 = "a42ef09efdc3053899ae007c41220d3ed7207582cc86e491b4f534539c992c5a";
    };
    buildInputs = with final.perlPackages; [ HTTPMessage Plack SubOverride TestDeep ];
    propagatedBuildInputs = with final.perlPackages; [ CatalystRuntime Moose PrometheusTiny PrometheusTinyShared ];
    meta = {
    description = "Prometheus metrics for Catalyst";
  • edit in flake.nix at line 376
    [10.1574]
    [10.1574]
    CatalystPluginPrometheusTiny
  • replacement in src/lib/Hydra.pm at line 19
    [5.3637][5.3637:3663]()
    Captcha/,
    [5.4331]
    [5.1473]
    Captcha
    PrometheusTiny/,
  • edit in src/lib/Hydra.pm at line 51
    [2.7]
    [2.7]
    'Plugin::PrometheusTiny' => {
    include_action_labels => 1,
    },
  • file addition: metrics.t (----------)
    [4.451]
    use feature 'unicode_strings';
    use strict;
    use Setup;
    use JSON qw(decode_json encode_json);
    my %ctx = test_init();
    require Hydra::Schema;
    require Hydra::Model::DB;
    require Hydra::Helper::Nix;
    use HTTP::Request::Common;
    use Test2::V0;
    require Catalyst::Test;
    Catalyst::Test->import('Hydra');
    my $db = Hydra::Model::DB->new;
    hydra_setup($db);
    request(GET '/');
    my $metrics = request(GET '/metrics');
    ok($metrics->is_success);
    like(
    $metrics->content,
    qr/http_requests_total\{action="index",code="200",controller="Hydra::Controller::Root",method="GET"\} 1/,
    "Metrics are collected"
    );
    done_testing;