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
37b44ff7
Commit
37b44ff7
authored
Nov 01, 2021
by
Matthew Slipper
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add proxy method metrics
parent
708c9410
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
203 additions
and
192 deletions
+203
-192
backend.go
go/proxyd/backend.go
+192
-175
server.go
go/proxyd/server.go
+11
-17
No files found.
go/proxyd/backend.go
View file @
37b44ff7
This diff is collapsed.
Click to expand it.
go/proxyd/server.go
View file @
37b44ff7
...
...
@@ -8,8 +8,8 @@ import (
"github.com/gorilla/mux"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/rs/cors"
"io"
"github.com/rs/cors"
"io"
"io/ioutil"
"net/http"
"time"
...
...
@@ -22,17 +22,11 @@ var (
Help
:
"Count of total HTTP requests."
,
})
httpRequestDurationHisto
=
promauto
.
NewHistogram
(
prometheus
.
HistogramOpts
{
Namespace
:
"proxyd"
,
Name
:
"http_request_duration_histogram_seconds"
,
Help
:
"Histogram of HTTP request durations."
,
Buckets
:
[]
float64
{
0
,
0.1
,
0.25
,
0.75
,
1
,
},
httpRequestDurationSummary
=
promauto
.
NewSummary
(
prometheus
.
SummaryOpts
{
Namespace
:
"proxyd"
,
Name
:
"http_request_duration_seconds"
,
Help
:
"Summary of HTTP request durations, in seconds."
,
Objectives
:
map
[
float64
]
float64
{
0.5
:
0.05
,
0.9
:
0.01
,
0.95
:
0.005
,
0.99
:
0.001
},
})
rpcRequestsCtr
=
promauto
.
NewCounterVec
(
prometheus
.
CounterOpts
{
...
...
@@ -96,8 +90,8 @@ func (s *Server) ListenAndServe(host string, port int) error {
hdlr
.
HandleFunc
(
"/healthz"
,
s
.
HandleHealthz
)
.
Methods
(
"GET"
)
hdlr
.
HandleFunc
(
"/"
,
s
.
HandleRPC
)
.
Methods
(
"POST"
)
c
:=
cors
.
New
(
cors
.
Options
{
AllowedOrigins
:
[]
string
{
"*"
},
})
AllowedOrigins
:
[]
string
{
"*"
},
})
addr
:=
fmt
.
Sprintf
(
"%s:%d"
,
host
,
port
)
server
:=
&
http
.
Server
{
Handler
:
instrumentedHdlr
(
c
.
Handler
(
hdlr
)),
...
...
@@ -142,7 +136,7 @@ func (s *Server) HandleRPC(w http.ResponseWriter, r *http.Request) {
return
}
backendRes
,
err
:=
group
.
Forward
(
body
)
backendRes
,
err
:=
group
.
Forward
(
req
)
if
err
!=
nil
{
log
.
Error
(
"error forwarding RPC request"
,
"group"
,
group
.
Name
,
"method"
,
req
.
Method
,
"err"
,
err
)
rpcErrorsCtr
.
WithLabelValues
(
"-32603"
)
.
Inc
()
...
...
@@ -184,6 +178,6 @@ func instrumentedHdlr(h http.Handler) http.HandlerFunc {
start
:=
time
.
Now
()
h
.
ServeHTTP
(
w
,
r
)
dur
:=
time
.
Since
(
start
)
httpRequestDuration
Histo
.
Observe
(
float64
(
dur
)
/
float64
(
time
.
Second
))
httpRequestDuration
Summary
.
Observe
(
float64
(
dur
)
/
float64
(
time
.
Second
))
}
}
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