Skip to content

Comments

Log metrics port#482

Merged
Sushisource merged 1 commit intocli-rewritefrom
more-logs
Feb 28, 2024
Merged

Log metrics port#482
Sushisource merged 1 commit intocli-rewritefrom
more-logs

Conversation

@Sushisource
Copy link
Member

What was changed

Log the port metrics uses on startup

Why?

Useful

Checklist

  1. Closes [Feature Request] Log metrics endpoint's port number for visibility #309

  2. How was this tested:
    Manually

  3. Any docs updates needed?

@Sushisource
Copy link
Member Author

Created temporalio/temporal#5461 since I had to work around this a bit

Comment on lines +63 to +66
// Grab a free port for metrics ahead-of-time so we know what port is selected
if opts.MetricsPort == 0 {
opts.MetricsPort = devserver.MustGetFreePort()
}
Copy link
Member

Choose a reason for hiding this comment

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

Hrmm, so looking at the dev server code, I am not seeing that metrics config is even set if no metrics port is given by the user which I wonder if that means that no metrics endpoint is even created/bound. Can you confirm what happens today if metrics port is unset (i.e. 0)?

Copy link
Member Author

Choose a reason for hiding this comment

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

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 the one that gets used here, right?

I don't think so. But I wonder if I introduced a regression copying over dev server code. Current CLI does default a metrics port:

cli/server/config/config.go

Lines 153 to 155 in 7267df6

if cfg.MetricsPort == 0 {
cfg.MetricsPort = cfg.portProvider.MustGetFreePort()
}
. But new CLI does not. I kinda like the behavior of not starting/binding a metrics server if they don't ask for it now that I think about it. But I think your current code re-institutes what was in the CLI before.

Can be convinced either way (can also get others' opinion on whether we should always start a metrics server if you want).

Copy link
Member Author

@Sushisource Sushisource Feb 28, 2024

Choose a reason for hiding this comment

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

I figure we might as well. I'm just not sure I see any real reason not to, and it's nice to have the metrics there if at some point after starting it you realize you wanted to see something.

Copy link
Member

@cretz cretz Feb 28, 2024

Choose a reason for hiding this comment

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

The only reason is not to bind a socket nobody uses. In current CLI they were starting a metrics server and didn't even tell anyone where to access it, so they were starting a full server unnecessarily. Now we are always starting it whether used or not.

Also I think showing the server API endpoint and the UI endpoint makes sense and is something most users will want, but a metrics endpoint is something very few users will want yet its endpoint is now printed right there with the other two important ones.

Having said all of this, I don't have a strong opinion. Worth getting anyone else's? If not, I can approve as is.

Copy link
Member Author

Choose a reason for hiding this comment

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

Eh, I think the discoverability is a nice thing actually. A curious person might open it up, go "oh hey this is nice" who otherwise never would've known.

Copy link
Member

@cretz cretz left a comment

Choose a reason for hiding this comment

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

Not a big fan of default starting a metrics server (and output line) that most will never use, but not a big deal

@Sushisource Sushisource merged commit cfd3f3e into cli-rewrite Feb 28, 2024
@Sushisource Sushisource deleted the more-logs branch February 28, 2024 22:56
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.

2 participants