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

feat: add Tokenserver metrics #1200

Merged
merged 5 commits into from
Jan 25, 2022
Merged

Conversation

ethowitz
Copy link
Contributor

@ethowitz ethowitz commented Jan 5, 2022

Description

Emits one log line and several useful metrics per Tokenserver request.

Testing

I tested this by running the integration tests with RUST_LOG=debug and ensuring that the output included the expected log lines. I wasn't sure how to test the metrics.

Issue(s)

Closes #1108

@ethowitz ethowitz requested a review from a team January 5, 2022 23:07
jrconlin
jrconlin previously approved these changes Jan 6, 2022
Ethan Donowitz added 2 commits January 7, 2022 16:07
@ethowitz ethowitz force-pushed the feat/add-tokenserver-logging-metrics branch from 8bb596d to 9c4907d Compare January 7, 2022 16:12
@ethowitz ethowitz requested a review from jrconlin January 7, 2022 16:39
pjenvey
pjenvey previously approved these changes Jan 14, 2022
@@ -211,6 +214,9 @@ impl TokenserverDb {
"#;
const DEFAULT_CAPACITY_RELEASE_RATE: f32 = 0.1;

let mut metrics = self.metrics.clone();
metrics.start_timer("tokenserver.storage.get_best_node", None);
Copy link
Member

Choose a reason for hiding this comment

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

You may have intended this but I just wanted to note that Cadence hardcodes a prefix that we set to the value of Settings::statsd_label so this emits "syncstorage.tokenserver.storage.get_best_node".

We could overwrite tokenserver's statsd_label to use "tokenserver" instead or look to the future with "syncstorage.tokenserver" or maybe it makes more sense to keep it as you have it 🤷‍♂️

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ooo I didn't notice this. I think it makes sense to overwrite statsd_label to "syncstorage.tokenserver" for Tokenserver. I'll make the change

@@ -241,7 +245,11 @@ impl Server {
let tokenserver_state = if settings.tokenserver.enabled {
Some(tokenserver::ServerState::from_settings(
&settings.tokenserver,
metrics.clone(),
metrics::metrics_from_opts(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tokenserver will have its own separate metrics client -- is that okay? It seems like it shouldn't be a problem to me, but I wanted to double-check

Copy link
Member

Choose a reason for hiding this comment

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

Yea, it's not a big deal for now.

@ethowitz ethowitz requested a review from pjenvey January 19, 2022 21:35
Comment on lines 179 to 180
label: String,
host: Option<String>,
Copy link
Member

@pjenvey pjenvey Jan 21, 2022

Choose a reason for hiding this comment

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

not terribly important but this could take references instead. Option::as_deref can easily give you an Option<&str> from the host field Option<String> (as_ref doesn't)

Suggested change
label: String,
host: Option<String>,
label: &str
host: Option<&str>,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice catch!

@@ -241,7 +245,11 @@ impl Server {
let tokenserver_state = if settings.tokenserver.enabled {
Some(tokenserver::ServerState::from_settings(
&settings.tokenserver,
metrics.clone(),
metrics::metrics_from_opts(
Copy link
Member

Choose a reason for hiding this comment

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

Yea, it's not a big deal for now.

@ethowitz ethowitz merged commit aa93312 into master Jan 25, 2022
@ethowitz ethowitz deleted the feat/add-tokenserver-logging-metrics branch January 25, 2022 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tokenserver: Add metrics
3 participants