Record-copy
Return a copy of a Record with the same field values. This helper is useful when code wants an explicit independent record value before passing it to sinks, patches, or other downstream steps.
Interface
pub fn Record::copy(self : Record) -> Record {}input
self : Record- Base record that should be copied.
output
Record- New record value containing the samelevel,message,timestamp_ms,target, andfields.
Explanation
Detailed rules explaining key parameters and behaviors
- This helper returns a new
Recordvalue instead of reusing the original one directly. level,message,timestamp_ms,target, andfieldsare preserved unchanged.- It is the narrowest explicit duplication helper for a record value.
- This is useful when a downstream path should receive its own record value even though the event data does not change.
How to Use
Here are some specific examples provided.
When Need An Explicit Duplicate For Fanout-style Handling
When one path should keep the current record value while another path continues independently:
let rec = Record::new(Level::Info, "started", target="svc")
let duplicate = rec.copy()In this example, the caller gets a second Record value with the same event data.
When Need A Stable Baseline Before Later Transformations
When one value should be copied before applying further replacement helpers:
let base = Record::new(Level::Warn, "retry")
let patched = base.copy().with_target("jobs.retry")In this example, the copy step makes the later transformation intent explicit.
Error Case
e.g.:
Record::copy()itself does not have a runtime failure mode.If the code does not actually need a second record value, copying adds no new information and may be unnecessary.
Notes
Use this helper when explicit value duplication improves clarity.
It pairs naturally with later
Recordtransformation helpers when one path should preserve a baseline value first.