Skip to content

Commit

Permalink
fix: revert "feat: faster json parsing" (#19838)
Browse files Browse the repository at this point in the history
Revert "feat: faster json parsing"
  • Loading branch information
pauldambra authored Jan 18, 2024
1 parent 4c9977b commit e049e2c
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 43 deletions.
1 change: 0 additions & 1 deletion plugin-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@
"prom-client": "^14.2.0",
"re2": "^1.20.3",
"safe-stable-stringify": "^2.4.0",
"simdjson": "^0.9.2",
"tail": "^2.2.6",
"uuid": "^8.3.2",
"v8-profiler-next": "^1.9.0",
Expand Down
14 changes: 0 additions & 14 deletions plugin-server/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { captureException, captureMessage } from '@sentry/node'
import { DateTime } from 'luxon'
import { KafkaConsumer, Message, MessageHeader, PartitionMetadata, TopicPartition } from 'node-rdkafka'
import path from 'path'
import { parse } from 'simdjson'

import { KAFKA_SESSION_RECORDING_SNAPSHOT_ITEM_EVENTS } from '../../../config/kafka-topics'
import { PipelineEvent, RawEventMessage, RRWebEvent } from '../../../types'
Expand Down Expand Up @@ -177,13 +176,8 @@ export const parseKafkaMessage = async (
let event: PipelineEvent

try {
// we only read distinct_id, team_id, token, and data from the message payload
// data is read into event
// TODO: simd json can lazily parse json, so if we could avoid parsing "events" from the data
// we'd get the biggest perf win, since that is the potentially large "blob" of data
// see: https://github.com/luizperes/simdjson_nodejs?tab=readme-ov-file#parsing-a-json-string-lazily
messagePayload = parse(message.value.toString())
event = parse(messagePayload.data)
messagePayload = JSON.parse(message.value.toString())
event = JSON.parse(messagePayload.data)
} catch (error) {
return dropMessage('invalid_json', { error })
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,25 +68,7 @@ describe('session-recording utils', () => {
)
expect(parsedMessage).toEqual({
distinct_id: String(numericId),
events: [
{
data: {
payload: {
level: 'log',
payload: ['"Hedgehog: Will \'jump\' for 2916.6666666666665ms"'],
trace: [
'HedgehogActor.setAnimation (http://127.0.0.1:8000/static/toolbar.js?_ts=1693421010000:105543:17)',
'HedgehogActor.setRandomAnimation (http://127.0.0.1:8000/static/toolbar.js?_ts=1693421010000:105550:14)',
'HedgehogActor.update (http://127.0.0.1:8000/static/toolbar.js?_ts=1693421010000:105572:16)',
'loop (http://127.0.0.1:8000/static/toolbar.js?_ts=1693421010000:105754:15)',
],
},
plugin: 'rrweb/console@1',
},
timestamp: 1693422950693,
type: 6,
},
],
events: expect.any(Array),
metadata: {
offset: 1,
partition: 1,
Expand All @@ -97,7 +79,6 @@ describe('session-recording utils', () => {
session_id: '018a47c2-2f4a-70a8-b480-5e51d8b8d070',
team_id: 1,
window_id: '018a47c2-2f4a-70a8-b480-5e52f5480448',
snapshot_source: undefined,
})
})

Expand Down

0 comments on commit e049e2c

Please sign in to comment.