statsd: add a chance to set hostname and port in hydra.conf

[?]
Feb 6, 2016, 2:44 AM
5DXGOH6QPIMK5CBZ6G3MN7UOIJRGFA3MP7C6FAFWLB7V2TAS33FAC

Dependencies

  • [2] 5MVWRWHT hydra-evaluator: Don't use the "timeout" command
  • [3] 3JXCTKEC Add markdown files for documentation
  • [4] 2JJP7673 tests: move to t, allow `yath test` from root
  • [5] IN272KZW * Automatically keep all builds in the latest successful release in
  • [6] JAH3UPWA Support revision control systems via plugins
  • [7] I6QMKSIS Move getBaseUrl
  • [8] WQXF2T3D hydra-evaluator: Don't require $HYDRA_CONFIG
  • [9] CUFVKLLA Remove Hydra::Helper::nix::txn_do from the Perl code
  • [10] A63IHCMX * Register GC roots properly.
  • [*] 2GK5DOU7 * Downloading closures.
  • [*] AFTXA575 * $HYDRA_DATA environment variable.
  • [*] N22GPKYT * Put info about logs / build products in the DB.
  • [*] WVD3YYON hydra-evaluator: Add some debug code
  • [*] DODOGD7M Send queue runner stats to statsd

Change contents

  • edit in doc/manual/src/installation.md at line 189
    [3.13942]
    [3.13942]
    Statsd Configuration
    --------------------
    By default, Hydra will send stats to statsd at `localhost:8125`. Point Hydra to a different server via:
    ```
    <statsd>
    host = alternative.host
    port = 18125
    </statsd>
    ```
  • replacement in doc/manual/src/installation.md at line 249
    [3.15610][3.15610:15619]()
    [3.15610]
  • replacement in src/lib/Hydra/Helper/Nix.pm at line 18
    [5.173][5.1502:1521](),[5.762][5.1502:1521](),[5.39][5.1502:1521]()
    getSCMCacheDir
    [5.762]
    [5.665]
    getSCMCacheDir getStatsdConfig
  • edit in src/lib/Hydra/Helper/Nix.pm at line 58
    [13.524]
    [5.174]
    # Return hash of statsd configuration of the following shape:
    # (
    # host => string,
    # port => digit
    # )
    sub getStatsdConfig {
    my ($config) = @_;
    my $cfg = $config->{statsd};
    my %statsd = defined $cfg ? ref $cfg eq "HASH" ? %$cfg : ($cfg) : ();
    return {
    "host" => %statsd{'host'} // 'localhost',
    "port" => %statsd{'port'} // 8125,
    }
    }
  • edit in src/script/hydra-eval-jobset at line 35
    [15.500]
    [2.92]
    my $statsdConfig = Hydra::Helper::Nix::getStatsdConfig($config);
    $Net::Statsd::HOST = $statsdConfig->{'host'};
    $Net::Statsd::PORT = $statsdConfig->{'port'};
  • edit in src/script/hydra-send-stats at line 12
    [16.580]
    [16.580]
    my $config = getHydraConfig();
    my $statsdConfig = Hydra::Helper::Nix::getStatsdConfig($config);
    $Net::Statsd::HOST = $statsdConfig->{'host'};
    $Net::Statsd::PORT = $statsdConfig->{'port'};
  • file addition: Config (d--r------)
    [4.697]
  • file addition: statsd.t (----------)
    [0.986]
    use strict;
    use Setup;
    my %ctx = test_init(hydra_config => q|
    <statsd>
    host = foo.bar
    port = 18125
    </statsd>
    |);
    require Hydra::Helper::Nix;
    use Test2::V0;
    is(Hydra::Helper::Nix::getStatsdConfig(Hydra::Helper::Nix::getHydraConfig()), {
    'host' => "foo.bar",
    'port' => 18125
    }, "Reading specific configuration from the hydra.conf works");
    is(Hydra::Helper::Nix::getStatsdConfig(), {
    'host' => "localhost",
    'port' => 8125
    }, "A totally empty configuration yields default options");
    is(Hydra::Helper::Nix::getStatsdConfig({
    "statsd" => {
    }
    }), {
    'host' => "localhost",
    'port' => 8125
    }, "A empty statsd block yields default options");
    is(Hydra::Helper::Nix::getStatsdConfig({
    "statsd" => {
    'host' => "statsdhost"
    }
    }), {
    'host' => "statsdhost",
    'port' => 8125
    }, "An overridden statsd host propogates, but the other defaults are returned");
    is(Hydra::Helper::Nix::getStatsdConfig({
    "statsd" => {
    'port' => 5218
    }
    }), {
    'host' => "localhost",
    'port' => 5218
    }, "An overridden statsd port propogates, but the other defaults are returned");
    is(Hydra::Helper::Nix::getStatsdConfig({
    "statsd" => {
    'host' => 'my.statsd.host',
    'port' => 5218
    }
    }), {
    'host' => "my.statsd.host",
    'port' => 5218
    }, "An overridden statsd port and host propogate");
    done_testing;