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

agent,billing: Move clients and queue into new pkg/reporting #1078

Merged
merged 4 commits into from
Nov 13, 2024

Conversation

sharnoff
Copy link
Member

@sharnoff sharnoff commented Sep 23, 2024

Initial refactoring for neondatabase/cloud#15939 — opening this PR early because it's rather substantial and might be good discuss earlier on.

Details of this change

This commit adds a new package: pkg/reporting.

The new package contains both the HTTP/S3/Azure Blob client implementations from pkg/billing, as well as the event queue and sender implementation from pkg/agent/billing.

The intent is to provide a 'plug and play' infrastructure for asynchronously sending billing events (among other event types) to a variety of sources, with the code responsible for generating those events only being responsible for setting up the clients and queueing the events.


Current state: All should be working as expected.

Notes for review: It's a big diff, sorry. I'm not totally sure if there's good ways to make it come out cleaner. Open for feedback on the new design — looking at pkg/reporting directly (particularly client.go and sink.go) is probably also the easiest way to get your bearings on the change as a whole.

@sharnoff sharnoff force-pushed the sharnoff/scaling-event-reporting-1 branch from 9bb7768 to c0ad93e Compare September 27, 2024 19:51
@sharnoff sharnoff marked this pull request as ready for review September 27, 2024 20:03
@sharnoff sharnoff requested a review from Omrigan September 27, 2024 20:03
@Omrigan Omrigan self-assigned this Oct 1, 2024
@Omrigan Omrigan requested a review from petuhovskiy October 9, 2024 00:25
Copy link
Contributor

@Omrigan Omrigan left a comment

Choose a reason for hiding this comment

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

Overall looks good, couple of places I think should be simplified, and couple names should be changed.

pkg/reporting/client_azureblob.go Outdated Show resolved Hide resolved
pkg/reporting/client.go Outdated Show resolved Hide resolved
pkg/reporting/client.go Outdated Show resolved Hide resolved
pkg/reporting/client.go Show resolved Hide resolved
pkg/reporting/client.go Outdated Show resolved Hide resolved
pkg/reporting/client.go Outdated Show resolved Hide resolved
@@ -1,21 +1,10 @@
package billing
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it make sense to get rid of this package and move all the stuff to either agent/billing or reporting?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'd like to do that, yeah. Wanted to leave it outside the scope of this change for now though — will keep this comment open as a reminder.

Copy link
Member Author

Choose a reason for hiding this comment

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

#1139

sharnoff added a commit that referenced this pull request Oct 12, 2024
This is part 2 of 2; see #1078 for the ground work.

In short, this commit:

* Adds a new package: 'pkg/agent/scalingevents'
* Adds new callbacks to core.State to allow it to report on scaling
  events changes in desired CU.
sharnoff added a commit that referenced this pull request Oct 12, 2024
This is part 2 of 2; see #1078 for the ground work.

In short, this commit:

* Adds a new package: 'pkg/agent/scalingevents'
* Adds new callbacks to core.State to allow it to report on scaling
  events changes in desired CU.
@sharnoff sharnoff force-pushed the sharnoff/scaling-event-reporting-1 branch 2 times, most recently from f608569 to 1c71a57 Compare October 12, 2024 22:06
sharnoff added a commit that referenced this pull request Oct 12, 2024
This is part 2 of 2; see #1078 for the ground work.

In short, this commit:

* Adds a new package: 'pkg/agent/scalingevents'
* Adds new callbacks to core.State to allow it to report on scaling
  events changes in desired CU.
@sharnoff sharnoff assigned sharnoff and unassigned Omrigan Oct 14, 2024
@sharnoff
Copy link
Member Author

@Omrigan I've responded to review comments. LMK what you think.

@sharnoff sharnoff assigned Omrigan and unassigned sharnoff Oct 14, 2024
Copy link
Contributor

@Omrigan Omrigan left a comment

Choose a reason for hiding this comment

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

Mostly nits.

pkg/reporting/client.go Outdated Show resolved Hide resolved
pkg/reporting/client.go Outdated Show resolved Hide resolved
pkg/reporting/client.go Outdated Show resolved Hide resolved
pkg/reporting/client.go Show resolved Hide resolved
@Omrigan Omrigan assigned sharnoff and unassigned Omrigan Oct 15, 2024
This commit adds a new package: pkg/reporting.

The new package contains both the HTTP/S3/Azure Blob client
implementations from pkg/billing, as well as the event queue and sender
implementation from pkg/agent/billing.

The intent is to provide a 'plug and play' infrastructure for
asynchronously sending billing events (among other event types) to a
variety of sources, with the code responsible for generating those
events only being responsible for setting up the clients and queueing
the events.
@sharnoff sharnoff force-pushed the sharnoff/scaling-event-reporting-1 branch from a46466d to df54b37 Compare October 17, 2024 17:13
sharnoff added a commit that referenced this pull request Oct 17, 2024
This is part 2 of 2; see #1078 for the ground work.

In short, this commit:

* Adds a new package: 'pkg/agent/scalingevents'
* Adds new callbacks to core.State to allow it to report on scaling
  events changes in desired CU.
@sharnoff sharnoff assigned Omrigan and unassigned sharnoff Oct 17, 2024
@sharnoff sharnoff requested a review from Omrigan October 17, 2024 17:14
Copy link

github-actions bot commented Oct 18, 2024

Merging this branch changes the coverage (1 decrease, 1 increase)

Impacted Packages Coverage Δ 🤖
github.com/neondatabase/autoscaling/pkg/agent 0.00% (ø)
github.com/neondatabase/autoscaling/pkg/agent/billing 0.00% (ø)
github.com/neondatabase/autoscaling/pkg/billing 0.00% (-21.37%) 💀 💀
github.com/neondatabase/autoscaling/pkg/reporting 8.29% (+8.29%) 👍

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/neondatabase/autoscaling/pkg/agent/billing/billing.go 0.00% (ø) 85 (-20) 0 85 (-20)
github.com/neondatabase/autoscaling/pkg/agent/billing/clients.go 0.00% (ø) 27 (+27) 0 27 (+27)
github.com/neondatabase/autoscaling/pkg/agent/billing/prommetrics.go 0.00% (ø) 11 (-2) 0 11 (-2)
github.com/neondatabase/autoscaling/pkg/agent/config.go 0.00% (ø) 67 0 67
github.com/neondatabase/autoscaling/pkg/agent/entrypoint.go 0.00% (ø) 49 0 49
github.com/neondatabase/autoscaling/pkg/billing/azureblobstoragebilling.go 0.00% (-41.67%) 0 (-36) 0 (-15) 0 (-21) 💀 💀 💀 💀
github.com/neondatabase/autoscaling/pkg/billing/client.go 0.00% (-12.99%) 11 (-66) 0 (-10) 11 (-56) 💀
github.com/neondatabase/autoscaling/pkg/reporting/client.go 22.58% (+22.58%) 31 (+31) 7 (+7) 24 (+24) 🌟
github.com/neondatabase/autoscaling/pkg/reporting/client_azureblob.go 37.50% (+37.50%) 24 (+24) 9 (+9) 15 (+15) 🌟
github.com/neondatabase/autoscaling/pkg/reporting/client_http.go 0.00% (ø) 23 (+23) 0 23 (+23)
github.com/neondatabase/autoscaling/pkg/reporting/client_s3.go 0.00% (ø) 26 (+26) 0 26 (+26)
github.com/neondatabase/autoscaling/pkg/reporting/queue.go 0.00% (ø) 18 (+18) 0 18 (+18)
github.com/neondatabase/autoscaling/pkg/reporting/send.go 0.00% (ø) 56 (+56) 0 56 (+56)
github.com/neondatabase/autoscaling/pkg/reporting/sink.go 0.00% (ø) 15 (+15) 0 15 (+15)

Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code.

Changed unit test files

  • github.com/neondatabase/autoscaling/pkg/reporting/client_azureblobbilling_test.go

HTML Report

Click to open

Copy link
Contributor

@Omrigan Omrigan left a comment

Choose a reason for hiding this comment

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

Looks mostly done!

pkg/reporting/client.go Show resolved Hide resolved
pkg/reporting/client.go Outdated Show resolved Hide resolved
pkg/reporting/client_http.go Show resolved Hide resolved
pkg/reporting/client_http.go Outdated Show resolved Hide resolved
@sharnoff sharnoff self-assigned this Oct 31, 2024
@sharnoff sharnoff merged commit 59f6746 into main Nov 13, 2024
22 checks passed
@sharnoff sharnoff deleted the sharnoff/scaling-event-reporting-1 branch November 13, 2024 16:50
sharnoff added a commit that referenced this pull request Nov 18, 2024
This is part 2 of 2; see #1078 for the ground work.

In short, this commit:

* Adds a new package: 'pkg/agent/scalingevents'
* Adds new callbacks to core.State to allow it to report on scaling
  events changes in desired CU.
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