Skip to content

feat(logs): Track accepted bytes per individual log item - #4886

Merged
Dav1dde merged 3 commits into
masterfrom
dav1d/count-bytes-logs
Jul 3, 2025
Merged

Dav1dde merged 3 commits into
masterfrom
dav1d/count-bytes-logs

Conversation

@Dav1dde

@Dav1dde Dav1dde commented Jul 1, 2025 •

Copy link
Copy Markdown
Member

Calculates the ingested bytes when deserializing individual log items, materializes it on the log and uses it for all outcomes which are to be emitted.

There are quite a bit of follow ups related to this:

See the tracking issue #4824 for details on the chosen algorithm to calculate the ingested bytes.

Additionally, this PR does implement proper counting for any data structure sent as an attribute value, this includes mixed arrays and objects. Relay will drop these attributes later on as they are not yet supported. This is generally the theme, Relay counts before making any modifications. That could be because of size limits, PII, inconsistencies etc.

This is inline with the approach we wanted to take with counting received bytes. In practice this should not be a large issue, as people are inclined to only send valid data, as the invalid data would not make it to the product and SDKs are safeguarding against invalid usage as well.

Closes: RELAY-111
Closes: #4824

@Dav1dde
Dav1dde requested a review from a team as a code owner July 1, 2025 13:59
@Dav1dde
Dav1dde force-pushed the dav1d/count-bytes-logs branch from 166184c to fc8399d Compare July 1, 2025 14:00
@Dav1dde
Dav1dde force-pushed the dav1d/count-bytes-logs branch from fc8399d to 9f98a14 Compare July 1, 2025 14:06
@Dav1dde Dav1dde self-assigned this Jul 1, 2025
@Dav1dde
Dav1dde requested a review from k-fish July 2, 2025 08:21
Comment thread relay-ourlogs/src/size.rs
Comment on lines +264 to +298
r#"{
"timestamp": 946684800.0,
"trace_id": "5b8efff798038103d269b633813fc60c",
"level": "warn",
"body": "7 bytes",
"some other": "fields that do not exist",
"attributes": {
"k1": {
"value": "string value",
"type": "string"
},
"k2": {
"value": 18446744073709551615,
"type": "integer"
},
"k3": {
"value": 42.01234567891234567899,
"type": "double"
},
"k4": {
"value": false,
"type": "boolean"
},
"k5": {
"value": {
"nested": {
"array": [1.0, 2, -12, "7 bytes", false]
}
},
"type": "not yet supported"
}
}
}"#
);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

With sizing you've written it looks like we will be calculating this as 89 bytes.

I want to point out that naively saving this in a file with whitespace, "raw", is 647 bytes. If you trim whitespace etc. this would still be at least 300-400 bytes.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Are you saying that the size calculation is too far off from the actual number of bytes that are sent?

@Dav1dde
Dav1dde added this pull request to the merge queue Jul 3, 2025
Merged via the queue into master with commit 9106270 Jul 3, 2025
@Dav1dde
Dav1dde deleted the dav1d/count-bytes-logs branch July 3, 2025 07:21
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.

Account Log Bytes

3 participants