-
Notifications
You must be signed in to change notification settings - Fork 15
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 prometheus metrics support #37
base: master
Are you sure you want to change the base?
Conversation
cmd/cli/bulk.go
Outdated
@@ -156,7 +156,7 @@ func processBulkEntry(entry string) (*BulkResponseItem, error) { | |||
return item, nil | |||
} | |||
|
|||
client, err := svrquery.NewClient(querySection, addressSection, options...) | |||
client, err := svrquery.NewUDPClient(querySection, addressSection, options...) |
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.
Will fix this
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.
Starting to form up, a few points of feedback
cmd/cli/main.go
Outdated
"github.com/multiplay/go-svrquery/lib/svrsample" | ||
"github.com/multiplay/go-svrquery/lib/svrsample/common" | ||
"log" |
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.
Import ordering here is wrong
lib/svrquery/client.go
Outdated
// NewClient creates a new client that talks to addr. | ||
func NewClient(proto, addr string, options ...Option) (*Client, error) { | ||
// NewUDPClient creates a new client that talks to addr. | ||
func NewUDPClient(proto, addr string, options ...Option) (*UDPClient, 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.
I think this is going to break users of the library as NewClient is publicly exported and the main way people will interact with the client.
Can we either have the struct do both or abstract it internally?
lib/svrquery/protocol/interfaces.go
Outdated
@@ -23,6 +23,7 @@ type Mapper interface { | |||
// Client is an interface which is implemented by types which can act a query transport. | |||
type Client interface { | |||
io.ReadWriteCloser | |||
Queryer |
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.
Out of interest, is this just usability? I see we populate this from the protocol.Get(...) call so seems sensible but just checking
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.
Mainly since I now have 2 types of clients, the interface was needed so that main.go
can use them as both io.ReadWriteCloser
and Queryer
(the UDP client implementation already implemented both). But I'll rework the client to make it backwards compatible so this might change again.
lib/svrquery/protocol/prom/query.go
Outdated
resp.MaxPlayers = *v.Metric[0].Gauge.Value | ||
case serverInfoMetricName: | ||
if len(v.Metric) == 0 || v.Metric[0] == nil || len(v.Metric[0].Label) == 0 { | ||
slog.Error("server_info metric is missing labels") |
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.
Logging messages like this will break the cli responses (e.g. when in json output mode) and in libraries is usually not done as you don't know the log format of the application running the code
TODO