@@ -30,6 +30,7 @@ type Metrics struct {
3030 impressions * prometheus.CounterVec
3131 prebidCacheWriteTimer * prometheus.HistogramVec
3232 requests * prometheus.CounterVec
33+ requestsSize * prometheus.HistogramVec
3334 debugRequests prometheus.Counter
3435 requestsTimer * prometheus.HistogramVec
3536 requestsQueueTimer * prometheus.HistogramVec
@@ -127,6 +128,7 @@ const (
127128 privacyBlockedLabel = "privacy_blocked"
128129 requestStatusLabel = "request_status"
129130 requestTypeLabel = "request_type"
131+ requestEndpointLabel = "request_size"
130132 stageLabel = "stage"
131133 statusLabel = "status"
132134 successLabel = "success"
@@ -171,6 +173,7 @@ func NewMetrics(cfg config.PrometheusMetrics, disabledMetrics config.DisabledMet
171173 priceBuckets := []float64 {250 , 500 , 750 , 1000 , 1500 , 2000 , 2500 , 3000 , 3500 , 4000 }
172174 queuedRequestTimeBuckets := []float64 {0 , 1 , 5 , 30 , 60 , 120 , 180 , 240 , 300 }
173175 overheadTimeBuckets := []float64 {0.05 , 0.06 , 0.07 , 0.08 , 0.09 , 0.1 , 0.2 , 0.3 , 0.4 , 0.5 , 0.6 , 0.7 , 0.8 , 0.9 , 1 }
176+ requestSizeBuckets := []float64 {100 , 500 , 750 , 1000 , 2000 , 4000 , 7000 , 10000 , 15000 , 20000 , 50000 , 75000 }
174177
175178 metrics := Metrics {}
176179 reg := prometheus .NewRegistry ()
@@ -227,6 +230,11 @@ func NewMetrics(cfg config.PrometheusMetrics, disabledMetrics config.DisabledMet
227230 "Count of total requests to Prebid Server labeled by type and status." ,
228231 []string {requestTypeLabel , requestStatusLabel })
229232
233+ metrics .requestsSize = newHistogramVec (cfg , reg ,
234+ "request_size_bytes" ,
235+ "Count that keeps track of incoming request size in bytes labeled by endpoint." ,
236+ []string {requestEndpointLabel }, requestSizeBuckets )
237+
230238 metrics .debugRequests = newCounterWithoutLabels (cfg , reg ,
231239 "debug_requests" ,
232240 "Count of total requests to Prebid Server that have debug enabled" )
@@ -682,6 +690,13 @@ func (m *Metrics) RecordRequest(labels metrics.Labels) {
682690 requestStatusLabel : string (labels .RequestStatus ),
683691 }).Inc ()
684692
693+ if labels .RequestSize > 0 && labels .RType != metrics .ReqTypeAMP {
694+ endpoint := metrics .GetEndpointFromRequestType (labels .RType )
695+ m .requestsSize .With (prometheus.Labels {
696+ requestEndpointLabel : string (endpoint ),
697+ }).Observe (float64 (labels .RequestSize ))
698+ }
699+
685700 if labels .CookieFlag == metrics .CookieFlagNo {
686701 m .requestsWithoutCookie .With (prometheus.Labels {
687702 requestTypeLabel : string (labels .RType ),
0 commit comments