fix:更新日志统计数据&增加消息缓冲区的时间戳

This commit is contained in:
nnbcccscdscdsc
2026-03-24 15:38:21 +08:00
parent b79bb082ab
commit 1cb964c30b
7 changed files with 136 additions and 38 deletions

View File

@@ -131,6 +131,23 @@ const summaryChartHTMLTemplate = `<!doctype html>
font-size: 13px;
margin-bottom: 12px;
}
.ratio-list {
display: flex;
flex-wrap: wrap;
gap: 8px;
margin: -2px 0 12px;
}
.ratio-pill {
display: inline-flex;
align-items: center;
padding: 6px 10px;
border-radius: 999px;
border: 1px solid var(--border);
background: #f7f9fc;
color: var(--text);
font-size: 12px;
line-height: 1.2;
}
.bar {
height: 24px;
display: flex;
@@ -216,6 +233,13 @@ const summaryChartHTMLTemplate = `<!doctype html>
</div>
<div class="row-meta">{{.Subtitle}}</div>
<div class="row-meta">{{.ApproxRTT}}</div>
{{if .RatioMetrics}}
<div class="ratio-list">
{{range .RatioMetrics}}
<span class="ratio-pill">{{.Label}} {{.Value}}</span>
{{end}}
</div>
{{end}}
<div class="bar">
{{range .Segments}}
<div class="segment" style="width: {{printf "%.4f" .WidthPercent}}%; background: {{.Color}}" title="{{.Label}}: {{.Value}}"></div>
@@ -265,6 +289,7 @@ type summaryChartRow struct {
EndToEnd string
ApproxRTT string
MissingTimestamps string
RatioMetrics []summaryChartValue
Segments []summaryChartSegment
}
@@ -275,6 +300,11 @@ type summaryChartSegment struct {
WidthPercent float64
}
type summaryChartValue struct {
Label string
Value string
}
type summaryChartSegmentMetric struct {
label string
value *int64
@@ -366,6 +396,24 @@ func buildSummaryChartRow(summary Summary) summaryChartRow {
row.ApproxRTT = fmt.Sprintf("Approx RTT: %s", formatLatencyNS(*summary.ApproxRTTNS))
}
ratioMetrics := []struct {
label string
value *float64
}{
{label: "A processing bitrate", value: summary.AProcessingBitrateBPS},
{label: "A-B transport + propagation bitrate", value: summary.ABTransportPropagationBitrateBPS},
{label: "End-to-end bitrate", value: summary.EndToEndBitrateBPS},
}
for _, metric := range ratioMetrics {
if metric.value == nil || *metric.value <= 0 {
continue
}
row.RatioMetrics = append(row.RatioMetrics, summaryChartValue{
Label: metric.label,
Value: formatBitrateBPS(*metric.value),
})
}
if summary.EndToEndLatencyNS == nil || *summary.EndToEndLatencyNS <= 0 {
return row
}
@@ -444,3 +492,7 @@ func buildSummaryChartSubtitle(summary Summary) string {
func formatLatencyNS(ns int64) string {
return fmt.Sprintf("%.3f ms", float64(ns)/1_000_000)
}
func formatBitrateBPS(bitsPerSecond float64) string {
return fmt.Sprintf("%.3f Mb/s", bitsPerSecond/1_000_000)
}