The value to (potentially) augment with trace context.
Optionalopts: InjectContextOptionsOptional settings (e.g. explicit Context).
The original value (non-objects) or a new object with propagation fields added.
// Object — trace context is injected from the active context
const params = injectContext({ userId: "abc" });
// => { userId: "abc", traceparent: "00-…", tracestate: "…" }
// Explicit context
const params = injectContext({ userId: "abc" }, { context: parentCtx });
// Non-object — returned as-is
const str = injectContext("hello");
// => "hello"
Inject trace context into an arbitrary value using the globally registered textmap propagator.
valueis a non-null object, propagation fields (traceparent,tracestate, etc.) are merged into a shallow copy and the augmented object is returned.