Skip to content

Connectum API Reference / @connectum/otel / shared / estimateMessageSize

Function: estimateMessageSize()

estimateMessageSize(message): number

Defined in: packages/otel/src/shared.ts:49

Estimates the serialized size of a protobuf message in bytes.

If the message exposes a toBinary() method (standard for protobuf-es messages), returns the byte length of the serialized form. Otherwise returns 0. Results are cached per message object using a WeakMap.

Parameters

message

unknown

The message to estimate size for

Returns

number

Size in bytes, or 0 if size cannot be determined