-
Notifications
You must be signed in to change notification settings - Fork 167
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
feat: track content length histogram #1206
Conversation
8d6c61c
to
30ccb60
Compare
Deploying with Cloudflare Pages
|
30ccb60
to
fffca73
Compare
fc55049
to
e6ce43d
Compare
e6ce43d
to
fb5065f
Compare
this.totalContentLengthBytes = | ||
(await this.state.storage.get(TOTAL_CONTENT_LENGTH_BYTES_ID)) || 0 | ||
// Total cached content length responses | ||
this.totalCachedContentLengthBytes = | ||
(await this.state.storage.get(TOTAL_CACHED_CONTENT_LENGTH_BYTES_ID)) || | ||
0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These need to be BigInt
. Apparently DO storage supports every type supported by the Structured Clone algorithm which includes BigInt
thankfully.
https://developers.cloudflare.com/workers/runtime-apis/durable-objects#transactional-storage-api
|
||
// We will count occurences per bucket where content size is less or equal than bucket value | ||
export const contentLengthHistogram = [ | ||
0.5, 1, 2, 5, 25, 50, 100, 500, 1000, 5000, 10000, 15000, 20000, 30000, 32000, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these need to be converted to bytes...?
@@ -70,6 +77,26 @@ test('Gets Metrics content', async (t) => { | |||
const response = await mf.dispatchFetch('http://localhost:8787/metrics') | |||
const metricsResponse = await response.text() | |||
|
|||
// content length of responses is 23 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
? is zero below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean below? Want to get the metrics before the requests and see if content length is zero?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added that case
Adds content length histogram tracking, as well as content length of cached responses, so that we can compare the amount of data we had cached
Closes #1181