-
Notifications
You must be signed in to change notification settings - Fork 183
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
feat: add built-in metrics #421
Conversation
Codecov ReportAttention:
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #421 +/- ##
==========================================
- Coverage 97.00% 96.94% -0.06%
==========================================
Files 76 77 +1
Lines 31588 31671 +83
==========================================
+ Hits 30641 30705 +64
- Misses 796 811 +15
- Partials 151 155 +4 ☔ View full report in Codecov by Sentry. |
rueidisotel/metrics.go
Outdated
.005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10, | ||
} | ||
|
||
var ErrDialFnRequired = errors.New("rueidisotel: clientOption.DialFn is required") |
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.
Could we set a default DialFn instead of throwing this error?
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.
OK. I Change it. e026def
rueidisotel/metrics.go
Outdated
// - rueidis_dial_success: number of successful dials | ||
// - rueidis_dial_conns: number of active connections | ||
// - rueidis_dial_latency: dial latency in seconds | ||
type Client struct { |
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.
Well, I think we should reuse and extend the otelclient
struct.
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 changed it. but It is bit weired.
rueidisotel/metrics.go
Outdated
type connTracker struct { | ||
net.Conn | ||
conns metric.Int64UpDownCounter | ||
once sync.Once |
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.
once sync.Once | |
once int32 |
sync.Once
is overkill. An int32 is enough for this use case.
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.
rueidisotel/metrics.go
Outdated
} | ||
) | ||
|
||
type DialLatencyHistogramOption struct { |
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.
type DialLatencyHistogramOption struct { | |
type HistogramOption struct { |
I believe we can reuse this option struct for other histogram metrics. So, name it just HistogramOption
may be better.
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.
Looks good to me. Thank you for your contribution! @proost |
previous discussion: #199
Add built-in metrics for connection.
I have to otel version up because 1.19.0 doesn't support bucket boundaries.