Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
e9ced79a
Unverified
Commit
e9ced79a
authored
Oct 25, 2023
by
felipe
Committed by
GitHub
Oct 25, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #7852 from ethereum-optimism/felipe/op-service-http-latency-metric
feat(op-service): new http latency metric
parents
48a01dac
412ac55e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
1 deletion
+25
-1
http.go
op-service/metrics/http.go
+25
-1
No files found.
op-service/metrics/http.go
View file @
e9ced79a
...
...
@@ -44,21 +44,41 @@ func (n *noopHTTPRecorder) RecordHTTPRequest(*HTTPParams) {}
func
(
n
*
noopHTTPRecorder
)
RecordHTTPResponse
(
*
HTTPParams
)
{}
type
PromHTTPRecorder
struct
{
HTTPRequestDuration
*
prometheus
.
HistogramVec
// HTTPRequestDuration is the old metric for request latency
// it was created with too tight buckets: [.005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10]
// in order to preserve backward compatibility we are keeping this metric for now
// and it will be removed when services opt in to HTTPRequestLatency
// Deprecated: HTTPRequestDuration is deprecated
HTTPRequestDuration
*
prometheus
.
HistogramVec
// HTTPRequestLatency measures request execution latency in *seconds*
// buckets are: [.025, .05, .1, .25, .5, 1, 2.5, 5, 10, 25, 50]
HTTPRequestLatency
*
prometheus
.
HistogramVec
HTTPResponseSize
*
prometheus
.
HistogramVec
HTTPInflightRequests
*
prometheus
.
GaugeVec
HTTPRequests
*
prometheus
.
CounterVec
HTTPResponses
*
prometheus
.
CounterVec
}
var
LatencyBuckets
=
[]
float64
{
.025
,
.05
,
.1
,
.25
,
.5
,
1
,
2.5
,
5
,
10
,
25
,
50
,
100
}
func
NewPromHTTPRecorder
(
r
*
prometheus
.
Registry
,
ns
string
)
HTTPRecorder
{
return
&
PromHTTPRecorder
{
// TODO(INF-509): remove this in the future when services opted in to HTTPRequestLatency
HTTPRequestDuration
:
promauto
.
With
(
r
)
.
NewHistogramVec
(
prometheus
.
HistogramOpts
{
Namespace
:
ns
,
Name
:
"http_request_duration_ms"
,
Help
:
"Tracks HTTP request durations, in ms"
,
Buckets
:
prometheus
.
DefBuckets
,
},
httpLabels
),
HTTPRequestLatency
:
promauto
.
With
(
r
)
.
NewHistogramVec
(
prometheus
.
HistogramOpts
{
Namespace
:
ns
,
Name
:
"http_request_latency_seconds"
,
Help
:
"Tracks HTTP request execution latency, in seconds"
,
Buckets
:
LatencyBuckets
,
},
httpLabels
),
HTTPResponseSize
:
promauto
.
With
(
r
)
.
NewHistogramVec
(
prometheus
.
HistogramOpts
{
Namespace
:
ns
,
Name
:
"http_response_size"
,
...
...
@@ -84,8 +104,12 @@ func NewPromHTTPRecorder(r *prometheus.Registry, ns string) HTTPRecorder {
}
func
(
p
*
PromHTTPRecorder
)
RecordHTTPRequestDuration
(
params
*
HTTPParams
,
dur
time
.
Duration
)
{
// TODO(INF-509): remove this in the future when services opted in to new metric
p
.
HTTPRequestDuration
.
WithLabelValues
(
params
.
Method
,
strconv
.
Itoa
(
params
.
StatusCode
))
.
Observe
(
float64
(
dur
.
Milliseconds
()))
p
.
HTTPRequestLatency
.
WithLabelValues
(
params
.
Method
,
strconv
.
Itoa
(
params
.
StatusCode
))
.
Observe
(
dur
.
Seconds
())
}
func
(
p
*
PromHTTPRecorder
)
RecordHTTPResponseSize
(
params
*
HTTPParams
,
size
int
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment