@@ -49,6 +49,7 @@ type httpMetrics struct {
49
49
serverResponseBytes * stats.Int64Measure
50
50
serverLatency * stats.Float64Measure
51
51
serverRequestCount * stats.Int64Measure
52
+ serverResponseCount * stats.Int64Measure
52
53
53
54
clientSentBytes * stats.Int64Measure
54
55
clientReceivedBytes * stats.Int64Measure
@@ -83,6 +84,10 @@ func newHTTPMetrics() *httpMetrics {
83
84
"http/server/request_count" ,
84
85
"Count of HTTP requests processed by the server." ,
85
86
stats .UnitDimensionless ),
87
+ serverResponseCount : stats .Int64 (
88
+ "http/server/response_count" ,
89
+ "The number of HTTP responses" ,
90
+ stats .UnitDimensionless ),
86
91
clientSentBytes : stats .Int64 (
87
92
"http/client/sent_bytes" ,
88
93
"Total bytes sent in request body (not including headers)" ,
@@ -130,6 +135,10 @@ func (h *httpMetrics) ServerRequestCompleted(ctx context.Context, method, path,
130
135
ctx ,
131
136
diagUtils .WithTags (h .serverLatency .Name (), appIDKey , h .appID , httpMethodKey , method , httpPathKey , path , httpStatusCodeKey , status ),
132
137
h .serverLatency .M (elapsed ))
138
+ stats .RecordWithTags (
139
+ ctx ,
140
+ diagUtils .WithTags (h .serverResponseCount .Name (), appIDKey , h .appID , httpPathKey , path , httpMethodKey , method , httpStatusCodeKey , status ),
141
+ h .serverResponseCount .M (1 ))
133
142
} else {
134
143
stats .RecordWithTags (
135
144
ctx ,
@@ -234,7 +243,8 @@ func (h *httpMetrics) Init(appID string, legacy bool) error {
234
243
serverTags = []tag.Key {appIDKey , httpMethodKey , httpStatusCodeKey }
235
244
clientTags = []tag.Key {appIDKey , httpStatusCodeKey }
236
245
}
237
- return view .Register (
246
+
247
+ views := []* view.View {
238
248
diagUtils .NewMeasureView (h .serverRequestBytes , tags , defaultSizeDistribution ),
239
249
diagUtils .NewMeasureView (h .serverResponseBytes , tags , defaultSizeDistribution ),
240
250
diagUtils .NewMeasureView (h .serverLatency , serverTags , defaultLatencyDistribution ),
@@ -245,7 +255,13 @@ func (h *httpMetrics) Init(appID string, legacy bool) error {
245
255
diagUtils .NewMeasureView (h .clientCompletedCount , clientTags , view .Count ()),
246
256
diagUtils .NewMeasureView (h .healthProbeRoundripLatency , []tag.Key {appIDKey , httpStatusCodeKey }, defaultLatencyDistribution ),
247
257
diagUtils .NewMeasureView (h .healthProbeCompletedCount , []tag.Key {appIDKey , httpStatusCodeKey }, view .Count ()),
248
- )
258
+ }
259
+
260
+ if h .legacy {
261
+ views = append (views , diagUtils .NewMeasureView (h .serverResponseCount , serverTags , view .Count ()))
262
+ }
263
+
264
+ return view .Register (views ... )
249
265
}
250
266
251
267
// HTTPMiddleware is the middleware to track HTTP server-side requests.
0 commit comments