Skip to content

Commit

Permalink
Handle empty Telemetry reports better
Browse files Browse the repository at this point in the history
  • Loading branch information
lizmat committed Nov 11, 2017
1 parent 345fbf5 commit b80d486
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions lib/Telemetry.pm6
Expand Up @@ -783,6 +783,15 @@ multi sub report(
--> Str:D
) {

# set up basic header
my $text := nqp::list_s(qq:to/HEADER/.chomp);
Telemetry Report of Process #$*PID ({Instant.from-posix(nqp::time_i).DateTime})
Number of Snapshots: {+@s}
HEADER

# return that if there's nothing to tell otherwise
return nqp::atpos_s($text,0) unless @s;

# get the sampler that was used
my $sampler := @s[0].sampler;

Expand Down Expand Up @@ -821,7 +830,6 @@ multi sub report(
}

# some initializations
my $text := nqp::list_s;
my @periods = periods(@s);

# only want CSV ready output
Expand All @@ -848,11 +856,6 @@ multi sub report(
my $header = "\n%format{@columns}>>.[HEADER].join(' ')";
my @formats = %format{@columns};

nqp::push_s($text,qq:to/HEADER/.chomp);
Telemetry Report of Process #$*PID ({Instant.from-posix(nqp::time_i).DateTime})
Number of Snapshots: {+@s}
HEADER

for $sampler.instruments -> \instrument {
nqp::push_s($text,$_)
with instrument.preamble: $first, $last, $total, @s;
Expand Down

0 comments on commit b80d486

Please sign in to comment.