Skip to content

Commit

Permalink
New HTTPTotal Metric for all http requests (#134)
Browse files Browse the repository at this point in the history
adds new HTTPTotal metric all requests by http_version:
```
fastly_rt_http_total{datacenter="BUR",http_version="1"}
fastly_rt_http_total{datacenter="BUR",http_version="2"}
fastly_rt_http_total{datacenter="BUR",http_version="3"}
```

This PR _does not_ remove the existing HTTP2Total or HTTP3Total metrics
so as not to introduce a breaking change.
  • Loading branch information
leklund authored Jun 26, 2023
1 parent b45aca3 commit 4b2196f
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 3 deletions.
2 changes: 2 additions & 0 deletions pkg/realtime/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ type Metrics struct {
FanoutSendPublishesTotal *prometheus.CounterVec
FetchSubCountTotal *prometheus.CounterVec
FetchSubTimeTotal *prometheus.CounterVec
HTTPTotal *prometheus.CounterVec
HTTP2Total *prometheus.CounterVec
HTTP3Total *prometheus.CounterVec
HashSubCountTotal *prometheus.CounterVec
Expand Down Expand Up @@ -278,6 +279,7 @@ func NewMetrics(namespace, subsystem string, nameFilter filter.Filter, r prometh
FanoutSendPublishesTotal: prometheus.NewCounterVec(prometheus.CounterOpts{Namespace: namespace, Subsystem: subsystem, Name: "fanout_send_publishes_total", Help: "Total published messages sent to end users."}, []string{"service_id", "service_name", "datacenter"}),
FetchSubCountTotal: prometheus.NewCounterVec(prometheus.CounterOpts{Namespace: namespace, Subsystem: subsystem, Name: "fetch_sub_count_total", Help: "Number of executions of the 'fetch' Varnish subroutine."}, []string{"service_id", "service_name", "datacenter"}),
FetchSubTimeTotal: prometheus.NewCounterVec(prometheus.CounterOpts{Namespace: namespace, Subsystem: subsystem, Name: "fetch_sub_time_total", Help: "Time spent inside the 'fetch' Varnish subroutine (in seconds)."}, []string{"service_id", "service_name", "datacenter"}),
HTTPTotal: prometheus.NewCounterVec(prometheus.CounterOpts{Namespace: namespace, Subsystem: subsystem, Name: "http_total", Help: "Number of requests received, by HTTP version."}, []string{"service_id", "service_name", "datacenter", "http_version"}),
HTTP2Total: prometheus.NewCounterVec(prometheus.CounterOpts{Namespace: namespace, Subsystem: subsystem, Name: "http2_total", Help: "Number of requests received over HTTP2."}, []string{"service_id", "service_name", "datacenter"}),
HTTP3Total: prometheus.NewCounterVec(prometheus.CounterOpts{Namespace: namespace, Subsystem: subsystem, Name: "http3_total", Help: "Number of requests received over HTTP3."}, []string{"service_id", "service_name", "datacenter"}),
HashSubCountTotal: prometheus.NewCounterVec(prometheus.CounterOpts{Namespace: namespace, Subsystem: subsystem, Name: "hash_sub_count_total", Help: "Number of executions of the 'hash' Varnish subroutine."}, []string{"service_id", "service_name", "datacenter"}),
Expand Down
3 changes: 3 additions & 0 deletions pkg/realtime/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ func Process(response *Response, serviceID, serviceName, serviceVersion string,
m.FanoutSendPublishesTotal.WithLabelValues(serviceID, serviceName, datacenter).Add(float64(stats.FanoutSendPublishes))
m.FetchSubCountTotal.WithLabelValues(serviceID, serviceName, datacenter).Add(float64(stats.FetchSubCount))
m.FetchSubTimeTotal.WithLabelValues(serviceID, serviceName, datacenter).Add(float64(stats.FetchSubTime))
m.HTTPTotal.WithLabelValues(serviceID, serviceName, datacenter, "1").Add(float64(stats.Requests - (stats.HTTP2 + stats.HTTP3)))
m.HTTPTotal.WithLabelValues(serviceID, serviceName, datacenter, "2").Add(float64(stats.HTTP2))
m.HTTPTotal.WithLabelValues(serviceID, serviceName, datacenter, "3").Add(float64(stats.HTTP3))
m.HTTP2Total.WithLabelValues(serviceID, serviceName, datacenter).Add(float64(stats.HTTP2))
m.HTTP3Total.WithLabelValues(serviceID, serviceName, datacenter).Add(float64(stats.HTTP3))
m.HashSubCountTotal.WithLabelValues(serviceID, serviceName, datacenter).Add(float64(stats.HashSubCount))
Expand Down
36 changes: 33 additions & 3 deletions pkg/rt/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ const rtResponseFixture = `{
{
"datacenter": {
"BUR": {
"requests": 1,
"requests": 2,
"tls": 1,
"http2": 1,
"http3": 0,
Expand Down Expand Up @@ -790,7 +790,7 @@ const rtResponseFixture = `{
}
},
"aggregated": {
"requests": 1,
"requests": 2,
"tls": 1,
"http2": 1,
"http3": 0,
Expand Down Expand Up @@ -2803,6 +2803,36 @@ var expetedMetricsOutputMap = map[string]float64{
`testspace_testsystem_hits_total{datacenter="TYO",service_id="my-service-id",service_name="my-service-name"}`: 1,
`testspace_testsystem_hits_total{datacenter="YUL",service_id="my-service-id",service_name="my-service-name"}`: 0,
`testspace_testsystem_hits_total{datacenter="YYZ",service_id="my-service-id",service_name="my-service-name"}`: 1,
`testspace_testsystem_http_total{datacenter="BUR",http_version="1",service_id="my-service-id",service_name="my-service-name"}`: 1,
`testspace_testsystem_http_total{datacenter="BWI",http_version="1",service_id="my-service-id",service_name="my-service-name"}`: 1,
`testspace_testsystem_http_total{datacenter="FRA",http_version="1",service_id="my-service-id",service_name="my-service-name"}`: 1,
`testspace_testsystem_http_total{datacenter="HHN",http_version="1",service_id="my-service-id",service_name="my-service-name"}`: 0,
`testspace_testsystem_http_total{datacenter="LGA",http_version="1",service_id="my-service-id",service_name="my-service-name"}`: 0,
`testspace_testsystem_http_total{datacenter="SEA",http_version="1",service_id="my-service-id",service_name="my-service-name"}`: 1,
`testspace_testsystem_http_total{datacenter="SYD",http_version="1",service_id="my-service-id",service_name="my-service-name"}`: 1,
`testspace_testsystem_http_total{datacenter="TYO",http_version="1",service_id="my-service-id",service_name="my-service-name"}`: 2,
`testspace_testsystem_http_total{datacenter="YUL",http_version="1",service_id="my-service-id",service_name="my-service-name"}`: 2,
`testspace_testsystem_http_total{datacenter="YYZ",http_version="1",service_id="my-service-id",service_name="my-service-name"}`: 1,
`testspace_testsystem_http_total{datacenter="BUR",http_version="2",service_id="my-service-id",service_name="my-service-name"}`: 1,
`testspace_testsystem_http_total{datacenter="BWI",http_version="2",service_id="my-service-id",service_name="my-service-name"}`: 0,
`testspace_testsystem_http_total{datacenter="FRA",http_version="2",service_id="my-service-id",service_name="my-service-name"}`: 0,
`testspace_testsystem_http_total{datacenter="HHN",http_version="2",service_id="my-service-id",service_name="my-service-name"}`: 15,
`testspace_testsystem_http_total{datacenter="LGA",http_version="2",service_id="my-service-id",service_name="my-service-name"}`: 32,
`testspace_testsystem_http_total{datacenter="SEA",http_version="2",service_id="my-service-id",service_name="my-service-name"}`: 0,
`testspace_testsystem_http_total{datacenter="SYD",http_version="2",service_id="my-service-id",service_name="my-service-name"}`: 0,
`testspace_testsystem_http_total{datacenter="TYO",http_version="2",service_id="my-service-id",service_name="my-service-name"}`: 0,
`testspace_testsystem_http_total{datacenter="YUL",http_version="2",service_id="my-service-id",service_name="my-service-name"}`: 0,
`testspace_testsystem_http_total{datacenter="YYZ",http_version="2",service_id="my-service-id",service_name="my-service-name"}`: 0,
`testspace_testsystem_http_total{datacenter="BUR",http_version="3",service_id="my-service-id",service_name="my-service-name"}`: 0,
`testspace_testsystem_http_total{datacenter="BWI",http_version="3",service_id="my-service-id",service_name="my-service-name"}`: 0,
`testspace_testsystem_http_total{datacenter="FRA",http_version="3",service_id="my-service-id",service_name="my-service-name"}`: 0,
`testspace_testsystem_http_total{datacenter="HHN",http_version="3",service_id="my-service-id",service_name="my-service-name"}`: 8,
`testspace_testsystem_http_total{datacenter="LGA",http_version="3",service_id="my-service-id",service_name="my-service-name"}`: 25,
`testspace_testsystem_http_total{datacenter="SEA",http_version="3",service_id="my-service-id",service_name="my-service-name"}`: 0,
`testspace_testsystem_http_total{datacenter="SYD",http_version="3",service_id="my-service-id",service_name="my-service-name"}`: 0,
`testspace_testsystem_http_total{datacenter="TYO",http_version="3",service_id="my-service-id",service_name="my-service-name"}`: 0,
`testspace_testsystem_http_total{datacenter="YUL",http_version="3",service_id="my-service-id",service_name="my-service-name"}`: 0,
`testspace_testsystem_http_total{datacenter="YYZ",http_version="3",service_id="my-service-id",service_name="my-service-name"}`: 0,
`testspace_testsystem_http2_total{datacenter="BUR",service_id="my-service-id",service_name="my-service-name"}`: 1,
`testspace_testsystem_http2_total{datacenter="BWI",service_id="my-service-id",service_name="my-service-name"}`: 0,
`testspace_testsystem_http2_total{datacenter="FRA",service_id="my-service-id",service_name="my-service-name"}`: 0,
Expand Down Expand Up @@ -3774,7 +3804,7 @@ var expetedMetricsOutputMap = map[string]float64{
`testspace_testsystem_req_header_bytes_total{datacenter="TYO",service_id="my-service-id",service_name="my-service-name"}`: 845,
`testspace_testsystem_req_header_bytes_total{datacenter="YUL",service_id="my-service-id",service_name="my-service-name"}`: 1186,
`testspace_testsystem_req_header_bytes_total{datacenter="YYZ",service_id="my-service-id",service_name="my-service-name"}`: 441,
`testspace_testsystem_requests_total{datacenter="BUR",service_id="my-service-id",service_name="my-service-name"}`: 1,
`testspace_testsystem_requests_total{datacenter="BUR",service_id="my-service-id",service_name="my-service-name"}`: 2,
`testspace_testsystem_requests_total{datacenter="BWI",service_id="my-service-id",service_name="my-service-name"}`: 1,
`testspace_testsystem_requests_total{datacenter="FRA",service_id="my-service-id",service_name="my-service-name"}`: 1,
`testspace_testsystem_requests_total{datacenter="HHN",service_id="my-service-id",service_name="my-service-name"}`: 23,
Expand Down

0 comments on commit 4b2196f

Please sign in to comment.