summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Sentry.pm
diff options
context:
space:
mode:
authorByron Jones <glob@mozilla.com>2015-07-21 06:53:46 +0200
committerByron Jones <glob@mozilla.com>2015-07-21 06:53:46 +0200
commitdc8e2b4c3e3a9a14c65f25ba59b4415cdf00c7e2 (patch)
treef045e67cce390f18afda02c747853c8583226f80 /Bugzilla/Sentry.pm
parent5af060abe8347ccac35038d40577fd09c07f64c9 (diff)
downloadbugzilla-dc8e2b4c3e3a9a14c65f25ba59b4415cdf00c7e2.tar.gz
bugzilla-dc8e2b4c3e3a9a14c65f25ba59b4415cdf00c7e2.tar.xz
Bug 1184001 - deliver error report to sentry via cron instead of immediately
Diffstat (limited to 'Bugzilla/Sentry.pm')
-rw-r--r--Bugzilla/Sentry.pm25
1 files changed, 14 insertions, 11 deletions
diff --git a/Bugzilla/Sentry.pm b/Bugzilla/Sentry.pm
index 4206118da..73f316a1d 100644
--- a/Bugzilla/Sentry.pm
+++ b/Bugzilla/Sentry.pm
@@ -17,9 +17,9 @@ our @EXPORT = qw(
);
use Carp;
-use Data::Dumper;
use DateTime;
use File::Temp;
+use JSON ();
use LWP::UserAgent;
use Sys::Hostname;
use URI;
@@ -215,10 +215,11 @@ sub sentry_handle_error {
if exists $ENV{$field};
}
+ my $now = DateTime->now();
my $data = {
event_id => $id,
message => $message,
- timestamp => DateTime->now->iso8601(),
+ timestamp => $now->iso8601(),
level => $level,
platform => 'Other',
logger => $logger,
@@ -235,17 +236,19 @@ sub sentry_handle_error {
},
};
- my $fh = File::Temp->new( UNLINK => 0 );
+ my $fh = File::Temp->new(
+ DIR => bz_locations()->{error_reports},
+ TEMPLATE => $now->ymd('') . $now->hms('') . '-XXXX',
+ SUFFIX => '.dump',
+ UNLINK => 0,
+
+ );
if (!$fh) {
- warn "Failed to create temp file: $!\n";
+ warn "Failed to create dump file: $!\n";
return;
}
- print $fh Dumper($data);
- close($fh) or die $!;
- my $filename = $fh->filename;
-
- my $command = bz_locations()->{'cgi_path'} . "/sentry.pl '$filename' &";
- system($command);
+ print $fh JSON->new->utf8(1)->pretty(0)->allow_nonref(1)->encode($data);
+ close($fh);
return 1;
}
@@ -259,7 +262,7 @@ sub _write_to_error_log {
Apache2::ServerRec::warn($message);
}
} else {
- print STDERR "$message\n";
+ print STDERR $message, "\n";
}
}