Andrew Farries
9d72fb5df9
[usage] Add billInstancesAfter config setting
...
Add a new config setting to the usage component.
`billInstancesAfter` sets the date after which instances should be
considered for billing - instances started before `billInstancesAfter`
will not be considered by the billing controller.
2022-08-05 09:47:49 -03:00
Milan Pavlik
f88afd76e5
[usage] Fix max call send message size
2022-08-05 05:58:49 -03:00
Milan Pavlik
6390f20643
[billing] Report metrics on updated subscriptions
2022-08-04 12:52:48 -03:00
Jan Keromnes
9519ee4385
[db][usage] Add d_b_billed_session table migration and Go definitions
...
Co-authored-by: Laurie T. Malau <laurie@gitpod.io>
2022-08-04 09:26:48 -03:00
Milan Pavlik
bb0483c3e0
[usage] Self-connection allows up to 30MB in message response
2022-08-04 04:30:48 -03:00
Milan Pavlik
35feada89f
[usage] Add metrics for number of usage records
2022-08-02 16:20:49 -03:00
Milan Pavlik
fc10f0b13a
[usage] Implement CollectUsage
2022-08-02 08:53:46 -03:00
Andrew Farries
a043243e6d
[usage] Set Content-Type header on PUT request
...
The signed upload URL only accepts requests with this Content-Type.
2022-08-02 06:58:46 -03:00
Andrew Farries
0805d02729
Delay gRPC self connection
...
The billing client tries to connect to the usage component gRPC server
before the gRPC server is ready. This is a non-fatal error as gRPC
dialing has built-in backoff/retry logic but it does produce ugly
warnings in the usage component logs.
Here we use a simple solution to delay the self-connection attempt for a
short period to give the gRPC server time to start.
2022-08-01 11:34:45 -03:00
Milan Pavlik
6c6d2689e8
[billing] GetLatestInvoice RPC protos
2022-07-27 11:58:22 -03:00
Milan Pavlik
c4708b3048
[usage] Implement BillingService
2022-07-27 04:48:22 -03:00
Milan Pavlik
c582420eb0
[usage] Fix BilledSession credits precision
2022-07-27 04:11:21 -03:00
Milan Pavlik
51375056a4
[usage] stripe.UpdateUsage uses context
2022-07-27 02:58:21 -03:00
Milan Pavlik
630b21e441
[usage] Remove pricer dependency from billing controller
2022-07-26 10:29:21 -03:00
Andrew Farries
8ce9022a1c
Change UploadFile to UploadUsageReport
...
The method will upload to the usage-records bucket so should not take
arbitrary inputs, only usage reports.
Do the encoding and gzipping of the report in the method rather than
the caller.
2022-07-25 11:09:20 -03:00
Andrew Farries
fb941f0f35
Add UploadFile method to contentservice client
...
Make the `GetSignedUploadUrl` method unexported and remove it from the
interface.
Compress reports before uploading to obj storage
* Stop writing the usage report to disk.
* Compress the report in memory.
* Upload the compressed report to object storage.
2022-07-25 11:09:20 -03:00
Milan Pavlik
6d2b49cd38
[usage] Allow marshalling of VarCharTime to JSON
2022-07-25 07:02:20 -03:00
Milan Pavlik
2b6778bcd9
[usage] Implement ordering
2022-07-25 06:59:20 -03:00
Andrew Farries
01af2de26b
Rename ContentServiceUrl to ContentServiceAddress
2022-07-25 05:56:20 -03:00
Andrew Farries
fab28265ed
Obtain and log signed upload URL
...
Show that the connection to the content service is up and running by
requesting a signed upload URL and logging it.
2022-07-25 05:56:20 -03:00
Andrew Farries
109a7a695d
Create contentservice and pass to it to reconciler
...
When the usage component starts up.
2022-07-25 05:56:20 -03:00
Andrew Farries
c582b0884a
Add pkg/contentservice package
...
To handle connecting to the content-service gRPC API, retrieving signed
upload URLs and uploading usage reports.
2022-07-25 05:56:20 -03:00
Andrew Farries
a70e56cc5a
Add build deps to BUILD.yaml
...
Add a dependency on the `content-service-api` component.
And run `leeway link`.
2022-07-25 05:56:20 -03:00
Milan Pavlik
f9ac10a96a
[usage] Fix usage query
2022-07-22 22:56:17 -03:00
Milan Pavlik
fd0b758c90
[usage] By default sort results descending
2022-07-22 11:47:17 -03:00
Milan Pavlik
0674341b6c
[usage] ListUsage filters by time range
2022-07-22 06:57:17 -03:00
Milan Pavlik
4df9c3e54e
[usage] Ensure billed usage results are ordered
2022-07-20 10:59:15 -03:00
Milan Pavlik
f44c15256d
[usage] CreateUsageRecords updates fields when they differ
2022-07-20 09:06:15 -03:00
Andrew Farries
071f60fda0
Use variable rather than literal
2022-07-20 08:17:15 -03:00
Milan Pavlik
2946bee541
[usage] Store workspace, project, type & class
2022-07-19 15:24:14 +02:00
Milan Pavlik
3fd02a710a
[usage] Return extra fields for ListBilledUsage
2022-07-19 09:06:14 +02:00
Milan Pavlik
ce2d00df02
[usage] Extend go model with extra fields for WorkspaceInstanceUsage
2022-07-19 08:58:14 +02:00
Andrew Farries
894937e8bb
Use floats to calculate instance credit usage
...
Per instance, we want to work with fractional credits and only round
the total for a team when we submit usage reports to stripe.
2022-07-18 16:21:14 +02:00
Andrew Farries
e2385352a4
[usage] Implement GetBilledUsage rpc
2022-07-18 13:57:13 +02:00
Andrew Farries
0945a996fb
Update tests with new field
2022-07-15 16:29:02 +02:00
Andrew Farries
f07b3e6628
Populate credits field for usage records
2022-07-15 16:29:02 +02:00
Andrew Farries
0745c88037
Extract CreditsUsedByInstance method
2022-07-15 16:29:02 +02:00
Andrew Farries
6fb78e92ac
Let the usage reconciler take a pricer
...
Instance pricing is a usage concern, not just a billing concern.
2022-07-15 16:29:02 +02:00
Andrew Farries
4692d0a166
Add tests for usage report/usage record conversion
2022-07-14 15:25:01 +02:00
Andrew Farries
f11d06691c
Create valid sql.NullTime
...
In the case where the instance has stopped.
2022-07-14 15:25:01 +02:00
Andrew Farries
8d6f8b0340
Update refs to column name in usage component
2022-07-14 15:25:01 +02:00
Andrew Farries
d74681d342
Store usage after reconciler runs
2022-07-14 15:25:01 +02:00
Andrew Farries
dee6ca4809
Add tests for usage record creation
2022-07-14 15:25:01 +02:00
Andrew Farries
bf85d64829
Add new type to db package
...
Add a GORM type that represents the "d_b_workspace_instance_usage" table
and methods for working with it.
2022-07-14 15:25:01 +02:00
Andrew Farries
d55ffabb26
Off topic: Use type alias in return type
2022-07-14 15:25:01 +02:00
Milan Pavlik
48411d7cfb
[usage] Workspace Pricer uses config
2022-07-13 08:49:59 +02:00
Milan Pavlik
de91fda8c0
fix up
2022-07-12 16:59:59 +02:00
Milan Pavlik
ad5dcd707b
fix up
2022-07-12 16:59:59 +02:00
Milan Pavlik
62c3212c10
Fix up
2022-07-12 16:59:59 +02:00
Milan Pavlik
9ed6dab095
[usage] Join workspace instances with workspaces to get project and type
2022-07-12 16:59:59 +02:00