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

Implement observer with SQL query support and parquet export #744

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

masih
Copy link
Member

@masih masih commented Nov 12, 2024

Implement an F3 observer that:

  • listens to F3 gossipsub messages
  • collects them as long as they can be decoded as CBOR
  • offers a SQL interface to query them over a HTTP
  • rotates them into Parquet files
  • deletes any rotated files based on a configured maximum age

@masih masih force-pushed the masih/observer-with-sql-support branch from 0d08bfd to 82c2371 Compare November 12, 2024 05:50
observer/query.go Show resolved Hide resolved
Copy link

codecov bot commented Nov 12, 2024

Codecov Report

Attention: Patch coverage is 0% with 558 lines in your changes missing coverage. Please review.

Project coverage is 69.34%. Comparing base (b1869c1) to head (d9a5ac4).

Files with missing lines Patch % Lines
observer/observer.go 0.00% 284 Missing ⚠️
observer/options.go 0.00% 139 Missing ⚠️
observer/query.go 0.00% 79 Missing ⚠️
observer/model.go 0.00% 55 Missing ⚠️
internal/psutil/psutil.go 0.00% 1 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (b1869c1) and HEAD (d9a5ac4). Click for more details.

HEAD has 2 uploads less than BASE
Flag BASE (b1869c1) HEAD (d9a5ac4)
4 2
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #744      +/-   ##
==========================================
- Coverage   75.15%   69.34%   -5.81%     
==========================================
  Files          70       74       +4     
  Lines        6939     7497     +558     
==========================================
- Hits         5215     5199      -16     
- Misses       1312     1884     +572     
- Partials      412      414       +2     
Files with missing lines Coverage Δ
internal/psutil/psutil.go 18.51% <0.00%> (-0.72%) ⬇️
observer/model.go 0.00% <0.00%> (ø)
observer/query.go 0.00% <0.00%> (ø)
observer/options.go 0.00% <0.00%> (ø)
observer/observer.go 0.00% <0.00%> (ø)

... and 5 files with indirect coverage changes

---- 🚨 Try these New Features:

@@ -1,75 +0,0 @@
package msgdump
Copy link
Member Author

Choose a reason for hiding this comment

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

Rewrote the stuff here, because:

  • there seem to be an issue with decoding parquet files previously generated. So far we have just been using the ndjson dump to query things.
  • I wanted to have a SQL interface that: 1) can query the latest messages and 2) can query the rotated messages all in one convenient view.
  • These changes are significant enough that it deserved its own package etc.

@@ -0,0 +1,22 @@
package main
Copy link
Member Author

Choose a reason for hiding this comment

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

Renamed the file due to typo in file name and moved common pubsub utility stuff from here to internal/psutil package.

@@ -0,0 +1,111 @@
package observer
Copy link
Member Author

Choose a reason for hiding this comment

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

This allows us to run the observer under F3 passive testing infra as a HTTP server and CURL it with SQL statements, e.g.:

$ curl -X POST -d 'select distinct sender from messages'  https://where-it-is-gonna-run/query

observer/query.go Show resolved Hide resolved
@masih masih force-pushed the masih/observer-with-sql-support branch from 82c2371 to 9219213 Compare November 12, 2024 06:10
@masih masih requested review from Kubuxu and rvagg November 12, 2024 06:11
@masih masih marked this pull request as ready for review November 12, 2024 06:12
@masih masih force-pushed the masih/observer-with-sql-support branch 2 times, most recently from 4bbc9af to 4914105 Compare November 17, 2024 11:07
observer/model.go Outdated Show resolved Hide resolved
Implement an F3 observer that:
* listens to F3 gossipsub messages
* collects them as long as they can be decoded as CBOR
* offers a SQL interface to query them over a HTTP
* rotates them into Parquet files
* deletes any rotated files based on a configured maximum age

Fix base image to distroless/cc because of duckdb libstdc++
dependencies.
@masih masih force-pushed the masih/observer-with-sql-support branch from d3bfd33 to d9a5ac4 Compare November 18, 2024 16:42
@Kubuxu
Copy link
Contributor

Kubuxu commented Nov 18, 2024

My only nit would be maybe support for BasicAuth, but I don't think it is immediately necessary as it can be reverse proxied onto it.

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