-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add metrics server #14
Conversation
…eci to GHA Signed-off-by: Hsn723 <[email protected]>
Signed-off-by: Hsn723 <[email protected]>
Signed-off-by: Hsn723 <[email protected]>
Signed-off-by: Hsn723 <[email protected]>
Signed-off-by: Hsn723 <[email protected]>
Signed-off-by: Hsn723 <[email protected]>
Signed-off-by: Hsn723 <[email protected]>
Signed-off-by: Hsn723 <[email protected]>
Signed-off-by: Hsn723 <[email protected]>
Signed-off-by: Hsn723 <[email protected]>
@pddg I got notified and found that the CI was failing because of CircleCI. |
socks/metrics.go
Outdated
socksResponseCounter = promauto.With(metrics.Registry).NewCounterVec(prometheus.CounterOpts{ | ||
Namespace: metrics.Namespace, | ||
Subsystem: "socks", | ||
Name: "responses_total", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
このメトリクスの値はリクエスト数と一致するはずなので、requests_total
にしたほうが慣習的な気がします
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The number of requests and responses do not always seem to match.
This is because if the request is not a correct SOCKS request, these are dropped.
Lines 128 to 156 in 03fb5bd
var preamble [2]byte | |
_, err := io.ReadFull(conn, preamble[:]) | |
if err != nil { | |
fields := well.FieldsFromContext(ctx) | |
fields["client_addr"] = conn.RemoteAddr().String() | |
fields[log.FnError] = err.Error() | |
_ = s.Logger.Error("failed to read preamble", fields) | |
return | |
} | |
connVer := version(preamble[0]) | |
var destConn net.Conn | |
switch connVer { | |
case SOCKS4: | |
destConn = s.handleSOCKS4(ctx, conn, preamble[1]) | |
if destConn == nil { | |
return | |
} | |
case SOCKS5: | |
destConn = s.handleSOCKS5(ctx, conn, preamble[1]) | |
if destConn == nil { | |
return | |
} | |
default: | |
fields := well.FieldsFromContext(ctx) | |
fields["client_addr"] = conn.RemoteAddr().String() | |
_ = s.Logger.Error("unknown SOCKS version", fields) | |
return | |
} |
Do you think we should count the number of these incorrect requests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recognized that the word "request" is ambiguous.
How about keeping the number of connections as a metric to clarify what counts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does that mean that even invalid SOCKS protocol connections count?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
The labels "reason" and "msg" have been removed. These could receive arbitrary error messages and could unnecessarily increase cardinality or contain strings that were not appropriate as labels. |
config_test.go
Outdated
@@ -30,6 +30,9 @@ func TestConfig(t *testing.T) { | |||
if c.Incoming.Port != 1080 { | |||
t.Error("incoming.port != 1080") | |||
} | |||
if c.Incoming.MetricsPort != 8081 { | |||
t.Error("incoming.port != 1080") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
8081?
These days, I use https://github.com/stretchr/testify to write this kind of tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wrote it by copying and pasting, sorry :(
This is a simple struct comparison, and I believe google/go-cmp is more appropriate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will fix this, soon.
Close #11
See #13 to get more detail.