summaryrefslogtreecommitdiffstats
path: root/Bugzilla.pm
diff options
context:
space:
mode:
authorDylan William Hardison <dylan@hardison.net>2018-08-26 07:55:24 +0200
committerDylan William Hardison <dylan@hardison.net>2018-08-26 07:55:24 +0200
commit9263f397e701f25af395e8cdee48c87ee3327157 (patch)
treecc7f6b6beef8947090a108701ca34316a5c8edb8 /Bugzilla.pm
parent23b94e8410d90e9e15584d3a9220b6bb214f4220 (diff)
parentd57aefa118802606ea7cc424aaa62173be9eec41 (diff)
downloadbugzilla-9263f397e701f25af395e8cdee48c87ee3327157.tar.gz
bugzilla-9263f397e701f25af395e8cdee48c87ee3327157.tar.xz
Merge remote-tracking branch 'bmo/mojo'
Diffstat (limited to 'Bugzilla.pm')
-rw-r--r--Bugzilla.pm43
1 files changed, 40 insertions, 3 deletions
diff --git a/Bugzilla.pm b/Bugzilla.pm
index a6f4e2b4d..0b88f5c3e 100644
--- a/Bugzilla.pm
+++ b/Bugzilla.pm
@@ -13,7 +13,7 @@ use warnings;
use Bugzilla::Logging;
-our $VERSION = '5.13';
+our $VERSION = '5.15';
use Bugzilla::Auth;
use Bugzilla::Auth::Persist::Cookie;
@@ -47,6 +47,7 @@ use File::Spec::Functions;
use Safe;
use JSON::XS qw(decode_json);
use URI;
+use Scope::Guard;
use parent qw(Bugzilla::CPAN);
@@ -86,6 +87,9 @@ sub init_page {
# request cache are very annoying (see bug 1347335)
# and this is not an expensive operation.
clear_request_cache();
+ if ($0 =~ /\.t/) {
+ return;
+ }
if (Bugzilla->usage_mode == USAGE_MODE_CMDLINE) {
init_console();
}
@@ -285,8 +289,20 @@ sub user {
}
sub set_user {
- my (undef, $user) = @_;
- request_cache->{user} = $user;
+ my (undef, $new_user, %option) = @_;
+
+ if ($option{scope_guard}) {
+ my $old_user = request_cache->{user};
+ request_cache->{user} = $new_user;
+ return Scope::Guard->new(
+ sub {
+ request_cache->{user} = $old_user;
+ }
+ )
+ }
+ else {
+ request_cache->{user} = $new_user;
+ }
}
sub sudoer {
@@ -790,6 +806,27 @@ sub memcached {
return request_cache->{memcached} ||= Bugzilla::Memcached->_new();
}
+# Connector to the Datadog metrics collection daemon.
+sub datadog {
+ my ($class, $namespace) = @_;
+ my $host = $class->localconfig->{datadog_host};
+ my $port = $class->localconfig->{datadog_port};
+
+ $namespace //= '';
+
+ if ($class->has_feature('datadog') && $host) {
+ require DataDog::DogStatsd;
+ return request_cache->{datadog}{$namespace} //= DataDog::DogStatsd->new(
+ host => $host,
+ port => $port,
+ namespace => $namespace ? "$namespace." : '',
+ );
+ }
+ else {
+ return undef;
+ }
+}
+
sub elastic {
my ($class) = @_;
$class->process_cache->{elastic} //= Bugzilla::Elastic->new();