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

Pass in metrics server to avssync #34

Closed
wants to merge 1 commit into from
Closed

Conversation

ian-shim
Copy link
Contributor

@ian-shim ian-shim commented May 9, 2024

Instead of creating a metrics server inside avssync, this change makes avssync constructor take the metrics server itself so that it can be passed in from the caller.

@ian-shim ian-shim requested review from samlaf and dmanc May 9, 2024 00:20
@ian-shim ian-shim marked this pull request as ready for review May 9, 2024 00:26
@ian-shim ian-shim marked this pull request as draft May 9, 2024 05:58
Copy link
Contributor

@samlaf samlaf left a comment

Choose a reason for hiding this comment

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

Changes look fine to me, but why do you need this exactly?
If you want to run this as a binary and share metrics with another service/goroutine, then typically you would want to share the prometheus registry instead I feel? How else are you thinking of creating a metrics server outside, and why is it useful?

@dmanc
Copy link
Contributor

dmanc commented May 9, 2024

Changes look fine to me, but why do you need this exactly? If you want to run this as a binary and share metrics with another service/goroutine, then typically you would want to share the prometheus registry instead I feel? How else are you thinking of creating a metrics server outside, and why is it useful?

The use case we're thinking of is running the avssync package as part of another service/binary. So with the current code it crashes because it tries to initialize the metrics server after the second run.

Copy link
Contributor

@samlaf samlaf left a comment

Choose a reason for hiding this comment

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

Added new set of comments after talking with @dmanc

Comment on lines +45 to 47
func NewMetrics(addr string, logger logging.Logger) *Metrics {
registry := prometheus.NewRegistry()
registry.MustRegister(updateStakeAttempt, txRevertedTotal, operatorsUpdated)
Copy link
Contributor

Choose a reason for hiding this comment

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

Talked with @dmanc about this.
Feel like we're not addressing the proper separation of concern (absolutely my fault for this, just realized now). Created Layr-Labs/eigensdk-go#238 to do this in sdk as well.

But how are you guys registering the above metrics (operatorsUpdated, etc) with a separate registry?
I feel like ideal scenario would be that NewMetrics takes a registry as input, and then registers the variables against that registry. Maybe a hacky way that doesn't require too mcuh refactor is just to add a one-off function in this file registerPromVariables(reg prometheus.Registry) that just registers against some prom registry?

@@ -35,12 +36,32 @@ var (
}, []string{"quorum"})
)

func StartMetricsServer(metricsAddr string) {
type Metrics struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

See my below comment. Feel like we should rename this to MetricsServer. It should just take a registry as argument but not register the prometheus variables into it (since its just a MetricsServer). Ideally this metricsServer would live in sdk.

Then you would first call the registerPromVariables(reg prometheus.Registry) in main to register the metrics, and then start the webserver (if needed, maybe put that as flag in the binary).

@dmanc
Copy link
Contributor

dmanc commented May 17, 2024

Closed in favor of #38

@dmanc dmanc closed this May 17, 2024
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.

3 participants