Skip to content
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 server connection count metric #464

Merged

Conversation

marcoferrer
Copy link
Contributor

This includes the following changes:

  • A baseplate wrapper for TServerTransport which wraps the result of Accept with a MonitoredTTransport
  • A baseplate wrapper for TTransport which emits counter metrics for invocations of Open and Close
  • A metricsbp.Config flag to allow users to enable recording connection count metrics from their application yaml
  • A thriftbp.ServerConfig flag to check if reporting connection counts is enabled inside of NewBaseplateServer

@marcoferrer marcoferrer requested a review from a team as a code owner January 4, 2022 20:39
@marcoferrer marcoferrer requested review from fishy, kylelemons and konradreiche and removed request for a team January 4, 2022 20:39
metricsbp/config.go Outdated Show resolved Hide resolved
thriftbp/server.go Outdated Show resolved Hide resolved
thriftbp/server_transport.go Outdated Show resolved Hide resolved
thriftbp/server_transport.go Outdated Show resolved Hide resolved
Copy link
Member

@konradreiche konradreiche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 lgtm, we just need some clarification on what metric path we want to use.

thriftbp/server_transport.go Outdated Show resolved Hide resolved
thriftbp/server_transport.go Outdated Show resolved Hide resolved
// a counter for the number of clients connected to the server
//
// Optional, defaults to false.
ReportServerConnectionCount bool `yaml:"reportServerConnectionCount"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is defined in the global metricsbp.Config, but it's only implemented in thrift server, not http server, which is kinda misleading.

I think we should remove the one from metricsbp.Config and only provide the one from thriftbp.ServerConfig?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to set the server config from the application yaml?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that desireable? Metrics are not usually the domain of configuration

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can also just remove this configuration and just report it always. an additional counter/gauge adds negligible overhead to a go service.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me know if I should update it to always enabled

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kylelemons what do you think to remove this configuration and just always on?

Copy link
Contributor

@kylelemons kylelemons Jan 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The metric is negligible but the additional thunk call per RPC might not be... though it may be dwarfed by thrift overhead.

I don't have enough experience to know, but if both of you agree it's ok to enable by default then it probably is

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which is why I prefer to just move it to thriftbp.ServerConfig instead of default on :)

in the current cookiecutter we always need to pass in thriftbp.ServerConfig to thriftbp.NewBaseplateServer manually, so adding a config there manually to make it opt-in is not something too out of the scope.

If you want it from yaml, you can just make thriftbp.ServerConfig part of your Config struct and override the Processor field (as that cannot be deserialized from yaml anyways).

thriftbp/server_transport.go Show resolved Hide resolved
thriftbp/server_transport.go Outdated Show resolved Hide resolved
thriftbp/server_transport.go Outdated Show resolved Hide resolved
thriftbp/server_transport.go Outdated Show resolved Hide resolved
thriftbp/server_transport.go Outdated Show resolved Hide resolved
thriftbp/server_transport.go Outdated Show resolved Hide resolved
marcoferrer and others added 2 commits January 5, 2022 15:48
Co-authored-by: Kyle Lemons <kyle@kylelemons.net>
// a counter for the number of clients connected to the server
//
// Optional, defaults to false.
ReportServerConnectionCount bool `yaml:"reportServerConnectionCount"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that desireable? Metrics are not usually the domain of configuration

Copy link
Member

@fishy fishy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Besides the configuration field, the code looks good to me.

Regarding the configuration field, I'm fine with either remove it from metricsbp.Config and only provide it in thriftbp.ServerConfig, or just remove it altogether and make it always on. But the current state is misleading and should be avoided.

@marcoferrer
Copy link
Contributor Author

Besides the configuration field, the code looks good to me.

Regarding the configuration field, I'm fine with either remove it from metricsbp.Config and only provide it in thriftbp.ServerConfig, or just remove it altogether and make it always on. But the current state is misleading and should be avoided.

Outside the scope of this PR, but we should probably come up with a preferred convention for sourcing configuration values from the application yaml. It seems like whenever theres a new option exposed to baseplate users they end up having to hard code their settigns or go through the work of creating a new field in their configuration struct. In this scenario, the path of least resistance usually wins. ie. hardcode settings.

thriftbp/server_transport.go Outdated Show resolved Hide resolved
@marcoferrer marcoferrer force-pushed the add-metrics-for-connection-count branch from 75166fa to ab63b93 Compare January 31, 2022 20:06
Copy link
Member

@fishy fishy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only minor comments/naming issues remaining.

thriftbp/server.go Outdated Show resolved Hide resolved
thriftbp/server.go Outdated Show resolved Hide resolved
@marcoferrer marcoferrer merged commit 2c2736a into reddit:master Feb 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants