﻿# Multiline worker logs: preserve source identity before recombining fragments

A practical investigation of multiline worker logs: preserve source identity before recombining fragments, with explicit observations, control cases and evidence limits.

Author: Retrivium team
Updated: 2026-11-06
Canonical URL: https://retrivium.ai/journal/field-observe-multiline-recombine-source-isolation/
Language: en

## The diagnostic situation

A collector combines stack-trace fragments into one record. Logs from independent serving workers are interleaved, and the source-grouping field was removed or mapped to a shared value. The output looks like a convincing exception with a valid timestamp and worker label, but its body contains fragments from different processes. The diagnostic evidence was fabricated by parsing rather than by the application.

## Why the observation changes meaning

The Collector Stanza recombine operator uses source_identifier to separate sources and configurable first-or-last-entry rules to identify record boundaries. It also has buffering and size limits, and metadata can come from the oldest or newest entry according to configuration. Boundary recognition alone therefore does not establish source purity. A shared file name is not necessarily a globally unique worker identity.

## Define the instrumentation contract

Define a safe grouping key that remains distinct for the actual sources entering the operator. Verify the required field exists after preceding transformations. Preserve process or container lifetime where reuse can occur, and retain the distinction between source metadata and parsed body content. Respect the operator’s documented input model rather than assuming it can infer upstream provenance from every connected path.

## A bounded verification procedure

Prepare synthetic multiline records with unmistakable source markers and interleave their fragments. Run the real filelog and recombination configuration. Compare output bodies and metadata with the expected per-source records. Include a missing grouping field, a boundary-like line inside a message and a forced partial flush. The test should expose cross-source mixing and incomplete records rather than merely count successful parser output.

## Evidence required for acceptance

Acceptance evidence includes receiver and operator versions, effective field mappings, original fragment order and reconstructed output. Show which metadata entry won and whether every body fragment belongs to that source. Preserve unmatched or partial cases with an explicit interpretation. A lower output-record count is not evidence of successful multiline recovery if unrelated sources were combined into one attractive but false incident narrative.

## Failure cases and limits

Correct recombination does not guarantee delivery, durable retention or trustworthy application content. Source identifiers can also be reused after rotation or restart unless their scope is defined. This protocol validates parsing isolation in the selected pipeline; it cannot restore provenance already discarded before collection. Keep synthetic fixtures after format changes so a new logging library cannot silently change record boundaries or ownership.

## Primary references and related reading

A multiline parser needs source isolation as well as boundary patterns; interleaved fragments must not become a fabricated exception. [Collector Stanza recombine operator](https://raw.githubusercontent.com/open-telemetry/opentelemetry-collector-contrib/main/pkg/stanza/docs/operators/recombine.md); [Collector File Log Receiver](https://raw.githubusercontent.com/open-telemetry/opentelemetry-collector-contrib/main/receiver/filelogreceiver/README.md).

The proposed investigation of multiline recombine source isolation is not an executed deployment benchmark. Related reading: [kubectl logs --previous is not enough: Pod log rotation and collection](/journal/kubernetes-log-rotation-restarts/); [Request IDs and trace context across gateway, API and engine](/journal/provider-request-id-trace-context/).
