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

[submitter] confirmed queue gauge #2822

Closed
trajan0x opened this issue Jun 29, 2024 · 1 comment · Fixed by #2821
Closed

[submitter] confirmed queue gauge #2822

trajan0x opened this issue Jun 29, 2024 · 1 comment · Fixed by #2821

Comments

@trajan0x
Copy link
Contributor

No description provided.

Copy link

greptile-apps bot commented Jun 29, 2024

To implement a confirmed queue gauge in the submitter package, follow these steps:

  1. Define the Gauge in txSubmitterImpl struct:
    Add a new field for the confirmed queue gauge in the txSubmitterImpl struct in submitter.go:

    confirmedQueueGauge metric.Int64ObservableGauge
  2. Initialize the Gauge in setupMetrics:
    Initialize the confirmed queue gauge in the setupMetrics method in submitter.go:

    func (t *txSubmitterImpl) setupMetrics() (err error) {
        // ... existing code ...
        t.confirmedQueueGauge, err = t.meter.Int64ObservableGauge("confirmed_queue_size")
        if err != nil {
            return fmt.Errorf("could not create confirmed queue gauge: %w", err)
        }
        _, err = t.meter.RegisterCallback(t.recordConfirmedQueueSize, t.confirmedQueueGauge)
        if err != nil {
            return fmt.Errorf("could not register callback: %w", err)
        }
        return nil
    }
  3. Implement the Callback Method:
    Implement the recordConfirmedQueueSize method to update the gauge value in submitter.go:

    func (t *txSubmitterImpl) recordConfirmedQueueSize(ctx context.Context, result metric.Int64ObserverResult) {
        size, err := t.db.GetConfirmedQueueSize(ctx, t.signer.Address())
        if err != nil {
            logger.Errorf("could not get confirmed queue size: %v", err)
            return
        }
        result.Observe(int64(size))
    }
  4. Update the Database Interface:
    Ensure the db.Service interface has the GetConfirmedQueueSize method in db.go:

    type Service interface {
        // ... existing methods ...
        GetConfirmedQueueSize(ctx context.Context, address common.Address) (int, error)
    }
  5. Implement the Database Method:
    Implement the GetConfirmedQueueSize method in the database service implementation in db.go:

    func (d *dbService) GetConfirmedQueueSize(ctx context.Context, address common.Address) (int, error) {
        // Implement the logic to count the confirmed transactions in the queue
    }

References

/ethergo/submitter/submitter.go
/ethergo/submitter/queue.go

About Greptile

This response provides a starting point for your research, not a precise solution.

Help us improve! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

Ask Greptile · Edit Issue Bot Settings

@trajan0x trajan0x mentioned this issue Jun 29, 2024
@trajan0x trajan0x linked a pull request Jun 29, 2024 that will close this issue
trajan0x added a commit that referenced this issue Jun 29, 2024
address #2823, #2822, #2820 and #2819

---------

Co-authored-by: Trajan0x <[email protected]>
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 a pull request may close this issue.

1 participant