Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

592 B
Raw Blame
import { Message } from 'node-rdkafka'

import { ok } from '~/ingestion/framework/results'
import { ProcessingStep } from '~/ingestion/framework/steps'

/**
 * Carries the Kafka message byte size on the value, so downstream chunk steps
 * (Cymbal batch chunking) can budget by payload size.
 */
export function createAttachMessageBytesStep<T extends { message: Message }>(): ProcessingStep<
    T,
    T & { messageBytes: number }
> {
    return function attachMessageBytesStep(input) {
        return Promise.resolve(ok({ ...input, messageBytes: input.message.value?.length ?? 0 }))
    }
}