Langfuse JS/TS SDKs
    Preparing search index...

    Function dropMetadataOverSpanAttributeLimit

    • Internal

      Drops new observation metadata attributes (langfuse.observation.metadata.<key>) that would exceed the span's attribute count limit (spanLimits.attributeCountLimit, default 128). OpenTelemetry JS silently drops new attributes once a span is full, so unbounded metadata would otherwise push out later attributes such as the output.

      Counts the attributes already on the span, the new keys with non-null values, and reservedKeys that are not on the span yet. Excess new metadata keys are dropped from the tail. Other attributes are never dropped, and overwrites of keys already on the span are always kept. Spans without SDK limits are left alone. Logs one warning if keys are dropped and never throws.

      Type Parameters

      • T extends Record<string, unknown>

      Parameters

      • span: unknown

        Span the attributes are about to be set on

      • attributes: T

        Attributes about to be set on the span

      • reservedKeys: readonly string[]

        Keys to keep room for, because they are written later

      Returns T

      attributes without the dropped metadata keys