1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//! Adapter from native OTel GenAI (`gen_ai.*`) OTLP/JSON span exports into canonical
//! [`amberfork_model::Run`]s.
//!
//! Sibling adapter to [`crate::openinference`]: the exact same [`crate::otlp`] envelope
//! (resource/scope flattening, `AnyValue` decoding, start-time ordering, `parentSpanId` →
//! `parent_idx`, `outcome` never inferred from span status), a different attribute vocabulary
//! ([`crate::genaivocab`], the native OTel GenAI semantic conventions rather than OpenInference's).
//! Deliberately not folded into `openinference` — notebook 042 drew this slice boundary before
//! either adapter was built: "OpenInference now, native `gen_ai.*` next — same envelope, additive
//! vocabulary."
//!
//! Slice boundary: targets the current `gen_ai.input.messages`/`gen_ai.output.messages` /
//! `gen_ai.tool.call.arguments`/`gen_ai.tool.call.result` span-attribute convention. The
//! superseded per-role event convention (`gen_ai.user.message`/`gen_ai.assistant.message`/…) is
//! not read.
use crate::;
use Path;
/// Parse a native OTel GenAI OTLP/JSON span export into one canonical run per `traceId`.
///
/// Returns the runs ordered by their earliest span's start time, each paired with any non-fatal
/// diagnostics raised while normalizing it. An export with no spans yields an empty vector.
///
/// # Errors
/// Returns [`IngestError::Parse`] if the string is not valid OTLP/JSON. Everything past a
/// successful parse is forgiving: a missing operation name, absent content, or a foreign
/// attribute yields a canonical fallback plus a warning, never an error.
/// Load a native OTel GenAI OTLP/JSON span export from a file on disk.
///
/// # Errors
/// Returns [`IngestError::Io`] if the file cannot be read, or [`IngestError::Parse`] (with the path
/// attached) if its contents are not valid OTLP/JSON.