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

stream/multiconnection: Default process reporter #1734

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

shazbert
Copy link
Collaborator

@shazbert shazbert commented Nov 28, 2024

PR Description

  • Adds optional reader process reporter for metrics aggregation
  • In the exchange config set WebsocketMetricsLogging to true (only for Gateio) functionality will expand when exchanges get converted over the multi-connection usage.
[DEBUG] | WEBSOCKET | 28/11/2024 13:21:50 | wss://api.gateio.ws/ws/v4/: Operations/Second: 10, Avg Processing/Operation: 323.81µs, Peak: 168.6498ms

Reasoning:

  • Can provide detailed websocket operation metrics to help identify performance bottlenecks and areas for improvement. As above clearly shows there can be improvements as per peak processing timing which needs to be investigated.
  • This can scale across all exchanges when the multi connection updates has occurred.
  • This can be defined outside of GCT

Opened as draft if this could be a potential update. Once look over is done I will write tests and cleanup.

Type of change

Please delete options that are not relevant and add an x in [] as item is complete.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How has this been tested

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration and
also consider improving test coverage whilst working on a certain feature or package.

  • go test ./... -race
  • golangci-lint run
  • Test X

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation and regenerated documentation via the documentation tool
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally and on Github Actions with my changes
  • Any dependent changes have been merged and published in downstream modules

@shazbert shazbert added help wanted review me This pull request is ready for review labels Nov 28, 2024
@shazbert shazbert requested a review from a team November 28, 2024 02:34
@shazbert shazbert self-assigned this Nov 28, 2024
Copy link
Collaborator

@gloriousCode gloriousCode left a comment

Choose a reason for hiding this comment

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

Looks good!

[DEBUG] | WEBSOCKET | 04/12/2024 09:41:05 | wss://op-ws.gateio.live/v4/ws: Operations/Second: 0, Avg Processing/Operation: 124.162µs, Peak: 786.542µs
...
[DEBUG] | WEBSOCKET | 04/12/2024 09:42:05 | wss://op-ws.gateio.live/v4/ws: Operations/Second: 1, Avg Processing/Operation: 127.424µs, Peak: 317.791µs

exchanges/stream/websocket.go Outdated Show resolved Hide resolved
engine/websocketroutine_manager.go Outdated Show resolved Hide resolved
Comment on lines 92 to 93
// Reset metrics for the next interval.
r.operations, r.totalProcessingTime, r.peakProcessingTime = 0, 0, 0
Copy link
Collaborator

@gloriousCode gloriousCode Dec 3, 2024

Choose a reason for hiding this comment

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

I think there'd be value in not resetting some so you can know the slowest ever etc. Trudging through logs looking for the highest number doesn't sound so good, but I don't really feel strongly to make you change it

edit: I SEE YOUR EYES. I think there is still great value in highlighting the slowest thing across all time. But I will add it for myself

@shazbert shazbert added low priority This enhancement or update will be implemented at a later date. and removed help wanted labels Dec 6, 2024
@shazbert shazbert marked this pull request as ready for review December 6, 2024 00:47
@shazbert shazbert requested a review from gloriousCode December 6, 2024 00:47
Copy link
Collaborator

@gloriousCode gloriousCode left a comment

Choose a reason for hiding this comment

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

I like this, thank you!

exchanges/stream/websocket.go Outdated Show resolved Hide resolved
Co-authored-by: Scott <gloriousCode@users.noreply.github.com>
Copy link
Collaborator

@gloriousCode gloriousCode left a comment

Choose a reason for hiding this comment

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

Nice! tACK! Optional minor changes that don't affect tackiness

exchanges/stream/reporting.go Outdated Show resolved Hide resolved
Comment on lines 110 to 113
peakCause = append(peakCause[:100], []byte("...")...)
}
// Log metrics outside of the critical section to avoid blocking other threads.
log.Debugf(log.WebsocketMgr, "Connection: %v Operations/Second: %.2f, Avg Processing/Operation: %v, Errors: %v Peak: %v Cause: %v...", conn.GetURL(), avgOperationsPerSecond, avgProcessingTime, errors, peakTime, string(peakCause))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
peakCause = append(peakCause[:100], []byte("...")...)
}
// Log metrics outside of the critical section to avoid blocking other threads.
log.Debugf(log.WebsocketMgr, "Connection: %v Operations/Second: %.2f, Avg Processing/Operation: %v, Errors: %v Peak: %v Cause: %v...", conn.GetURL(), avgOperationsPerSecond, avgProcessingTime, errors, peakTime, string(peakCause))
peakCause = append(peakCause[:100], []byte("...")...)
}
// Log metrics outside of the critical section to avoid blocking other threads.
log.Debugf(log.WebsocketMgr, "Connection: %v Operations/Second: %.2f, Avg Processing/Operation: %v, Errors: %v Peak: %v Cause: %v", conn.GetURL(), avgOperationsPerSecond, avgProcessingTime, errors, peakTime, string(peakCause))

I removed the ellipses in the main output because you add them if its > 100 and doesn't really mean much if < 100

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

shazbert and others added 2 commits December 11, 2024 14:48
Co-authored-by: Scott <gloriousCode@users.noreply.github.com>
@gloriousCode gloriousCode added the gcrc GloriousCode Review Complete label Dec 12, 2024
@shazbert shazbert added requires config upgrade and removed review me This pull request is ready for review labels Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gcrc GloriousCode Review Complete low priority This enhancement or update will be implemented at a later date. requires config upgrade
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants