Serializes observation metadata into the single JSON value written to the
langfuse.observation.metadata span attribute.
Top-level keys with null or undefined values are skipped. Values are
serialized one by one, so a value that fails to serialize is replaced with
"<failed to serialize>" instead of dropping the whole metadata object.
Parameters
metadata: unknown
Metadata to serialize
Returns undefined|string
JSON string, or undefined if there is no metadata to write
Serializes observation metadata into the single JSON value written to the
langfuse.observation.metadataspan attribute.Top-level keys with
nullorundefinedvalues are skipped. Values are serialized one by one, so a value that fails to serialize is replaced with"<failed to serialize>"instead of dropping the whole metadata object.