Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add rpc exception metrics #2459

Merged
merged 3 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions metrics/rpc/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ func (c *rpcCollector) afterInvokeHandler(event *metricsEvent) {
if event.result != nil {
if event.result.Error() == nil {
c.incRequestsSucceedTotal(role, labels)
} else {
// TODO: Breaking down RPC exceptions further
c.incRequestsFailedTotal(role, labels)
}
}
c.reportRTMilliseconds(role, labels, event.costTime.Milliseconds())
Expand Down Expand Up @@ -149,6 +152,17 @@ func (c *rpcCollector) incRequestsSucceedTotal(role string, labels map[string]st
}
}

func (c *rpcCollector) incRequestsFailedTotal(role string, labels map[string]string) {
switch role {
case constant.SideProvider:
c.metricSet.provider.requestsFailedTotal.Inc(labels)
c.metricSet.provider.requestsFailedTotalAggregate.Inc(labels)
case constant.SideConsumer:
c.metricSet.consumer.requestsFailedTotal.Inc(labels)
c.metricSet.consumer.requestsFailedTotalAggregate.Inc(labels)
}
}

func (c *rpcCollector) reportRTMilliseconds(role string, labels map[string]string, cost int64) {
switch role {
case constant.SideProvider:
Expand Down
10 changes: 8 additions & 2 deletions metrics/rpc/metric_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ type rpcCommonMetrics struct {
requestsProcessingTotal metrics.GaugeVec
requestsSucceedTotal metrics.CounterVec
requestsSucceedTotalAggregate metrics.AggregateCounterVec
requestsFailedTotal metrics.CounterVec
requestsFailedTotalAggregate metrics.AggregateCounterVec
rtMilliseconds metrics.RtVec
rtMillisecondsQuantiles metrics.QuantileMetricVec
rtMillisecondsAggregate metrics.RtVec
Expand All @@ -66,12 +68,14 @@ func (pm *providerMetrics) init(registry metrics.MetricRegistry) {
pm.requestsProcessingTotal = metrics.NewGaugeVec(registry, metrics.NewMetricKey("dubbo_provider_requests_processing_total", "The number of received requests being processed by the provider"))
pm.requestsSucceedTotal = metrics.NewCounterVec(registry, metrics.NewMetricKey("dubbo_provider_requests_succeed_total", "The number of requests successfully received by the provider"))
pm.requestsSucceedTotalAggregate = metrics.NewAggregateCounterVec(registry, metrics.NewMetricKey("dubbo_provider_requests_succeed_total_aggregate", "The number of successful requests received by the provider under the sliding window"))
pm.requestsFailedTotal = metrics.NewCounterVec(registry, metrics.NewMetricKey("dubbo_provider_requests_failed_total", "Total Failed Requests"))
pm.requestsFailedTotalAggregate = metrics.NewAggregateCounterVec(registry, metrics.NewMetricKey("dubbo_provider_requests_failed_total_aggregate", "Total Failed Aggregate Requests"))
pm.rtMilliseconds = metrics.NewRtVec(registry,
metrics.NewMetricKey("dubbo_provider_rt_milliseconds", "response time among all requests processed by the provider"),
&metrics.RtOpts{Aggregate: false},
)
pm.rtMillisecondsAggregate = metrics.NewRtVec(registry,
metrics.NewMetricKey("dubbo_provider_rt_milliseconds", "response time of the provider under the sliding window"),
metrics.NewMetricKey("dubbo_provider_rt", "response time of the provider under the sliding window"),
&metrics.RtOpts{Aggregate: true, BucketNum: metrics.DefaultBucketNum, TimeWindowSeconds: metrics.DefaultTimeWindowSeconds},
)
pm.rtMillisecondsQuantiles = metrics.NewQuantileMetricVec(registry, []*metrics.MetricKey{
Expand All @@ -89,12 +93,14 @@ func (cm *consumerMetrics) init(registry metrics.MetricRegistry) {
cm.requestsProcessingTotal = metrics.NewGaugeVec(registry, metrics.NewMetricKey("dubbo_consumer_requests_processing_total", "The number of received requests being processed by the consumer"))
cm.requestsSucceedTotal = metrics.NewCounterVec(registry, metrics.NewMetricKey("dubbo_consumer_requests_succeed_total", "The number of successful requests sent by consumers"))
cm.requestsSucceedTotalAggregate = metrics.NewAggregateCounterVec(registry, metrics.NewMetricKey("dubbo_consumer_requests_succeed_total_aggregate", "The number of successful requests sent by consumers under the sliding window"))
cm.requestsFailedTotal = metrics.NewCounterVec(registry, metrics.NewMetricKey("dubbo_consumer_requests_failed_total", "Total Failed Requests"))
cm.requestsFailedTotalAggregate = metrics.NewAggregateCounterVec(registry, metrics.NewMetricKey("dubbo_consumer_requests_failed_total_aggregate", "Total Failed Aggregate Requests"))
cm.rtMilliseconds = metrics.NewRtVec(registry,
metrics.NewMetricKey("dubbo_consumer_rt_milliseconds", "response time among all requests from consumers"),
&metrics.RtOpts{Aggregate: false},
)
cm.rtMillisecondsAggregate = metrics.NewRtVec(registry,
metrics.NewMetricKey("dubbo_consumer_rt_milliseconds", "response time of the consumer under the sliding window"),
metrics.NewMetricKey("dubbo_consumer_rt", "response time of the consumer under the sliding window"),
&metrics.RtOpts{Aggregate: true, BucketNum: metrics.DefaultBucketNum, TimeWindowSeconds: metrics.DefaultTimeWindowSeconds},
)
cm.rtMillisecondsQuantiles = metrics.NewQuantileMetricVec(registry, []*metrics.MetricKey{
Expand Down
Loading