-
Notifications
You must be signed in to change notification settings - Fork 3
/
smoke.json.html
1063 lines (936 loc) · 38.3 KB
/
smoke.json.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<title>Artillery report</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.6.0/chart.min.js"
integrity="sha384-scMuAXtFmPAlw0+pXLvnpHCt6VHh7AknTPdNrwiph5BA6MJWysg5WgSDl7r63txN"
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.6/moment.min.js"
integrity="sha384-v7eExOYhwaHa3+GhP+lHytJsMcidazNdjiaggRhdbvVTVTCjweLpa23t37ZKxaCf"
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.21/lodash.min.js"
integrity="sha384-H6KKS1H1WwuERMSm+54dYLzjg0fKqRK5ZRyASdbrI/lwrCc6bXEmtGYr5SwvP1pZ"
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.5.3/ace.js" charset="utf=8"
integrity="sha512-NofUHaTd/uaO1GXfw0JvXptI9XdO5LLrfjl7jVqnFlbxdgqVlE3SmuXAUoqRTB5GQKd82yzhchaDlc6C6+SylA=="
crossorigin="anonymous"></script>
<link href="https://artilleryio.github.io/artillery-tailwind/src/build.css" rel="stylesheet" type="text/css"
crossorigin="anonymous" />
<style>
html {
--bg-dark: #161616;
--bg: #202020;
--text: #ffffff;
--text-faded: #9b9b9b;
--border: #383838;
height: 100%;
}
.tab {
color: #9B9B9B;
border-color: transparent;
}
.tab:hover {
color: #FFFFFF;
}
.tab.active {
color: #FFFFFF;
border-color: #FFFFFF;
}
.tab.active:hover {
color: #FFFFFF;
}
.tab:hover span:first-child,
.tab.active:hover span:first-child {
background: #000000;
}
#errorsContainer>p {
color: var(--green);
}
#editor {
font-size: 10pt;
}
#editor input,
button {
color: var(--bg-dark);
}
.hidden {
display: none;
}
.border-gray {
border: 1px solid var(--border);
}
.border-bottom-gray {
border-bottom: 1px solid var(--border);
}
.chevron-down span {
transform: rotate(180deg);
}
.cursor-pointer {
cursor: pointer;
}
.index-tree-wrapper {
display: none;
}
@media (min-width: 768px) {
.index-tree-wrapper {
display: inline-flex;
}
}
</style>
<script>
!function(t,e){var o,n,p,r;e.__SV||(window.posthog=e,e._i=[],e.init=function(i,s,a){function g(t,e){var o=e.split(".");2==o.length&&(t=t[o[0]],e=o[1]),t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}}(p=t.createElement("script")).type="text/javascript",p.async=!0,p.src=s.api_host+"/static/array.js",(r=t.getElementsByTagName("script")[0]).parentNode.insertBefore(p,r);var u=e;for(void 0!==a?u=e[a]=[]:a="posthog",u.people=u.people||[],u.toString=function(t){var e="posthog";return"posthog"!==a&&(e+="."+a),t||(e+=" (stub)"),e},u.people.toString=function(){return u.toString(1)+".people (stub)"},o="capture identify alias people.set people.set_once set_config register register_once unregister opt_out_capturing has_opted_out_capturing opt_in_capturing reset isFeatureEnabled onFeatureFlags".split(" "),n=0;n<o.length;n++)g(u,o[n]);e._i.push([i,s,a])},e.__SV=1)}(document,window.posthog||[]);
posthog.init('_uzX-_WJoVmE_tsLvu0OFD2tpd0HGz72D5sU1zM2hbs', {api_host: 'https://app.posthog.com', autocapture: false});
posthog.capture('report view', { });
</script>
</head>
<body>
<header class="header bg-black-default border-b border-gray-700 mb-9">
<div class="container m-auto relative flex items-center justify-between py-3 px-4 md:px-8">
<div class="flex items-center">
<div
class="group-hover:border-black-200 flex overflow-hidden rounded-md border-2 border-gray-800 transition mr-2">
<svg width="32" height="32" viewBox="0 0 300 306" fill="white" xmlns="http://www.w3.org/2000/svg">
<path
d="M177.235 169.156L138.632 132.074L107.952 144.704L93.2929 130.623L228.213 75.9894L180.953 214.829L166.06 200.523L177.235 169.156ZM183.738 150.815L199.254 106.778L156.348 124.505L183.738 150.815Z"
fill="white" />
<path
d="M136.138 135.974L175.036 173.339L208.275 137.452L221.883 150.524L136.914 242.26L123.306 229.189L162.984 186.35L124.087 148.986L84.4087 191.824L70.8005 178.752L155.769 87.0157L169.378 100.088L136.138 135.974Z"
fill="white" />
</svg>
</div>
<div class="flex flex-col">
<h1 class="font-medium text-sm" id="report-name">
Artillery Report
</h1>
<div class="text-gray-default my-0 block text-xs transition group-hover:text-gray-700" id="timestamp"></div>
</div>
</div>
<div class="text-xsm">
<a target="_blank" rel="nofollow noopener" class="focus:text-beige text-gray-default transition-colors hover:text-gray-300 flex items-center space-x-1" href="https://artillery.io/docs">
<span>Docs</span>
<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" aria-label="External link" aria-labelledby="icon_external_1" x="0px" y="0px" role="img"><title id="icon_external_1" lang="en">External link</title><g fill="currentColor"><path d="M19 19H5V5H12V3H5C3.89 3 3 3.9 3 5V19C3 20.1 3.89 21 5 21H19C20.1 21 21 20.1 21 19V12H19V19ZM14 3V5H17.59L7.76 14.83L9.17 16.24L19 6.41V10H21V3H14Z"></path></g></svg>
</a>
</div>
</div>
<!-- tabs -->
<div class="bg-black-default relative pt-4 text-sm">
<div class="container m-auto flex items-center space-x-2 px-4 md:px-8">
<button id="charts-tab" class="tab active group border-b border-b-2 py-2 transition-all">
<span class="text-xsm flex items-center space-x-2 rounded py-1.5 px-2.5 transition-all">
<svg width="12" height="12" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M2.33331 12.3267L6.33331 8.32001L8.99998 10.9867L14.6666 4.61334L13.7266 3.67334L8.99998 8.98667L6.33331 6.32001L1.33331 11.3267L2.33331 12.3267Z" fill="currentColor"/>
</svg>
<span class="leading-4">Reports</span>
</span>
</button>
<button id="json-tab" class="tab group border-b border-b-2 py-2 transition-all">
<span class="text-xsm flex items-center space-x-2 rounded py-1.5 px-2.5 transition-all">
<svg width="12" height="12" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M6.26665 11.0667L3.19998 8L6.26665 4.93333L5.33331 4L1.33331 8L5.33331 12L6.26665 11.0667ZM9.73331 11.0667L12.8 8L9.73331 4.93333L10.6666 4L14.6666 8L10.6666 12L9.73331 11.0667V11.0667Z" fill="currentColor"/>
</svg>
<span class="leading-4">JSON Output</span>
</span>
</button>
</div>
</div>
</header>
<main style="margin-bottom: 2.5rem;">
<div class="container text-sm m-auto px-4 md:px-8">
<!-- summary blocks -->
<div class="app-test-stats w-full">
<ul class="flex flex-wrap space-x-3.5" id="summary-blocks">
</ul>
</div>
<div class="flex items-start w-full flex-row space-x-0 md:space-x-4 mt-1">
<!-- counters summary -->
<div class="w-full" id="charts-col">
<div class="overflow-x-auto overflow-y-hidden rounded border-gray mb-4">
<table class="w-full border-collapse text-left">
<thead class="text-gray-default bg-black-200 border-b border-gray-800" style="background-color: #2b2b2b;">
<tr>
<th class="whitespace-nowrap p-2" colspan="6">
<span class="text-xsm" style="font-weight: 500 !important;">Metric</span>
</th>
<th class="whitespace-nowrap p-2" colspan="6">
<span class="text-xsm" style="font-weight: 500 !important;">Value</span>
</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-800" id="customCountersTable">
</tbody>
</table>
</div>
<div id="errorsChartsRow">
<h4><i class="fas fa-chart-area"></i> Errors at intervals</h4>
<canvas id="errorsAtIntervalsChart"></canvas>
</div>
<!-- charts -->
<div id="customCountersAtIntervalsChart" class="space-y-4"></div>
</div>
<div class="index-tree-wrapper w-56 text-xsm sticky top-3">
<div id="index-tree">
</div>
</div>
</div>
<!-- json text output -->
<div>
<div class="hidden border-gray rounded" style="overflow: hidden;" id="json-output">
<div class="p-2 text-gray-default text-xsm flex items-center justify-between text-gray-default" style="border-bottom: 1px solid #383838; background-color: #2b2b2b; font-weight: 500;">JSON Output
<button id="copy-json" class="flex justify-center items-center space-x-2 font-medium text-center rounded transition-all p-1.5 text-xsm hover:text-gray-300 focus:text-gray-300 bg-transparent focus:ring hover:bg-black-700 text-gray-default focus:ring-black-200">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" aria-label="" aria-labelledby="icon_copy" x="0px" y="0px" role="img" class="inline false"><title id="icon_copy" lang="en"></title><g fill="#9b9b9b"><path d="M16 1H4C2.9 1 2 1.9 2 3V17H4V3H16V1ZM19 5H8C6.9 5 6 5.9 6 7V21C6 22.1 6.9 23 8 23H19C20.1 23 21 22.1 21 21V7C21 5.9 20.1 5 19 5ZM19 21H8V7H19V21Z"></path></g></svg>
</button>
</div>
<div id="editor"></div>
</div>
</div>
</div> <!-- /.row -->
<div class="row">
<div class="codes-line text-center col-lg-12"></div>
</div>
<div class="row">
<div class="errors-line text-center col-lg-12"></div>
</div>
</div>
</main>
<footer id="footer" class="bg-black-default py-4 text-xsm text-gray-default" style="margin-top: 2rem;">
<div class="container m-auto px-4 md:px-8">
<a href="https://www.artillery.io">Artillery</a> • move fast, stay fast, stay reliable • <a href="https://www.artillery.io">www.artillery.io</a>
</div>
</footer>
<script charset="utf-8">
const Report = {
"aggregate": {
"counters": {
"vusers.created_by_name.petclinic_add_vets": 50,
"vusers.created": 50,
"http.requests": 100,
"http.codes.201": 50,
"http.responses": 100,
"plugins.expect.ok": 150,
"plugins.expect.ok.matchesRegexp": 50,
"http.codes.200": 50,
"plugins.expect.ok.statusCode": 50,
"plugins.expect.ok.contentType": 50,
"vusers.failed": 0,
"vusers.completed": 50
},
"rates": {
"http.request_rate": 22
},
"firstCounterAt": 1658803577069,
"firstHistogramAt": 1658803577151,
"lastCounterAt": 1658803581959,
"lastHistogramAt": 1658803581959,
"firstMetricAt": 1658803577069,
"lastMetricAt": 1658803581959,
"period": 1658803580000,
"summaries": {
"http.response_time": {
"min": 0,
"max": 22,
"count": 100,
"p50": 7.9,
"median": 7.9,
"p75": 10.1,
"p90": 15,
"p95": 16.9,
"p99": 22,
"p999": 22
},
"vusers.session_length": {
"min": 20.5,
"max": 150.5,
"count": 50,
"p50": 39.3,
"median": 39.3,
"p75": 47.9,
"p90": 70.1,
"p95": 80.6,
"p99": 125.2,
"p999": 125.2
}
},
"histograms": {
"http.response_time": {
"min": 0,
"max": 22,
"count": 100,
"p50": 7.9,
"median": 7.9,
"p75": 10.1,
"p90": 15,
"p95": 16.9,
"p99": 22,
"p999": 22
},
"vusers.session_length": {
"min": 20.5,
"max": 150.5,
"count": 50,
"p50": 39.3,
"median": 39.3,
"p75": 47.9,
"p90": 70.1,
"p95": 80.6,
"p99": 125.2,
"p999": 125.2
}
}
},
"intermediate": [
{
"counters": {
"vusers.created_by_name.petclinic_add_vets": 30,
"vusers.created": 30,
"http.requests": 60,
"http.codes.201": 30,
"http.responses": 60,
"plugins.expect.ok": 90,
"plugins.expect.ok.matchesRegexp": 30,
"http.codes.200": 30,
"plugins.expect.ok.statusCode": 30,
"plugins.expect.ok.contentType": 30,
"vusers.failed": 0,
"vusers.completed": 30
},
"rates": {
"http.request_rate": 22
},
"http.request_rate": null,
"firstCounterAt": 1658803577069,
"firstHistogramAt": 1658803577151,
"lastCounterAt": 1658803579959,
"lastHistogramAt": 1658803579959,
"firstMetricAt": 1658803577069,
"lastMetricAt": 1658803579959,
"period": "1658803570000",
"summaries": {
"http.response_time": {
"min": 0,
"max": 22,
"count": 60,
"p50": 8.9,
"median": 8.9,
"p75": 12.1,
"p90": 15,
"p95": 16.9,
"p99": 19.9,
"p999": 19.9
},
"vusers.session_length": {
"min": 23.2,
"max": 150.5,
"count": 30,
"p50": 46.1,
"median": 46.1,
"p75": 51.9,
"p90": 70.1,
"p95": 80.6,
"p99": 125.2,
"p999": 125.2
}
},
"histograms": {
"http.response_time": {
"min": 0,
"max": 22,
"count": 60,
"p50": 8.9,
"median": 8.9,
"p75": 12.1,
"p90": 15,
"p95": 16.9,
"p99": 19.9,
"p999": 19.9
},
"vusers.session_length": {
"min": 23.2,
"max": 150.5,
"count": 30,
"p50": 46.1,
"median": 46.1,
"p75": 51.9,
"p90": 70.1,
"p95": 80.6,
"p99": 125.2,
"p999": 125.2
}
}
}
],
"name": "smoke.json"
};
const editor = ace.edit("editor");
editor.getSession().setMode("ace/mode/javascript");
editor.setValue(JSON.stringify(Report, null, 2));
editor.gotoLine(1);
editor.setHighlightActiveLine(false);
editor.setOption("maxLines", 50);
editor.setTheme("ace/theme/clouds_midnight");
// let sanitizedName = Report.name.replace(/_/, " ").split(" ").map((w) => w[0].toUpperCase()+w.substring(1,w.length)).join(" ")
$('#report-name').html(Report.name.replace(".json", ""))
const l = _;
const chartBgColors = {
red: "rgba(255, 99, 132, 0.2)",
orange: "rgba(255, 159, 64, 0.2)",
yellow: "rgba(255, 205, 86, 0.2)",
green: "rgba(75, 192, 192, 0.2)",
blue: "rgba(54, 162, 235, 0.2)",
};
const chartBorderColors = {
green: "#24EB70",
red: "#ff0000",
orange: "#FF6D1B",
purple: "#6100FF",
blue: "#0047FF"
};
const getHttpColor = (httpCode) => {
const code = parseInt(httpCode, 10);
if (code >= 100 && code < 200) {
return chartBorderColors.blue;
} else if (code >= 200 && code < 300) {
return chartBorderColors.green;
} else if (code >= 300 && code < 400) {
return chartBorderColors.red;
} else if (code >= 400 && code < 500) {
return chartBorderColors.purple;
}
return chartBorderColors.orange;
}
const getLatencyColor = (latency) => {
switch (latency) {
case "min":
return chartBorderColors.red;
case "max":
return chartBorderColors.orange;
case "median":
return chartBorderColors.purple;
case "p95":
return chartBorderColors.green;
case "p99":
return chartBorderColors.green;
default:
return '';
}
};
const getCustomStats = (stats) =>
l.omitBy(
stats,
(_, key) =>
key.startsWith("errors.") ||
key.startsWith("core.") ||
key.startsWith("engine.")
);
const scenarioCounts = l.pickBy(Report.aggregate.counters, (_, key) =>
key.startsWith("vusers.created_by_name")
);
if (l.size(scenarioCounts) > 0) {
l.each(scenarioCounts, function (count, key) {
const [, , name] = key.split(".");
const $tdName = $("<td>" + name + "</td>");
const percentage =
Math.round(
(count / Report.aggregate.counters["vusers.created"]) *
100 *
1000
) / 1000;
const $tdCount = $("<td>" + count + " (" + percentage + "%)" + "</td>");
$("<tr></tr>")
.append($tdName)
.append($tdCount)
.appendTo($("#scenarioCounts"));
});
} else {
$("#scenarioCountsContainer").hide();
}
const httpCodes = l.pickBy(Report.aggregate.counters, (_, key) =>
key.startsWith("http.codes")
);
const errors = l.pickBy(Report.aggregate.counters, (_, key) =>
key.startsWith("errors.")
);
if (l.size(errors) > 0) {
l.each(errors, function (count, error) {
const [, errorDetail] = error.split("errors.");
$("<tr></tr>")
.append($("<td>" + errorDetail + "</td>"))
.append($("<td>" + count + "</td>"))
.appendTo($("#errors"));
});
} else {
$("#errorsContainer > p").html(
"✔ Test completed without network or OS errors."
);
}
const getTimePeriodAggregates = (summaries) => {
const summary =
summaries["socketio.response_time"] ||
summaries["http.response_time"];
const metrics = ["min", "max", "median", "p95", "p99"];
return l.pickBy(summary, (_, key) => metrics.includes(key));
};
const getLatencyDistribution = (data) => {
return l.reduce(
data,
(acc, value, key) => {
acc.labels.push(key);
acc.values.push(value);
return acc;
},
{ labels: [], values: [] }
);
};
const randomRgbColor = () => {
const r = Math.floor(Math.random() * 256);
const g = Math.floor(Math.random() * 256);
const b = Math.floor(Math.random() * 256);
return "rgb(" + r + ", " + g + ", " + b + ")";
};
const latencyDistributionData = getLatencyDistribution(
getTimePeriodAggregates(Report.aggregate.summaries)
);
const latencyAtIntervalsData = (intermediates = []) => {
const data = intermediates.reduce(
(acc, entry, idx) => {
const latencies = getTimePeriodAggregates(entry.summaries);
l.each(latencies, (latency, key) => {
acc.values[key] = acc.values[key] || [];
acc.values[key].push(latency);
});
acc.labels.push((idx + 1) * 10);
return acc;
},
{ labels: [], values: {} }
);
return {
labels: data.labels,
datasets: l.map(data.values, (entry, key) => {
const color = getLatencyColor(key);
return {
label: key,
data: entry,
fill: false,
backgroundColor: color,
borderColor: color,
tension: 0.5,
};
})
};
};
const getMeanRpsData = (intermediates = []) => {
const data = intermediates.reduce(
(acc, entry, idx) => {
const count =
entry.rates["http.request_rate"] ||
entry.rates["socketio.emit_rate"] ||
entry.rates["websocket.send_rate"] ||
0;
acc.labels.push((idx + 1) * 10);
acc.values.push(count);
return acc;
},
{ labels: [], values: [] }
);
return {
labels: data.labels,
datasets: [
{
data: data.values,
fill: false,
borderColor: "#0047FF",
tension: 0.5,
},
],
};
};
const getHttpCodesData = (counters) => {
const httpCodes = l.pickBy(counters, (_, key) =>
key.startsWith("http.codes")
);
const labels = [];
const data = [];
const bgColors = [
"rgba(54, 232, 235, 0.5)",
"rgba(54, 235, 93, 0.5)",
"rgba(229, 235, 54, 0.5)",
"rgba(166, 54, 235, 0.5)",
"rgba(235, 54, 69, 0.5)",
];
if (l.size(httpCodes) > 0) {
l.each(httpCodes, function (count, key) {
let [, , , code] = key.split(".");
code = parseInt(code, 10);
labels.push(code);
data.push(count);
});
}
return {
labels,
datasets: [
{
backgroundColor: labels.map(getHttpColor),
hoverOffset: 4,
data,
},
],
};
};
const timeFormat = "DD[/]MM[/]YYYY, hh:mm:ss"
$("#timestamp").html(
moment(Report.aggregate.period).format(timeFormat)
);
$('#copy-json').on("click", (e) => {
navigator.clipboard.writeText(JSON.stringify(Report, null, 2));
$('#copy-json').html(`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" aria-label="" aria-labelledby="icon_start" x="0px" y="0px" role="img" class="inline false"><title id="icon_start" lang="en"></title><g fill="currentColor"><path d="M16 1H4C2.9 1 2 1.9 2 3V17H4V3H16V1ZM19 5H8C6.9 5 6 5.9 6 7V21C6 22.1 6.9 23 8 23H19C20.1 23 21 22.1 21 21V7C21 5.9 20.1 5 19 5ZM19 21H8V7H19V21Z"></path></g></svg>`)
setTimeout(function () {
$('#copy-json').html(`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" aria-label="" aria-labelledby="icon_start" x="0px" y="0px" role="img" class="inline false"><title id="icon_start" lang="en"></title><g fill="currentColor"><path d="M16 1H4C2.9 1 2 1.9 2 3V17H4V3H16V1ZM19 5H8C6.9 5 6 5.9 6 7V21C6 22.1 6.9 23 8 23H19C20.1 23 21 22.1 21 21V7C21 5.9 20.1 5 19 5ZM19 21H8V7H19V21Z"></path></g></svg>`)
}, 1000)
})
// tabs logic
$("#charts-tab").on("click", (e) => {
$("#charts-tab").addClass("active")
$("#json-tab").removeClass("active")
$("#index-tree").removeClass("hidden")
$("#charts-col").removeClass("hidden")
$("#json-output").addClass("hidden")
})
$("#json-tab").on("click", (e) => {
$("#json-tab").addClass("active")
$("#charts-tab").removeClass("active")
$("#index-tree").addClass("hidden")
$("#charts-col").addClass("hidden")
$("#json-output").removeClass("hidden")
})
//counters toggle
$("#counters-title").on("click", (e) => {
$('#customCountersTable').hasClass("hidden") ? $('#customCountersTable').removeClass("hidden") : $('#customCountersTable').addClass("hidden")
$('#counters-title').hasClass("chevron-down") ? $('#counters-title').removeClass("chevron-down") : $('#counters-title').addClass("chevron-down")
})
const iconDuration = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" aria-label="Duration" aria-labelledby="icon_duration" x="0px" y="0px" role="img"><title id="icon_duration" lang="en">Duration</title><g fill="#9B9B9B"><path d="M15 1H9V3H15V1ZM11 14H13V8H11V14ZM19.03 7.39L20.45 5.97C20.02 5.46 19.55 4.98 19.04 4.56L17.62 5.98C16.07 4.74 14.12 4 12 4C7.03 4 3 8.03 3 13C3 17.97 7.02 22 12 22C16.98 22 21 17.97 21 13C21 10.88 20.26 8.93 19.03 7.39ZM12 20C8.13 20 5 16.87 5 13C5 9.13 8.13 6 12 6C15.87 6 19 9.13 19 13C19 16.87 15.87 20 12 20Z"></path></g></svg>`
const checkCircle = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-check-circle" viewBox="0 0 16 16">
<path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z"/>
<path d="M10.97 4.97a.235.235 0 0 0-.02.022L7.477 9.417 5.384 7.323a.75.75 0 0 0-1.06 1.06L6.97 11.03a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 0 0-1.071-1.05z"/>
</svg>`
const xCircle = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" aria-label="Regions" aria-labelledby="icon_regions" x="0px" y="0px" role="img"><title id="icon_regions" lang="en">Regions</title><g fill="#9B9B9B"><path d="M12 2C6.47 2 2 6.47 2 12C2 17.53 6.47 22 12 22C17.53 22 22 17.53 22 12C22 6.47 17.53 2 12 2ZM12 20C7.59 20 4 16.41 4 12C4 7.59 7.59 4 12 4C16.41 4 20 7.59 20 12C20 16.41 16.41 20 12 20ZM15.59 7L12 10.59L8.41 7L7 8.41L10.59 12L7 15.59L8.41 17L12 13.41L15.59 17L17 15.59L13.41 12L17 8.41L15.59 7Z"></path></g></svg>`
const iconStarted = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" aria-label="Started" aria-labelledby="icon_started" x="0px" y="0px" role="img"><title id="icon_started" lang="en">Started</title><g fill="#9B9B9B"><path d="M11.99 2C6.47 2 2 6.48 2 12C2 17.52 6.47 22 11.99 22C17.52 22 22 17.52 22 12C22 6.48 17.52 2 11.99 2ZM12 20C7.58 20 4 16.42 4 12C4 7.58 7.58 4 12 4C16.42 4 20 7.58 20 12C20 16.42 16.42 20 12 20ZM12.5 7H11V13L16.25 16.15L17 14.92L12.5 12.25V7Z"></path></g></svg>`
const iconFinished = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" aria-label="Finished" aria-labelledby="icon_finished" x="0px" y="0px" role="img"><title id="icon_finished" lang="en">Finished</title><g fill="#9B9B9B"><path d="M12 2C6.48 2 2 6.48 2 12C2 17.52 6.48 22 12 22C17.52 22 22 17.52 22 12C22 6.48 17.52 2 12 2ZM12 20C7.59 20 4 16.41 4 12C4 7.59 7.59 4 12 4C16.41 4 20 7.59 20 12C20 16.41 16.41 20 12 20ZM16.59 7.58L10 14.17L7.41 11.59L6 13L10 17L18 9L16.59 7.58Z"></path></g></svg>`
// summary blocks
const timeStarted = moment(Report.aggregate.firstMetricAt)
const timeFinished = moment(Report.aggregate.lastMetricAt)
function formatDuration(s) {
var min = Math.floor(s / 60)
var sec = s - min * 60
return min + "m " + sec + "s"
}
const summaryInfo = [
{ icon: iconDuration, name: "Duration", value: formatDuration(timeFinished.diff(timeStarted, "seconds")) || "n/a" },
{ icon: iconStarted, name: "Started", value: timeStarted.format(timeFormat) || "n/a" },
{ icon: iconFinished, name: "Completed", value: timeFinished.format(timeFormat) || "n/a" },
{ icon: xCircle, name: "Errors", value: !errors ? "n/a" : errors.length ? errors.length : "0" },
]
function summaryBlock(block) {
return (
`<li class="summary-block flex flex-auto items-center justify-start rounded py-2 px-3 mb-3 border-gray" >
<div class="mr-3 text-gray-default">`+
block.icon +
`</div>
<div><div class="text-gray-default text-xsm">`+
block.name +
`</div>
<div class="text-xsm">
`+ block.value + `
</div>
</div>
</li>`
)
}
summaryInfo.forEach((block) => {
const appendage = summaryBlock(block)
$("#summary-blocks").append(appendage);
})
if (l.size(errors) > 0) {
const getErrorsAtIntervalsData = (intermediates = []) => {
const data = intermediates.reduce(
(acc, entry, idx) => {
const errorsCounters = l.pickBy(entry.counters, (_, key) =>
key.startsWith("errors.")
);
l.each(errorsCounters, (count, key) => {
const [, errorDetail] = key.split("errors.");
acc.values[errorDetail] = acc.values[errorDetail] || [];
acc.values[errorDetail].push(count);
});
acc.labels.push((idx + 1) * 10);
return acc;
},
{ labels: [], values: {} }
);
return {
labels: data.labels,
datasets: l.map(data.values, (entry, key) => {
return {
label: key,
data: entry,
fill: false,
backgroundColor: Object.values(chartBorderColors),
borderColor: Object.values(chartBorderColors),
tension: 0.5,
};
})
};
};
new Chart(document.getElementById("errorsAtIntervalsChart"), {
type: "line",
data: getErrorsAtIntervalsData(Report.intermediate),
options: {
plugins: { legend: { position: "bottom" } },
aspectRatio: 3.5,
scales: {
y: {
beginAtZero: true,
title: {
display: true,
text: "ms",
},
},
},
},
});
}
!errors.length && $("#errorsChartsRow").hide();
const unorderedCustomCounters = Report.aggregate.counters;
const customCounters = Object.keys(unorderedCustomCounters).sort().reduce(
(obj, key) => {
obj[key] = unorderedCustomCounters[key];
return obj;
},
{}
);
if (l.size(customCounters) > 0) {
let rows = [];
l.each(customCounters, function (count, key) {
const row = $("<tr></tr>")
.append($('<td class="text-xsm whitespace-nowrap p-2 font-normal text-white" colspan="6">' + key + '</td>'))
.append($('<td class="text-xsm whitespace-nowrap p-2 font-normal text-white" colspan="6">' + count + '</td>'));
rows.push(row);
});
rows.forEach((row) => row.appendTo($("#customCountersTable")));
const getCustomStatsAtIntervalsData = (intermediates = []) => {
const data = intermediates.reduce(
(acc, entry, idx) => {
const customCounters = entry.counters;
l.each(customCounters, (count, key) => {
acc.values[key] = acc.values[key] || [];
acc.values[key].push(count);
});
acc.labels.push((idx + 1) * 10);
return acc;
},
{ labels: [], values: {} }
);
return {
labels: data.labels,
datasets: l.map(data.values, (entry, key) => {
color = "#0047FF";
return {
label: key,
data: entry,
fill: false,
backgroundColor: color,
borderColor: color,
tension: 0.5,
};
}),
};
};
$("#expandCustomCountersRow").on("click", (e) => {
e.preventDefault();
$("#customCountersTable tr").removeClass("hidden");
$("#expandCustomCountersRow").addClass("hidden");
});
// create intermediate charts array with name and type
let intervalChartsArray = []
Report.intermediate.forEach((interval, i) => {
Object.keys(interval.counters).forEach((counter) => {
intervalChartsArray.find((chart) => chart.name == counter) || intervalChartsArray.push({ name: counter, data: [], type: "interval" })
})
})
let intervalChartsSet = []
intervalChartsArray.forEach((c) => {
if (!intervalChartsSet.includes(c)) {
intervalChartsSet.push(c);
}
});
// add data per interval for each chart
intervalChartsSet.forEach((chart, i) => {
Report.intermediate.forEach((interval, j) => {
const value = interval.counters[chart.name] || 0
intervalChartsSet[i].data.push({ counters: { [chart.name]: value } })
})
})
// add summary data
let aggregateChartsArray = []
Object.keys(Report.aggregate.summaries).forEach((summary) => {
const data = Report.aggregate.summaries[summary]
aggregateChartsArray.push({ name: summary, data: data, type: "aggregate" })
})
let chartsSet = [...intervalChartsSet, ...aggregateChartsArray].sort((a, b) => a.name < b.name ? -1 : 1)
const sanitizer = /[.| |'|"]/g
chartsSet.forEach((chart) => {
$('#customCountersAtIntervalsChart').append("<div id='" + chart.name.replaceAll(sanitizer, "-")
+ "-wrapper' class='text-xsm rounded' style='border: 1px solid #383838;'><div class='p-2 text-gray-default' style='border-bottom: 1px solid #383838; background-color: #2b2b2b; font-weight: 500;''>"
+ chart.name + "</div><div class='p-4'><canvas id='" + chart.name + "'>unable to create chart</canvas></div></div>")
if (chart.type === 'interval') {
new Chart(document.getElementById(chart.name), {
type: "bar",
data: getCustomStatsAtIntervalsData(chart.data),
options: {
barPercentage: 0.2,
plugins: { legend: { display: false } },
aspectRatio: 2.5,
responsive: true,
maintainAspectRatio: true,
scales: {
x: {
title: {
display: true,
text: "time"
},
ticks: {
color: '#9b9b9b',
},
grid: {
color: 'transparent',
borderColor: '#383838',
},
},
y: {
beginAtZero: true,
title: {
display: true,
text: "ms",
},
ticks: {
color: '#9b9b9b',
precision: 0,
},
grid: {
color: '#383838',
borderColor: '#383838',
},
},
},
},
});
} else if (chart.type === 'aggregate') {
const { labels, values } = getLatencyDistribution(
l.pickBy(chart.data, (_, key) =>
["min", "max", "median", "p95", "p99"].includes(key)
)
);
new Chart(document.getElementById(chart.name), {
type: "bar",
data: {
labels: labels,
datasets: [
{
data: values,
backgroundColor: Object.values(chartBorderColors),
borderColor: Object.values(chartBgColors),
borderWidth: 1,
},
],
},
options: {
plugins: { legend: { display: false } },
barPercentage: 0.4,
scales: {
x: {
ticks: {
color: '#9b9b9b',
precision: 0,
},
grid: {
color: 'transparent',
borderColor: '#383838',
},
},
y: {
beginAtZero: true,
title: {
display: true,
text: "ms",
},
ticks: {
color: '#9b9b9b',
precision: 0,
},
grid: {
color: '#383838',
borderColor: '#383838',
},
},
},
},
})
}
})
// parse out index tabs from custom counters for index nav
const parentRegex = /^([^.| ]+)/
const nodeRegex = /[ |\.](.*)/
let indexSet = new Set(chartsSet.map((c) => {
return c.name.match(parentRegex)[0]
}))