mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-03 20:27:35 +03:00
metrics: add Prometheus metrics for sent and received packets (#4910)
* add Prometheus metrics for sent long and short header packets * add Prometheus metrics for received long and short header packets * add Grafana panels for sent and received packets
This commit is contained in:
parent
e12f91cfc7
commit
fb9d8e3ede
2 changed files with 266 additions and 3 deletions
|
@ -49,6 +49,22 @@ var (
|
|||
},
|
||||
[]string{"dir"},
|
||||
)
|
||||
packetsSent = prometheus.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Namespace: metricNamespace,
|
||||
Name: "packets_sent_total",
|
||||
Help: "Packets Sent",
|
||||
},
|
||||
[]string{"type"},
|
||||
)
|
||||
packetsReceived = prometheus.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Namespace: metricNamespace,
|
||||
Name: "packets_received_total",
|
||||
Help: "Packets Received",
|
||||
},
|
||||
[]string{"type"},
|
||||
)
|
||||
)
|
||||
|
||||
// DefaultConnectionTracer returns a callback that creates a metrics ConnectionTracer.
|
||||
|
@ -82,6 +98,8 @@ func newConnectionTracerWithRegisterer(registerer prometheus.Registerer, isClien
|
|||
connHandshakeDuration,
|
||||
connClosed,
|
||||
connDuration,
|
||||
packetsSent,
|
||||
packetsReceived,
|
||||
} {
|
||||
if err := registerer.Register(c); err != nil {
|
||||
if ok := errors.As(err, &prometheus.AlreadyRegisteredError{}); !ok {
|
||||
|
@ -188,5 +206,52 @@ func newConnectionTracerWithRegisterer(registerer prometheus.Registerer, isClien
|
|||
*tags = append(*tags, direction)
|
||||
connHandshakeDuration.WithLabelValues(*tags...).Observe(time.Since(startTime).Seconds())
|
||||
},
|
||||
SentLongHeaderPacket: func(hdr *logging.ExtendedHeader, _ logging.ByteCount, _ logging.ECN, _ *logging.AckFrame, _ []logging.Frame) {
|
||||
tags := getStringSlice()
|
||||
defer putStringSlice(tags)
|
||||
|
||||
*tags = append(*tags, longHeaderType(hdr))
|
||||
packetsSent.WithLabelValues(*tags...).Inc()
|
||||
},
|
||||
SentShortHeaderPacket: func(*logging.ShortHeader, logging.ByteCount, logging.ECN, *logging.AckFrame, []logging.Frame) {
|
||||
tags := getStringSlice()
|
||||
defer putStringSlice(tags)
|
||||
|
||||
*tags = append(*tags, "1rtt")
|
||||
packetsSent.WithLabelValues(*tags...).Inc()
|
||||
},
|
||||
ReceivedLongHeaderPacket: func(hdr *logging.ExtendedHeader, _ logging.ByteCount, _ logging.ECN, _ []logging.Frame) {
|
||||
tags := getStringSlice()
|
||||
defer putStringSlice(tags)
|
||||
|
||||
*tags = append(*tags, longHeaderType(hdr))
|
||||
packetsReceived.WithLabelValues(*tags...).Inc()
|
||||
},
|
||||
ReceivedShortHeaderPacket: func(*logging.ShortHeader, logging.ByteCount, logging.ECN, []logging.Frame) {
|
||||
tags := getStringSlice()
|
||||
defer putStringSlice(tags)
|
||||
|
||||
*tags = append(*tags, "1rtt")
|
||||
packetsReceived.WithLabelValues(*tags...).Inc()
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func longHeaderType(hdr *logging.ExtendedHeader) string {
|
||||
//nolint:exhaustive // only these packet types are of interest
|
||||
switch logging.PacketTypeFromHeader(&hdr.Header) {
|
||||
case logging.PacketTypeRetry:
|
||||
return "retry"
|
||||
case logging.PacketTypeInitial:
|
||||
return "initial"
|
||||
case logging.PacketTypeHandshake:
|
||||
return "handshake"
|
||||
case logging.PacketType0RTT:
|
||||
return "0rtt"
|
||||
case logging.PacketTypeStatelessReset:
|
||||
return "stateless_reset"
|
||||
case logging.PacketTypeVersionNegotiation:
|
||||
return "version_negotiation"
|
||||
}
|
||||
return "unknown"
|
||||
}
|
||||
|
|
|
@ -463,7 +463,7 @@
|
|||
"refId": "C"
|
||||
}
|
||||
],
|
||||
"title": "Handshake Latency",
|
||||
"title": "Handshake Duration",
|
||||
"type": "timeseries"
|
||||
},
|
||||
{
|
||||
|
@ -683,6 +683,204 @@
|
|||
],
|
||||
"title": "Connection Durations",
|
||||
"type": "timeseries"
|
||||
},
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "${DS_PROMETHEUS}"
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"color": {
|
||||
"mode": "palette-classic"
|
||||
},
|
||||
"custom": {
|
||||
"axisBorderShow": false,
|
||||
"axisCenteredZero": false,
|
||||
"axisColorMode": "text",
|
||||
"axisLabel": "",
|
||||
"axisPlacement": "auto",
|
||||
"barAlignment": 0,
|
||||
"drawStyle": "line",
|
||||
"fillOpacity": 0,
|
||||
"gradientMode": "none",
|
||||
"hideFrom": {
|
||||
"legend": false,
|
||||
"tooltip": false,
|
||||
"viz": false
|
||||
},
|
||||
"insertNulls": false,
|
||||
"lineInterpolation": "linear",
|
||||
"lineWidth": 1,
|
||||
"pointSize": 5,
|
||||
"scaleDistribution": {
|
||||
"type": "linear"
|
||||
},
|
||||
"showPoints": "auto",
|
||||
"spanNulls": false,
|
||||
"stacking": {
|
||||
"group": "A",
|
||||
"mode": "none"
|
||||
},
|
||||
"thresholdsStyle": {
|
||||
"mode": "off"
|
||||
}
|
||||
},
|
||||
"mappings": [],
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
{
|
||||
"color": "green",
|
||||
"value": null
|
||||
},
|
||||
{
|
||||
"color": "red",
|
||||
"value": 80
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 8,
|
||||
"w": 12,
|
||||
"x": 0,
|
||||
"y": 26
|
||||
},
|
||||
"id": 13,
|
||||
"options": {
|
||||
"legend": {
|
||||
"calcs": [],
|
||||
"displayMode": "list",
|
||||
"placement": "bottom",
|
||||
"showLegend": true
|
||||
},
|
||||
"tooltip": {
|
||||
"mode": "single",
|
||||
"sort": "none"
|
||||
}
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "${DS_PROMETHEUS}"
|
||||
},
|
||||
"disableTextWrap": false,
|
||||
"editorMode": "code",
|
||||
"expr": "sum(rate(quicgo_packets_received_total{instance=~\"$instance\"}[$__rate_interval])) by (type)",
|
||||
"fullMetaSearch": false,
|
||||
"includeNullMetadata": false,
|
||||
"instant": false,
|
||||
"legendFormat": "{{type}}",
|
||||
"range": true,
|
||||
"refId": "A",
|
||||
"useBackend": false
|
||||
}
|
||||
],
|
||||
"title": "Packets Received",
|
||||
"type": "timeseries"
|
||||
},
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "${DS_PROMETHEUS}"
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"color": {
|
||||
"mode": "palette-classic"
|
||||
},
|
||||
"custom": {
|
||||
"axisBorderShow": false,
|
||||
"axisCenteredZero": false,
|
||||
"axisColorMode": "text",
|
||||
"axisLabel": "",
|
||||
"axisPlacement": "auto",
|
||||
"barAlignment": 0,
|
||||
"drawStyle": "line",
|
||||
"fillOpacity": 0,
|
||||
"gradientMode": "none",
|
||||
"hideFrom": {
|
||||
"legend": false,
|
||||
"tooltip": false,
|
||||
"viz": false
|
||||
},
|
||||
"insertNulls": false,
|
||||
"lineInterpolation": "linear",
|
||||
"lineWidth": 1,
|
||||
"pointSize": 5,
|
||||
"scaleDistribution": {
|
||||
"type": "linear"
|
||||
},
|
||||
"showPoints": "auto",
|
||||
"spanNulls": false,
|
||||
"stacking": {
|
||||
"group": "A",
|
||||
"mode": "none"
|
||||
},
|
||||
"thresholdsStyle": {
|
||||
"mode": "off"
|
||||
}
|
||||
},
|
||||
"mappings": [],
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
{
|
||||
"color": "green",
|
||||
"value": null
|
||||
},
|
||||
{
|
||||
"color": "red",
|
||||
"value": 80
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 8,
|
||||
"w": 12,
|
||||
"x": 12,
|
||||
"y": 26
|
||||
},
|
||||
"id": 15,
|
||||
"options": {
|
||||
"legend": {
|
||||
"calcs": [],
|
||||
"displayMode": "list",
|
||||
"placement": "bottom",
|
||||
"showLegend": true
|
||||
},
|
||||
"tooltip": {
|
||||
"mode": "single",
|
||||
"sort": "none"
|
||||
}
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "${DS_PROMETHEUS}"
|
||||
},
|
||||
"disableTextWrap": false,
|
||||
"editorMode": "code",
|
||||
"expr": "sum(rate(quicgo_packets_sent_total{instance=~\"$instance\"}[$__rate_interval])) by (type)",
|
||||
"fullMetaSearch": false,
|
||||
"includeNullMetadata": false,
|
||||
"instant": false,
|
||||
"legendFormat": "{{type}}",
|
||||
"range": true,
|
||||
"refId": "A",
|
||||
"useBackend": false
|
||||
}
|
||||
],
|
||||
"title": "Packets Sent",
|
||||
"type": "timeseries"
|
||||
}
|
||||
],
|
||||
"refresh": "",
|
||||
|
@ -723,6 +921,6 @@
|
|||
"timezone": "",
|
||||
"title": "quic-go",
|
||||
"uid": "afd27180-618a-42ab-99fd-0508776d9c29",
|
||||
"version": 15,
|
||||
"version": 17,
|
||||
"weekStart": ""
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue