String tag = new String(tagbytes, CharEncUtils.RAW);
if (Arrays.equals(bench, BenchmarkInjectDecorator.BENCH_START)) {
StringWriter out = new StringWriter();
PrintWriter pw = new PrintWriter(out);
Benchmark b = new Benchmark(tag, pw, pw);
b.mark("benchmarkStart");
benchmarks.put(tag, new Pair<Benchmark, StringWriter>(b, out));
} else if (Arrays.equals(bench, BenchmarkInjectDecorator.BENCH_FIRST)) {
Benchmark b = benchmarks.get(tag).getLeft();
b.mark("benchmarkFirst");
} else if (Arrays.equals(bench, BenchmarkInjectDecorator.BENCH_STOP)) {
Benchmark b = benchmarks.get(tag).getLeft();
b.mark("benchmarkDone");
b.done();
ReportEvent rpt = getMetrics();
LOG.info(rpt.toText());
reportSink.append(rpt);
} else if (Arrays.equals(bench, BenchmarkInjectDecorator.BENCH_ERROR)) {
Benchmark b = benchmarks.get(tag).getLeft();
b.mark("benchmarkError");
b.done();
LOG.info(getMetrics().toText());
ReportEvent rpt = getMetrics();
LOG.info(rpt.toText());
reportSink.append(rpt);